@brightspace-ui/core 2.82.0 → 2.82.2

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.
@@ -90,6 +90,7 @@
90
90
  <d2l-menu-item text="Telescopes"></d2l-menu-item>
91
91
  </d2l-menu>
92
92
  </d2l-menu-item>
93
+ <d2l-menu-item text="Aliens, The Search Extraterrestrial Life, Unidentified Flying Objects, and Other Astronomical Phenomenon"></d2l-menu-item>
93
94
  <d2l-menu-item text="The Universe"></d2l-menu-item>
94
95
  </d2l-menu>
95
96
  </d2l-dropdown-menu>
@@ -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
  }
@@ -18,7 +18,7 @@
18
18
  <d2l-demo-snippet>
19
19
  <template>
20
20
  <d2l-menu label="Checkbox Menu" style="max-width: 400px;">
21
- <d2l-menu-item-checkbox text="Checkbox 1 with a very long title that will be cut off" value="1"></d2l-menu-item-checkbox>
21
+ <d2l-menu-item-checkbox text="Checkbox 1 with an extremely long title that will only be cut off with an ellipsis after two lines" value="1"></d2l-menu-item-checkbox>
22
22
  <d2l-menu-item-checkbox text="Checkbox 2" value="2"></d2l-menu-item-checkbox>
23
23
  <d2l-menu-item-checkbox text="Checkbox 3" value="3"></d2l-menu-item-checkbox>
24
24
  </d2l-menu>
@@ -29,6 +29,7 @@
29
29
  <d2l-menu-item text="The Solar System"></d2l-menu-item>
30
30
  <d2l-menu-item text="Stars &amp; Galaxies"></d2l-menu-item>
31
31
  <d2l-menu-item disabled text="The Night Sky"></d2l-menu-item>
32
+ <d2l-menu-item text="Aliens, The Search Extraterrestrial Life, Unidentified Flying Objects, and Other Astronomical Phenomenon"></d2l-menu-item>
32
33
  <d2l-menu-item text="The Universe"></d2l-menu-item>
33
34
  </d2l-menu>
34
35
  </template>
@@ -46,6 +47,7 @@
46
47
  <d2l-menu-item text="Stars &amp; Galaxies"></d2l-menu-item>
47
48
  <d2l-menu-item text="The Night Sky"></d2l-menu-item>
48
49
  <d2l-menu-item-link href="https://en.wikipedia.org/wiki/Universe" text="The Universe (link)"></d2l-menu-item-link>
50
+ <d2l-menu-item-link href="https://en.wikipedia.org/wiki/Universe" text="Aliens, The Search Extraterrestrial Life, Unidentified Flying Objects, and Other Astronomical Phenomenon"></d2l-menu-item-link>
49
51
  </d2l-menu>
50
52
  </template>
51
53
  </d2l-demo-snippet>
@@ -111,7 +113,7 @@
111
113
  </d2l-menu-item>
112
114
  </d2l-menu>
113
115
  </d2l-menu-item>
114
- <d2l-menu-item text="The Night Sky">
116
+ <d2l-menu-item text="Aliens, The Search Extraterrestrial Life, Unidentified Flying Objects, and Other Astronomical Phenomenon">
115
117
  <d2l-menu>
116
118
  <d2l-menu-item text="Constellations"></d2l-menu-item>
117
119
  <d2l-menu-item text="Mapping the Heavens"></d2l-menu-item>
@@ -18,7 +18,7 @@
18
18
  <d2l-demo-snippet>
19
19
  <template>
20
20
  <d2l-menu id="menu" label="Radio Menu" style="max-width: 400px;">
21
- <d2l-menu-item-radio text="Radio Option 1 with a very long title that will be cut off" value="1"></d2l-menu-item-radio>
21
+ <d2l-menu-item-radio text="Radio Option 1 with an extremely long title that will only be cut off with an ellipsis after two lines" value="1"></d2l-menu-item-radio>
22
22
  <d2l-menu-item-radio text="Radio Option 2" value="2"></d2l-menu-item-radio>
23
23
  <d2l-menu-item-radio text="Radio Option 3" value="3"></d2l-menu-item-radio>
24
24
  </d2l-menu>
@@ -48,8 +48,6 @@ class MenuItemLink extends MenuItemMixin(LitElement) {
48
48
  overflow-x: hidden;
49
49
  padding: 0.75rem 1rem;
50
50
  text-decoration: none;
51
- text-overflow: ellipsis;
52
- white-space: nowrap;
53
51
  }
54
52
  `
55
53
  ];
@@ -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
  }
@@ -51,12 +50,15 @@ export const menuItemStyles = css`
51
50
  }
52
51
 
53
52
  .d2l-menu-item-text {
53
+ -webkit-box-orient: vertical;
54
+ display: -webkit-box;
54
55
  flex: auto;
56
+ -webkit-line-clamp: 2;
55
57
  line-height: 1rem;
58
+ overflow-wrap: anywhere;
56
59
  overflow-x: hidden;
57
60
  overflow-y: hidden;
58
- text-overflow: ellipsis;
59
- white-space: nowrap;
61
+ white-space: normal;
60
62
  }
61
63
 
62
64
  .d2l-menu-item-supporting {
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.82.0",
3
+ "version": "2.82.2",
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",