@brightspace-ui/core 2.187.2 → 2.187.4

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.
@@ -138,7 +138,7 @@ The `d2l-button-icon` element can be used just like the native `button`, for ins
138
138
  |--|--|--|
139
139
  | `description` | String | A description to be added to the `button` for accessibility for additional context |
140
140
  | `icon` | String, required | [Preset icon key](../../components/icons#preset-icons) (e.g. `tier1:gear`) |
141
- | `text` | String, required | Accessible text for the buton |
141
+ | `text` | String, required | Accessible text for the button |
142
142
  | `disabled` | Boolean | Disables the button |
143
143
  | `disabledTooltip` | String | Tooltip text when disabled |
144
144
  | `h-align` | String | Possible values are undefined (default) or `text`. If `text`, aligns the button content to the leading edge of text. |
@@ -1,20 +1,43 @@
1
1
  import '../input-radio-spacer.js';
2
2
  import { html, LitElement } from 'lit';
3
+ import { bodySmallStyles } from '../../typography/styles.js';
3
4
  import { radioStyles } from '../input-radio-styles.js';
4
5
 
5
6
  class TestInputRadioSpacer extends LitElement {
6
7
 
7
8
  static get styles() {
8
- return radioStyles;
9
+ return [ radioStyles, bodySmallStyles ];
9
10
  }
10
11
 
11
12
  render() {
12
13
  return html`
13
- <input type="radio" class="d2l-input-radio" aria-label="Option 1"> Option 1
14
- <d2l-input-radio-spacer>
15
- Additional content can go here and will
16
- line up nicely with the edge of the radio.
17
- </d2l-input-radio-spacer>
14
+ <div>
15
+ <label class="d2l-input-radio-label">
16
+ <input type="radio" name="myGroup" value="normal" checked>
17
+ Option 1
18
+ </label>
19
+ <d2l-input-radio-spacer>
20
+ Additional content can go here and will line up nicely with the edge of the radio.
21
+ </d2l-input-radio-spacer>
22
+ </div>
23
+ <div>
24
+ <label class="d2l-input-radio-label">
25
+ <input type="radio" name="myGroup" value="normal">
26
+ Option 1 (A really really long label that will wrap to the next line where the indentation will be applied. All the text should align.)
27
+ </label>
28
+ <d2l-input-radio-spacer>
29
+ Additional content can go here and will line up nicely with the edge of the radio.
30
+ </d2l-input-radio-spacer>
31
+ </div>
32
+ <div>
33
+ <label class="d2l-input-radio-label">
34
+ <input type="radio" name="myGroup" value="normal">
35
+ Option 1
36
+ </label>
37
+ <d2l-input-radio-spacer>
38
+ <div class="d2l-body-small">Additional content can go here and will line up nicely with the edge of the radio.</div>
39
+ </d2l-input-radio-spacer>
40
+ </div>
18
41
  `;
19
42
  }
20
43
 
@@ -116,7 +116,7 @@ If you'd like to manually link the radio input with a label, or use an ARIA labe
116
116
 
117
117
  ## Radio Spacer [d2l-input-radio-spacer]
118
118
 
119
- To align related content below radio buttons, the `d2l-input-radio-spacer` element can be used:
119
+ To align related content below radio buttons, the `d2l-input-radio-spacer` element can be used in conjunction with the `d2l-input-radio-label` class:
120
120
 
121
121
  <!-- docs: demo code display:block -->
122
122
  ```html
@@ -133,11 +133,13 @@ To align related content below radio buttons, the `d2l-input-radio-spacer` eleme
133
133
 
134
134
  render() {
135
135
  return html`
136
- <input type="radio" class="d2l-input-radio" aria-label="Option 1"> Option 1
137
- <d2l-input-radio-spacer>
138
- Additional content can go here and will
139
- line up nicely with the edge of the radio.
140
- </d2l-input-radio-spacer>
136
+ <label class="d2l-input-radio-label">
137
+ <input type="radio" value="normal" checked>
138
+ Option 1
139
+ </label>
140
+ <d2l-input-radio-spacer>
141
+ Additional content can go here and will line up nicely with the edge of the radio.
142
+ </d2l-input-radio-spacer>
141
143
  `;
142
144
  }
143
145
 
@@ -16,17 +16,17 @@ import { DemoPassthroughMixin } from '../../demo/demo-passthrough-mixin.js';
16
16
  import { ifDefined } from 'lit/directives/if-defined.js';
17
17
  import { RtlMixin } from '../../../mixins/rtl/rtl-mixin.js';
18
18
 
19
- const fruits = ['Apples', 'Oranges', 'Bananas'];
19
+ const columns = ['Population', 'Size', 'Elevation'];
20
20
  const thText = ['Additional', 'Placeholder', 'Header', 'Row'];
21
21
 
22
22
  const data = () => [
23
- { name: 'Canada', fruit: { 'apples': 356863, 'oranges': 0, 'bananas': 0 }, selected: true },
24
- { name: 'Australia', fruit: { 'apples': 308298, 'oranges': 398610, 'bananas': 354241 }, selected: true },
25
- { name: 'Mexico', fruit: { 'apples': 716931, 'oranges': 4603253, 'bananas': 2384778 }, selected: false },
26
- { name: 'Brazil', fruit: { 'apples': 1300000, 'oranges': 50000, 'bananas': 6429875 }, selected: false },
27
- { name: 'England', fruit: { 'apples': 345782, 'oranges': 4, 'bananas': 1249875 }, selected: false },
28
- { name: 'Hawaii', fruit: { 'apples': 129875, 'oranges': 856765, 'bananas': 123 }, selected: false },
29
- { name: 'Japan', fruit: { 'apples': 8534, 'oranges': 1325, 'bananas': 78382756 }, selected: false }
23
+ { name: 'Ottawa, Canada', city: 'Ottawa', country: 'Canada', data: { 'population': 994837, 'size': 2790, 'elevation': 70 }, selected: true },
24
+ { name: 'Toronto, Canada', city: 'Toronto', country: 'Canada', data: { 'population': 2930000, 'size': 630, 'elevation': 76 }, selected: true },
25
+ { name: 'Sydney, Australia', city: 'Sydney', country: 'Australia', data: { 'population': 5312000, 'size': 12368, 'elevation': 3 }, selected: false },
26
+ { name: 'Cairo, Egypt', city: 'Cairo', country: 'Egypt', data: { 'population': 9540000, 'size': 3085, 'elevation': 23 }, selected: false },
27
+ { name: 'Moscow, Russia', city: 'Moscow', country: 'Russia', data: { 'population': 12712305, 'size': 2511, 'elevation': 124 }, selected: false },
28
+ { name: 'London, England', city: 'London', country: 'England', data: { 'population': 8982000, 'size': 1572, 'elevation': 11 }, selected: false },
29
+ { name: 'Tokyo, Japan', city: 'Tokyo', country: 'Japan', data: { 'population': 13960000, 'size': 2194, 'elevation': 40 }, selected: false }
30
30
  ];
31
31
 
32
32
  const formatter = new Intl.NumberFormat('en-US');
@@ -67,12 +67,6 @@ class TestTable extends RtlMixin(DemoPassthroughMixin(TableWrapper, 'd2l-table-w
67
67
  }
68
68
 
69
69
  render() {
70
- const sorted = this._data.sort((a, b) => {
71
- if (this._sortDesc) {
72
- return b.fruit[this._sortField] - a.fruit[this._sortField];
73
- }
74
- return a.fruit[this._sortField] - b.fruit[this._sortField];
75
- });
76
70
  return html`
77
71
  <d2l-table-wrapper item-count="${ifDefined(this.paging ? 500 : undefined)}">
78
72
  <d2l-table-controls slot="controls" ?no-sticky="${!this.stickyControls}" select-all-pages-allowed>
@@ -92,21 +86,24 @@ class TestTable extends RtlMixin(DemoPassthroughMixin(TableWrapper, 'd2l-table-w
92
86
  <thead>
93
87
  <tr>
94
88
  <th scope="col" sticky><d2l-selection-select-all></d2l-selection-select-all></th>
95
- <th scope="col">Country</th>
96
- ${fruits.map(fruit => this._renderSortButton(fruit))}
89
+ ${this._renderDoubleSortButton('City', 'Country')}
90
+ ${columns.map(columnHeading => this._renderSortButton(columnHeading))}
97
91
  </tr>
98
92
  </thead>
99
93
  <tbody>
100
94
  <tr class="d2l-table-header">
101
95
  <th scope="col" sticky></th>
102
- ${this._renderSortButton('Avocado')}
103
- ${fruits.map(fruit => this._renderSortButton(fruit))}
96
+ ${thText.map(text => html`<th scope="col">${text}</th>`)}
104
97
  </tr>
105
98
  <tr header>
106
99
  <th scope="col" sticky></th>
107
- ${thText.map(text => html`<th scope="col">${text}</th>`)}
100
+ ${thText.map(text => html`
101
+ <th scope="col">
102
+ ${text}
103
+ </th>
104
+ `)}
108
105
  </tr>
109
- ${sorted.map(row => html`
106
+ ${this._data.map(row => html`
110
107
  <tr ?selected="${row.selected}" data-name="${row.name}">
111
108
  <th scope="row" sticky>
112
109
  <d2l-selection-input
@@ -117,9 +114,10 @@ class TestTable extends RtlMixin(DemoPassthroughMixin(TableWrapper, 'd2l-table-w
117
114
  </d2l-selection-input>
118
115
  </th>
119
116
  <th scope="row">${row.name}</th>
120
- ${fruits.map(fruit => html`<td>${formatter.format(row.fruit[fruit.toLowerCase()])}</td>`)}
117
+ ${columns.map(columnHeading => html`<td>${formatter.format(row.data[columnHeading.toLowerCase()])}</td>`)}
121
118
  </tr>
122
119
  `)}
120
+
123
121
  </tbody>
124
122
  </table>
125
123
  ${this.paging ? html`<d2l-pager-load-more slot="pager"
@@ -134,7 +132,7 @@ class TestTable extends RtlMixin(DemoPassthroughMixin(TableWrapper, 'd2l-table-w
134
132
  _handlePagerLoadMore(e) {
135
133
  const startIndex = this._data.length + 1;
136
134
  for (let i = 0; i < e.target.pageSize; i++) {
137
- this._data.push({ name: `Country ${startIndex + i}`, fruit: { 'apples': 8534, 'oranges': 1325, 'bananas': 78382756 }, selected: false });
135
+ this._data.push({ name: `Country ${startIndex + i}`, data: { 'population': 26320000, 'size': 6340, 'elevation': 4 }, selected: false });
138
136
  }
139
137
  this.requestUpdate();
140
138
  e.detail.complete();
@@ -143,18 +141,50 @@ class TestTable extends RtlMixin(DemoPassthroughMixin(TableWrapper, 'd2l-table-w
143
141
  _handleSort(e) {
144
142
  const field = e.target.innerText.toLowerCase();
145
143
  const desc = e.target.hasAttribute('desc');
144
+ this._sortDesc = field === this._sortField ? !desc : false; // if sorting on same field then reverse, otherwise sort ascending
146
145
  this._sortField = field;
147
- this._sortDesc = !desc;
146
+
147
+ this._data = this._data.sort((a, b) => {
148
+ if (this._sortField === 'city' || this._sortField === 'country') {
149
+ if (this._sortDesc) {
150
+ if (a[this._sortField] > b[this._sortField]) return -1;
151
+ if (a[this._sortField] < b[this._sortField]) return 1;
152
+ } else {
153
+ if (a[this._sortField] < b[this._sortField]) return -1;
154
+ if (a[this._sortField] > b[this._sortField]) return 1;
155
+ }
156
+ } else {
157
+ if (this._sortDesc) {
158
+ return b.data[this._sortField] - a.data[this._sortField];
159
+ }
160
+ return a.data[this._sortField] - b.data[this._sortField];
161
+ }
162
+ });
163
+ }
164
+
165
+ _renderDoubleSortButton(item1, item2) {
166
+ return html`
167
+ <th scope="col">
168
+ <d2l-table-col-sort-button
169
+ @click="${this._handleSort}"
170
+ ?desc="${this._sortDesc}"
171
+ ?nosort="${this._sortField !== item1.toLowerCase()}">${item1}</d2l-table-col-sort-button>
172
+ <d2l-table-col-sort-button
173
+ @click="${this._handleSort}"
174
+ ?desc="${this._sortDesc}"
175
+ ?nosort="${this._sortField !== item2.toLowerCase()}">${item2}</d2l-table-col-sort-button>
176
+ </th>
177
+ `;
148
178
  }
149
179
 
150
- _renderSortButton(fruit) {
151
- const noSort = this._sortField !== fruit.toLowerCase();
180
+ _renderSortButton(item) {
181
+ const noSort = this._sortField !== item.toLowerCase();
152
182
  return html`
153
183
  <th scope="col">
154
184
  <d2l-table-col-sort-button
155
185
  @click="${this._handleSort}"
156
186
  ?desc="${this._sortDesc}"
157
- ?nosort="${noSort}">${fruit}</d2l-table-col-sort-button>
187
+ ?nosort="${noSort}">${item}</d2l-table-col-sort-button>
158
188
  </th>
159
189
  `;
160
190
  }
@@ -111,6 +111,16 @@ export const TagListItemMixin = superclass => class extends LocalizeCoreElement(
111
111
  :host(:focus-within:hover) .tag-list-item-container {
112
112
  box-shadow: inset 0 0 0 2px var(--d2l-color-celestine), 0 2px 4px rgba(0, 0, 0, 0.03);
113
113
  }
114
+ @supports selector(:has(a, b)) {
115
+ :host(:focus-within) .tag-list-item-container,
116
+ :host(:focus-within:hover) .tag-list-item-container {
117
+ box-shadow: inset 0 0 0 1px var(--d2l-color-gypsum), 0 2px 4px rgba(0, 0, 0, 0.03);
118
+ }
119
+ :host(:hover) .tag-list-item-container:has(:focus-visible),
120
+ .tag-list-item-container:has(:focus-visible) {
121
+ box-shadow: inset 0 0 0 2px var(--d2l-color-celestine), 0 2px 4px rgba(0, 0, 0, 0.03) !important;
122
+ }
123
+ }
114
124
  :host(:hover) .tag-list-item-container,
115
125
  :host(:focus-within) .tag-list-item-container {
116
126
  background-color: var(--d2l-color-sylvite);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.187.2",
3
+ "version": "2.187.4",
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",