@brightspace-ui/core 3.267.0 → 3.267.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,8 +1,10 @@
|
|
|
1
1
|
import { css, unsafeCSS } from 'lit';
|
|
2
|
-
import { getFocusPseudoClass } from '../../helpers/focus.js';
|
|
2
|
+
import { getFocusPseudoClass, getFocusVisibleStyles } from '../../helpers/focus.js';
|
|
3
|
+
import { _isValidCssSelector } from '../../helpers/internal/css.js';
|
|
4
|
+
import { getFlag } from '../../helpers/flags.js';
|
|
3
5
|
import { registerSemanticVariableForSvgImageUrl } from '../colors/colors.js';
|
|
4
6
|
|
|
5
|
-
const focusClass = unsafeCSS(getFocusPseudoClass());
|
|
7
|
+
const focusClass = unsafeCSS(globalThis.document !== undefined ? getFocusPseudoClass() : 'focus-visible');
|
|
6
8
|
|
|
7
9
|
registerSemanticVariableForSvgImageUrl(
|
|
8
10
|
'--d2l-input-invalid-image',
|
|
@@ -12,7 +14,142 @@ registerSemanticVariableForSvgImageUrl(
|
|
|
12
14
|
</svg>`
|
|
13
15
|
);
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
function getStyleDelegates(selector, focusSelector, textAreaSelector) {
|
|
18
|
+
return {
|
|
19
|
+
input: {
|
|
20
|
+
selector: focusClass => `
|
|
21
|
+
${focusSelector ? `${focusSelector},` : ''}
|
|
22
|
+
${selector}:${focusClass}:not(:disabled),
|
|
23
|
+
${selector}:hover:not(:disabled)
|
|
24
|
+
`,
|
|
25
|
+
style: fullSelector => css`
|
|
26
|
+
${fullSelector} {
|
|
27
|
+
border-color: var(--d2l-theme-border-color-focus);
|
|
28
|
+
border-width: 2px;
|
|
29
|
+
outline: none;
|
|
30
|
+
padding: var(--d2l-input-padding-focus, calc(0.4rem - 1px) calc(0.75rem - 1px));
|
|
31
|
+
}
|
|
32
|
+
`
|
|
33
|
+
},
|
|
34
|
+
textarea: {
|
|
35
|
+
selector: focusClass => `
|
|
36
|
+
${textAreaSelector}:hover:not(:disabled),
|
|
37
|
+
${textAreaSelector}:${focusClass}:not(:disabled)
|
|
38
|
+
`,
|
|
39
|
+
style: fullSelector => css`
|
|
40
|
+
${fullSelector} {
|
|
41
|
+
padding-block: calc(0.5rem - 1px);
|
|
42
|
+
}
|
|
43
|
+
`
|
|
44
|
+
},
|
|
45
|
+
textareaInvalid: {
|
|
46
|
+
selector: focusClass => `
|
|
47
|
+
${textAreaSelector}-focus[aria-invalid="true"],
|
|
48
|
+
${textAreaSelector}[aria-invalid="true"]:hover,
|
|
49
|
+
${textAreaSelector}[aria-invalid="true"]:${focusClass}
|
|
50
|
+
`,
|
|
51
|
+
style: fullSelector => css`
|
|
52
|
+
${fullSelector} {
|
|
53
|
+
background-position: top calc(12px - 1px) var(--d2l-inline-end, right) calc(18px - 1px);
|
|
54
|
+
padding-inline-end: calc(18px + 0.8rem - 1px);
|
|
55
|
+
}
|
|
56
|
+
`
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function _generateInputStyles(selector, focusSelector) {
|
|
62
|
+
if (!_isValidCssSelector(selector) || (focusSelector && !_isValidCssSelector(focusSelector))) return '';
|
|
63
|
+
const lastSpaceIndex = selector.lastIndexOf(' ');
|
|
64
|
+
const textareaSelector = unsafeCSS(`${selector.substring(0, lastSpaceIndex + 1)}textarea${selector.substring(lastSpaceIndex + 1)}`);
|
|
65
|
+
const delegates = getStyleDelegates(selector, focusSelector, textareaSelector);
|
|
66
|
+
|
|
67
|
+
selector = unsafeCSS(selector);
|
|
68
|
+
return css`
|
|
69
|
+
${selector} {
|
|
70
|
+
background-color: var(--d2l-input-background-color, var(--d2l-theme-background-color-base));
|
|
71
|
+
border: 1px solid var(--d2l-input-border-color, var(--d2l-theme-border-color-emphasized));
|
|
72
|
+
border-radius: var(--d2l-input-border-radius, 0.3rem);
|
|
73
|
+
box-shadow: var(--d2l-theme-shadow-inset);
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
color: var(--d2l-theme-text-color-static-standard);
|
|
76
|
+
display: inline-block;
|
|
77
|
+
font-family: inherit;
|
|
78
|
+
font-size: 0.8rem;
|
|
79
|
+
font-weight: 400;
|
|
80
|
+
height: var(--d2l-input-height, auto);
|
|
81
|
+
letter-spacing: 0.02rem;
|
|
82
|
+
line-height: 1.2rem;
|
|
83
|
+
margin: 0;
|
|
84
|
+
min-width: calc(2rem + 1em);
|
|
85
|
+
padding: var(--d2l-input-padding, 0.4rem 0.75rem);
|
|
86
|
+
position: var(--d2l-input-position, relative); /* overridden by sticky headers in grades */
|
|
87
|
+
text-align: var(--d2l-input-text-align, start);
|
|
88
|
+
vertical-align: middle;
|
|
89
|
+
width: 100%;
|
|
90
|
+
}
|
|
91
|
+
${getFocusVisibleStyles(delegates.input.selector, delegates.input.style)}
|
|
92
|
+
|
|
93
|
+
${selector}::placeholder {
|
|
94
|
+
color: var(--d2l-theme-text-color-static-faint);
|
|
95
|
+
font-size: 0.8rem;
|
|
96
|
+
font-weight: 400;
|
|
97
|
+
opacity: 1; /* Firefox has non-1 default */
|
|
98
|
+
}
|
|
99
|
+
${selector}::-ms-input-placeholder {
|
|
100
|
+
color: var(--d2l-theme-text-color-static-faint);
|
|
101
|
+
font-size: 0.8rem;
|
|
102
|
+
font-weight: 400;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
[aria-invalid="true"]${selector}:not(:disabled) {
|
|
106
|
+
border-color: var(--d2l-theme-status-color-error);
|
|
107
|
+
}
|
|
108
|
+
${selector}:disabled {
|
|
109
|
+
opacity: var(--d2l-theme-opacity-disabled-control);
|
|
110
|
+
}
|
|
111
|
+
${selector}::-webkit-search-cancel-button,
|
|
112
|
+
${selector}::-webkit-search-decoration {
|
|
113
|
+
display: none;
|
|
114
|
+
}
|
|
115
|
+
${selector}::-ms-clear {
|
|
116
|
+
display: none;
|
|
117
|
+
height: 0;
|
|
118
|
+
width: 0;
|
|
119
|
+
}
|
|
120
|
+
${textareaSelector} {
|
|
121
|
+
line-height: normal;
|
|
122
|
+
padding-block: 0.5rem;
|
|
123
|
+
}
|
|
124
|
+
${getFocusVisibleStyles(delegates.textarea.selector, delegates.textarea.style)}
|
|
125
|
+
${textareaSelector}[aria-invalid="true"] {
|
|
126
|
+
background-image: var(--d2l-input-invalid-image);
|
|
127
|
+
background-position: top 12px var(--d2l-inline-end, right) 18px;
|
|
128
|
+
background-repeat: no-repeat;
|
|
129
|
+
background-size: 0.8rem 0.8rem;
|
|
130
|
+
padding-inline-end: calc(18px + 0.8rem);
|
|
131
|
+
}
|
|
132
|
+
${getFocusVisibleStyles(delegates.textareaInvalid.selector, delegates.textareaInvalid.style)}
|
|
133
|
+
${textareaSelector}[aria-invalid="true"]:disabled {
|
|
134
|
+
background-image: none;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@media (prefers-contrast: more) {
|
|
138
|
+
${selector}[aria-invalid="true"] {
|
|
139
|
+
background-color: Field;
|
|
140
|
+
border-color: var(--d2l-theme-status-color-error);
|
|
141
|
+
box-shadow: none;
|
|
142
|
+
color: FieldText;
|
|
143
|
+
forced-color-adjust: none;
|
|
144
|
+
}
|
|
145
|
+
${focusSelector ? css`${unsafeCSS(focusSelector)} {
|
|
146
|
+
border-color: Highlight;
|
|
147
|
+
}` : css``}
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const inputStyles = getFlag('GAUD-8852-use-input-generated-styles', true) ? _generateInputStyles('.d2l-input', '.d2l-input-focus') : css`
|
|
16
153
|
.d2l-input {
|
|
17
154
|
background-color: var(--d2l-input-background-color, var(--d2l-theme-background-color-base));
|
|
18
155
|
border-radius: var(--d2l-input-border-radius, 0.3rem);
|
package/custom-elements.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.267.
|
|
3
|
+
"version": "3.267.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",
|