@brightspace-ui/core 3.148.9 → 3.149.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.
@@ -8,7 +8,8 @@ import { ifDefined } from 'lit/directives/if-defined.js';
8
8
  class ListNestedIterationsHelper extends LitElement {
9
9
  static get properties() {
10
10
  return {
11
- isDraggable: { attribute: 'is-draggable', type: Boolean }
11
+ isDraggable: { attribute: 'is-draggable', type: Boolean },
12
+ separators: { type: String }
12
13
  };
13
14
  }
14
15
 
@@ -109,7 +110,7 @@ class ListNestedIterationsHelper extends LitElement {
109
110
 
110
111
  _createList(parentOptions, childrenOptions) {
111
112
  return html`
112
- <d2l-list>
113
+ <d2l-list separators=${ifDefined(this.separators)}>
113
114
  ${this._getParentItems(parentOptions, this._getChildItems(childrenOptions))}
114
115
  </d2l-list>
115
116
  `;
@@ -133,7 +134,7 @@ class ListNestedIterationsHelper extends LitElement {
133
134
  <d2l-list-item key="${childKey}" label="${childL2Text}" ?selectable="${!!childOptions[0]}" ?draggable="${this.isDraggable}" ?expandable="${childOptions[1] && i !== 1}" color="${ifDefined((childOptions[2] && i === 0) || childOptions[3] ? '#ff0000' : undefined)}">
134
135
  <d2l-list-item-content>${childL2Text}</d2l-list-item-content>
135
136
  ${i === 1 || !childOptions[1] ? nothing : html`
136
- <d2l-list slot="nested">
137
+ <d2l-list slot="nested" separators=${ifDefined(this.separators)}>
137
138
  <d2l-list-item key="${`${childKey}-child`}" label="${childL3Text}" ?selectable="${!!childOptions[0]}" ?draggable="${this.isDraggable}" color="${ifDefined(childOptions[3] ? '#00ff00' : undefined)}">
138
139
  <d2l-list-item-content>${childL3Text}</d2l-list-item-content>
139
140
  </d2l-list-item>
@@ -155,7 +156,7 @@ class ListNestedIterationsHelper extends LitElement {
155
156
  <d2l-list-item key="${parentKey}" label="${parentText}" ?selectable="${!!parentOptions[0]}" ?draggable="${this.isDraggable}" ?expandable="${parentOptions[1] && i !== 1}" ?expanded="${parentOptions[1] && i === 0}" color="${ifDefined((parentOptions[2] && i === 0) || parentOptions[3] ? '#ff0000' : undefined)}">
156
157
  <d2l-list-item-content>${parentText}</d2l-list-item-content>
157
158
  ${i === 1 || (i === 2 && !parentOptions[1]) ? nothing : html`
158
- <d2l-list slot="nested">${nested}</d2l-list>
159
+ <d2l-list slot="nested" separators=${ifDefined(this.separators)}>${nested}</d2l-list>
159
160
  `}
160
161
  </d2l-list-item>
161
162
  `);
@@ -151,8 +151,8 @@ export const ListItemMixin = superclass => class extends composeMixins(
151
151
 
152
152
  :host(:first-of-type) [slot="control-container"]::before,
153
153
  [slot="control-container"]::after,
154
- :host([_list-item-new-styles][expandable][expanded]:not(:last-of-type))::after,
155
- :host([_list-item-new-styles][_has-nested-list]:not([expandable]):not(:last-of-type))::after {
154
+ :host([_list-item-new-styles]:not([_separators="none"])[expandable][expanded]:not(:last-of-type))::after,
155
+ :host([_list-item-new-styles]:not([_separators="none"])[_has-nested-list]:not([expandable]):not(:last-of-type))::after {
156
156
  border-top: 1px solid var(--d2l-color-mica);
157
157
  content: "";
158
158
  position: absolute;
@@ -293,6 +293,50 @@
293
293
  </template>
294
294
  </d2l-demo-snippet>
295
295
 
296
+ <h2>Tabs (before selected)</h2>
297
+
298
+ <d2l-demo-snippet>
299
+ <template>
300
+ <d2l-tabs text="Courses" id="courses-before-selection">
301
+ <d2l-tab id="all" text="All" slot="tabs"></d2l-tab>
302
+ <d2l-tab id="biology" text="Biology" slot="tabs" selected></d2l-tab>
303
+ <d2l-tab-panel labelled-by="all" slot="panels" id="all-panel">Tab content for All</d2l-tab-panel>
304
+ <d2l-tab-panel labelled-by="biology" slot="panels" id="biology-panel">Tab content for Biology</d2l-tab-panel>
305
+ </d2l-tabs>
306
+
307
+ <script>
308
+ document.querySelector('#courses-before-selection').addEventListener('d2l-tab-before-selected', e => {
309
+ e.preventDefault();
310
+ setTimeout(() => {
311
+ e.detail.select();
312
+ }, 2000);
313
+ });
314
+ </script>
315
+ </template>
316
+ </d2l-demo-snippet>
317
+
318
+ <h2>Tabs (before selected, don't select)</h2>
319
+
320
+ <d2l-demo-snippet>
321
+ <template>
322
+ <d2l-tabs text="Courses" id="courses-before-selection-reset">
323
+ <d2l-tab id="all" text="All" slot="tabs"></d2l-tab>
324
+ <d2l-tab id="biology" text="Biology" slot="tabs" selected></d2l-tab>
325
+ <d2l-tab-panel labelled-by="all" slot="panels" id="all-panel">Tab content for All</d2l-tab-panel>
326
+ <d2l-tab-panel labelled-by="biology" slot="panels" id="biology-panel">Tab content for Biology</d2l-tab-panel>
327
+ </d2l-tabs>
328
+
329
+ <script>
330
+ document.querySelector('#courses-before-selection-reset').addEventListener('d2l-tab-before-selected', e => {
331
+ e.preventDefault();
332
+ setTimeout(() => {
333
+ e.detail.reset();
334
+ }, 2000);
335
+ });
336
+ </script>
337
+ </template>
338
+ </d2l-demo-snippet>
339
+
296
340
  <h2>Tabs (deprecated structure)</h2>
297
341
 
298
342
  <d2l-demo-snippet>
@@ -24,7 +24,8 @@ export const TabMixin = superclass => class extends SkeletonMixin(superclass) {
24
24
  /**
25
25
  * @ignore
26
26
  */
27
- tabIndex: { type: Number, reflect: true, attribute: 'tabindex' }
27
+ tabIndex: { type: Number, reflect: true, attribute: 'tabindex' },
28
+ _clicked: { type: Boolean, reflect: true },
28
29
  };
29
30
  }
30
31
 
@@ -66,6 +67,9 @@ export const TabMixin = superclass => class extends SkeletonMixin(superclass) {
66
67
  color: var(--d2l-color-celestine);
67
68
  cursor: pointer;
68
69
  }
70
+ :host([_clicked]) {
71
+ color: var(--d2l-color-celestine);
72
+ }
69
73
  :host([selected]:hover) {
70
74
  color: inherit;
71
75
  cursor: default;
@@ -88,6 +92,8 @@ export const TabMixin = superclass => class extends SkeletonMixin(superclass) {
88
92
  this.role = 'tab';
89
93
  this.selected = false;
90
94
  this.tabIndex = -1;
95
+
96
+ this._clicked = false;
91
97
  }
92
98
 
93
99
  firstUpdated(changedProperties) {
@@ -135,7 +141,21 @@ export const TabMixin = superclass => class extends SkeletonMixin(superclass) {
135
141
  }
136
142
 
137
143
  #handleClick() {
144
+ this._clicked = true;
145
+ const beforeSelectedEvent = new CustomEvent('d2l-tab-before-selected', {
146
+ detail: {
147
+ select: () => { this.selected = true; this._clicked = false; },
148
+ reset: () => this._clicked = false
149
+ },
150
+ cancelable: true,
151
+ bubbles: true,
152
+ composed: true
153
+ });
154
+ this.dispatchEvent(beforeSelectedEvent);
155
+ if (beforeSelectedEvent.defaultPrevented) return;
156
+
138
157
  this.selected = true;
158
+ this._clicked = false;
139
159
  };
140
160
 
141
161
  #handleKeydown(e) {
@@ -15,6 +15,7 @@ const focusRingStyles = getFocusRingStyles(
15
15
  /**
16
16
  * @attr {string} id - REQUIRED: Unique identifier for the tab
17
17
  * @fires d2l-tab-content-change - Dispatched when the text attribute is changed. Triggers virtual scrolling calculations in parent d2l-tabs.
18
+ * @fires d2l-tab-before-selected - Dispatched before selected state is updated. Can be canceled to allow the consumer to handle when selected is set. This is useful if something needs to happen prior to selection.
18
19
  * @slot before - Slot for content to be displayed before the tab text. Supports `d2l-icon`, `d2l-icon-custom`, and `d2l-count-badge`. Only the *first* item assigned to this slot will be shown.
19
20
  * @slot after - Slot for content to be displayed after the tab text. Supports `d2l-icon`, `d2l-icon-custom`, and `d2l-count-badge`. Only the *last* item assigned to this slot will be shown.
20
21
  */
@@ -8421,6 +8421,10 @@
8421
8421
  "name": "d2l-demo-list-nested-iterations-helper",
8422
8422
  "path": "./components/list/demo/demo-list-nested-iterations-helper.js",
8423
8423
  "attributes": [
8424
+ {
8425
+ "name": "separators",
8426
+ "type": "string"
8427
+ },
8424
8428
  {
8425
8429
  "name": "is-draggable",
8426
8430
  "type": "boolean",
@@ -8428,6 +8432,11 @@
8428
8432
  }
8429
8433
  ],
8430
8434
  "properties": [
8435
+ {
8436
+ "name": "separators",
8437
+ "attribute": "separators",
8438
+ "type": "string"
8439
+ },
8431
8440
  {
8432
8441
  "name": "isDraggable",
8433
8442
  "attribute": "is-draggable",
@@ -13740,6 +13749,9 @@
13740
13749
  },
13741
13750
  {
13742
13751
  "name": "d2l-tab-content-change"
13752
+ },
13753
+ {
13754
+ "name": "d2l-tab-before-selected"
13743
13755
  }
13744
13756
  ]
13745
13757
  },
@@ -13947,6 +13959,10 @@
13947
13959
  "name": "d2l-tab-content-change",
13948
13960
  "description": "Dispatched when the text attribute is changed. Triggers virtual scrolling calculations in parent d2l-tabs."
13949
13961
  },
13962
+ {
13963
+ "name": "d2l-tab-before-selected",
13964
+ "description": "Dispatched before selected state is updated. Can be canceled to allow the consumer to handle when selected is set. This is useful if something needs to happen prior to selection."
13965
+ },
13950
13966
  {
13951
13967
  "name": "d2l-tab-selected",
13952
13968
  "description": "Dispatched when a tab is selected"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.148.9",
3
+ "version": "3.149.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",