@brightspace-ui/core 3.104.0 → 3.106.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.
@@ -241,7 +241,7 @@ Daylight buttons rely on standard button semantics to ensure a smooth experience
241
241
  * If the button's context is implied by visual layout, then `description` can be used to add missing context
242
242
  * Example: if multiple page sections have an Edit button relying on visual layout to indicate which section it edits, there could be extra information in the `description` to help differentiate the Edit buttons for non-sighted users
243
243
 
244
- * If expanding other content in a dropdown, use the [Dropdown](../../components/dropdown) component; if building custom expand/collapse behaviour, be sure to use [`aria-expanded`](https://www.w3.org/TR/wai-aria/states_and_properties#aria-expanded) and [`aria-haspopup`](https://www.w3.org/TR/wai-aria/states_and_properties#aria-haspopup) attributes in accordance with best practices.
244
+ * If expanding other content in a dropdown, use the [Dropdown](../../components/dropdown) component; if building custom expand/collapse behaviour, be sure to use [`expanded`](https://www.w3.org/TR/wai-aria/states_and_properties#aria-expanded) and [`aria-haspopup`](https://www.w3.org/TR/wai-aria/states_and_properties#aria-haspopup) attributes in accordance with best practices.
245
245
 
246
246
  * Disabled buttons are normally not focusable as per web standards, but if the disabled state needs explaining you can use `disabled-tooltip` to provide an explanation that appears in a [tooltip](../../components/tooltip) via [aria-describedby](https://www.w3.org/TR/wai-aria/states_and_properties#aria-describedby)
247
247
 
@@ -172,7 +172,7 @@ class ButtonIcon extends PropertyRequiredMixin(ThemeMixin(ButtonMixin(VisibleOnA
172
172
  <button
173
173
  aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
174
174
  aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
175
- aria-expanded="${ifDefined(this.ariaExpanded)}"
175
+ aria-expanded="${ifDefined(this.expanded)}"
176
176
  aria-haspopup="${ifDefined(this.ariaHaspopup)}"
177
177
  aria-label="${this.ariaLabel ? this.ariaLabel : ifDefined(this.text)}"
178
178
  ?autofocus="${this.autofocus}"
@@ -21,6 +21,11 @@ export const ButtonMixin = superclass => class extends FocusMixin(superclass) {
21
21
  */
22
22
  // eslint-disable-next-line lit/no-native-attributes
23
23
  autofocus: { type: Boolean, reflect: true },
24
+ /**
25
+ * Wether the controlled element is expanded. Replaces 'aria-expanded'
26
+ * @type {'true' | 'false'}
27
+ */
28
+ expanded: { type: String, reflect: true, attribute: 'expanded' },
24
29
  /**
25
30
  * Disables the button
26
31
  * @type {boolean}
@@ -102,6 +107,10 @@ export const ButtonMixin = superclass => class extends FocusMixin(superclass) {
102
107
  return 'button';
103
108
  }
104
109
 
110
+ get isButtonMixin() {
111
+ return true;
112
+ }
113
+
105
114
  connectedCallback() {
106
115
  super.connectedCallback();
107
116
  this.addEventListener('click', this._handleClick, true);
@@ -112,6 +121,13 @@ export const ButtonMixin = superclass => class extends FocusMixin(superclass) {
112
121
  this.removeEventListener('click', this._handleClick, true);
113
122
  }
114
123
 
124
+ willUpdate(changedProperties) {
125
+ super.willUpdate(changedProperties);
126
+ if (changedProperties.has('ariaExpanded') && this.ariaExpanded !== undefined) {
127
+ this.expanded = this.ariaExpanded;
128
+ }
129
+ }
130
+
115
131
  /** @internal */
116
132
  _getType() {
117
133
  if (this.type === 'submit' || this.type === 'reset') {
@@ -204,7 +204,7 @@ class ButtonSubtle extends ButtonMixin(LitElement) {
204
204
  <button
205
205
  aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
206
206
  aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
207
- aria-expanded="${ifDefined(this.ariaExpanded)}"
207
+ aria-expanded="${ifDefined(this.expanded)}"
208
208
  aria-haspopup="${ifDefined(this.ariaHaspopup)}"
209
209
  aria-label="${ifDefined(this.ariaLabel)}"
210
210
  ?autofocus="${this.autofocus}"
@@ -99,7 +99,7 @@ class Button extends ButtonMixin(LitElement) {
99
99
  <button
100
100
  aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
101
101
  aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
102
- aria-expanded="${ifDefined(this.ariaExpanded)}"
102
+ aria-expanded="${ifDefined(this.expanded)}"
103
103
  aria-haspopup="${ifDefined(this.ariaHaspopup)}"
104
104
  aria-label="${ifDefined(this.ariaLabel)}"
105
105
  ?autofocus="${this.autofocus}"
@@ -15,6 +15,7 @@
15
15
  import '../../filter/filter.js';
16
16
  import '../../filter/filter-dimension-set.js';
17
17
  import '../../filter/filter-dimension-set-value.js';
18
+ import '../../inputs/input-checkbox.js';
18
19
  import '../../list/demo/demo-list.js';
19
20
  import '../dialog.js';
20
21
  import './dialog-async-content.js';
@@ -296,6 +297,38 @@
296
297
  </template>
297
298
  </d2l-demo-snippet>
298
299
 
300
+ <h2>Dialog (no content scrolling)</h2>
301
+
302
+ <d2l-demo-snippet>
303
+ <template>
304
+ <d2l-button id="openNoScrollDialog">Show Dialog</d2l-button>
305
+ <d2l-dialog id="noScrollDialog" title-text="Dialog Title">
306
+ <d2l-input-checkbox id="noScroll">Show extra paragraphs</d2l-input-checkbox>
307
+ <div>
308
+ <p>Deadlights jack lad schooner scallywag dance the hempen jig carouser broadside cable strike colors. Bring a spring upon her cable holystone blow the man down spanker</p>
309
+ <p id="p2" style="display: none;">Shiver me timbers to go on account lookout wherry doubloon chase. Belay yo-ho-ho keelhaul squiffy black spot yardarm spyglass sheet transom heave to.</p>
310
+ <p id="p3" style="display: none;">Trysail Sail ho Corsair red ensign hulk smartly boom jib rum gangway. Case shot Shiver me timbers gangplank crack Jennys tea cup ballast Blimey lee snow crow's nest rutters. Fluke jib scourge of the seven seas boatswain schooner gaff booty Jack Tar transom spirits.</p>
311
+ </div>
312
+ <d2l-button slot="footer" primary data-dialog-action="ok">Click Me!</d2l-button>
313
+ <d2l-button slot="footer" data-dialog-action>Cancel</d2l-button>
314
+ </d2l-dialog>
315
+ <script>
316
+ document.querySelector('#noScroll').addEventListener('change', async(e) => {
317
+ const dialog = document.querySelector('#noScrollDialog');
318
+ dialog.noContentScroll = true;
319
+ const display = e.target.checked ? 'block' : 'none';
320
+ dialog.querySelector('#p2').style.display = display;
321
+ dialog.querySelector('#p3').style.display = display;
322
+ await dialog.resize();
323
+ dialog.noContentScroll = false;
324
+ });
325
+ document.querySelector('#openNoScrollDialog').addEventListener('click', () => {
326
+ document.querySelector('#noScrollDialog').opened = true;
327
+ });
328
+ </script>
329
+ </template>
330
+ </d2l-demo-snippet>
331
+
299
332
  </d2l-demo-page>
300
333
  </body>
301
334
  </html>
@@ -41,7 +41,10 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
41
41
  * Whether or not the dialog is open
42
42
  */
43
43
  opened: { type: Boolean, reflect: true },
44
-
44
+ /**
45
+ * ADVANCED: Opt out of dialog content scrolling
46
+ */
47
+ noContentScroll: { type: Boolean, attribute: 'no-content-scroll', reflect: true },
45
48
  /**
46
49
  * The optional title for the dialog
47
50
  */
@@ -68,6 +71,7 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
68
71
  constructor() {
69
72
  super();
70
73
  this.focusableContentElemPresent = false;
74
+ this.noContentScroll = false;
71
75
  this.opened = false;
72
76
  this._autoSize = true;
73
77
  this._dialogId = getUniqueId();
@@ -147,7 +147,7 @@ export const dialogStyles = css`
147
147
  height: 100%;
148
148
  }
149
149
 
150
- .d2l-dialog-outer-scroll .d2l-dialog-content {
150
+ :host(:not([no-content-scroll])) .d2l-dialog-outer-scroll .d2l-dialog-content {
151
151
  overflow: auto;
152
152
  }
153
153
 
@@ -113,13 +113,8 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
113
113
 
114
114
  this.addEventListener('d2l-dropdown-open', this.__onOpened);
115
115
  this.addEventListener('d2l-dropdown-close', this.__onClosed);
116
-
117
- const opener = this.getOpenerElement();
118
116
  const content = this.__getContentElement();
119
- if (!opener) {
120
- return;
121
- }
122
- opener.setAttribute('aria-expanded', (content && content.opened || false).toString());
117
+ this._setOpenerElementAttribute(content?.opened || false);
123
118
  }
124
119
 
125
120
  updated(changedProperties) {
@@ -201,12 +196,7 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
201
196
  __onClosed() {
202
197
  intersectionObserver.unobserve(this);
203
198
 
204
- const opener = this.getOpenerElement();
205
- if (!opener) {
206
- return;
207
- }
208
- opener.setAttribute('aria-expanded', 'false');
209
- opener.removeAttribute('active');
199
+ if (!this._setOpenerElementAttribute(false, true)) return;
210
200
  this.dropdownOpened = false;
211
201
  this._isOpenedViaClick = false;
212
202
  }
@@ -273,12 +263,7 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
273
263
  }
274
264
 
275
265
  __onOpened() {
276
- const opener = this.getOpenerElement();
277
- if (!opener) {
278
- return;
279
- }
280
- opener.setAttribute('aria-expanded', 'true');
281
- opener.setAttribute('active', 'true');
266
+ if (!this._setOpenerElementAttribute(true, true)) return;
282
267
  this._isFading = false;
283
268
 
284
269
  intersectionObserver.observe(this);
@@ -345,4 +330,16 @@ export const DropdownOpenerMixin = superclass => class extends superclass {
345
330
  this.closeDropdown();
346
331
  }
347
332
  }
333
+
334
+ _setOpenerElementAttribute(val, setActive = false) {
335
+ const opener = this.getOpenerElement();
336
+ if (!opener) return false;
337
+ const attribute = opener.isButtonMixin ? 'expanded' : 'aria-expanded';
338
+ opener.setAttribute(attribute, val.toString());
339
+ if (setActive) {
340
+ if (val) opener.setAttribute('active', 'true');
341
+ else opener.removeAttribute('active');
342
+ }
343
+ return true;
344
+ }
348
345
  };
@@ -14,7 +14,7 @@ The `d2l-expand-collapse-content` element can be used to create expandable and c
14
14
  button.addEventListener('click', () => {
15
15
  const section = document.querySelector('d2l-expand-collapse-content');
16
16
  section.expanded = !section.expanded;
17
- button.setAttribute('aria-expanded', section.expanded ? 'true' : 'false');
17
+ button.setAttribute('expanded', section.expanded ? 'true' : 'false');
18
18
  });
19
19
  </script>
20
20
  <d2l-button primary>Toggle</d2l-button>
@@ -43,6 +43,6 @@ To make your usage of `d2l-expand-collapse-content` accessible, it should follow
43
43
  To achieve this, the control that toggles the expanded state should:
44
44
  - Use the [`d2l-button`](../button) or use an element with the [`button`](https://w3c.github.io/aria/#button) role
45
45
  - Toggle between states when using the `Enter` and `Space` buttons and retain focus upon toggle
46
- - Have the [`aria-expanded`](https://www.w3.org/TR/wai-aria/#aria-expanded) attribute set to `'true'` or `'false'` depending on expansion state so that screen reader users will know what state it's in
46
+ - Have the [`aria-expanded`](https://www.w3.org/TR/wai-aria/#aria-expanded)(`expanded` on controls using `ButtonMixin` like core [button components](../../components/button)) attribute set to `'true'` or `'false'` depending on expansion state so that screen reader users will know what state it's in
47
47
  - Be adjacent to the expanded/collapsed content
48
48
 
@@ -43,7 +43,7 @@
43
43
  button.addEventListener('click', () => {
44
44
  const section = document.querySelector('d2l-expand-collapse-content');
45
45
  section.expanded = !section.expanded;
46
- button.setAttribute('aria-expanded', section.expanded ? 'true' : 'false');
46
+ button.setAttribute('expanded', section.expanded ? 'true' : 'false');
47
47
  });
48
48
  </script>
49
49
  </template>
@@ -71,7 +71,7 @@ class FormErrorSummary extends LocalizeCoreElement(RtlMixin(LitElement)) {
71
71
  <div class="d2l-form-error-summary-header" @click=${this._toggleExpandCollapse}>
72
72
  <div class="d2l-form-error-summary-text">${this.localize('components.form-error-summary.errorSummary', { count: this.errors.length })}</div>
73
73
  <d2l-button-icon
74
- aria-expanded=${this._expanded ? 'true' : 'false'}
74
+ expanded=${this._expanded ? 'true' : 'false'}
75
75
  icon=${this._expanded ? 'tier1:arrow-collapse-small' : 'tier1:arrow-expand-small' }
76
76
  text="${this.localize('components.form-error-summary.text')}"
77
77
  @click=${this._toggleExpandCollapse}>
@@ -131,7 +131,7 @@ export const ListItemExpandCollapseMixin = superclass => class extends SkeletonM
131
131
  <d2l-button-icon
132
132
  class="d2l-skeletize"
133
133
  icon="${this.expanded ? 'tier1:arrow-collapse-small' : 'tier1:arrow-expand-small' }"
134
- aria-expanded="${this.expanded ? 'true' : 'false'}"
134
+ expanded="${this.expanded ? 'true' : 'false'}"
135
135
  text="${this.label}"
136
136
  @click="${this._toggleExpandCollapse}"></d2l-button-icon>`;
137
137
  }
@@ -152,7 +152,7 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
152
152
  class="d2l-more-less-toggle"
153
153
  icon="${this.__computeIcon()}"
154
154
  aria-controls="${this.__contentId}"
155
- aria-expanded="${this.__computeAriaExpanded()}"
155
+ expanded="${this.__computeAriaExpanded()}"
156
156
  @click="${this.__toggleOnClick}"
157
157
  text="${this.__computeText()}"
158
158
  h-align="${ifDefined(this.hAlign)}">
@@ -426,6 +426,11 @@
426
426
  "type": "boolean",
427
427
  "default": "false"
428
428
  },
429
+ {
430
+ "name": "expanded",
431
+ "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
432
+ "type": "'true' | 'false'"
433
+ },
429
434
  {
430
435
  "name": "disabled-tooltip",
431
436
  "description": "Tooltip text when disabled",
@@ -470,12 +475,22 @@
470
475
  "type": "boolean",
471
476
  "default": "false"
472
477
  },
478
+ {
479
+ "name": "expanded",
480
+ "attribute": "expanded",
481
+ "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
482
+ "type": "'true' | 'false'"
483
+ },
473
484
  {
474
485
  "name": "disabledTooltip",
475
486
  "attribute": "disabled-tooltip",
476
487
  "description": "Tooltip text when disabled",
477
488
  "type": "string"
478
489
  },
490
+ {
491
+ "name": "isButtonMixin",
492
+ "type": "boolean"
493
+ },
479
494
  {
480
495
  "name": "disabled",
481
496
  "attribute": "disabled",
@@ -641,6 +656,11 @@
641
656
  "type": "boolean",
642
657
  "default": "false"
643
658
  },
659
+ {
660
+ "name": "expanded",
661
+ "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
662
+ "type": "'true' | 'false'"
663
+ },
644
664
  {
645
665
  "name": "disabled-tooltip",
646
666
  "description": "Tooltip text when disabled",
@@ -692,12 +712,22 @@
692
712
  "type": "boolean",
693
713
  "default": "false"
694
714
  },
715
+ {
716
+ "name": "expanded",
717
+ "attribute": "expanded",
718
+ "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
719
+ "type": "'true' | 'false'"
720
+ },
695
721
  {
696
722
  "name": "disabledTooltip",
697
723
  "attribute": "disabled-tooltip",
698
724
  "description": "Tooltip text when disabled",
699
725
  "type": "string"
700
726
  },
727
+ {
728
+ "name": "isButtonMixin",
729
+ "type": "boolean"
730
+ },
701
731
  {
702
732
  "name": "disabled",
703
733
  "attribute": "disabled",
@@ -765,6 +795,11 @@
765
795
  "type": "boolean",
766
796
  "default": "false"
767
797
  },
798
+ {
799
+ "name": "expanded",
800
+ "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
801
+ "type": "'true' | 'false'"
802
+ },
768
803
  {
769
804
  "name": "disabled-tooltip",
770
805
  "description": "Tooltip text when disabled",
@@ -791,12 +826,22 @@
791
826
  "type": "boolean",
792
827
  "default": "false"
793
828
  },
829
+ {
830
+ "name": "expanded",
831
+ "attribute": "expanded",
832
+ "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
833
+ "type": "'true' | 'false'"
834
+ },
794
835
  {
795
836
  "name": "disabledTooltip",
796
837
  "attribute": "disabled-tooltip",
797
838
  "description": "Tooltip text when disabled",
798
839
  "type": "string"
799
840
  },
841
+ {
842
+ "name": "isButtonMixin",
843
+ "type": "boolean"
844
+ },
800
845
  {
801
846
  "name": "disabled",
802
847
  "attribute": "disabled",
@@ -2072,6 +2117,12 @@
2072
2117
  "description": "The optional title for the dialog",
2073
2118
  "type": "string"
2074
2119
  },
2120
+ {
2121
+ "name": "no-content-scroll",
2122
+ "description": "ADVANCED: Opt out of dialog content scrolling",
2123
+ "type": "boolean",
2124
+ "default": "false"
2125
+ },
2075
2126
  {
2076
2127
  "name": "opened",
2077
2128
  "description": "Whether or not the dialog is open",
@@ -2104,6 +2155,13 @@
2104
2155
  "type": "boolean",
2105
2156
  "default": "false"
2106
2157
  },
2158
+ {
2159
+ "name": "noContentScroll",
2160
+ "attribute": "no-content-scroll",
2161
+ "description": "ADVANCED: Opt out of dialog content scrolling",
2162
+ "type": "boolean",
2163
+ "default": "false"
2164
+ },
2107
2165
  {
2108
2166
  "name": "opened",
2109
2167
  "attribute": "opened",
@@ -2161,6 +2219,12 @@
2161
2219
  "description": "REQUIRED: the title for the dialog",
2162
2220
  "type": "string"
2163
2221
  },
2222
+ {
2223
+ "name": "no-content-scroll",
2224
+ "description": "ADVANCED: Opt out of dialog content scrolling",
2225
+ "type": "boolean",
2226
+ "default": "false"
2227
+ },
2164
2228
  {
2165
2229
  "name": "opened",
2166
2230
  "description": "Whether or not the dialog is open",
@@ -2210,6 +2274,13 @@
2210
2274
  "type": "boolean",
2211
2275
  "default": "false"
2212
2276
  },
2277
+ {
2278
+ "name": "noContentScroll",
2279
+ "attribute": "no-content-scroll",
2280
+ "description": "ADVANCED: Opt out of dialog content scrolling",
2281
+ "type": "boolean",
2282
+ "default": "false"
2283
+ },
2213
2284
  {
2214
2285
  "name": "opened",
2215
2286
  "attribute": "opened",
@@ -2283,6 +2354,12 @@
2283
2354
  "description": "REQUIRED: the title for the dialog",
2284
2355
  "type": "string"
2285
2356
  },
2357
+ {
2358
+ "name": "no-content-scroll",
2359
+ "description": "ADVANCED: Opt out of dialog content scrolling",
2360
+ "type": "boolean",
2361
+ "default": "false"
2362
+ },
2286
2363
  {
2287
2364
  "name": "opened",
2288
2365
  "description": "Whether or not the dialog is open",
@@ -2346,6 +2423,13 @@
2346
2423
  "type": "boolean",
2347
2424
  "default": "false"
2348
2425
  },
2426
+ {
2427
+ "name": "noContentScroll",
2428
+ "attribute": "no-content-scroll",
2429
+ "description": "ADVANCED: Opt out of dialog content scrolling",
2430
+ "type": "boolean",
2431
+ "default": "false"
2432
+ },
2349
2433
  {
2350
2434
  "name": "opened",
2351
2435
  "attribute": "opened",
@@ -11337,6 +11421,11 @@
11337
11421
  "description": "Id of the `SelectionMixin` component this component wants to observe (if not located within that component)",
11338
11422
  "type": "string"
11339
11423
  },
11424
+ {
11425
+ "name": "expanded",
11426
+ "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
11427
+ "type": "'true' | 'false'"
11428
+ },
11340
11429
  {
11341
11430
  "name": "disabled-tooltip",
11342
11431
  "description": "Tooltip text when disabled",
@@ -11385,12 +11474,22 @@
11385
11474
  {
11386
11475
  "name": "selectionInfo"
11387
11476
  },
11477
+ {
11478
+ "name": "expanded",
11479
+ "attribute": "expanded",
11480
+ "description": "Wether the controlled element is expanded. Replaces 'aria-expanded'",
11481
+ "type": "'true' | 'false'"
11482
+ },
11388
11483
  {
11389
11484
  "name": "disabledTooltip",
11390
11485
  "attribute": "disabled-tooltip",
11391
11486
  "description": "Tooltip text when disabled",
11392
11487
  "type": "string"
11393
11488
  },
11489
+ {
11490
+ "name": "isButtonMixin",
11491
+ "type": "boolean"
11492
+ },
11394
11493
  {
11395
11494
  "name": "disabled",
11396
11495
  "attribute": "disabled",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.104.0",
3
+ "version": "3.106.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",