@brightspace-ui/core 3.159.7 → 3.160.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.
- package/helpers/demo/template-tags.html +2 -0
- package/helpers/focus.js +45 -11
- package/package.json +1 -1
@@ -67,11 +67,13 @@
|
|
67
67
|
one {There is # person}
|
68
68
|
other {There are # people}
|
69
69
|
}`;
|
70
|
+
/* eslint-disable @stylistic/indent */
|
70
71
|
document.querySelector('#complex-no-tag2').value =
|
71
72
|
`{peopleCount, plural,
|
72
73
|
one {There is # person}
|
73
74
|
other {There are # people}
|
74
75
|
}`;
|
76
|
+
/* eslint-enable @stylistic/indent */
|
75
77
|
</script>
|
76
78
|
</template>
|
77
79
|
</d2l-demo-snippet>
|
package/helpers/focus.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { css, unsafeCSS } from 'lit';
|
2
2
|
import { getComposedChildren, getComposedParent, getFirstVisibleAncestor, getNextAncestorSibling, getPreviousAncestorSibling, isVisible } from './dom.js';
|
3
|
+
import { getFlag } from './flags.js';
|
3
4
|
|
4
5
|
const focusableElements = {
|
5
6
|
a: true,
|
@@ -14,6 +15,8 @@ const focusableElements = {
|
|
14
15
|
textarea: true
|
15
16
|
};
|
16
17
|
|
18
|
+
const focusVisibleSupportChangesEnabled = getFlag('focus-visible-support-changes-for-focus-rings', true);
|
19
|
+
|
17
20
|
export function getComposedActiveElement() {
|
18
21
|
let node = document.activeElement;
|
19
22
|
|
@@ -75,19 +78,50 @@ export function getFocusableDescendants(node, options) {
|
|
75
78
|
export function getFocusPseudoClass() {
|
76
79
|
return isFocusVisibleSupported() ? 'focus-visible' : 'focus';
|
77
80
|
}
|
78
|
-
export function getFocusRingStyles(selector, {
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
export function getFocusRingStyles(selector, { extraStyles = null } = {}) {
|
82
|
+
// Remove when cleaning up focus-visible-support-changes-for-focus-rings
|
83
|
+
if (!focusVisibleSupportChangesEnabled) {
|
84
|
+
const selectorDelegate = typeof selector === 'string' ? pseudoClass => `${selector}:${pseudoClass}` : selector;
|
85
|
+
const cssSelector = unsafeCSS(selectorDelegate(getFocusPseudoClass()));
|
86
|
+
return css`${cssSelector} {
|
87
|
+
${extraStyles ?? css``}
|
88
|
+
outline: 2px solid var(--d2l-focus-ring-color, var(--d2l-color-celestine));
|
89
|
+
outline-offset: var(--d2l-focus-ring-offset, 2px);
|
90
|
+
}
|
91
|
+
@media (prefers-contrast: more) {
|
92
|
+
${cssSelector} {
|
93
|
+
outline-color: Highlight;
|
94
|
+
}
|
95
|
+
}`;
|
85
96
|
}
|
86
|
-
|
87
|
-
|
88
|
-
|
97
|
+
|
98
|
+
const stylesDelegate = selector => css`
|
99
|
+
${selector} {
|
100
|
+
${extraStyles ?? css``}
|
101
|
+
outline: 2px solid var(--d2l-focus-ring-color, var(--d2l-color-celestine));
|
102
|
+
outline-offset: var(--d2l-focus-ring-offset, 2px);
|
103
|
+
}
|
104
|
+
@media (prefers-contrast: more) {
|
105
|
+
${selector} {
|
106
|
+
outline-color: Highlight;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
`;
|
110
|
+
return getFocusVisibleStyles(selector, stylesDelegate);
|
111
|
+
}
|
112
|
+
|
113
|
+
export function getFocusVisibleStyles(selector, stylesDelegate) {
|
114
|
+
const selectorDelegate = typeof selector === 'string' ? pseudoClass => `${selector}:${pseudoClass}` : selector;
|
115
|
+
const focusSelector = unsafeCSS(selectorDelegate('focus'));
|
116
|
+
const focusVisibleSelector = unsafeCSS(selectorDelegate('focus-visible'));
|
117
|
+
return unsafeCSS(css`
|
118
|
+
@supports not selector(:focus-visible) {
|
119
|
+
${stylesDelegate(focusSelector)}
|
120
|
+
}
|
121
|
+
@supports selector(:focus-visible) {
|
122
|
+
${stylesDelegate(focusVisibleSelector)}
|
89
123
|
}
|
90
|
-
|
124
|
+
`);
|
91
125
|
}
|
92
126
|
|
93
127
|
export function getLastFocusableDescendant(node, includeHidden) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.160.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",
|