@brightspace-ui/core 2.82.0 → 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.
|
@@ -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
|
|
104
|
+
a:${unsafeCSS(getFocusPseudoClass())} {
|
|
103
105
|
border-radius: 3px;
|
|
104
106
|
outline: 2px solid var(--d2l-color-celestine, #006fbf);
|
|
105
107
|
outline-offset: 1px;
|
package/components/link/link.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
24
|
-
:host(
|
|
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
|
-
|
|
40
|
-
:host([disabled]:focus-visible) {
|
|
39
|
+
:host([disabled]:${unsafeCSS(getFocusPseudoClass())}) {
|
|
41
40
|
cursor: default;
|
|
42
41
|
opacity: 0.75;
|
|
43
42
|
}
|
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.
|
|
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",
|