@brightspace-ui/core 3.5.1 → 3.6.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.
@@ -60,8 +60,11 @@ class ButtonSubtle extends ButtonMixin(LitElement) {
60
60
  return [ labelStyles, buttonStyles,
61
61
  css`
62
62
  :host {
63
+ --d2l-count-badge-background-color: var(--d2l-color-celestine);
64
+ --d2l-count-badge-foreground-color: #ffffff;
63
65
  display: inline-block;
64
66
  }
67
+
65
68
  :host([hidden]) {
66
69
  display: none;
67
70
  }
@@ -103,11 +106,13 @@ class ButtonSubtle extends ButtonMixin(LitElement) {
103
106
  button::-moz-focus-inner {
104
107
  border: 0;
105
108
  }
109
+
106
110
  button[disabled]:hover,
107
111
  button[disabled]:focus,
108
112
  :host([active]) button[disabled] {
109
113
  background-color: transparent;
110
114
  }
115
+
111
116
  button:hover,
112
117
  button:focus,
113
118
  :host([active]) button {
@@ -117,14 +122,24 @@ class ButtonSubtle extends ButtonMixin(LitElement) {
117
122
  .d2l-button-subtle-content {
118
123
  color: var(--d2l-color-celestine);
119
124
  }
125
+
120
126
  button:hover:not([disabled]) .d2l-button-subtle-content,
121
127
  button:focus:not([disabled]) .d2l-button-subtle-content,
122
128
  :host([active]:not([disabled])) button .d2l-button-subtle-content {
123
129
  color: var(--d2l-color-celestine-minus-1);
124
130
  }
131
+
132
+ button:hover:not([disabled]),
133
+ button:focus:not([disabled]),
134
+ :host([active]:not([disabled])) {
135
+ --d2l-count-badge-background-color: var(--d2l-color-celestine-minus-1);
136
+ }
137
+
138
+
125
139
  .d2l-button-subtle-has-icon .d2l-button-subtle-content-wrapper {
126
140
  padding-inline: 1.2rem 0;
127
141
  }
142
+
128
143
  :host([icon-right]) .d2l-button-subtle-has-icon .d2l-button-subtle-content-wrapper {
129
144
  padding-inline: 0 1.2rem;
130
145
  }
@@ -106,26 +106,26 @@ export const CountBadgeMixin = superclass => class extends LocalizeCoreElement(S
106
106
  :host([hidden]) {
107
107
  display: none;
108
108
  }
109
-
109
+
110
110
  :host {
111
111
  display: inline-block;
112
112
  min-width: 0.9rem;
113
113
  }
114
-
114
+
115
115
  .d2l-count-badge-number {
116
116
  font-weight: bold;
117
117
  }
118
-
118
+
119
119
  :host([type="notification"]) .d2l-count-badge-number {
120
120
  background-color: var(--d2l-color-carnelian-minus-1);
121
121
  color: white;
122
122
  }
123
-
123
+
124
124
  :host([type="count"]) .d2l-count-badge-number {
125
- background-color: var(--d2l-color-gypsum);
126
- color: var(--d2l-color-ferrite);
125
+ background-color: var(--d2l-count-badge-background-color, var(--d2l-color-gypsum));
126
+ color: var(--d2l-count-badge-foreground-color, var(--d2l-color-ferrite));
127
127
  }
128
-
128
+
129
129
  :host([size="small"]) .d2l-count-badge-number {
130
130
  border-radius: 0.55rem;
131
131
  font-size: 0.6rem;
@@ -133,7 +133,7 @@ export const CountBadgeMixin = superclass => class extends LocalizeCoreElement(S
133
133
  padding-left: 0.3rem;
134
134
  padding-right: 0.3rem;
135
135
  }
136
-
136
+
137
137
  :host([size="large"]) .d2l-count-badge-number {
138
138
  border-radius: 0.7rem;
139
139
  font-size: 0.8rem;
@@ -203,7 +203,7 @@ export const CountBadgeMixin = superclass => class extends LocalizeCoreElement(S
203
203
  }
204
204
  return html`
205
205
  <div class="d2l-count-badge-number" style=${styleMap(numberStyles)}>
206
- <div aria-hidden="true">${this.getNumberString()}</div>
206
+ <div aria-hidden="true">${this.getNumberString()}</div>
207
207
  </div>
208
208
  `;
209
209
  }
@@ -41,6 +41,19 @@
41
41
  </template>
42
42
  </d2l-demo-snippet>
43
43
 
44
+ <h2>Override Colorway of Count Badge</h2>
45
+ <d2l-demo-snippet>
46
+ <template>
47
+ <d2l-count-badge id="colorway-override" size="large" text="1 new notification." type="count" number="1"></d2l-count-badge>
48
+ <style>
49
+ #colorway-override {
50
+ --d2l-count-badge-background-color: purple;
51
+ --d2l-count-badge-foreground-color: #ffffff;
52
+ }
53
+ </style>
54
+ </template>
55
+ </d2l-demo-snippet>
56
+
44
57
  <h2>Small Notification Badge with Tooltip</h2>
45
58
  <d2l-demo-snippet>
46
59
  <template>
@@ -2,7 +2,7 @@ import '../colors/colors.js';
2
2
  import '../count-badge/count-badge.js';
3
3
  import '../button/button-icon.js';
4
4
  import '../button/button-subtle.js';
5
- import '../dropdown/dropdown-button-subtle.js';
5
+ import '../dropdown/dropdown.js';
6
6
  import '../dropdown/dropdown-content.js';
7
7
  import '../dropdown/dropdown-menu.js';
8
8
  import '../empty-state/empty-state-action-button.js';
@@ -208,7 +208,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
208
208
  }
209
209
 
210
210
  static get focusElementSelector() {
211
- return 'd2l-dropdown-button-subtle';
211
+ return 'd2l-button-subtle';
212
212
  }
213
213
 
214
214
  firstUpdated(changedProperties) {
@@ -228,9 +228,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
228
228
  const header = this._buildHeader(singleDimension);
229
229
  const dimensions = this._buildDimensions(singleDimension);
230
230
 
231
- const filterCount = this._formatFilterCount(this._totalAppliedCount);
232
- let buttonText = singleDimension ? this._dimensions[0].text : (this.text || this.localize('components.filter.filters'));
233
- if (filterCount) buttonText = `${buttonText} (${filterCount})`;
231
+ const buttonText = singleDimension ? this._dimensions[0].text : (this.text || this.localize('components.filter.filters'));
234
232
 
235
233
  let description = singleDimension ? this.localize('components.filter.singleDimensionDescription', { filterName: this._dimensions[0].text }) : this.localize('components.filter.filters');
236
234
  description += `. ${this.localize('components.filter.filterCountDescription', { number: this._totalAppliedCount })}`;
@@ -266,17 +264,34 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
266
264
  </d2l-dropdown-menu>
267
265
  `;
268
266
 
267
+ const countBadgeTemplate = this._totalAppliedCount ?
268
+ html`
269
+ <d2l-count-badge
270
+ aria-hidden="true"
271
+ max-digits="2"
272
+ type="count"
273
+ number="${this._totalAppliedCount}">
274
+ </d2l-count-badge>`
275
+ : nothing;
276
+
269
277
  return html`
270
- <d2l-dropdown-button-subtle
271
- class="vdiff-target"
278
+ <d2l-dropdown
272
279
  @d2l-dropdown-close="${this._handleDropdownClose}"
273
280
  @d2l-dropdown-open="${this._handleDropdownOpen}"
274
281
  @d2l-dropdown-position="${this._stopPropagation}"
275
- text="${buttonText}"
276
- description="${description}"
282
+ class="vdiff-target"
277
283
  ?disabled="${this.disabled}">
284
+ <d2l-button-subtle
285
+ class="d2l-dropdown-opener"
286
+ description="${description}"
287
+ text="${buttonText}"
288
+ icon="tier1:chevron-down"
289
+ icon-right
290
+ ?disabled="${this.disabled}">
291
+ ${countBadgeTemplate}
292
+ </d2l-button-subtle>
278
293
  ${dropdownContent}
279
- </d2l-dropdown-button-subtle>
294
+ </d2l-dropdown>
280
295
  <slot @slotchange="${this._handleSlotChange}"></slot>
281
296
  `;
282
297
  }
@@ -608,12 +623,6 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
608
623
  }
609
624
  }
610
625
 
611
- _formatFilterCount(count) {
612
- if (count === 0) return;
613
- else if (count >= 100) return '99+';
614
- else return `${count}`;
615
- }
616
-
617
626
  _getActiveDimension() {
618
627
  return !this._activeDimensionKey ? this._dimensions[0] : this._getDimensionByKey(this._activeDimensionKey);
619
628
  }
@@ -241,3 +241,4 @@ class MyComponent extends HierarchicalViewMixin(LitElement) {
241
241
  - `d2l-hierarchical-view-show-complete`: dispatched when child view is shown (when animation ends)
242
242
  - `d2l-hierarchical-view-hide-start`: dispatched when child view will be hidden (before animation begins)
243
243
  - `d2l-hierarchical-view-hide-complete`: dispatched when child view is hidden (when animation ends)
244
+ - `d2l-hierarchical-view-resize`: dispatched when child view is resized
@@ -1,6 +1,13 @@
1
1
  import { css, html, LitElement } from 'lit';
2
2
  import { HierarchicalViewMixin } from '../hierarchical-view/hierarchical-view-mixin.js';
3
3
 
4
+ /**
5
+ * @fires d2l-hierarchical-view-show-start - Dispatched when child view will be shown (before animation begins)
6
+ * @fires d2l-hierarchical-view-show-complete - Dispatched when child view is shown (when animation ends)
7
+ * @fires d2l-hierarchical-view-hide-start - Dispatched when child view will be hidden (before animation begins)
8
+ * @fires d2l-hierarchical-view-hide-complete - Dispatched when child view is hidden (when animation ends)
9
+ * @fires d2l-hierarchical-view-resize - Dispatched when child view is resized
10
+ */
4
11
  class HierarchicalView extends HierarchicalViewMixin(LitElement) {
5
12
 
6
13
  static get styles() {
@@ -132,7 +132,9 @@ For long tables, the header row can be made to "stick" in place as the user scro
132
132
 
133
133
  ## Sortable Column Buttons [d2l-table-col-sort-button]
134
134
 
135
- When tabular data can be sorted, the `<d2l-table-col-sort-button>` can be used to provide an interactive sort button as well as arrows to indicate the ascending/descending sort direction.
135
+ When tabular data can be sorted, the `<d2l-table-col-sort-button>` can be used to provide an interactive sort button as well as arrows to indicate the ascending/descending sort direction. This is meant to be used within a `d2l-table-wrapper`.
136
+
137
+ Note that the example below hides much of the implementation. See the code in [Multi-Faceted Sort Button](#multi-faceted-sort-button) for a more detailed implementation example.
136
138
 
137
139
  <!-- docs: demo -->
138
140
  ```html
@@ -210,15 +212,17 @@ When tabular data can be sorted, the `<d2l-table-col-sort-button>` can be used t
210
212
  ```
211
213
 
212
214
  ```html
213
- <table class="d2l-table">
214
- <thead>
215
- <tr>
216
- <th><d2l-table-col-sort-button>Ascending</d2l-table-col-sort-button></th>
217
- <th><d2l-table-col-sort-button desc>Descending</d2l-table-col-sort-button></th>
218
- <th><d2l-table-col-sort-button nosort>Not Sorted</d2l-table-col-sort-button></th>
219
- </tr>
220
- </thead>
221
- </table>
215
+ <d2l-table-wrapper>
216
+ <table class="d2l-table">
217
+ <thead>
218
+ <tr>
219
+ <th><d2l-table-col-sort-button>Ascending</d2l-table-col-sort-button></th>
220
+ <th><d2l-table-col-sort-button desc>Descending</d2l-table-col-sort-button></th>
221
+ <th><d2l-table-col-sort-button nosort>Not Sorted</d2l-table-col-sort-button></th>
222
+ </tr>
223
+ </thead>
224
+ </table>
225
+ </d2l-table-wrapper>
222
226
  ```
223
227
 
224
228
  ### Properties
@@ -228,7 +232,134 @@ When tabular data can be sorted, the `<d2l-table-col-sort-button>` can be used t
228
232
  | `desc` | boolean | Whether sort direction is descending | false |
229
233
  | `nosort` | boolean | Column is not currently sorted. Hides the ascending/descending sort icon. | false |
230
234
  | `position` | string | Position of the button content. Accepted values are 'start', 'center', and 'end'. | 'start' |
231
- | `source-type` | string | The type of data in the column. Used to set the title. Accepted values are 'words', 'numbers', and 'dates'. | 'unknown' |
235
+ | `source-type` | string | The type of data in the column. Used to set the title. Accepted values are 'words', 'numbers', and 'dates'. This is only applicable to cases that are not using the multi-faceted dropdown. | 'unknown' |
236
+
237
+ ### Slots
238
+ | Name | Description |
239
+ |---|---|
240
+ | `Default` | Column header text |
241
+ | `items` | Multi-facted sort items. Generally assigned to the `slot` attribute on a nested `d2l-table-col-sort-button-item`. |
242
+
243
+ ### Slotted Item [d2l-table-col-sort-button-item]
244
+
245
+ This is a radio menu item to be used within the `d2l-table-col-sort-button` component for a [multi-faceted sort](#multi-faceted-sort-button).
246
+
247
+ <!-- docs: demo code properties autoSize:false align:start name:d2l-table-col-sort-button-item -->
248
+ ```html
249
+ <script type="module">
250
+ import '@brightspace-ui/core/components/table/table-col-sort-button.js';
251
+ import '@brightspace-ui/core/components/table/table-col-sort-button-item.js';
252
+ </script>
253
+ <!-- docs: start hidden content -->
254
+ <style>
255
+ d2l-table-col-sort-button {
256
+ --d2l-table-cell-padding: 10px;
257
+ }
258
+ </style>
259
+ <!-- docs: end hidden content -->
260
+ <d2l-table-col-sort-button desc>
261
+ Items
262
+ <d2l-table-col-sort-button-item text="Item 1" slot="items" value="item1"></d2l-table-col-sort-button-item>
263
+ <d2l-table-col-sort-button-item text="Item 2" slot="items" value="item2"></d2l-table-col-sort-button-item>
264
+ </d2l-table-col-sort-button>
265
+ ```
266
+
267
+ ### Multi-Faceted Sort Button
268
+
269
+ When a single column is responsible for sorting in multiple facets (e.g., first name and last name), it is recommended to use the dropdown menu approach by slotting `d2l-table-col-sort-button-item` components within the `d2l-table-col-sort-button`. Please note that the consumer is responsible for all sort logic, including when `desc` and `nosort` are set on `d2l-table-col-sort-button`.
270
+
271
+ **WARNING**: Do NOT use this if the table is using `sticky-headers` AND multiple header rows. It is not currently supported. In that siuation, continue to put multiple `d2l-table-col-sort-button` components in the same column.
272
+
273
+ <!-- docs: demo code display:block -->
274
+ ```html
275
+ <script type="module">
276
+ import '@brightspace-ui/core/components/table/table-col-sort-button.js';
277
+ import '@brightspace-ui/core/components/table/table-col-sort-button-item.js';
278
+ import { html, LitElement } from 'lit';
279
+ import { tableStyles } from '@brightspace-ui/core/components/table/table-wrapper.js';
280
+ const data = () => [
281
+ { firstname: 'John', lastname: 'Smith', grade: 85 },
282
+ { firstname: 'Emily', lastname: 'Jones', grade: 92 },
283
+ { firstname: 'Michael', lastname: 'Davis', grade: 78 },
284
+ { firstname: 'Sarah', lastname: 'Brown', grade: 90 },
285
+ { firstname: 'David', lastname: 'Wilson', grade: 88 },
286
+ { firstname: 'Jessica', lastname: 'Taylor', grade: 95 },
287
+ { firstname: 'Christopher', lastname: 'Martinez', grade: 83 }
288
+ ];
289
+ class MyComplexSortableTableElem extends LitElement {
290
+ static get properties() {
291
+ return {
292
+ _desc: { state: true },
293
+ _field: { state: true }
294
+ };
295
+ }
296
+ static get styles() {
297
+ return tableStyles;
298
+ }
299
+ constructor() {
300
+ super();
301
+ this._data = data();
302
+ this._desc = false;
303
+ }
304
+ render() {
305
+ const rowData = this._field ? this._data.sort((a, b) => {
306
+ if (this._desc) {
307
+ if (a[this._field] > b[this._field]) return -1;
308
+ if (a[this._field] < b[this._field]) return 1;
309
+ } else {
310
+ if (a[this._field] < b[this._field]) return -1;
311
+ if (a[this._field] > b[this._field]) return 1;
312
+ }
313
+ return 0;
314
+ }) : this._data;
315
+ const rows = rowData.map(i => {
316
+ return html`<tr>
317
+ <td>${i.firstname} ${i.lastname}</td>
318
+ <td>${i.grade}</td>
319
+ </tr>
320
+ `;
321
+ });
322
+ return html`
323
+ <d2l-table-wrapper>
324
+ <table class="d2l-table">
325
+ <thead>
326
+ <tr>
327
+ <th>
328
+ <d2l-table-col-sort-button ?desc="${this._desc}" ?nosort="${this._field !== 'firstname' && this._field !== 'lastname'}">
329
+ Learner
330
+ <d2l-table-col-sort-button-item slot="items" text="First Name, A to Z" data-field="firstname" @d2l-table-col-sort-button-item-change="${this._handleSortComplex}" value="1"></d2l-table-col-sort-button-item>
331
+ <d2l-table-col-sort-button-item slot="items" text="First Name, Z to A" data-field="firstname" data-desc @d2l-table-col-sort-button-item-change="${this._handleSortComplex}" value="2"></d2l-table-col-sort-button-item>
332
+ <d2l-table-col-sort-button-item slot="items" text="Last Name, A to Z" data-field="lastname" @d2l-table-col-sort-button-item-change="${this._handleSortComplex}" value="3"></d2l-table-col-sort-button-item>
333
+ <d2l-table-col-sort-button-item slot="items" text="Last Name, Z to A" data-field="lastname" data-desc @d2l-table-col-sort-button-item-change="${this._handleSortComplex}" value="4"></d2l-table-col-sort-button-item>
334
+ </d2l-table-col-sort-button>
335
+ </th>
336
+ <th>
337
+ <d2l-table-col-sort-button ?desc="${this._desc}" data-field="grade" @click="${this._handleSort}" ?nosort="${this._field !== 'grade'}">Grade</d2l-table-col-sort-button>
338
+ </th>
339
+ </tr>
340
+ </thead>
341
+ <tbody>
342
+ ${rows}
343
+ </tbody>
344
+ </table>
345
+ </d2l-table-wrapper>
346
+ `;
347
+ }
348
+ _handleSort(e) {
349
+ const field = e.target.getAttribute('data-field');
350
+ const desc = e.target.hasAttribute('desc');
351
+ this._desc = field === this._field ? !desc : false;
352
+ this._field = field;
353
+ }
354
+ _handleSortComplex(e) {
355
+ this._field = e.target.getAttribute('data-field');
356
+ this._desc = e.target.hasAttribute('data-desc');
357
+ }
358
+ }
359
+ customElements.define('d2l-my-complex-sortable-table-elem', MyComplexSortableTableElem);
360
+ </script>
361
+ <d2l-my-complex-sortable-table-elem></d2l-my-complex-sortable-table-elem>
362
+ ```
232
363
 
233
364
  ## Selection
234
365
 
@@ -6,6 +6,9 @@ import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
6
6
 
7
7
  /**
8
8
  * A radio menu item to be used within the d2l-table-col-sort-button component for a multi-faceted sort.
9
+ * @fires d2l-menu-item-change - Internal event
10
+ * @fires d2l-menu-item-select - Internal event
11
+ * @fires d2l-menu-item-visibility-change - Internal event
9
12
  */
10
13
  class TableColSortButtonItem extends RtlMixin(MenuItemRadioMixin(LitElement)) {
11
14
 
@@ -4564,7 +4564,29 @@
4564
4564
  },
4565
4565
  {
4566
4566
  "name": "d2l-hierarchical-view",
4567
- "path": "./components/hierarchical-view/hierarchical-view.js"
4567
+ "path": "./components/hierarchical-view/hierarchical-view.js",
4568
+ "events": [
4569
+ {
4570
+ "name": "d2l-hierarchical-view-show-start",
4571
+ "description": "Dispatched when child view will be shown (before animation begins)"
4572
+ },
4573
+ {
4574
+ "name": "d2l-hierarchical-view-show-complete",
4575
+ "description": "Dispatched when child view is shown (when animation ends)"
4576
+ },
4577
+ {
4578
+ "name": "d2l-hierarchical-view-hide-start",
4579
+ "description": "Dispatched when child view will be hidden (before animation begins)"
4580
+ },
4581
+ {
4582
+ "name": "d2l-hierarchical-view-hide-complete",
4583
+ "description": "Dispatched when child view is hidden (when animation ends)"
4584
+ },
4585
+ {
4586
+ "name": "d2l-hierarchical-view-resize",
4587
+ "description": "Dispatched when child view is resized"
4588
+ }
4589
+ ]
4568
4590
  },
4569
4591
  {
4570
4592
  "name": "d2l-html-block",
@@ -12118,21 +12140,21 @@
12118
12140
  }
12119
12141
  ],
12120
12142
  "events": [
12121
- {
12122
- "name": "d2l-table-col-sort-button-item-change",
12123
- "description": "Dispatched when the selected multi-faceted sort option changes"
12124
- },
12125
12143
  {
12126
12144
  "name": "d2l-menu-item-change",
12127
- "description": "Dispatched when the selected menu item changes"
12145
+ "description": "Internal event"
12128
12146
  },
12129
12147
  {
12130
12148
  "name": "d2l-menu-item-select",
12131
- "description": "Dispatched when the menu item is selected"
12149
+ "description": "Internal event"
12132
12150
  },
12133
12151
  {
12134
12152
  "name": "d2l-menu-item-visibility-change",
12135
- "description": "Dispatched when the visibility of the menu item changes"
12153
+ "description": "Internal event"
12154
+ },
12155
+ {
12156
+ "name": "d2l-table-col-sort-button-item-change",
12157
+ "description": "Dispatched when the selected multi-faceted sort option changes"
12136
12158
  }
12137
12159
  ]
12138
12160
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.5.1",
3
+ "version": "3.6.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",