@brightspace-ui/core 2.142.1 → 2.143.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.
@@ -318,7 +318,7 @@ class Card extends FocusMixin(RtlMixin(LitElement)) {
318
318
  _onBadgeResize(entries) {
319
319
  if (!entries || entries.length === 0) return;
320
320
  const entry = entries[0];
321
- this._badgeMarginTop = `${-0.5 * entry.contentRect.height}px`;
321
+ requestAnimationFrame(() => this._badgeMarginTop = `${-0.5 * entry.contentRect.height}px`);
322
322
  }
323
323
 
324
324
  _onDropdownClose() {
@@ -334,7 +334,7 @@ class Card extends FocusMixin(RtlMixin(LitElement)) {
334
334
  const entry = entries[0];
335
335
  // firefox has a rounding error when calculating the height of the contentRect
336
336
  // with `box-sizing: border-box;` so check for numbers which are close to 0 as well
337
- this._footerHidden = (entry.contentRect.height < 1);
337
+ requestAnimationFrame(() => this._footerHidden = (entry.contentRect.height < 1));
338
338
  }
339
339
 
340
340
  _onLinkBlur() {
@@ -216,7 +216,7 @@ export const CountBadgeMixin = superclass => class extends LocalizeCoreElement(S
216
216
  aria-live="${this.announceChanges ? 'polite' : 'off'}">
217
217
  ${innerHtml}
218
218
  </div>
219
- ${this.hasTooltip && !this.skeleton ? html`<d2l-tooltip for="${badgeId}" for-type="label">${this.text}</d2l-tooltip>` : null}
219
+ ${this.hasTooltip && !this.skeleton ? html`<d2l-tooltip class="vdiff-target" for="${badgeId}" for-type="label">${this.text}</d2l-tooltip>` : null}
220
220
  `;
221
221
  }
222
222
  };
@@ -11,6 +11,7 @@
11
11
  import '../../dropdown/dropdown-more.js';
12
12
  import '../../menu/menu.js';
13
13
  import '../../menu/menu-item.js';
14
+ import '../list-controls.js';
14
15
  import '../list-item-content.js';
15
16
  import '../list-item.js';
16
17
  import '../list.js';
@@ -161,10 +162,6 @@
161
162
  <d2l-demo-snippet code-view-hidden>
162
163
  <template>
163
164
  <d2l-list>
164
- <d2l-list-controls slot="controls">
165
- <d2l-selection-action icon="tier1:bookmark-hollow" text="Bookmark" requires-selection></d2l-selection-action>
166
- <d2l-selection-action icon="tier1:gear" text="Settings"></d2l-selection-action>
167
- </d2l-list-controls>
168
165
  <d2l-list-item key="L1-1" label="Label for L1-1" color="#ffba59" expandable expanded>
169
166
  <d2l-list-item-content>
170
167
  <div>Earth Sciences (L1)</div>
@@ -1,4 +1,5 @@
1
1
  import { css } from 'lit';
2
+ import { EventSubscriberController } from '../../controllers/subscriber/subscriberControllers.js';
2
3
  import { findComposedAncestor } from '../../helpers/dom.js';
3
4
  import { SelectionControls } from '../selection/selection-controls.js';
4
5
 
@@ -8,7 +9,8 @@ import { SelectionControls } from '../selection/selection-controls.js';
8
9
  export class ListControls extends SelectionControls {
9
10
  static get properties() {
10
11
  return {
11
- _extendSeparator: { state: true }
12
+ _extendSeparator: { state: true },
13
+ _siblingHasColor: { state: true }
12
14
  };
13
15
  }
14
16
 
@@ -22,6 +24,9 @@ export class ListControls extends SelectionControls {
22
24
  :host([no-sticky]) {
23
25
  z-index: auto;
24
26
  }
27
+ .d2l-list-controls-color {
28
+ padding: 0 1.8rem;
29
+ }
25
30
  .d2l-list-controls-extend-separator {
26
31
  padding: 0 0.9rem;
27
32
  }
@@ -31,6 +36,9 @@ export class ListControls extends SelectionControls {
31
36
  constructor() {
32
37
  super();
33
38
  this._extendSeparator = false;
39
+ this._siblingHasColor = false;
40
+
41
+ this._parentChildUpdateSubscription = new EventSubscriberController(this, 'list-child-status');
34
42
  }
35
43
 
36
44
  connectedCallback() {
@@ -41,9 +49,18 @@ export class ListControls extends SelectionControls {
41
49
  if (this._extendSeparator) this.style.setProperty('--d2l-selection-controls-padding', '0px');
42
50
  }
43
51
 
52
+ updateSiblingHasChildren() {
53
+ // TODO: implement this in order to have consistent spacing when nested items
54
+ }
55
+
56
+ updateSiblingHasColor(value) {
57
+ this._siblingHasColor = value;
58
+ }
59
+
44
60
  _getSelectionControlsContainerClasses() {
45
61
  return {
46
62
  ...super._getSelectionControlsContainerClasses(),
63
+ 'd2l-list-controls-color': this._siblingHasColor,
47
64
  'd2l-list-controls-extend-separator': this._extendSeparator
48
65
  };
49
66
  }
@@ -70,7 +70,7 @@ export const ListItemMixin = superclass => class extends composeMixins(
70
70
  */
71
71
  breakpoints: { type: Array },
72
72
  /**
73
- * A color indicator to appear at the beginning of a list item. Expected value is a valid 6 or 8 character CSS color hex code (e.g., #006fbf).
73
+ * A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).
74
74
  * @type {string}
75
75
  */
76
76
  color: { type: String },
@@ -91,13 +91,15 @@ export const ListItemMixin = superclass => class extends composeMixins(
91
91
  paddingType: { type: String, attribute: 'padding-type' },
92
92
  _breakpoint: { type: Number },
93
93
  _displayKeyboardTooltip: { type: Boolean },
94
+ _hasColorSlot: { type: Boolean, reflect: true, attribute: '_has-color-slot' },
94
95
  _hovering: { type: Boolean, reflect: true },
95
96
  _hoveringPrimaryAction: { type: Boolean, attribute: '_hovering-primary-action', reflect: true },
96
97
  _focusing: { type: Boolean, reflect: true },
97
98
  _focusingPrimaryAction: { type: Boolean, attribute: '_focusing-primary-action', reflect: true },
98
99
  _highlight: { type: Boolean, reflect: true },
99
100
  _highlighting: { type: Boolean, reflect: true },
100
- _hasNestedList: { state: true }
101
+ _hasNestedList: { state: true },
102
+ _siblingHasColor: { state: true }
101
103
  };
102
104
  }
103
105
 
@@ -318,10 +320,10 @@ export const ListItemMixin = superclass => class extends composeMixins(
318
320
  margin: 0;
319
321
  }
320
322
 
321
- :host(:not([draggable])[color]) [slot="outside-control-container"] {
323
+ :host(:not([draggable])[_has-color-slot]) [slot="outside-control-container"] {
322
324
  margin-left: -6px;
323
325
  }
324
- :host(:not([draggable])[dir="rtl"][color]) [slot="outside-control-container"] {
326
+ :host(:not([draggable])[dir="rtl"][_has-color-slot]) [slot="outside-control-container"] {
325
327
  margin-left: 0;
326
328
  margin-right: -6px;
327
329
  }
@@ -394,12 +396,12 @@ export const ListItemMixin = superclass => class extends composeMixins(
394
396
  padding-left: 12px;
395
397
  padding-right: 0;
396
398
  }
397
- :host([expandable]) .d2l-list-item-color-outer {
398
- padding-right: 6px;
399
+ .d2l-list-item-color-outer + .d2l-list-expand-collapse {
400
+ margin-left: -6px;
399
401
  }
400
- :host([dir="rtl"][expandable]) .d2l-list-item-color-outer {
401
- padding-left: 6px;
402
- padding-right: 0;
402
+ :host([dir="rtl"]) .d2l-list-item-color-outer + .d2l-list-expand-collapse {
403
+ margin-left: 0;
404
+ margin-right: -6px;
403
405
  }
404
406
  `];
405
407
 
@@ -415,7 +417,9 @@ export const ListItemMixin = superclass => class extends composeMixins(
415
417
  this._breakpoint = 0;
416
418
  this._contentId = getUniqueId();
417
419
  this._displayKeyboardTooltip = false;
420
+ this._hasColorSlot = false;
418
421
  this._hasNestedList = false;
422
+ this._siblingHasColor = false;
419
423
  }
420
424
 
421
425
  get breakpoints() {
@@ -437,6 +441,7 @@ export const ListItemMixin = superclass => class extends composeMixins(
437
441
  const oldValue = this._color;
438
442
  this._color = getValidHexColor(value, true);
439
443
  this.requestUpdate('value', oldValue);
444
+ this.dispatchEvent(new CustomEvent('d2l-list-item-property-change', { bubbles: true, composed: true, detail: { name: 'color', value: this._color } }));
440
445
  }
441
446
 
442
447
  connectedCallback() {
@@ -514,6 +519,16 @@ export const ListItemMixin = superclass => class extends composeMixins(
514
519
  else this.scrollIntoView({ behavior: 'smooth', block: alignToTop ? 'start' : 'end' });
515
520
  }
516
521
 
522
+ updateSiblingHasColor(siblingHasColor) {
523
+ this._siblingHasColor = siblingHasColor;
524
+ }
525
+
526
+ willUpdate(changedProperties) {
527
+ if (changedProperties.has('_siblingHasColor') || changedProperties.has('color')) {
528
+ this._hasColorSlot = this.color || this._siblingHasColor;
529
+ }
530
+ }
531
+
517
532
  _getFlattenedListItems(listItem) {
518
533
  const listItems = new Map();
519
534
  const lazyLoadListItems = new Map();
@@ -642,7 +657,7 @@ export const ListItemMixin = superclass => class extends composeMixins(
642
657
  'd2l-dragging-over': this._draggingOver
643
658
  };
644
659
  const colorStyles = {
645
- backgroundColor: this.color || undefined
660
+ backgroundColor: this._hasColorSlot ? this.color : undefined
646
661
  };
647
662
 
648
663
  const primaryAction = ((!this.noPrimaryAction && this._renderPrimaryAction) ? this._renderPrimaryAction(this._contentId) : null);
@@ -662,7 +677,7 @@ export const ListItemMixin = superclass => class extends composeMixins(
662
677
  ${this._renderDragHandle(this._renderOutsideControl)}
663
678
  ${this._renderDragTarget(this.dragTargetHandleOnly ? this._renderOutsideControlHandleOnly : this._renderOutsideControlAction)}
664
679
  <div slot="control-container"></div>
665
- ${this.color ? html`
680
+ ${this._hasColorSlot ? html`
666
681
  <div slot="color-indicator" class="d2l-list-item-color-outer">
667
682
  <div class="d2l-list-item-color-inner" style="${styleMap(colorStyles)}"></div>
668
683
  </div>` : nothing}
@@ -78,6 +78,7 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
78
78
  this.extendSeparators = false;
79
79
  this.grid = false;
80
80
  this._listItemChanges = [];
81
+ this._childHasColor = false;
81
82
  this._childHasExpandCollapseToggle = false;
82
83
 
83
84
  this._listChildrenUpdatedSubscribers = new SubscriberRegistryController(this, 'list-child-status', {
@@ -90,6 +91,7 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
90
91
  super.connectedCallback();
91
92
  this.addEventListener('d2l-list-item-showing-count-change', this._handleListItemShowingCountChange);
92
93
  this.addEventListener('d2l-list-item-nested-change', (e) => this._handleListIemNestedChange(e));
94
+ this.addEventListener('d2l-list-item-property-change', (e) => this._handleListItemPropertyChange(e));
93
95
  }
94
96
 
95
97
  disconnectedCallback() {
@@ -224,17 +226,31 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
224
226
  e.stopPropagation();
225
227
  }
226
228
  const items = this.getItems();
229
+ let aChildHasColor = false;
227
230
  let aChildHasToggleEnabled = false;
228
231
  for (const item of items) {
229
- if (item.expandable) {
230
- aChildHasToggleEnabled = true;
231
- break;
232
- }
232
+ if (item.color) aChildHasColor = true;
233
+ if (item.expandable) aChildHasToggleEnabled = true;
234
+ if (aChildHasToggleEnabled && aChildHasColor) break;
233
235
  }
236
+ this._childHasColor = aChildHasColor;
234
237
  this._childHasExpandCollapseToggle = aChildHasToggleEnabled;
235
238
  this._listChildrenUpdatedSubscribers.updateSubscribers();
236
239
  }
237
240
 
241
+ _handleListItemPropertyChange(e) {
242
+ e.stopPropagation();
243
+ if (e.detail.name === 'color') {
244
+ if (e.detail.value) {
245
+ this._childHasColor = true;
246
+ this._listChildrenUpdatedSubscribers.updateSubscribers();
247
+ } else {
248
+ // if color has had its value removed then need to loop through all the items to determine if there are still others with colors
249
+ this._handleListIemNestedChange(e);
250
+ }
251
+ }
252
+ }
253
+
238
254
  _handleListItemShowingCountChange() {
239
255
  if (this.slot === 'nested') return;
240
256
 
@@ -260,10 +276,14 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
260
276
 
261
277
  _updateActiveSubscriber(subscriber) {
262
278
  subscriber.updateSiblingHasChildren(this._childHasExpandCollapseToggle);
279
+ subscriber.updateSiblingHasColor(this._childHasColor);
263
280
  }
264
281
 
265
282
  _updateActiveSubscribers(subscribers) {
266
- subscribers.forEach(subscriber => subscriber.updateSiblingHasChildren(this._childHasExpandCollapseToggle));
283
+ subscribers.forEach(subscriber => {
284
+ subscriber.updateSiblingHasChildren(this._childHasExpandCollapseToggle);
285
+ subscriber.updateSiblingHasColor(this._childHasColor);
286
+ });
267
287
  }
268
288
 
269
289
  }
@@ -3,6 +3,7 @@ import { css, html, LitElement } from 'lit';
3
3
  import { cssEscape, elemIdListAdd, elemIdListRemove, getBoundingAncestor, getOffsetParent } from '../../helpers/dom.js';
4
4
  import { announce } from '../../helpers/announce.js';
5
5
  import { bodySmallStyles } from '../typography/styles.js';
6
+ import { classMap } from 'lit/directives/class-map.js';
6
7
  import { getUniqueId } from '../../helpers/uniqueId.js';
7
8
  import { isFocusable } from '../../helpers/focus.js';
8
9
  import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
@@ -501,11 +502,17 @@ class Tooltip extends RtlMixin(LitElement) {
501
502
  }
502
503
  }
503
504
 
505
+ const contentClasses = {
506
+ 'd2l-tooltip-content': true,
507
+ 'd2l-body-small': true,
508
+ 'vdiff-target': this.showing
509
+ };
510
+
504
511
  // Note: role="text" is a workaround for Safari. Otherwise, list-item content is not announced with VoiceOver
505
512
  return html`
506
513
  <div class="d2l-tooltip-container">
507
514
  <div class="d2l-tooltip-position" style=${styleMap(tooltipPositionStyle)}>
508
- <div class="d2l-body-small d2l-tooltip-content">
515
+ <div class="${classMap(contentClasses)}">
509
516
  <div role="text">
510
517
  <slot></slot>
511
518
  </div>
@@ -7895,7 +7895,7 @@
7895
7895
  },
7896
7896
  {
7897
7897
  "name": "color",
7898
- "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 6 or 8 character CSS color hex code (e.g., #006fbf).",
7898
+ "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
7899
7899
  "type": "string"
7900
7900
  },
7901
7901
  {
@@ -7997,7 +7997,7 @@
7997
7997
  {
7998
7998
  "name": "color",
7999
7999
  "attribute": "color",
8000
- "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 6 or 8 character CSS color hex code (e.g., #006fbf).",
8000
+ "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
8001
8001
  "type": "string"
8002
8002
  },
8003
8003
  {
@@ -8118,6 +8118,9 @@
8118
8118
  }
8119
8119
  ],
8120
8120
  "events": [
8121
+ {
8122
+ "name": "d2l-list-item-property-change"
8123
+ },
8121
8124
  {
8122
8125
  "name": "d2l-list-item-selected",
8123
8126
  "description": "Dispatched when the component item is selected"
@@ -8249,7 +8252,7 @@
8249
8252
  },
8250
8253
  {
8251
8254
  "name": "color",
8252
- "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 6 or 8 character CSS color hex code (e.g., #006fbf).",
8255
+ "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
8253
8256
  "type": "string"
8254
8257
  },
8255
8258
  {
@@ -8358,7 +8361,7 @@
8358
8361
  {
8359
8362
  "name": "color",
8360
8363
  "attribute": "color",
8361
- "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 6 or 8 character CSS color hex code (e.g., #006fbf).",
8364
+ "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
8362
8365
  "type": "string"
8363
8366
  },
8364
8367
  {
@@ -8483,6 +8486,9 @@
8483
8486
  "name": "d2l-list-item-button-click",
8484
8487
  "description": "Dispatched when the item's primary button action is clicked"
8485
8488
  },
8489
+ {
8490
+ "name": "d2l-list-item-property-change"
8491
+ },
8486
8492
  {
8487
8493
  "name": "d2l-list-item-selected",
8488
8494
  "description": "Dispatched when the component item is selected"
@@ -8732,7 +8738,7 @@
8732
8738
  },
8733
8739
  {
8734
8740
  "name": "color",
8735
- "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 6 or 8 character CSS color hex code (e.g., #006fbf).",
8741
+ "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
8736
8742
  "type": "string"
8737
8743
  },
8738
8744
  {
@@ -8846,7 +8852,7 @@
8846
8852
  {
8847
8853
  "name": "color",
8848
8854
  "attribute": "color",
8849
- "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 6 or 8 character CSS color hex code (e.g., #006fbf).",
8855
+ "description": "A color indicator to appear at the beginning of a list item. Expected value is a valid 3, 4, 6, or 8 character CSS color hex code (e.g., #006fbf).",
8850
8856
  "type": "string"
8851
8857
  },
8852
8858
  {
@@ -8971,6 +8977,9 @@
8971
8977
  "name": "d2l-list-item-link-click",
8972
8978
  "description": "Dispatched when the item's primary link action is clicked"
8973
8979
  },
8980
+ {
8981
+ "name": "d2l-list-item-property-change"
8982
+ },
8974
8983
  {
8975
8984
  "name": "d2l-list-item-selected",
8976
8985
  "description": "Dispatched when the component item is selected"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.142.1",
3
+ "version": "2.143.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",
@@ -46,7 +46,7 @@
46
46
  "devDependencies": {
47
47
  "@babel/eslint-parser": "^7",
48
48
  "@brightspace-ui/stylelint-config": "^0.8",
49
- "@brightspace-ui/testing": "^0.30",
49
+ "@brightspace-ui/testing": "^0.32",
50
50
  "@open-wc/semantic-dom-diff": "^0.20",
51
51
  "@rollup/plugin-dynamic-import-vars": "^2",
52
52
  "@rollup/plugin-node-resolve": "^15",