@brightspace-ui/core 2.55.4 → 2.56.1

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.
@@ -3,6 +3,7 @@ import './code-view.js';
3
3
  import '../colors/colors.js';
4
4
  import '../typography/typography.js';
5
5
  import { css, html, LitElement } from 'lit';
6
+ import { classMap } from 'lit/directives/class-map.js';
6
7
  import { heading2Styles } from '../typography/styles.js';
7
8
 
8
9
  document.body.classList.add('d2l-typography');
@@ -20,7 +21,8 @@ class DemoPage extends LitElement {
20
21
 
21
22
  static get properties() {
22
23
  return {
23
- pageTitle: { type: String, attribute: 'page-title' }
24
+ pageTitle: { type: String, attribute: 'page-title' },
25
+ _noScroll: { state: true }
24
26
  };
25
27
  }
26
28
 
@@ -31,6 +33,11 @@ class DemoPage extends LitElement {
31
33
  display: block;
32
34
  padding: 30px;
33
35
  }
36
+ main.no-scroll {
37
+ height: 0;
38
+ overflow: hidden;
39
+ padding: 0;
40
+ }
34
41
  .d2l-heading-2 {
35
42
  margin-top: 0;
36
43
  }
@@ -41,6 +48,7 @@ class DemoPage extends LitElement {
41
48
  line-height: 1.2rem;
42
49
  margin: 1.5rem 0 1.5rem 0;
43
50
  }
51
+
44
52
  .d2l-demo-page-content > ::slotted(d2l-code-view),
45
53
  .d2l-demo-page-content > ::slotted(d2l-demo-snippet) {
46
54
  margin-bottom: 36px;
@@ -56,14 +64,28 @@ class DemoPage extends LitElement {
56
64
  }
57
65
 
58
66
  render() {
67
+ const classes = {
68
+ 'no-scroll': this._noScroll
69
+ };
59
70
  return html`
60
- <main>
71
+ <main class="${classMap(classes)}">
61
72
  <h1 class="d2l-heading-2">${this.pageTitle}</h1>
62
- <div class="d2l-demo-page-content"><slot></slot></div>
73
+ <div class="d2l-demo-page-content" @d2l-demo-snippet-fullscreen-toggle="${this._handleFullscreenToggle}"><slot></slot></div>
63
74
  </main>
64
75
  `;
65
76
  }
66
77
 
78
+ async _handleFullscreenToggle() {
79
+ if (this._noScroll) {
80
+ this._noScroll = false;
81
+ await this.updateComplete;
82
+ document.documentElement.scrollTop = this._previousScrollTop;
83
+ }
84
+ else {
85
+ this._previousScrollTop = document.documentElement.scrollTop;
86
+ this._noScroll = true;
87
+ }
88
+ }
67
89
  }
68
90
 
69
91
  customElements.define('d2l-demo-page', DemoPage);
@@ -8,11 +8,12 @@ class DemoSnippet extends LitElement {
8
8
  static get properties() {
9
9
  return {
10
10
  codeViewHidden: { type: Boolean, reflect: true, attribute: 'code-view-hidden' },
11
- fullscreen: { type: Boolean, reflect: true },
11
+ fullWidth: { type: Boolean, reflect: true },
12
12
  noPadding: { type: Boolean, reflect: true, attribute: 'no-padding' },
13
13
  overflowHidden: { type: Boolean, reflect: true, attribute: 'overflow-hidden' },
14
14
  _code: { type: String },
15
15
  _dir: { type: String, attribute: false },
16
+ _fullscreen: { state: true },
16
17
  _hasSkeleton: { type: Boolean, attribute: false },
17
18
  _skeletonOn: { type: Boolean, reflect: false }
18
19
  };
@@ -31,12 +32,19 @@ class DemoSnippet extends LitElement {
31
32
  :host([hidden]) {
32
33
  display: none;
33
34
  }
34
- :host([fullscreen]) {
35
+ :host([full-width]) {
35
36
  max-width: unset;
36
37
  }
37
38
  .d2l-demo-snippet-demo-wrapper {
38
39
  display: flex;
39
40
  }
41
+ .d2l-demo-snippet-demo-wrapper.fullscreen {
42
+ background-color: white;
43
+ inset: 0;
44
+ overflow: auto;
45
+ position: fixed;
46
+ z-index: 2;
47
+ }
40
48
  .d2l-demo-snippet-demo {
41
49
  flex: 1 1 auto;
42
50
  position: relative;
@@ -47,7 +55,8 @@ class DemoSnippet extends LitElement {
47
55
  .d2l-demo-snippet-demo-padding {
48
56
  padding: 18px;
49
57
  }
50
- :host([no-padding]) .d2l-demo-snippet-demo-padding {
58
+ :host([no-padding]) .d2l-demo-snippet-demo-padding,
59
+ .d2l-demo-snippet-demo-wrapper.fullscreen .d2l-demo-snippet-demo-padding {
51
60
  padding: 0;
52
61
  }
53
62
  .d2l-demo-snippet-settings {
@@ -55,6 +64,10 @@ class DemoSnippet extends LitElement {
55
64
  flex: 0 0 auto;
56
65
  padding: 6px;
57
66
  }
67
+ .d2l-demo-snippet-demo-wrapper.fullscreen .d2l-demo-snippet-settings {
68
+ position: sticky;
69
+ top: 0;
70
+ }
58
71
  d2l-code-view {
59
72
  border: none;
60
73
  border-top-left-radius: 0;
@@ -70,8 +83,9 @@ class DemoSnippet extends LitElement {
70
83
 
71
84
  constructor() {
72
85
  super();
73
- this.fullscreen = false;
86
+ this.fullWidth = false;
74
87
  this._dir = document.documentElement.dir;
88
+ this._fullscreen = false;
75
89
  this._hasSkeleton = false;
76
90
  this._skeletonOn = false;
77
91
  }
@@ -84,7 +98,7 @@ class DemoSnippet extends LitElement {
84
98
  const dirAttr = this._dir === 'rtl' ? 'rtl' : 'ltr';
85
99
  const skeleton = this._hasSkeleton ? html`<d2l-switch text="Skeleton" ?on="${this._skeletonOn}" @change="${this._handleSkeletonChange}"></d2l-switch>` : null;
86
100
  return html`
87
- <div class="d2l-demo-snippet-demo-wrapper">
101
+ <div class="d2l-demo-snippet-demo-wrapper ${this._fullscreen ? 'fullscreen' : ''}">
88
102
  <div class="d2l-demo-snippet-demo" dir="${dirAttr}">
89
103
  <div class="d2l-demo-snippet-demo-padding">
90
104
  <slot name="_demo"></slot>
@@ -92,7 +106,8 @@ class DemoSnippet extends LitElement {
92
106
  </div>
93
107
  </div>
94
108
  <div class="d2l-demo-snippet-settings">
95
- <d2l-switch text="RTL" ?on="${dirAttr === 'rtl'}" @change="${this._handleDirChange}"></d2l-switch><br>
109
+ <d2l-switch text="RTL" ?on="${dirAttr === 'rtl'}" @change="${this._handleDirChange}"></d2l-switch><br />
110
+ <d2l-switch text="Fullscreen" ?on="${this._fullscreen}" @change="${this._handleFullscreenChange}"></d2l-switch><br />
96
111
  ${skeleton}
97
112
  </div>
98
113
  </div>
@@ -186,6 +201,12 @@ class DemoSnippet extends LitElement {
186
201
  this._applyAttr('dir', this._dir, true);
187
202
  }
188
203
 
204
+ _handleFullscreenChange(e) {
205
+ this._fullscreen = e.target.on;
206
+ const event = new CustomEvent('d2l-demo-snippet-fullscreen-toggle', { bubbles: true, composed: true });
207
+ this.dispatchEvent(event);
208
+ }
209
+
189
210
  _handleSkeletonChange(e) {
190
211
  this._skeletonOn = e.target.on;
191
212
  this._applyAttr('skeleton', this._skeletonOn, false);
@@ -14,12 +14,12 @@
14
14
  <d2l-demo-page page-title="d2l-description-list">
15
15
 
16
16
  <h2>Short</h2>
17
- <d2l-demo-snippet fullscreen>
17
+ <d2l-demo-snippet full-width>
18
18
  <d2l-test-dl></d2l-test-dl>
19
19
  </d2l-demo-snippet>
20
20
 
21
21
  <h2>Long</h2>
22
- <d2l-demo-snippet fullscreen>
22
+ <d2l-demo-snippet full-width>
23
23
  <d2l-test-dl type="long" breakpoint="300"></d2l-test-dl>
24
24
  </d2l-demo-snippet>
25
25
 
@@ -29,17 +29,17 @@
29
29
  </d2l-demo-snippet>
30
30
 
31
31
  <h2>Activity Display</h2>
32
- <d2l-demo-snippet fullscreen>
32
+ <d2l-demo-snippet full-width>
33
33
  <d2l-test-dl type="activity-display"></d2l-test-dl>
34
34
  </d2l-demo-snippet>
35
35
 
36
36
  <h2>Bulk Course Import</h2>
37
- <d2l-demo-snippet fullscreen>
37
+ <d2l-demo-snippet full-width>
38
38
  <d2l-test-dl type="bulk-course-import"></d2l-test-dl>
39
39
  </d2l-demo-snippet>
40
40
 
41
41
  <h2>Slotted content</h2>
42
- <d2l-demo-snippet fullscreen>
42
+ <d2l-demo-snippet full-width>
43
43
  <d2l-test-dl type="slotted"></d2l-test-dl>
44
44
  </d2l-demo-snippet>
45
45
 
@@ -407,14 +407,19 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
407
407
  if (!activeElement
408
408
  || !isComposedAncestor(dialog, activeElement)
409
409
  || !activeElement.classList.contains('focus-visible')) {
410
- this._focusInitial();
410
+ // wait till the dialog is visible for Safari
411
+ requestAnimationFrame(() => this._focusInitial());
411
412
  }
412
413
 
413
- if (!reduceMotion) await animPromise;
414
+ // if not animating, we need to wait a frame before dispatching due to focus rAF above
415
+ if (reduceMotion) await new Promise(resolve => requestAnimationFrame(resolve));
416
+ else await animPromise;
417
+
414
418
  /** Dispatched when the dialog is opened */
415
419
  this.dispatchEvent(new CustomEvent(
416
420
  'd2l-dialog-open', { bubbles: true, composed: true }
417
421
  ));
422
+
418
423
  }, 0);
419
424
 
420
425
  }
@@ -40,7 +40,7 @@
40
40
  });
41
41
 
42
42
  </script>
43
- <d2l-demo-snippet fullscreen>
43
+ <d2l-demo-snippet full-width>
44
44
  <d2l-tag-list description="A bunch of example tags">
45
45
  <d2l-tag-list-item text="Example 1"></d2l-tag-list-item>
46
46
  <d2l-tag-list-item text="Example 2 - much much much much much much much much longer"></d2l-tag-list-item>
@@ -55,7 +55,7 @@
55
55
  </d2l-demo-snippet>
56
56
 
57
57
  <h2>Clearable Tag List</h2>
58
- <d2l-demo-snippet fullscreen>
58
+ <d2l-demo-snippet full-width>
59
59
  <d2l-tag-list description="A bunch of example tags" clearable>
60
60
  <d2l-tag-list-item text="Example 1"></d2l-tag-list-item>
61
61
  <d2l-tag-list-item text="Example 2 - much much much much much much much much longer"></d2l-tag-list-item>
@@ -88,7 +88,7 @@
88
88
  </d2l-demo-snippet>
89
89
 
90
90
  <h2>Tag List with Interactive</h2>
91
- <d2l-demo-snippet fullscreen>
91
+ <d2l-demo-snippet full-width>
92
92
  <div grid>
93
93
  <d2l-tag-list description="A bunch of example tags" clearable>
94
94
  <d2l-tag-list-item text="Example Tag"></d2l-tag-list-item>
@@ -103,7 +103,7 @@
103
103
  </d2l-demo-snippet>
104
104
 
105
105
  <h2>Tag List - Custom Tooltip Description</h2>
106
- <d2l-demo-snippet fullscreen>
106
+ <d2l-demo-snippet full-width>
107
107
  <d2l-tag-list description="A bunch of example tags">
108
108
  <d2l-tag-list-item text="Longer Example Tag - much much much much much longer" description="display text and description value when truncated"></d2l-tag-list-item>
109
109
  <d2l-tag-list-item text="Example Tag 5" description="custom tooltip text - display description only when not truncated"></d2l-tag-list-item>
@@ -1436,7 +1436,7 @@
1436
1436
  "type": "boolean"
1437
1437
  },
1438
1438
  {
1439
- "name": "fullscreen",
1439
+ "name": "fullWidth",
1440
1440
  "type": "boolean",
1441
1441
  "default": "false"
1442
1442
  }
@@ -1458,11 +1458,16 @@
1458
1458
  "type": "boolean"
1459
1459
  },
1460
1460
  {
1461
- "name": "fullscreen",
1462
- "attribute": "fullscreen",
1461
+ "name": "fullWidth",
1462
+ "attribute": "fullWidth",
1463
1463
  "type": "boolean",
1464
1464
  "default": "false"
1465
1465
  }
1466
+ ],
1467
+ "events": [
1468
+ {
1469
+ "name": "d2l-demo-snippet-fullscreen-toggle"
1470
+ }
1466
1471
  ]
1467
1472
  },
1468
1473
  {
package/helpers/focus.js CHANGED
@@ -1,4 +1,4 @@
1
- import { findComposedAncestor, getComposedChildren, getComposedParent, getNextAncestorSibling, getPreviousAncestorSibling } from './dom.js';
1
+ import { findComposedAncestor, getComposedChildren, getComposedParent, getNextAncestorSibling, getPreviousAncestorSibling, isVisible } from './dom.js';
2
2
 
3
3
  const focusableElements = {
4
4
  a: true,
@@ -175,7 +175,7 @@ export function isFocusable(node, includeHidden, includeTabbablesOnly, includeDi
175
175
 
176
176
  if (_isFocusable && !includeHidden) {
177
177
  // only perform visibility check if absolutely necessary
178
- if (nodeName !== 'body' && node.offsetParent === null) return false;
178
+ if (nodeName !== 'body' && !isVisible(node)) return false;
179
179
  }
180
180
 
181
181
  return _isFocusable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.55.4",
3
+ "version": "2.56.1",
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",