@instructure/ui-avatar 11.7.4-snapshot-135 → 11.7.4-snapshot-142
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/CHANGELOG.md +7 -1
- package/es/Avatar/v1/styles.js +6 -1
- package/es/Avatar/v2/styles.js +1 -0
- package/lib/Avatar/v1/styles.js +6 -1
- package/lib/Avatar/v2/styles.js +1 -0
- package/package.json +11 -10
- package/src/Avatar/v1/styles.ts +14 -1
- package/src/Avatar/v2/styles.ts +1 -0
- package/tsconfig.build.json +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Avatar/v1/styles.d.ts.map +1 -1
- package/types/Avatar/v2/styles.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,12 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [11.7.4-snapshot-
|
|
6
|
+
## [11.7.4-snapshot-142](https://github.com/instructure/instructure-ui/compare/v11.7.3...v11.7.4-snapshot-142) (2026-07-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **many:** do not allow javascript: and data: hrefs ([4a0ac03](https://github.com/instructure/instructure-ui/commit/4a0ac038c6a4102646e04d27c1c3251f97367822))
|
|
7
12
|
|
|
8
13
|
|
|
9
14
|
### Features
|
|
10
15
|
|
|
11
16
|
* **many:** support current spacing tokens in the margin prop for v2 components ([1b47c5f](https://github.com/instructure/instructure-ui/commit/1b47c5f23eaa60b532cdfd53c39bd71f0cf51aaa))
|
|
17
|
+
* **ui-codemods:** update tokens and move theme.componentOverrides to themeOverride.components ([7f94400](https://github.com/instructure/instructure-ui/commit/7f94400b25e32effc7b748d4c77ced7ecb1a70ef))
|
|
12
18
|
|
|
13
19
|
|
|
14
20
|
|
package/es/Avatar/v1/styles.js
CHANGED
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
import { safeHref } from '@instructure/ui-utils';
|
|
26
|
+
// Escape characters that could break out of a CSS single-quoted url() string.
|
|
27
|
+
const escapeCssUrl = value => value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/[\r\n]/g, '');
|
|
25
28
|
/**
|
|
26
29
|
* ---
|
|
27
30
|
* private: true
|
|
@@ -41,6 +44,8 @@ const generateStyle = (componentTheme, params) => {
|
|
|
41
44
|
src,
|
|
42
45
|
showBorder
|
|
43
46
|
} = params;
|
|
47
|
+
const safeSrc = safeHref(src, 'img', 'src');
|
|
48
|
+
const backgroundImageValue = safeSrc ? `url('${escapeCssUrl(safeSrc)}')` : undefined;
|
|
44
49
|
|
|
45
50
|
// TODO: this is a temporary solution and should be revised on component update
|
|
46
51
|
// NOTE: this is needed due to design changes. The size of the component is calculated from "em" which means it is
|
|
@@ -187,7 +192,7 @@ const generateStyle = (componentTheme, params) => {
|
|
|
187
192
|
...sizeStyles[size],
|
|
188
193
|
...shapeStyles[shape],
|
|
189
194
|
...(loaded ? {
|
|
190
|
-
backgroundImage:
|
|
195
|
+
backgroundImage: backgroundImageValue,
|
|
191
196
|
...(showBorder !== 'always' && {
|
|
192
197
|
border: 0
|
|
193
198
|
}),
|
package/es/Avatar/v2/styles.js
CHANGED
|
@@ -146,6 +146,7 @@ const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
|
146
146
|
color: hasInverseColor ? componentTheme.textOnColor : colorVariants[color].text,
|
|
147
147
|
borderColor: componentTheme.borderColor,
|
|
148
148
|
fontWeight: componentTheme.fontWeight,
|
|
149
|
+
fontFamily: componentTheme.fontFamily,
|
|
149
150
|
overflow: 'hidden',
|
|
150
151
|
// TODO handle the merging on tokens inside the util
|
|
151
152
|
margin: calcSpacingFromShorthand(margin, {
|
package/lib/Avatar/v1/styles.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _safeHref = require("@instructure/ui-utils/lib/safeHref.js");
|
|
7
8
|
/*
|
|
8
9
|
* The MIT License (MIT)
|
|
9
10
|
*
|
|
@@ -28,6 +29,8 @@ exports.default = void 0;
|
|
|
28
29
|
* SOFTWARE.
|
|
29
30
|
*/
|
|
30
31
|
|
|
32
|
+
// Escape characters that could break out of a CSS single-quoted url() string.
|
|
33
|
+
const escapeCssUrl = value => value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/[\r\n]/g, '');
|
|
31
34
|
/**
|
|
32
35
|
* ---
|
|
33
36
|
* private: true
|
|
@@ -47,6 +50,8 @@ const generateStyle = (componentTheme, params) => {
|
|
|
47
50
|
src,
|
|
48
51
|
showBorder
|
|
49
52
|
} = params;
|
|
53
|
+
const safeSrc = (0, _safeHref.safeHref)(src, 'img', 'src');
|
|
54
|
+
const backgroundImageValue = safeSrc ? `url('${escapeCssUrl(safeSrc)}')` : undefined;
|
|
50
55
|
|
|
51
56
|
// TODO: this is a temporary solution and should be revised on component update
|
|
52
57
|
// NOTE: this is needed due to design changes. The size of the component is calculated from "em" which means it is
|
|
@@ -193,7 +198,7 @@ const generateStyle = (componentTheme, params) => {
|
|
|
193
198
|
...sizeStyles[size],
|
|
194
199
|
...shapeStyles[shape],
|
|
195
200
|
...(loaded ? {
|
|
196
|
-
backgroundImage:
|
|
201
|
+
backgroundImage: backgroundImageValue,
|
|
197
202
|
...(showBorder !== 'always' && {
|
|
198
203
|
border: 0
|
|
199
204
|
}),
|
package/lib/Avatar/v2/styles.js
CHANGED
|
@@ -152,6 +152,7 @@ const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
|
152
152
|
color: hasInverseColor ? componentTheme.textOnColor : colorVariants[color].text,
|
|
153
153
|
borderColor: componentTheme.borderColor,
|
|
154
154
|
fontWeight: componentTheme.fontWeight,
|
|
155
|
+
fontFamily: componentTheme.fontFamily,
|
|
155
156
|
overflow: 'hidden',
|
|
156
157
|
// TODO handle the merging on tokens inside the util
|
|
157
158
|
margin: (0, _emotion.calcSpacingFromShorthand)(margin, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-avatar",
|
|
3
|
-
"version": "11.7.4-snapshot-
|
|
3
|
+
"version": "11.7.4-snapshot-142",
|
|
4
4
|
"description": "An image or letters that represents a user.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -15,20 +15,21 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.29.7",
|
|
18
|
-
"@instructure/emotion": "11.7.4-snapshot-
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/ui-
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/
|
|
23
|
-
"@instructure/ui-
|
|
18
|
+
"@instructure/emotion": "11.7.4-snapshot-142",
|
|
19
|
+
"@instructure/ui-icons": "11.7.4-snapshot-142",
|
|
20
|
+
"@instructure/ui-themes": "11.7.4-snapshot-142",
|
|
21
|
+
"@instructure/ui-react-utils": "11.7.4-snapshot-142",
|
|
22
|
+
"@instructure/shared-types": "11.7.4-snapshot-142",
|
|
23
|
+
"@instructure/ui-utils": "11.7.4-snapshot-142",
|
|
24
|
+
"@instructure/ui-view": "11.7.4-snapshot-142"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@testing-library/jest-dom": "^6.9.1",
|
|
27
28
|
"@testing-library/react": "16.3.2",
|
|
28
29
|
"vitest": "^4.1.9",
|
|
29
|
-
"@instructure/ui-
|
|
30
|
-
"@instructure/ui-
|
|
31
|
-
"@instructure/ui-
|
|
30
|
+
"@instructure/ui-axe-check": "11.7.4-snapshot-142",
|
|
31
|
+
"@instructure/ui-color-utils": "11.7.4-snapshot-142",
|
|
32
|
+
"@instructure/ui-babel-preset": "11.7.4-snapshot-142"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
35
|
"react": ">=18 <=19"
|
package/src/Avatar/v1/styles.ts
CHANGED
|
@@ -23,8 +23,16 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import type { AvatarTheme } from '@instructure/shared-types'
|
|
26
|
+
import { safeHref } from '@instructure/ui-utils'
|
|
26
27
|
import { AvatarProps, AvatarStyle } from './props.js'
|
|
27
28
|
|
|
29
|
+
// Escape characters that could break out of a CSS single-quoted url() string.
|
|
30
|
+
const escapeCssUrl = (value: string) =>
|
|
31
|
+
value
|
|
32
|
+
.replace(/\\/g, '\\\\')
|
|
33
|
+
.replace(/'/g, "\\'")
|
|
34
|
+
.replace(/[\r\n]/g, '')
|
|
35
|
+
|
|
28
36
|
type StyleParams = {
|
|
29
37
|
loaded: boolean
|
|
30
38
|
size: AvatarProps['size']
|
|
@@ -51,6 +59,11 @@ const generateStyle = (
|
|
|
51
59
|
const { loaded, size, color, hasInverseColor, shape, src, showBorder } =
|
|
52
60
|
params
|
|
53
61
|
|
|
62
|
+
const safeSrc = safeHref(src, 'img', 'src')
|
|
63
|
+
const backgroundImageValue = safeSrc
|
|
64
|
+
? `url('${escapeCssUrl(safeSrc)}')`
|
|
65
|
+
: undefined
|
|
66
|
+
|
|
54
67
|
// TODO: this is a temporary solution and should be revised on component update
|
|
55
68
|
// NOTE: this is needed due to design changes. The size of the component is calculated from "em" which means it is
|
|
56
69
|
// tied to the fontSize. The font sizes changed for the icons, which meant that the container (component) size would've
|
|
@@ -209,7 +222,7 @@ const generateStyle = (
|
|
|
209
222
|
...shapeStyles[shape!],
|
|
210
223
|
...(loaded
|
|
211
224
|
? {
|
|
212
|
-
backgroundImage:
|
|
225
|
+
backgroundImage: backgroundImageValue,
|
|
213
226
|
...(showBorder !== 'always' && {
|
|
214
227
|
border: 0
|
|
215
228
|
}),
|
package/src/Avatar/v2/styles.ts
CHANGED
|
@@ -173,6 +173,7 @@ const generateStyle = (
|
|
|
173
173
|
: colorVariants[color!].text,
|
|
174
174
|
borderColor: componentTheme.borderColor,
|
|
175
175
|
fontWeight: componentTheme.fontWeight,
|
|
176
|
+
fontFamily: componentTheme.fontFamily,
|
|
176
177
|
overflow: 'hidden',
|
|
177
178
|
// TODO handle the merging on tokens inside the util
|
|
178
179
|
margin: calcSpacingFromShorthand(margin, {
|