@brightspace-ui/core 2.81.1 → 2.82.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.
@@ -180,6 +180,64 @@
180
180
  </template>
181
181
  </d2l-demo-snippet>
182
182
 
183
+ <h2>Fullscreen Dialog using width property</h2>
184
+
185
+ <d2l-demo-snippet>
186
+ <template>
187
+ <d2l-button id="openWidth">Show Dialog</d2l-button>
188
+ <d2l-dropdown-more text="Open!">
189
+ <d2l-dropdown-menu>
190
+ <d2l-menu label="Dialog">
191
+ <d2l-menu-item id="dropdownWidth" text="See dialog"></d2l-menu-item>
192
+ </d2l-menu>
193
+ </d2l-dropdown-menu>
194
+ </d2l-dropdown-more>
195
+ <d2l-dialog-fullscreen id="dialogWidth" title-text="Fullscreen Title" width="1800">
196
+ <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>
197
+ <p>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>
198
+ <p>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>
199
+ <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>
200
+ <p>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>
201
+ <p>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>
202
+ <d2l-dropdown-button-subtle text="More">
203
+ <d2l-dropdown-content mobile-tray="bottom">
204
+ <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>
205
+ <p>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>
206
+ <p>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>
207
+ </d2l-dropdown-content>
208
+ </d2l-dropdown-button-subtle>
209
+ <d2l-filter>
210
+ <d2l-filter-dimension-set key="course" text="Course" select-all>
211
+ <d2l-filter-dimension-set-value key="art" text="Art"></d2l-filter-dimension-set-value>
212
+ <d2l-filter-dimension-set-value key="astronomy" text="Astronomy" selected></d2l-filter-dimension-set-value>
213
+ <d2l-filter-dimension-set-value key="biology" text="Biology"></d2l-filter-dimension-set-value>
214
+ <d2l-filter-dimension-set-value key="chemistry" text="Chemistry"></d2l-filter-dimension-set-value>
215
+ <d2l-filter-dimension-set-value key="drama" text="Drama"></d2l-filter-dimension-set-value>
216
+ <d2l-filter-dimension-set-value key="english" text="English"></d2l-filter-dimension-set-value>
217
+ <d2l-filter-dimension-set-value key="how-to" text="How To Write a How To Article With a Flashy Title"></d2l-filter-dimension-set-value>
218
+ <d2l-filter-dimension-set-value key="math" text="Math"></d2l-filter-dimension-set-value>
219
+ <d2l-filter-dimension-set-value key="physics" text="Physics"></d2l-filter-dimension-set-value>
220
+ <d2l-filter-dimension-set-value key="stats" text="Statistics"></d2l-filter-dimension-set-value>
221
+ <d2l-filter-dimension-set-value key="writerscraft" text="Writer's Craft"></d2l-filter-dimension-set-value>
222
+ </d2l-filter-dimension-set>
223
+ </d2l-filter>
224
+ <d2l-button slot="footer" primary data-dialog-action="save">Save</d2l-button>
225
+ <d2l-button slot="footer" data-dialog-action>Cancel</d2l-button>
226
+ </d2l-dialog-fullscreen>
227
+ <script>
228
+ document.querySelector('#openWidth').addEventListener('click', () => {
229
+ document.querySelector('#dialogWidth').opened = true;
230
+ });
231
+ document.querySelector('#dropdownWidth').addEventListener('click', () => {
232
+ document.querySelector('#dialogWidth').opened = true;
233
+ });
234
+ document.querySelector('#dialogWidth').addEventListener('d2l-dialog-close', (e) => {
235
+ console.log('confirm action:', e.detail.action);
236
+ });
237
+ </script>
238
+ </template>
239
+ </d2l-demo-snippet>
240
+
183
241
  </d2l-demo-page>
184
242
  </body>
185
243
  </html>
@@ -27,9 +27,14 @@ class DialogFullscreen extends LocalizeCoreElement(AsyncContainerMixin(DialogMix
27
27
  * @type {boolean}
28
28
  */
29
29
  async: { type: Boolean },
30
+
31
+ /**
32
+ * The preferred width (unit-less) for the dialog. Maximum 1170.
33
+ */
34
+ width: { type: Number },
30
35
  _hasFooterContent: { type: Boolean, attribute: false },
31
36
  _icon: { type: String, attribute: false },
32
- _headerStyle: { type: String, attribute: false }
37
+ _headerStyle: { type: String, attribute: false },
33
38
  };
34
39
  }
35
40
 
@@ -44,6 +49,10 @@ class DialogFullscreen extends LocalizeCoreElement(AsyncContainerMixin(DialogMix
44
49
  text-align: center;
45
50
  }
46
51
 
52
+ .d2l-dialog-outer {
53
+ max-width: calc(100% - 3rem);
54
+ }
55
+
47
56
  @media (min-width: 616px) {
48
57
 
49
58
  .d2l-dialog-header {
@@ -78,7 +87,6 @@ class DialogFullscreen extends LocalizeCoreElement(AsyncContainerMixin(DialogMix
78
87
  animation: d2l-dialog-fullscreen-close 200ms ease-out;
79
88
  border-radius: 8px;
80
89
  margin: 1.5rem;
81
- max-width: 1170px;
82
90
  top: 0;
83
91
  width: auto;
84
92
  }
@@ -179,6 +187,7 @@ class DialogFullscreen extends LocalizeCoreElement(AsyncContainerMixin(DialogMix
179
187
  this._headerStyle = 'd2l-heading-2';
180
188
  this._handleResize = this._handleResize.bind(this);
181
189
  this._handleResize();
190
+ this.width = 1170;
182
191
  }
183
192
 
184
193
  get asyncContainerCustom() {
@@ -196,7 +205,7 @@ class DialogFullscreen extends LocalizeCoreElement(AsyncContainerMixin(DialogMix
196
205
  }
197
206
 
198
207
  render() {
199
-
208
+ this._width = Math.max(1170, this.width);
200
209
  const heightOverride = {} ;
201
210
  let topOverride = null;
202
211
  if (this._ifrauContextInfo) {
@@ -432,6 +432,7 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
432
432
  _render(inner, info, iframeTopOverride) {
433
433
 
434
434
  const styles = {};
435
+ if (this._width) styles.width = `${this._width}px`;
435
436
  if (this._autoSize) {
436
437
  if (this._ifrauContextInfo) styles.top = `${this._top}px`;
437
438
  if (this._ifrauContextInfo) styles.bottom = 'auto';
@@ -1,9 +1,11 @@
1
1
  import '../colors/colors.js';
2
2
  import { codeStyles, createHtmlBlockRenderer as createCodeRenderer } from '../../helpers/prism.js';
3
- import { css, html, LitElement } from 'lit';
3
+ import { css, html, LitElement, unsafeCSS } from 'lit';
4
4
  import { classMap } from 'lit/directives/class-map.js';
5
5
  import { createHtmlBlockRenderer as createMathRenderer } from '../../helpers/mathjax.js';
6
+ import { getFocusPseudoClass } from '../../helpers/focus.js';
6
7
  import { HtmlAttributeObserverController } from '../../controllers/attributeObserver/htmlAttributeObserverController.js';
8
+
7
9
  import { requestInstance } from '../../mixins/provider-mixin.js';
8
10
 
9
11
  export const htmlBlockContentStyles = css`
@@ -99,7 +101,7 @@ export const htmlBlockContentStyles = css`
99
101
  color: var(--d2l-color-celestine-minus-1, #004489);
100
102
  text-decoration: underline;
101
103
  }
102
- a:focus {
104
+ a:${unsafeCSS(getFocusPseudoClass())} {
103
105
  border-radius: 3px;
104
106
  outline: 2px solid var(--d2l-color-celestine, #006fbf);
105
107
  outline-offset: 1px;
@@ -1,7 +1,8 @@
1
1
  import '../colors/colors.js';
2
- import { css, html, LitElement } from 'lit';
2
+ import { css, html, LitElement, unsafeCSS } from 'lit';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import { FocusMixin } from '../../mixins/focus-mixin.js';
5
+ import { getFocusPseudoClass } from '../../helpers/focus.js';
5
6
  import { ifDefined } from 'lit/directives/if-defined.js';
6
7
 
7
8
  export const linkStyles = css`
@@ -19,7 +20,7 @@ export const linkStyles = css`
19
20
  color: var(--d2l-color-celestine-minus-1);
20
21
  text-decoration: underline;
21
22
  }
22
- .d2l-link:focus {
23
+ .d2l-link:${unsafeCSS(getFocusPseudoClass())} {
23
24
  border-radius: 3px;
24
25
  outline: 2px solid var(--d2l-color-celestine);
25
26
  outline-offset: 1px;
@@ -14,12 +14,17 @@
14
14
  color: $d2l-color-celestine-minus-1;
15
15
  text-decoration: underline;
16
16
  }
17
- &:focus,
18
- &.d2l-link-focus {
17
+ &:focus-visible {
19
18
  outline: 2px solid $d2l-color-celestine;
20
19
  outline-offset: 1px;
21
20
  text-decoration: underline;
22
21
  }
22
+ .d2l-focus-visible-not-supported &:focus {
23
+ outline: 2px solid $d2l-color-celestine;
24
+ outline-offset: 1px;
25
+ text-decoration: underline;
26
+ }
27
+
23
28
  &[main] {
24
29
  font-weight: 700;
25
30
  }
@@ -1,5 +1,6 @@
1
1
  import '../colors/colors.js';
2
- import { css } from 'lit';
2
+ import { css, unsafeCSS } from 'lit';
3
+ import { getFocusPseudoClass } from '../../helpers/focus.js';
3
4
 
4
5
  export const menuItemStyles = css`
5
6
  :host {
@@ -20,9 +21,8 @@ export const menuItemStyles = css`
20
21
  color: var(--d2l-menu-foreground-color-hover);
21
22
  }
22
23
 
23
- /** separated from hover selectors because Safari <15.4 is having trouble parsing these */
24
- :host(:focus-visible),
25
- :host([first]:focus-visible) {
24
+ :host(:${unsafeCSS(getFocusPseudoClass())}),
25
+ :host([first]:${unsafeCSS(getFocusPseudoClass())}) {
26
26
  border-radius: 6px;
27
27
  border-top-color: transparent;
28
28
  color: var(--d2l-menu-foreground-color-hover);
@@ -36,8 +36,7 @@ export const menuItemStyles = css`
36
36
  opacity: 0.75;
37
37
  }
38
38
 
39
- /** separated because Safari <15.4 is having trouble parsing these */
40
- :host([disabled]:focus-visible) {
39
+ :host([disabled]:${unsafeCSS(getFocusPseudoClass())}) {
41
40
  cursor: default;
42
41
  opacity: 0.75;
43
42
  }
@@ -1816,6 +1816,12 @@
1816
1816
  "type": "boolean",
1817
1817
  "default": "false"
1818
1818
  },
1819
+ {
1820
+ "name": "width",
1821
+ "description": "The preferred width (unit-less) for the dialog. Maximum 1170.",
1822
+ "type": "number",
1823
+ "default": "1170"
1824
+ },
1819
1825
  {
1820
1826
  "name": "title-text",
1821
1827
  "description": "The optional title for the dialog",
@@ -1836,6 +1842,13 @@
1836
1842
  "type": "boolean",
1837
1843
  "default": "false"
1838
1844
  },
1845
+ {
1846
+ "name": "width",
1847
+ "attribute": "width",
1848
+ "description": "The preferred width (unit-less) for the dialog. Maximum 1170.",
1849
+ "type": "number",
1850
+ "default": "1170"
1851
+ },
1839
1852
  {
1840
1853
  "name": "documentLocaleSettings",
1841
1854
  "default": "\"getDocumentLocaleSettings()\""
package/helpers/README.md CHANGED
@@ -129,6 +129,9 @@ getComposedActiveElement()
129
129
  // gets the first focusable descendant given a node, including those within the shadow DOM
130
130
  getFirstFocusableDescendant(node, includeHidden, predicate, includeTabbablesOnly)
131
131
 
132
+ // gets the focus pseudo-class to used in selectors (focus-visible if supported, or focus)
133
+ getFocusPseudoClass()
134
+
132
135
  // gets the last focusable descendant given a node, including those within the shadow DOM
133
136
  getLastFocusableDescendant(node, includeHidden)
134
137
 
@@ -144,6 +147,9 @@ getPreviousFocusableAncestor(node, includeHidden, includeTabbablesOnly)
144
147
  // returns true/false whether the element is focusable
145
148
  isFocusable(node, includeHidden, includeTabbablesOnly, includeDisabled)
146
149
 
150
+ // returns true/false whether the :focus-visible is supported
151
+ isFocusVisibleSupported()
152
+
147
153
  // returns true and focuses on node or its nearest focusable ancestor;
148
154
  // or false if node and its ancestors are not focusable
149
155
  tryApplyFocus(node)
package/helpers/focus.js CHANGED
@@ -52,6 +52,10 @@ export function getFirstFocusableDescendant(node, includeHidden, predicate, incl
52
52
  return null;
53
53
  }
54
54
 
55
+ export function getFocusPseudoClass() {
56
+ return isFocusVisibleSupported() ? 'focus-visible' : 'focus';
57
+ }
58
+
55
59
  export function getLastFocusableDescendant(node, includeHidden) {
56
60
  const composedChildren = getComposedChildren(node);
57
61
 
@@ -182,6 +186,25 @@ export function isFocusable(node, includeHidden, includeTabbablesOnly, includeDi
182
186
 
183
187
  }
184
188
 
189
+ let _isFocusVisibleSupported;
190
+
191
+ export function isFocusVisibleSupported() {
192
+ if (_isFocusVisibleSupported === undefined) {
193
+ const style = document.createElement('style');
194
+ try {
195
+ document.head.appendChild(style);
196
+ style.sheet.insertRule(':focus-visible { color: inherit; }');
197
+ _isFocusVisibleSupported = true;
198
+ } catch (error) {
199
+ _isFocusVisibleSupported = false;
200
+ } finally {
201
+ style.remove();
202
+ }
203
+ }
204
+
205
+ return _isFocusVisibleSupported;
206
+ }
207
+
185
208
  export function tryApplyFocus(elem) {
186
209
  if (isFocusable(elem)) {
187
210
  forceFocusVisible(elem);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.81.1",
3
+ "version": "2.82.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",