@pingux/astro 2.178.4-alpha.0 → 2.180.1-alpha.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/lib/cjs/components/Avatar/Avatar.js +8 -6
- package/lib/cjs/components/Avatar/Avatar.test.js +57 -0
- package/lib/cjs/components/Icon/Icon.stories.js +8 -8
- package/lib/cjs/libs/astro/src/types/avatar.d.ts +1 -1
- package/lib/cjs/libs/astro/tsconfig.lib.tsbuildinfo +1 -1
- package/lib/components/Avatar/Avatar.js +8 -6
- package/lib/components/Avatar/Avatar.test.js +57 -0
- package/lib/components/Icon/Icon.stories.js +8 -8
- package/package.json +6 -11
|
@@ -34,14 +34,16 @@ var Avatar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
34
34
|
isSquare = props.isSquare,
|
|
35
35
|
isLogo = props.isLogo,
|
|
36
36
|
others = _objectWithoutProperties(props, _excluded);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
var safeColorId = colorId || '_INTERNAL_DEFAULT_ID_';
|
|
38
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
39
|
+
if (!src && !color && !colorId) {
|
|
40
|
+
console.warn("[Astro] Avatar: No 'src', 'color', or 'colorId' provided. " + 'The component is falling back to a default generated color.');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
40
43
|
var finalColor = useMemo(function () {
|
|
41
44
|
if (color) return color;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, [color, colorId, avatarColors]);
|
|
45
|
+
return getColorFromUUID(safeColorId, avatarColors);
|
|
46
|
+
}, [color, safeColorId]);
|
|
45
47
|
var _useStatusClasses = useStatusClasses(className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "is-".concat(finalColor), finalColor), "size-".concat(size), size), "font-size-".concat(size), src ? false : size), 'is-square', isSquare), 'is-image', src), 'is-logo', isLogo)),
|
|
46
48
|
classNames = _useStatusClasses.classNames;
|
|
47
49
|
if (src) {
|
|
@@ -43,12 +43,14 @@ test('an avatar is rendered with custom alt', function () {
|
|
|
43
43
|
expect(img).toHaveAttribute('alt', 'Custom Alt');
|
|
44
44
|
});
|
|
45
45
|
test('an avatar is rendered with custom alt', function () {
|
|
46
|
+
var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
46
47
|
getComponent({
|
|
47
48
|
src: undefined,
|
|
48
49
|
defaultText: 'KL'
|
|
49
50
|
});
|
|
50
51
|
var avatar = screen.getByText('KL');
|
|
51
52
|
expect(avatar).toBeInTheDocument();
|
|
53
|
+
warnSpy.mockRestore();
|
|
52
54
|
});
|
|
53
55
|
describe('getColorFromUUID', function () {
|
|
54
56
|
test('returns a consistent color for the same UUID', function () {
|
|
@@ -107,6 +109,61 @@ describe('getColorFromUUID', function () {
|
|
|
107
109
|
expect(avatar).toHaveClass('is-green');
|
|
108
110
|
});
|
|
109
111
|
});
|
|
112
|
+
describe('Avatar fallback behavior', function () {
|
|
113
|
+
test('warns in development when no src, color, or colorId is provided', function () {
|
|
114
|
+
var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
115
|
+
getComponent({
|
|
116
|
+
src: undefined
|
|
117
|
+
});
|
|
118
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("No 'src', 'color', or 'colorId' provided"));
|
|
119
|
+
warnSpy.mockRestore();
|
|
120
|
+
});
|
|
121
|
+
test('does not crash when colorId is null', function () {
|
|
122
|
+
var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
123
|
+
getComponent({
|
|
124
|
+
src: undefined,
|
|
125
|
+
colorId: null
|
|
126
|
+
});
|
|
127
|
+
var avatar = screen.getByTestId(datatestId);
|
|
128
|
+
var classList = _Array$from(avatar.classList);
|
|
129
|
+
var colorClass = _findInstanceProperty(classList).call(classList, function (cls) {
|
|
130
|
+
return _startsWithInstanceProperty(cls).call(cls, 'is-');
|
|
131
|
+
});
|
|
132
|
+
expect(colorClass).toBeDefined();
|
|
133
|
+
warnSpy.mockRestore();
|
|
134
|
+
});
|
|
135
|
+
test('two avatars with missing colorId get the same color class', function () {
|
|
136
|
+
var _context, _context2;
|
|
137
|
+
var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
138
|
+
var _render = render(___EmotionJSX(Avatar, {
|
|
139
|
+
"data-testid": "avatar-1"
|
|
140
|
+
})),
|
|
141
|
+
unmount = _render.unmount;
|
|
142
|
+
var avatar1 = screen.getByTestId('avatar-1');
|
|
143
|
+
var colorClass1 = _findInstanceProperty(_context = _Array$from(avatar1.classList)).call(_context, function (cls) {
|
|
144
|
+
return _startsWithInstanceProperty(cls).call(cls, 'is-');
|
|
145
|
+
});
|
|
146
|
+
unmount();
|
|
147
|
+
render(___EmotionJSX(Avatar, {
|
|
148
|
+
"data-testid": "avatar-2"
|
|
149
|
+
}));
|
|
150
|
+
var avatar2 = screen.getByTestId('avatar-2');
|
|
151
|
+
var colorClass2 = _findInstanceProperty(_context2 = _Array$from(avatar2.classList)).call(_context2, function (cls) {
|
|
152
|
+
return _startsWithInstanceProperty(cls).call(cls, 'is-');
|
|
153
|
+
});
|
|
154
|
+
expect(colorClass1).toBe(colorClass2);
|
|
155
|
+
warnSpy.mockRestore();
|
|
156
|
+
});
|
|
157
|
+
test('does not warn when color prop is provided', function () {
|
|
158
|
+
var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
159
|
+
getComponent({
|
|
160
|
+
src: undefined,
|
|
161
|
+
color: 'blue'
|
|
162
|
+
});
|
|
163
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
164
|
+
warnSpy.mockRestore();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
110
167
|
describe('getColorFromUUID Distribution', function () {
|
|
111
168
|
test('distributes 10,000 UUIDs evenly across 10 colors', function () {
|
|
112
169
|
var iterations = 10000;
|
|
@@ -111,44 +111,44 @@ export var Sizes = function Sizes() {
|
|
|
111
111
|
borderBottom: 'unset'
|
|
112
112
|
}
|
|
113
113
|
}, ___EmotionJSX(TableRow, {
|
|
114
|
-
height: "
|
|
114
|
+
height: "auto",
|
|
115
115
|
bg: "transparent !important"
|
|
116
116
|
}, ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, null, "XXS | 9px")), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
|
|
117
117
|
fontFamily: "monospace"
|
|
118
|
-
}, '<Icon icon={SearchIcon}
|
|
118
|
+
}, '<Icon icon={SearchIcon} size="xxs"/>')), ___EmotionJSX(TableCell, null, ___EmotionJSX(Icon, {
|
|
119
119
|
icon: SearchIcon,
|
|
120
120
|
size: "xxs",
|
|
121
121
|
title: {
|
|
122
122
|
name: 'Search Icon'
|
|
123
123
|
}
|
|
124
124
|
}))), ___EmotionJSX(TableRow, {
|
|
125
|
-
height: "
|
|
125
|
+
height: "auto",
|
|
126
126
|
bg: "transparent !important"
|
|
127
127
|
}, ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, null, "XS | 15px")), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
|
|
128
128
|
fontFamily: "monospace"
|
|
129
|
-
}, '<Icon icon={SearchIcon}
|
|
129
|
+
}, '<Icon icon={SearchIcon} size="xs"/>')), ___EmotionJSX(TableCell, null, ___EmotionJSX(Icon, {
|
|
130
130
|
icon: SearchIcon,
|
|
131
131
|
size: "xs",
|
|
132
132
|
title: {
|
|
133
133
|
name: 'Search Icon'
|
|
134
134
|
}
|
|
135
135
|
}))), ___EmotionJSX(TableRow, {
|
|
136
|
-
height: "
|
|
136
|
+
height: "auto",
|
|
137
137
|
bg: "transparent !important"
|
|
138
138
|
}, ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, null, "SM | 20px")), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
|
|
139
139
|
fontFamily: "monospace"
|
|
140
|
-
}, '<Icon icon={SearchIcon}
|
|
140
|
+
}, '<Icon icon={SearchIcon} size="sm"/>')), ___EmotionJSX(TableCell, null, ___EmotionJSX(Icon, {
|
|
141
141
|
icon: SearchIcon,
|
|
142
142
|
size: "sm",
|
|
143
143
|
title: {
|
|
144
144
|
name: 'Search Icon'
|
|
145
145
|
}
|
|
146
146
|
}))), ___EmotionJSX(TableRow, {
|
|
147
|
-
height: "
|
|
147
|
+
height: "auto",
|
|
148
148
|
bg: "transparent !important"
|
|
149
149
|
}, ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, null, "MD | 25px")), ___EmotionJSX(TableCell, null, ___EmotionJSX(Text, {
|
|
150
150
|
fontFamily: "monospace"
|
|
151
|
-
}, '<Icon icon={SearchIcon}
|
|
151
|
+
}, '<Icon icon={SearchIcon} size="md"/>')), ___EmotionJSX(TableCell, null, ___EmotionJSX(Icon, {
|
|
152
152
|
icon: SearchIcon,
|
|
153
153
|
size: "md",
|
|
154
154
|
title: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pingux/astro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.180.1-alpha.0",
|
|
4
4
|
"description": "React component library for Ping Identity's design system",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"@babel/runtime-corejs3": "7.13.8",
|
|
37
37
|
"@emotion/react": "^11.1.1",
|
|
38
38
|
"@emotion/styled": "^11.1.1",
|
|
39
|
-
"@faker-js/faker": "~7.5.0",
|
|
40
39
|
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
|
41
40
|
"@fortawesome/free-brands-svg-icons": "^6.7.2",
|
|
42
41
|
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|
|
@@ -44,7 +43,6 @@
|
|
|
44
43
|
"@internationalized/date": "^3.5.3",
|
|
45
44
|
"@internationalized/number": "^3.6.0",
|
|
46
45
|
"@material-symbols/font-400": "^0.40.2",
|
|
47
|
-
"@mdx-js/react": "^2.0.0",
|
|
48
46
|
"@monaco-editor/react": "4.4.2",
|
|
49
47
|
"@pingux/mdi-react": "^1.2.0",
|
|
50
48
|
"@pingux/onyx-tokens": "^0.18.0",
|
|
@@ -99,28 +97,23 @@
|
|
|
99
97
|
"@react-types/combobox": "^3.13.8",
|
|
100
98
|
"@react-types/slider": "^3.7.9",
|
|
101
99
|
"@styled-system/prop-types": "^5.1.5",
|
|
102
|
-
"@styled-system/props": "^5.1.5",
|
|
103
100
|
"@styled-system/should-forward-prop": "^5.1.5",
|
|
104
101
|
"@styled-system/theme-get": "^5.1.2",
|
|
105
102
|
"chroma-js": "^2.1.0",
|
|
106
|
-
"chromatic": "^6.5.3",
|
|
107
103
|
"classnames": "^2.2.6",
|
|
108
104
|
"countries-list": "^2.6.1",
|
|
109
105
|
"deepmerge": "^4.3.1",
|
|
110
106
|
"emotion-normalize": "^11.0.1",
|
|
111
|
-
"globals": "^13.19.0",
|
|
112
107
|
"listbox-layout": "npm:@react-stately/layout@3.9.0",
|
|
113
108
|
"listbox-virtualizer": "npm:@react-aria/virtualizer@3.6.0",
|
|
114
109
|
"lodash": "^4.17.23",
|
|
115
110
|
"markdown-to-jsx": "^7.7.4",
|
|
116
|
-
"moment": "^2.29.4",
|
|
117
111
|
"monaco-editor": "0.34.1",
|
|
118
112
|
"pluralize": "^8.0.0",
|
|
119
113
|
"prism-react-renderer": "1.2.1",
|
|
120
114
|
"prismjs": "^1.27.0",
|
|
121
115
|
"prop-types": "^15.7.2",
|
|
122
116
|
"react-aria": "~3.19.0",
|
|
123
|
-
"react-calendar": "^3.4.0",
|
|
124
117
|
"react-color": "^2.19.3",
|
|
125
118
|
"react-dropzone": "^11.4.2",
|
|
126
119
|
"react-stately": "^3.31.0",
|
|
@@ -162,7 +155,6 @@
|
|
|
162
155
|
"@storybook/addons": "^7.1.0",
|
|
163
156
|
"@storybook/react": "^7.1.0",
|
|
164
157
|
"@storybook/react-vite": "^7.1.0",
|
|
165
|
-
"@storybook/react-webpack5": "^7.1.0",
|
|
166
158
|
"@storybook/theming": "^7.1.0",
|
|
167
159
|
"@testing-library/jest-dom": "^5.11.4",
|
|
168
160
|
"@testing-library/react": "15.0.6",
|
|
@@ -199,7 +191,6 @@
|
|
|
199
191
|
"storybook-addon-designs": "beta",
|
|
200
192
|
"ts-jest": "^29.0.0",
|
|
201
193
|
"typescript": "~5.5.2",
|
|
202
|
-
"use-resize-observer": "^8.0.0",
|
|
203
194
|
"vite-plugin-dts": "~3.8.1",
|
|
204
195
|
"vitest": "^1.3.1",
|
|
205
196
|
"whatwg-fetch": "^3.2.0",
|
|
@@ -222,7 +213,11 @@
|
|
|
222
213
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
223
214
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
224
215
|
"eslint-plugin-testing-library": "^7.0.0",
|
|
225
|
-
"
|
|
216
|
+
"@faker-js/faker": "~7.5.0",
|
|
217
|
+
"@nx/vite": "20.0.5",
|
|
218
|
+
"globals": "^13.19.0",
|
|
219
|
+
"@mdx-js/react": "^2.0.0",
|
|
220
|
+
"chromatic": "^6.5.3"
|
|
226
221
|
},
|
|
227
222
|
"peerDependencies": {
|
|
228
223
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
|