carbon-react 104.17.0 → 104.18.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.
@@ -9,7 +9,6 @@ declare function PortraitGravatar({ gravatarEmail, size, alt, shape, errorCallba
9
9
  }): JSX.Element;
10
10
  declare namespace PortraitGravatar {
11
11
  namespace propTypes {
12
- const theme: PropTypes.Requireable<object>;
13
12
  const gravatarEmail: PropTypes.Validator<string>;
14
13
  const size: PropTypes.Validator<string>;
15
14
  const shape: PropTypes.Requireable<string>;
@@ -51,9 +51,6 @@ const PortraitGravatar = ({
51
51
  };
52
52
 
53
53
  PortraitGravatar.propTypes = {
54
- /** The theme to use. */
55
- theme: _propTypes.default.object,
56
-
57
54
  /** The user's email address for the Gravatar. */
58
55
  gravatarEmail: _propTypes.default.string.isRequired,
59
56
 
@@ -1,8 +1,6 @@
1
1
  import { PortraitSizes, PortraitShapes } from "./portrait";
2
2
 
3
3
  export interface PortraitGravatarProps {
4
- /** The theme to use. */
5
- theme?: Record<string, unknown>;
6
4
  /** The user's email address for the Gravatar. */
7
5
  gravatarEmail: string;
8
6
  /** The size of the Gravatar. */
@@ -1,8 +1,23 @@
1
- declare var _default: React.ForwardRefExoticComponent<{
1
+ export default PortraitInitials;
2
+ declare function PortraitInitials({ initials, size, shape, darkBackground, alt, ...rest }: {
2
3
  [x: string]: any;
3
- [x: number]: any;
4
- } & {
5
- theme?: any;
6
- }>;
7
- export default _default;
8
- import React from "react";
4
+ initials: any;
5
+ size: any;
6
+ shape: any;
7
+ darkBackground: any;
8
+ alt: any;
9
+ }): JSX.Element;
10
+ declare namespace PortraitInitials {
11
+ namespace propTypes {
12
+ const initials: PropTypes.Validator<string>;
13
+ const size: PropTypes.Validator<string>;
14
+ const darkBackground: PropTypes.Requireable<boolean>;
15
+ const shape: PropTypes.Requireable<string>;
16
+ const alt: PropTypes.Requireable<string>;
17
+ }
18
+ namespace defaultProps {
19
+ const shape_1: string;
20
+ export { shape_1 as shape };
21
+ }
22
+ }
23
+ import PropTypes from "prop-types";
@@ -9,9 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _styledComponents = require("styled-components");
13
-
14
- var _base = _interopRequireDefault(require("../../style/themes/base"));
12
+ var _common = _interopRequireDefault(require("@sage/design-tokens/js/base/common"));
15
13
 
16
14
  var _browser = _interopRequireDefault(require("../../__internal__/utils/helpers/browser"));
17
15
 
@@ -28,7 +26,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
28
26
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
29
27
 
30
28
  const PortraitInitials = ({
31
- theme,
32
29
  initials,
33
30
  size,
34
31
  shape,
@@ -39,7 +36,7 @@ const PortraitInitials = ({
39
36
  const [cachedImageDataUrl, setCachedImageDataUrl] = (0, _react.useState)();
40
37
  (0, _react.useEffect)(() => {
41
38
  setCachedImageDataUrl(null);
42
- }, [theme, initials, size, darkBackground]);
39
+ }, [initials, size, darkBackground]);
43
40
 
44
41
  const generateDataUrl = () => {
45
42
  if (cachedImageDataUrl) {
@@ -49,7 +46,7 @@ const PortraitInitials = ({
49
46
  const {
50
47
  textColor,
51
48
  bgColor
52
- } = (0, _portrait.getColorsForInitials)(theme, darkBackground);
49
+ } = (0, _portrait.getColorsForInitials)(darkBackground);
53
50
 
54
51
  let canvas = _browser.default.getDocument().createElement("canvas");
55
52
 
@@ -66,9 +63,9 @@ const PortraitInitials = ({
66
63
  context.font = `${Math.round(canvas.width / 2.4)}px Lato, Arial`;
67
64
  context.textAlign = "center"; // Setup background and front color
68
65
 
69
- context.fillStyle = bgColor;
66
+ context.fillStyle = _common.default[bgColor];
70
67
  context.fillRect(0, 0, dimensions, dimensions);
71
- context.fillStyle = textColor;
68
+ context.fillStyle = _common.default[textColor];
72
69
  context.fillText(initials.slice(0, 3).toUpperCase(), dimensions / 2, dimensions / 1.5); // Set image representation in default format (png)
73
70
 
74
71
  const dataURI = canvas.toDataURL(); // Dispose canvas element
@@ -81,8 +78,7 @@ const PortraitInitials = ({
81
78
  return /*#__PURE__*/_react.default.createElement(_portrait.StyledPortraitInitials, _extends({
82
79
  "data-element": "initials",
83
80
  size: size,
84
- shape: shape,
85
- theme: theme
81
+ shape: shape
86
82
  }, rest), /*#__PURE__*/_react.default.createElement(_portrait.StyledPortraitInitialsImg, {
87
83
  src: generateDataUrl(),
88
84
  alt: alt
@@ -90,9 +86,6 @@ const PortraitInitials = ({
90
86
  };
91
87
 
92
88
  PortraitInitials.propTypes = {
93
- /** The theme to use. */
94
- theme: _propTypes.default.object,
95
-
96
89
  /** The user's initials to render. */
97
90
  initials: _propTypes.default.string.isRequired,
98
91
 
@@ -109,10 +102,7 @@ PortraitInitials.propTypes = {
109
102
  alt: _propTypes.default.string
110
103
  };
111
104
  PortraitInitials.defaultProps = {
112
- shape: "square",
113
- theme: _base.default
105
+ shape: "square"
114
106
  };
115
-
116
- var _default = (0, _styledComponents.withTheme)(PortraitInitials);
117
-
107
+ var _default = PortraitInitials;
118
108
  exports.default = _default;
@@ -1,8 +1,6 @@
1
1
  import { PortraitSizes, PortraitShapes } from "./portrait";
2
2
 
3
3
  export interface PortraitInitialsProps {
4
- /** The theme to use. */
5
- theme?: Record<string, unknown>;
6
4
  /** The user's initials to render. */
7
5
  initials: string;
8
6
  /** The size of the initials image. */
@@ -27,11 +27,11 @@ const PORTRAIT_SIZE_PARAMS = {
27
27
  },
28
28
  L: {
29
29
  dimensions: 72,
30
- iconDimensions: 32
30
+ iconDimensions: 40
31
31
  },
32
32
  XL: {
33
33
  dimensions: 104,
34
- iconDimensions: 48
34
+ iconDimensions: 56
35
35
  },
36
36
  XXL: {
37
37
  dimensions: 128,
@@ -1,10 +1,10 @@
1
- export function getColorsForInitials(theme: any, darkBackground: any): {
2
- textColor: any;
3
- bgColor: any;
1
+ export function getColorsForInitials(darkBackground: any): {
2
+ textColor: string;
3
+ bgColor: string;
4
4
  };
5
5
  export const StyledPortraitInitials: import("styled-components").StyledComponent<"div", any, {}, never>;
6
6
  export const StyledPortraitInitialsImg: import("styled-components").StyledComponent<"img", any, {}, never>;
7
7
  export const StyledPortraitGravatar: import("styled-components").StyledComponent<"img", any, {}, never>;
8
8
  export const StyledCustomImg: import("styled-components").StyledComponent<"img", any, {}, never>;
9
- export const StyledIcon: import("styled-components").StyledComponent<({ darkBackground, ...rest }: any) => JSX.Element, any, {}, never>;
9
+ export const StyledIcon: import("styled-components").StyledComponent<({ size, darkBackground, ...rest }: any) => JSX.Element, any, {}, never>;
10
10
  export const StyledPortraitContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -54,7 +54,6 @@ function stylingForShape({
54
54
 
55
55
  function stylingForIcon({
56
56
  size,
57
- theme,
58
57
  darkBackground
59
58
  }) {
60
59
  const params = _portrait.PORTRAIT_SIZE_PARAMS[size];
@@ -63,31 +62,28 @@ function stylingForIcon({
63
62
  return (0, _styledComponents.css)``;
64
63
  }
65
64
 
66
- let color = theme.portrait.border;
67
- let backgroundColor = theme.portrait.background;
65
+ let color = "var(--colorsUtilityMajor200)";
66
+ let backgroundColor = "var(--colorsUtilityMajor025)";
68
67
 
69
68
  if (darkBackground) {
70
- color = theme.portrait.background;
71
- backgroundColor = theme.portrait.border;
69
+ color = "var(--colorsUtilityMajor025)";
70
+ backgroundColor = "var(--colorsUtilityMajor200)";
72
71
  }
73
72
 
74
73
  return (0, _styledComponents.css)`
75
74
  background-color: ${backgroundColor};
76
75
  color: ${color};
77
76
 
78
- ${params.iconDimensions && (0, _styledComponents.css)`
79
- svg {
80
- width: ${params.iconDimensions}px;
81
- height: ${params.iconDimensions}px;
82
- }
83
- `}
77
+ ::before {
78
+ font-size: ${params.iconDimensions}px;
79
+ }
84
80
  `;
85
81
  }
86
82
 
87
- function getColorsForInitials(theme, darkBackground) {
83
+ function getColorsForInitials(darkBackground) {
88
84
  return {
89
- textColor: darkBackground ? theme.portrait.background : theme.portrait.initials,
90
- bgColor: darkBackground ? theme.portrait.initials : theme.portrait.background
85
+ textColor: darkBackground ? "colorsUtilityYang100" : "colorsUtilityYin055",
86
+ bgColor: darkBackground ? "colorsUtilityMajor400" : "colorsUtilityMajor025"
91
87
  };
92
88
  }
93
89
 
@@ -97,20 +93,14 @@ const StyledPortraitInitials = _styledComponents.default.div`
97
93
  box-sizing: border-box;
98
94
  ${stylingForSize}
99
95
  ${stylingForShape}
100
- ${({
101
- theme
102
- }) => (0, _styledComponents.css)`
103
- border: 1px solid ${theme.portrait.border};
104
- `}
96
+ border: 1px solid var(--colorsUtilityMajor200);
105
97
  `;
106
98
  exports.StyledPortraitInitials = StyledPortraitInitials;
107
99
  StyledPortraitInitials.propTypes = {
108
- theme: _propTypes.default.object,
109
100
  size: _propTypes.default.oneOf(_portrait.PORTRAIT_SIZES).isRequired,
110
101
  shape: _propTypes.default.oneOf(_portrait.PORTRAIT_SHAPES)
111
102
  };
112
103
  StyledPortraitInitials.defaultProps = {
113
- theme: _base.default,
114
104
  shape: "square"
115
105
  };
116
106
  const StyledPortraitInitialsImg = _styledComponents.default.img`
@@ -134,9 +124,6 @@ StyledPortraitGravatar.propTypes = {
134
124
  src: _propTypes.default.string.isRequired,
135
125
  alt: _propTypes.default.string
136
126
  };
137
- StyledPortraitGravatar.defaultProps = {
138
- theme: _base.default
139
- };
140
127
  const StyledCustomImg = _styledComponents.default.img`
141
128
  display: block;
142
129
  ${stylingForSize}
@@ -151,6 +138,7 @@ StyledCustomImg.propTypes = {
151
138
  }; // && is used here to increase the specificity
152
139
 
153
140
  const StyledIcon = (0, _styledComponents.default)(({
141
+ size,
154
142
  darkBackground,
155
143
  ...rest
156
144
  }) => /*#__PURE__*/_react.default.createElement(_icon.default, rest))`
@@ -160,11 +148,9 @@ const StyledIcon = (0, _styledComponents.default)(({
160
148
  ${stylingForSize}
161
149
  ${stylingForIcon}
162
150
  ${stylingForShape}
163
- ${({
164
- theme
165
- }) => (0, _styledComponents.css)`
166
- border: 1px dashed ${theme.portrait.border};
167
- `}
151
+ border: 1px dashed ${({
152
+ darkBackground
153
+ }) => darkBackground ? "var(--colorsUtilityMajorTransparent)" : "var(--colorsUtilityMajor200)"};
168
154
  }
169
155
  `;
170
156
  exports.StyledIcon = StyledIcon;
@@ -172,14 +158,12 @@ StyledIcon.propTypes = {
172
158
  darkBackground: _propTypes.default.bool,
173
159
  size: _propTypes.default.oneOf(_portrait.PORTRAIT_SIZES),
174
160
  shape: _propTypes.default.oneOf(_portrait.PORTRAIT_SHAPES),
175
- theme: _propTypes.default.object,
176
161
  type: _propTypes.default.string.isRequired
177
162
  };
178
163
  StyledIcon.defaultProps = {
179
164
  darkBackground: false,
180
165
  size: "M",
181
- shape: "square",
182
- theme: _base.default
166
+ shape: "square"
183
167
  };
184
168
  const StyledPortraitContainer = _styledComponents.default.div`
185
169
  display: inline-block;
@@ -1,7 +1,6 @@
1
1
  export const PROFILE_SIZES: string[];
2
2
  declare namespace _default {
3
3
  namespace XS {
4
- const dimensions: number;
5
4
  const nameSize: string;
6
5
  const emailSize: string;
7
6
  const lineHeight: string;
@@ -9,11 +8,10 @@ declare namespace _default {
9
8
  const marginTop: string;
10
9
  }
11
10
  namespace S {
12
- const dimensions_1: number;
13
- export { dimensions_1 as dimensions };
14
11
  const nameSize_1: string;
15
12
  export { nameSize_1 as nameSize };
16
- export const emailsize: string;
13
+ const emailSize_1: string;
14
+ export { emailSize_1 as emailSize };
17
15
  const lineHeight_1: string;
18
16
  export { lineHeight_1 as lineHeight };
19
17
  const marginLeft_1: string;
@@ -22,12 +20,10 @@ declare namespace _default {
22
20
  export { marginTop_1 as marginTop };
23
21
  }
24
22
  namespace M {
25
- const dimensions_2: number;
26
- export { dimensions_2 as dimensions };
27
23
  const nameSize_2: string;
28
24
  export { nameSize_2 as nameSize };
29
- const emailSize_1: string;
30
- export { emailSize_1 as emailSize };
25
+ const emailSize_2: string;
26
+ export { emailSize_2 as emailSize };
31
27
  const lineHeight_2: string;
32
28
  export { lineHeight_2 as lineHeight };
33
29
  const marginLeft_2: string;
@@ -36,12 +32,10 @@ declare namespace _default {
36
32
  export { marginTop_2 as marginTop };
37
33
  }
38
34
  namespace ML {
39
- const dimensions_3: number;
40
- export { dimensions_3 as dimensions };
41
35
  const nameSize_3: string;
42
36
  export { nameSize_3 as nameSize };
43
- const emailSize_2: string;
44
- export { emailSize_2 as emailSize };
37
+ const emailSize_3: string;
38
+ export { emailSize_3 as emailSize };
45
39
  const lineHeight_3: string;
46
40
  export { lineHeight_3 as lineHeight };
47
41
  const marginLeft_3: string;
@@ -50,12 +44,10 @@ declare namespace _default {
50
44
  export { marginTop_3 as marginTop };
51
45
  }
52
46
  namespace L {
53
- const dimensions_4: number;
54
- export { dimensions_4 as dimensions };
55
47
  const nameSize_4: string;
56
48
  export { nameSize_4 as nameSize };
57
- const emailSize_3: string;
58
- export { emailSize_3 as emailSize };
49
+ const emailSize_4: string;
50
+ export { emailSize_4 as emailSize };
59
51
  const lineHeight_4: string;
60
52
  export { lineHeight_4 as lineHeight };
61
53
  const marginLeft_4: string;
@@ -64,12 +56,10 @@ declare namespace _default {
64
56
  export { marginTop_4 as marginTop };
65
57
  }
66
58
  namespace XL {
67
- const dimensions_5: number;
68
- export { dimensions_5 as dimensions };
69
59
  const nameSize_5: string;
70
60
  export { nameSize_5 as nameSize };
71
- const emailSize_4: string;
72
- export { emailSize_4 as emailSize };
61
+ const emailSize_5: string;
62
+ export { emailSize_5 as emailSize };
73
63
  const lineHeight_5: string;
74
64
  export { lineHeight_5 as lineHeight };
75
65
  const marginLeft_5: string;
@@ -78,12 +68,10 @@ declare namespace _default {
78
68
  export { marginTop_5 as marginTop };
79
69
  }
80
70
  namespace XXL {
81
- const dimensions_6: number;
82
- export { dimensions_6 as dimensions };
83
71
  const nameSize_6: string;
84
72
  export { nameSize_6 as nameSize };
85
- const emailSize_5: string;
86
- export { emailSize_5 as emailSize };
73
+ const emailSize_6: string;
74
+ export { emailSize_6 as emailSize };
87
75
  const lineHeight_6: string;
88
76
  export { lineHeight_6 as lineHeight };
89
77
  const marginLeft_6: string;
@@ -8,57 +8,50 @@ const PROFILE_SIZES = ["XS", "S", "M", "ML", "L", "XL", "XXL"];
8
8
  exports.PROFILE_SIZES = PROFILE_SIZES;
9
9
  var _default = {
10
10
  XS: {
11
- dimensions: 24,
12
- nameSize: "13px",
13
- emailSize: "12px",
11
+ nameSize: "var(--fontSizes050)",
12
+ emailSize: "var(--fontSizes025)",
14
13
  lineHeight: "12px",
15
14
  marginLeft: "16px",
16
15
  marginTop: "1px"
17
16
  },
18
17
  S: {
19
- dimensions: 32,
20
- nameSize: "14px",
21
- emailsize: "12px",
18
+ nameSize: "var(--fontSizes100)",
19
+ emailSize: "var(--fontSizes100)",
22
20
  lineHeight: "16px",
23
21
  marginLeft: "16px",
24
22
  marginTop: "1px"
25
23
  },
26
24
  M: {
27
- dimensions: 40,
28
- nameSize: "14px",
29
- emailSize: "14px",
25
+ nameSize: "var(--fontSizes100)",
26
+ emailSize: "var(--fontSizes100)",
30
27
  lineHeight: "16px",
31
28
  marginLeft: "16px",
32
29
  marginTop: "4px"
33
30
  },
34
31
  ML: {
35
- dimensions: 56,
36
- nameSize: "14px",
37
- emailSize: "14px",
32
+ nameSize: "var(--fontSizes200)",
33
+ emailSize: "var(--fontSizes100)",
38
34
  lineHeight: "20px",
39
35
  marginLeft: "24px",
40
36
  marginTop: "8px"
41
37
  },
42
38
  L: {
43
- dimensions: 72,
44
- nameSize: "20px",
45
- emailSize: "14px",
39
+ nameSize: "var(--fontSizes400)",
40
+ emailSize: "var(--fontSizes100)",
46
41
  lineHeight: "22px",
47
42
  marginLeft: "24px",
48
43
  marginTop: "14px"
49
44
  },
50
45
  XL: {
51
- dimensions: 104,
52
- nameSize: "24px",
53
- emailSize: "20px",
46
+ nameSize: "var(--fontSizes600)",
47
+ emailSize: "var(--fontSizes300)",
54
48
  lineHeight: "26px",
55
49
  marginLeft: "32px",
56
50
  marginTop: "24px"
57
51
  },
58
52
  XXL: {
59
- dimensions: 128,
60
- nameSize: "32px",
61
- emailSize: "24px",
53
+ nameSize: "var(--fontSizes700)",
54
+ emailSize: "var(--fontSizes600)",
62
55
  lineHeight: "30px",
63
56
  marginLeft: "40px",
64
57
  marginTop: "32px"
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ProfileEmailStyle = exports.ProfileAvatarStyle = exports.ProfileDetailsStyle = exports.ProfileNameStyle = exports.ProfileStyle = void 0;
7
7
 
8
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
 
10
10
  var _styledSystem = require("styled-system");
11
11
 
@@ -17,10 +17,6 @@ var _profile = _interopRequireDefault(require("./profile.config"));
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
21
-
22
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
-
24
20
  const ProfileNameStyle = _styledComponents.default.span`
25
21
  font-weight: bold;
26
22
  display: block;
@@ -37,12 +33,7 @@ const ProfileEmailStyle = _styledComponents.default.span`
37
33
  exports.ProfileEmailStyle = ProfileEmailStyle;
38
34
  const ProfileStyle = _styledComponents.default.div`
39
35
  white-space: nowrap;
40
- ${({
41
- theme
42
- }) => (0, _styledComponents.css)`
43
- color: ${theme.text.color};
44
- `};
45
-
36
+ color: var(--colorsUtilityYin090);
46
37
  display: ${({
47
38
  hasSrc
48
39
  }) => hasSrc ? "flex" : ""};
@@ -73,14 +64,11 @@ ProfileStyle.defaultProps = {
73
64
  theme: _base.default
74
65
  };
75
66
  ProfileNameStyle.defaultProps = {
76
- size: "M",
77
- theme: _base.default
67
+ size: "M"
78
68
  };
79
69
  ProfileEmailStyle.defaultProps = {
80
- size: "M",
81
- theme: _base.default
70
+ size: "M"
82
71
  };
83
72
  ProfileDetailsStyle.defaultProps = {
84
- size: "M",
85
- theme: _base.default
73
+ size: "M"
86
74
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.17.0",
3
+ "version": "104.18.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {