@brightspace-ui/core 3.147.5 → 3.148.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.
@@ -446,6 +446,111 @@ If an item is draggable, the `drag-handle-text` attribute should be used to prov
446
446
  <d2l-my-drag-drop-elem></d2l-my-drag-drop-elem>
447
447
  ```
448
448
 
449
+ #### Draggable lists with interactive content
450
+
451
+ When a list item contains interactive content and the list item is not interactive in any way other than being `draggable` (i.e., not a link, button, `selectable`, or `expandable`), in order for the interactive content to have mouse events work as expected, one of the following should be done:
452
+ - use the `drag-target-handle-only` on the list item; this causes the drag target to be the handle only rather than the entire cell
453
+ - put the interactive content in the `actions` slot
454
+
455
+ These scenarios can be seen in the demo below.
456
+
457
+ <!-- docs: demo code display:block sandboxTitle:'List - Drag & Drop with interactive content'-->
458
+ ```html
459
+ <script type="module">
460
+ import '@brightspace-ui/core/components/list/list.js';
461
+ import '@brightspace-ui/core/components/list/list-item.js';
462
+ import '@brightspace-ui/core/components/list/list-item-content.js';
463
+ import '@brightspace-ui/core/components/switch/switch.js';
464
+ import '@brightspace-ui/core/components/tooltip/tooltip-help.js';
465
+ import { css, html, LitElement } from 'lit';
466
+ import { labelStyles } from '@brightspace-ui/core/components/typography/styles.js';
467
+
468
+ class ListDemoDragAndDropInteractiveUsage extends LitElement {
469
+ static get properties() {
470
+ return {
471
+ list: { type: Array }
472
+ };
473
+ }
474
+
475
+ static get styles() {
476
+ return labelStyles;
477
+ }
478
+
479
+ constructor() {
480
+ super();
481
+ this.list = [
482
+ { key: '1', content: 'Initially first list item' },
483
+ { key: '2', content: 'Initially second list item' }
484
+ ];
485
+ }
486
+
487
+ render() {
488
+ return html`
489
+ <div style="display: flex; gap: 2rem; flex-wrap: wrap;">
490
+ <div style="flex-grow: 1; min-width: 100px;">
491
+ <div class="d2l-label-text" style="padding-bottom: 1rem;">Using "drag-target-handle-only":</div>
492
+ ${this._renderList1()}
493
+ </div>
494
+
495
+ <div style="flex-grow: 1; min-width: 100px;">
496
+ <div class="d2l-label-text" style="padding-bottom: 1rem;">Using "actions" slot:</div>
497
+ ${this._renderList2()}
498
+ </div>
499
+ </div>
500
+ `;
501
+ }
502
+
503
+ _renderList1() {
504
+ const listItems = this.list.map((item) => {
505
+ return html`
506
+ <d2l-list-item draggable key="${item.key}" label="Draggable List Item" drag-target-handle-only>
507
+ <d2l-list-item-content>
508
+ ${item.content}
509
+ <div slot="secondary"><d2l-tooltip-help text="Hover for more info">Secondary information</d2l-tooltip-help></div>
510
+ </d2l-list-item-content>
511
+ </d2l-list-item>
512
+ `;
513
+ });
514
+
515
+ return html`
516
+ <d2l-list @d2l-list-item-position-change="${this._moveItems}">
517
+ ${listItems}
518
+ </d2l-list>
519
+ `;
520
+ }
521
+
522
+ _renderList2() {
523
+ const listItems = this.list.map((item) => {
524
+ return html`
525
+ <d2l-list-item draggable key="${item.key}" label="Draggable List Item">
526
+ <d2l-list-item-content>
527
+ ${item.content}
528
+ <div slot="secondary">Secondary information</div>
529
+ </d2l-list-item-content>
530
+ <div slot="actions">
531
+ <d2l-switch text="Action switch" text-position="hidden"></d2l-switch>
532
+ </div>
533
+ </d2l-list-item>
534
+ `;
535
+ });
536
+
537
+ return html`
538
+ <d2l-list @d2l-list-item-position-change="${this._moveItems}" >
539
+ ${listItems}
540
+ </d2l-list>
541
+ `;
542
+ }
543
+
544
+ _moveItems(e) {
545
+ e.detail.reorder(this.list, { keyFn: (item) => item.key });
546
+ this.requestUpdate('list', []);
547
+ }
548
+ }
549
+ customElements.define('d2l-my-drag-drop-elem-interactive', ListDemoDragAndDropInteractiveUsage);
550
+ </script>
551
+ <d2l-my-drag-drop-elem-interactive></d2l-my-drag-drop-elem-interactive>
552
+ ```
553
+
449
554
  ## List Controls [d2l-list-controls]
450
555
 
451
556
  The `d2l-list-controls` component can be placed in the `d2l-list`'s `controls` slot to provide a select-all checkbox, summary, a slot for `d2l-selection-action`s, and overflow-group behaviour.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.147.5",
3
+ "version": "3.148.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",