@redocly/theme 0.19.4 → 0.19.5

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.
@@ -74,7 +74,7 @@ function changeCasing(str, casing) {
74
74
  return str.toUpperCase();
75
75
  }
76
76
  if (casing === 'sentence') {
77
- const words = str.split(/[\s-_]+/);
77
+ const words = str === null || str === void 0 ? void 0 : str.split(/[\s-_]+/);
78
78
  return words.map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase()).join(' ');
79
79
  }
80
80
  }
@@ -8,7 +8,7 @@ const react_1 = __importDefault(require("react"));
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
9
  function parseSrcSet(srcSet) {
10
10
  const result = new Map();
11
- const parts = srcSet.split(', ');
11
+ const parts = srcSet === null || srcSet === void 0 ? void 0 : srcSet.split(', ');
12
12
  for (const part of parts) {
13
13
  const [url, theme] = part.split(' ');
14
14
  result.set(theme, url);
@@ -8,7 +8,8 @@ export interface ProfileProps {
8
8
  export declare const Profile: React.NamedExoticComponent<ProfileProps>;
9
9
  export declare const ProfileWrapper: import("styled-components").StyledComponent<"div", any, {
10
10
  'data-component-name': string;
11
- }, "data-component-name">;
11
+ 'data-cy': string;
12
+ }, "data-component-name" | "data-cy">;
12
13
  export declare const AvatarWrapper: import("styled-components").StyledComponent<"div", any, {
13
14
  background?: string | undefined;
14
15
  }, never>;
@@ -31,9 +31,9 @@ function ProfileComponent({ name = 'User', imageUrl, onClick }) {
31
31
  var _a;
32
32
  if (imageUrl) {
33
33
  return (react_1.default.createElement(exports.ProfileWrapper, { onClick: onClick, role: "link" }, imageUrl && (react_1.default.createElement(exports.AvatarWrapper, null,
34
- react_1.default.createElement("img", { "data-cy": "user-avatar", src: imageUrl, alt: "profile" })))));
34
+ react_1.default.createElement("img", { src: imageUrl, alt: "profile" })))));
35
35
  }
36
- const avatarLetters = `${name.charAt(0).toUpperCase()}${((_a = name.split(' ')[1]) === null || _a === void 0 ? void 0 : _a.charAt(0).toUpperCase()) || ''}`;
36
+ const avatarLetters = `${name === null || name === void 0 ? void 0 : name.charAt(0).toUpperCase()}${((_a = name === null || name === void 0 ? void 0 : name.split(' ')[1]) === null || _a === void 0 ? void 0 : _a.charAt(0).toUpperCase()) || ''}`;
37
37
  return (react_1.default.createElement(exports.ProfileWrapper, { onClick: onClick, role: "link" },
38
38
  react_1.default.createElement(exports.AvatarWrapper, { background: (0, utils_1.stringToHslColor)(name) },
39
39
  react_1.default.createElement("span", null, avatarLetters))));
@@ -41,6 +41,7 @@ function ProfileComponent({ name = 'User', imageUrl, onClick }) {
41
41
  exports.Profile = (0, react_1.memo)(ProfileComponent);
42
42
  exports.ProfileWrapper = styled_components_1.default.div.attrs(() => ({
43
43
  'data-component-name': 'Profile/Profile',
44
+ 'data-cy': 'user-profile',
44
45
  })) `
45
46
  display: flex;
46
47
  align-items: center;
@@ -67,6 +67,7 @@ exports.UserProfile = UserProfile;
67
67
  const ProfileDropdown = (0, styled_components_1.default)(Dropdown_1.Dropdown).attrs(() => ({
68
68
  dataAttributes: {
69
69
  'data-component-name': 'Profile/ProfileDropdown',
70
+ 'data-cy': 'user-profile-dropdown',
70
71
  },
71
72
  })) `
72
73
  font-size: var(--profile-dropdown-font-size);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.19.4",
3
+ "version": "0.19.5",
4
4
  "description": "Shared UI components lib",
5
5
  "keywords": [
6
6
  "theme",
@@ -142,7 +142,7 @@ function changeCasing(
142
142
  }
143
143
 
144
144
  if (casing === 'sentence') {
145
- const words = str.split(/[\s-_]+/);
145
+ const words = str?.split(/[\s-_]+/);
146
146
  return words.map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase()).join(' ');
147
147
  }
148
148
  }
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
 
4
4
  function parseSrcSet(srcSet: string): Map<string, string> {
5
5
  const result = new Map<string, string>();
6
- const parts = srcSet.split(', ');
6
+ const parts = srcSet?.split(', ');
7
7
 
8
8
  for (const part of parts) {
9
9
  const [url, theme] = part.split(' ');
@@ -16,15 +16,15 @@ function ProfileComponent({ name = 'User', imageUrl, onClick }: ProfileProps): J
16
16
  <ProfileWrapper onClick={onClick} role="link">
17
17
  {imageUrl && (
18
18
  <AvatarWrapper>
19
- <img data-cy="user-avatar" src={imageUrl} alt="profile" />
19
+ <img src={imageUrl} alt="profile" />
20
20
  </AvatarWrapper>
21
21
  )}
22
22
  </ProfileWrapper>
23
23
  );
24
24
  }
25
25
 
26
- const avatarLetters = `${name.charAt(0).toUpperCase()}${
27
- name.split(' ')[1]?.charAt(0).toUpperCase() || ''
26
+ const avatarLetters = `${name?.charAt(0).toUpperCase()}${
27
+ name?.split(' ')[1]?.charAt(0).toUpperCase() || ''
28
28
  }`;
29
29
 
30
30
  return (
@@ -40,6 +40,7 @@ export const Profile = memo<ProfileProps>(ProfileComponent);
40
40
 
41
41
  export const ProfileWrapper = styled.div.attrs(() => ({
42
42
  'data-component-name': 'Profile/Profile',
43
+ 'data-cy': 'user-profile',
43
44
  }))`
44
45
  display: flex;
45
46
  align-items: center;
@@ -77,6 +77,7 @@ export function UserProfile({
77
77
  const ProfileDropdown = styled(Dropdown).attrs(() => ({
78
78
  dataAttributes: {
79
79
  'data-component-name': 'Profile/ProfileDropdown',
80
+ 'data-cy': 'user-profile-dropdown',
80
81
  },
81
82
  }))`
82
83
  font-size: var(--profile-dropdown-font-size);