@brightspace-ui/core 3.207.1 → 3.208.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.
@@ -243,6 +243,53 @@
243
243
  </template>
244
244
  </d2l-demo-snippet>
245
245
 
246
+ <h2>Selectable (show selection when one or more selected or on hover/focus)</h2>
247
+
248
+ <d2l-demo-snippet>
249
+ <template>
250
+ <d2l-view-switcher label="Layout Options">
251
+ <d2l-view-switcher-button key="list" text="List"></d2l-view-switcher-button>
252
+ <d2l-view-switcher-button selected key="tiles" text="Tiles"></d2l-view-switcher-button>
253
+ </d2l-view-switcher>
254
+ <d2l-list layout="tiles" selection-when-interacted>
255
+ <d2l-list-item label="item 1" key="1" selectable tile-header>
256
+ <img slot="illustration" src="https://s.brightspace.com/course-images/images/38e839b1-37fa-470c-8830-b189ce4ae134/tile-high-density-max-size.jpg"></img>
257
+ <d2l-list-item-content>
258
+ <div>Identify categories of physical activities</div>
259
+ <div slot="secondary">Secondary Information</div>
260
+ <div slot="supporting-info">Specific Expectation A1.2</div>
261
+ </d2l-list-item-content>
262
+ </d2l-list-item>
263
+ <d2l-list-item label="item 2" key="2" selectable>
264
+ <img slot="illustration" src="https://s.brightspace.com/course-images/images/e5fd575a-bc14-4a80-89e1-46f349a76178/tile-high-density-max-size.jpg"></img>
265
+ <d2l-list-item-content>
266
+ <div>Apply a decision-making process to assess risks and make safe decisions in a variety of situations</div>
267
+ <div slot="secondary">Secondary Information</div>
268
+ <div slot="supporting-info">Specific Expectation B2.1</div>
269
+ </d2l-list-item-content>
270
+ </d2l-list-item>
271
+ <d2l-list-item label="item 3" key="3" selectable>
272
+ <img slot="illustration" src="https://s.brightspace.com/course-images/images/63b162ab-b582-4bf9-8c1d-1dad04714121/tile-high-density-max-size.jpg"></img>
273
+ <d2l-list-item-content>
274
+ <div>Retain objects of various shapes and sizes in different ways, while moving around others and equipment</div>
275
+ <div slot="secondary">Secondary Information</div>
276
+ <div slot="supporting-info">Specific Expectation B2.2</div>
277
+ </d2l-list-item-content>
278
+ </d2l-list-item>
279
+ <d2l-list-item label="item 4" key="4" selectable tile-header>
280
+ <d2l-list-item-content>
281
+ <div>Retain objects of various shapes and sizes in different ways, while moving around others and equipment</div>
282
+ <div slot="secondary">Secondary Information</div>
283
+ <div slot="supporting-info">Specific Expectation B2.2</div>
284
+ </d2l-list-item-content>
285
+ </d2l-list-item>
286
+ </d2l-list>
287
+ <script data-demo-hide>
288
+ (demo => window.window.wireupViewSwitcher(demo))(document.currentScript.parentNode);
289
+ </script>
290
+ </template>
291
+ </d2l-demo-snippet>
292
+
246
293
  <h2>Actions</h2>
247
294
 
248
295
  <d2l-demo-snippet>
@@ -124,9 +124,11 @@ export const ListItemMixin = superclass => class extends composeMixins(
124
124
  _hoveringPrimaryAction: { type: Boolean, attribute: '_hovering-primary-action', reflect: true },
125
125
  _focusing: { type: Boolean, reflect: true },
126
126
  _focusingPrimaryAction: { type: Boolean, attribute: '_focusing-primary-action', reflect: true },
127
+ _forceShowSelection: { type: Boolean, attribute: '_force-show-selection', reflect: true },
127
128
  _highlight: { type: Boolean, reflect: true },
128
129
  _highlighting: { type: Boolean, reflect: true },
129
130
  _showAddButton: { type: Boolean, attribute: '_show-add-button', reflect: true },
131
+ _selectionWhenInteracted: { type: Boolean, attribute: '_selection-when-interacted', reflect: true },
130
132
  _siblingHasColor: { state: true },
131
133
  };
132
134
  }
@@ -467,6 +469,35 @@ export const ListItemMixin = superclass => class extends composeMixins(
467
469
  padding: 0;
468
470
  }
469
471
 
472
+ :host([layout="tile"][_selection-when-interacted]) [slot="control"] {
473
+ opacity: 0;
474
+ transform: translateY(-10px);
475
+ transition: opacity 200ms ease-out, transform 0ms ease-out 300ms;
476
+ }
477
+ :host([layout="tile"][_selection-when-interacted]) [slot="control"]:hover,
478
+ :host([layout="tile"][_selection-when-interacted][_focusing]) [slot="control"],
479
+ :host([layout="tile"][_selection-when-interacted][_force-show-selection]) [slot="control"],
480
+ :host([layout="tile"][_selection-when-interacted][_hovering-selection]) [slot="control"],
481
+ :host([layout="tile"][_selection-when-interacted][_hovering]) [slot="control"] {
482
+ opacity: 1;
483
+ transform: none;
484
+ transition: opacity 200ms ease-out, transform 200ms ease-out;
485
+ }
486
+
487
+ @media (prefers-reduced-motion: reduce) {
488
+ :host([layout="tile"][_selection-when-interacted]) [slot="control"] {
489
+ transform: none;
490
+ transition: none;
491
+ }
492
+ :host([layout="tile"][_selection-when-interacted]) [slot="control"]:hover,
493
+ :host([layout="tile"][_selection-when-interacted][_focusing]) [slot="control"],
494
+ :host([layout="tile"][_selection-when-interacted][_force-show-selection]) [slot="control"],
495
+ :host([layout="tile"][_selection-when-interacted][_hovering-selection]) [slot="control"],
496
+ :host([layout="tile"][_selection-when-interacted][_hovering]) [slot="control"] {
497
+ transition: none;
498
+ }
499
+ }
500
+
470
501
  :host([layout="tile"]) [slot="content"] ::slotted([slot="illustration"]),
471
502
  :host([layout="tile"]) .d2l-list-item-illustration > * {
472
503
  border-end-end-radius: 0;
@@ -649,11 +680,13 @@ export const ListItemMixin = superclass => class extends composeMixins(
649
680
  this.isVisibleOnAncestorTarget = true;
650
681
  this.noPrimaryAction = false;
651
682
  this.paddingType = 'normal';
683
+ this._selectionWhenInteracted = false;
652
684
  this.tileHeader = false;
653
685
  this.tilePaddingType = 'normal';
654
686
  this._addButtonTopId = getUniqueId();
655
687
  this._contentId = getUniqueId();
656
688
  this._displayKeyboardTooltip = false;
689
+ this._forceShowSelection = false;
657
690
  this._hasColorSlot = false;
658
691
  this._hasListItemContent = true;
659
692
  this._hasNestedList = false;
@@ -955,7 +988,7 @@ export const ListItemMixin = superclass => class extends composeMixins(
955
988
  </d2l-button-add>
956
989
  </div>
957
990
  ` : nothing}
958
- <div slot="header"></div>
991
+ <div slot="header" @mouseenter="${this._onMouseEnter}" @mouseleave="${this._onMouseLeave}"></div>
959
992
  <div slot="outside-control-container" class="${classMap(outsideClasses)}"></div>
960
993
  <div slot="before-content"></div>
961
994
  ${this._renderDropTarget()}
@@ -95,6 +95,11 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
95
95
  * @default "all"
96
96
  */
97
97
  separators: { type: String, reflect: true },
98
+ /**
99
+ * Show selection only on hover, focus or if at least one item is selected. Exclusive for the tile layout
100
+ * @type {boolean}
101
+ */
102
+ selectionWhenInteracted: { type: Boolean, attribute: 'selection-when-interacted', reflect: true },
98
103
  _breakpoint: { type: Number, reflect: true },
99
104
  _slimColor: { type: Boolean, reflect: true, attribute: '_slim-color' }
100
105
  };
@@ -216,6 +221,7 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
216
221
  // check if list items are expandable on first render so we adjust sibling spacing appropriately
217
222
  this._handleListItemNestedChange();
218
223
  this.addEventListener('d2l-list-item-selected', e => {
224
+ this._updateItemShowSelection();
219
225
 
220
226
  // batch the changes from select-all and nested lists
221
227
  if (this._listItemChanges.length === 0) {
@@ -269,6 +275,9 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
269
275
  if (changedProperties.has('layout') && changedProperties.get('layout') !== undefined && this.layout) {
270
276
  this._updateItemLayouts();
271
277
  }
278
+ if (changedProperties.has('selectionWhenInteracted')) {
279
+ this._updateItemShowSelection();
280
+ }
272
281
  if (changedProperties.has('dragHandleShowAlways')) {
273
282
  this._updateItemDragHandleShowAlways();
274
283
  }
@@ -508,6 +517,7 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
508
517
  });
509
518
 
510
519
  this._updateItemLayouts(items);
520
+ this._updateItemShowSelection(items);
511
521
  this._updateItemDragHandleShowAlways(items);
512
522
 
513
523
  /** @ignore */
@@ -540,6 +550,15 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
540
550
  if (!items) items = this.getItems();
541
551
  items.forEach(item => item.layout = (this.layout === listLayouts.tiles ? 'tile' : 'normal'));
542
552
  }
553
+ _updateItemShowSelection(items) {
554
+ if (!items) items = this.getItems();
555
+ const state = this.getSelectionInfo().state;
556
+ items.forEach(item => {
557
+ item._selectionWhenInteracted = this.selectionWhenInteracted;
558
+ item._forceShowSelection = this.selectionWhenInteracted && (state === SelectionInfo.states.some || state === SelectionInfo.states.all);
559
+ });
560
+ }
561
+
543
562
  }
544
563
 
545
564
  customElements.define('d2l-list', List);
@@ -10619,6 +10619,11 @@
10619
10619
  "type": "'all'|'between'|'none'",
10620
10620
  "default": "\"\\\"all\\\"\""
10621
10621
  },
10622
+ {
10623
+ "name": "selection-when-interacted",
10624
+ "description": "Show selection only on hover, focus or if at least one item is selected. Exclusive for the tile layout",
10625
+ "type": "boolean"
10626
+ },
10622
10627
  {
10623
10628
  "name": "add-button",
10624
10629
  "description": "When true, show the inline add button after each list item.",
@@ -10699,6 +10704,12 @@
10699
10704
  "type": "'all'|'between'|'none'",
10700
10705
  "default": "\"\\\"all\\\"\""
10701
10706
  },
10707
+ {
10708
+ "name": "selectionWhenInteracted",
10709
+ "attribute": "selection-when-interacted",
10710
+ "description": "Show selection only on hover, focus or if at least one item is selected. Exclusive for the tile layout",
10711
+ "type": "boolean"
10712
+ },
10702
10713
  {
10703
10714
  "name": "addButton",
10704
10715
  "attribute": "add-button",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.207.1",
3
+ "version": "3.208.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",