@instructure/ui-avatar 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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 CHANGED
@@ -3,6 +3,19 @@
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.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
7
+
8
+ ### Build System
9
+
10
+ * **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * **many:** `@instructure/ui-babel-preset` and
15
+ `@instructure/browserslist-config-instui` are removed and will no longer be
16
+ published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
17
+
18
+
6
19
  ## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
7
20
 
8
21
  **Note:** Version bump only for package @instructure/ui-avatar
@@ -1,162 +1,114 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
25
2
  import { useStyle as useStyleNew } from '@instructure/emotion';
26
3
  import { useState, useEffect, forwardRef, useRef } from 'react';
27
4
  import { View } from '@instructure/ui-view/v11_6';
28
5
  import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils';
29
6
  import generateStyle from './styles.js';
30
7
  import generateComponentTheme from './theme.js';
31
-
32
- /**
33
- ---
34
- category: components
35
- ---
36
- **/
37
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
38
- const Avatar = /*#__PURE__*/forwardRef(({
39
- size = 'medium',
40
- color = 'default',
41
- hasInverseColor = false,
42
- showBorder = 'auto',
43
- shape = 'circle',
44
- display = 'inline-block',
45
- onImageLoaded,
46
- src,
47
- name,
48
- renderIcon,
49
- alt,
50
- as,
51
- margin,
52
- themeOverride,
53
- elementRef,
54
- ...rest
55
- }, ref) => {
56
- const imgRef = useRef(null);
57
- const [loaded, setLoaded] = useState(false);
58
- const styles = useStyleNew({
59
- generateStyle,
60
- generateComponentTheme,
61
- params: {
62
- loaded,
63
- size,
64
- color,
65
- hasInverseColor,
66
- shape,
67
- src,
68
- showBorder,
69
- themeOverride
70
- },
71
- componentId: 'Avatar',
72
- displayName: 'Avatar'
73
- });
74
- useEffect(() => {
75
- // in case the image is unset in an update, show icons/initials again
76
- if (loaded && !src) {
77
- setLoaded(false);
78
- }
79
- // Image already loaded (common in SSR)
80
- if (src && !loaded && imgRef.current && imgRef.current.complete) {
81
- setLoaded(true);
82
- onImageLoaded?.();
83
- }
84
- }, [loaded, src]);
85
- const makeInitialsFromName = () => {
86
- if (!name || typeof name !== 'string') {
87
- return;
88
- }
89
- const currentName = name.trim();
90
- if (currentName.length === 0) {
91
- return;
92
- }
93
- if (currentName.match(/\s+/)) {
94
- const names = currentName.split(/\s+/);
95
- return (names[0][0] + names[names.length - 1][0]).toUpperCase();
96
- } else {
97
- return currentName[0].toUpperCase();
98
- }
99
- };
100
- const handleImageLoaded = event => {
101
- setLoaded(true);
102
- onImageLoaded?.(event);
103
- };
104
- const renderInitials = () => {
105
- return _jsx("span", {
106
- css: styles?.initials,
107
- "aria-hidden": "true",
108
- children: makeInitialsFromName()
8
+ const Avatar = /*#__PURE__*/ forwardRef(({ size = 'medium', color = 'default', hasInverseColor = false, showBorder = 'auto', shape = 'circle', display = 'inline-block', onImageLoaded, src, name, renderIcon, alt, as, margin, themeOverride, elementRef, ...rest }, ref)=>{
9
+ const imgRef = useRef(null);
10
+ const [loaded, setLoaded] = useState(false);
11
+ const styles = useStyleNew({
12
+ generateStyle,
13
+ generateComponentTheme,
14
+ params: {
15
+ loaded,
16
+ size,
17
+ color,
18
+ hasInverseColor,
19
+ shape,
20
+ src,
21
+ showBorder,
22
+ themeOverride
23
+ },
24
+ componentId: 'Avatar',
25
+ displayName: 'Avatar'
109
26
  });
110
- };
111
- const renderContent = () => {
112
- if (!renderIcon) {
113
- return renderInitials();
114
- }
115
- return _jsx("span", {
116
- css: styles?.iconSVG,
117
- children: callRenderProp(renderIcon)
27
+ useEffect(()=>{
28
+ if (loaded && !src) {
29
+ setLoaded(false);
30
+ }
31
+ if (src && !loaded && imgRef.current && imgRef.current.complete) {
32
+ setLoaded(true);
33
+ onImageLoaded?.();
34
+ }
35
+ }, [
36
+ loaded,
37
+ src
38
+ ]);
39
+ const makeInitialsFromName = ()=>{
40
+ if (!name || typeof name !== 'string') {
41
+ return;
42
+ }
43
+ const currentName = name.trim();
44
+ if (currentName.length === 0) {
45
+ return;
46
+ }
47
+ if (currentName.match(/\s+/)) {
48
+ const names = currentName.split(/\s+/);
49
+ return (names[0][0] + names[names.length - 1][0]).toUpperCase();
50
+ } else {
51
+ return currentName[0].toUpperCase();
52
+ }
53
+ };
54
+ const handleImageLoaded = (event)=>{
55
+ setLoaded(true);
56
+ onImageLoaded?.(event);
57
+ };
58
+ const renderInitials = ()=>{
59
+ return /*#__PURE__*/ _jsx("span", {
60
+ css: styles?.initials,
61
+ "aria-hidden": "true",
62
+ children: makeInitialsFromName()
63
+ });
64
+ };
65
+ const renderContent = ()=>{
66
+ if (!renderIcon) {
67
+ return renderInitials();
68
+ }
69
+ return /*#__PURE__*/ _jsx("span", {
70
+ css: styles?.iconSVG,
71
+ children: callRenderProp(renderIcon)
72
+ });
73
+ };
74
+ return /*#__PURE__*/ _jsxs(View, {
75
+ ...passthroughProps({
76
+ size,
77
+ color,
78
+ hasInverseColor,
79
+ showBorder,
80
+ shape,
81
+ display,
82
+ src,
83
+ name,
84
+ renderIcon,
85
+ alt,
86
+ as,
87
+ margin,
88
+ ...rest
89
+ }),
90
+ ref: ref,
91
+ "aria-label": alt ? alt : undefined,
92
+ role: alt ? 'img' : undefined,
93
+ as: as,
94
+ elementRef: elementRef,
95
+ margin: margin,
96
+ css: styles?.avatar,
97
+ display: display,
98
+ children: [
99
+ /*#__PURE__*/ _jsx("img", {
100
+ src: src,
101
+ ref: imgRef,
102
+ css: styles?.loadImage,
103
+ alt: alt,
104
+ onLoad: handleImageLoaded,
105
+ "aria-hidden": "true"
106
+ }),
107
+ !loaded && renderContent()
108
+ ]
118
109
  });
119
- };
120
- return _jsxs(View, {
121
- ...passthroughProps({
122
- size,
123
- color,
124
- hasInverseColor,
125
- showBorder,
126
- shape,
127
- display,
128
- src,
129
- name,
130
- renderIcon,
131
- alt,
132
- as,
133
- margin,
134
- ...rest
135
- }),
136
- ref: ref,
137
- "aria-label": alt ? alt : undefined,
138
- role: alt ? 'img' : undefined,
139
- as: as,
140
- elementRef: elementRef,
141
- margin: margin,
142
- css: styles?.avatar,
143
- display: display,
144
- children: [_jsx("img", {
145
- // This is visually hidden and is here for loading purposes only
146
- src: src,
147
- ref: imgRef,
148
- css: styles?.loadImage,
149
- alt: alt,
150
- onLoad: handleImageLoaded,
151
- "aria-hidden": "true"
152
- }), !loaded && renderContent()]
153
- });
154
110
  });
155
- // Ensures React DevTools shows "Avatar" instead of "ForwardRef"
156
- Avatar.displayName = 'Avatar'
157
-
158
- // expose generateComponentTheme so Document can render "Default Theme Variables" for v11.6
159
- ;
111
+ Avatar.displayName = 'Avatar';
160
112
  Avatar.generateComponentTheme = generateComponentTheme;
161
113
  export default Avatar;
162
- export { Avatar };
114
+ export { Avatar };
@@ -1,26 +1,17 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- const allowedProps = ['name', 'src', 'alt', 'size', 'color', 'hasInverseColor', 'shape', 'margin', 'display', 'onImageLoaded', 'as', 'elementRef', 'renderIcon', 'showBorder'];
26
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'name',
3
+ 'src',
4
+ 'alt',
5
+ 'size',
6
+ 'color',
7
+ 'hasInverseColor',
8
+ 'shape',
9
+ 'margin',
10
+ 'display',
11
+ 'onImageLoaded',
12
+ 'as',
13
+ 'elementRef',
14
+ 'renderIcon',
15
+ 'showBorder'
16
+ ];
17
+ export { allowedProps };