carbon-react 119.9.1 → 119.9.2
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.
|
@@ -3,7 +3,11 @@ import { MarginProps } from "styled-system";
|
|
|
3
3
|
import { IconType } from "../icon";
|
|
4
4
|
export declare type PortraitShapes = "circle" | "square";
|
|
5
5
|
export declare type PortraitSizes = "XS" | "S" | "M" | "ML" | "L" | "XL" | "XXL";
|
|
6
|
-
export interface
|
|
6
|
+
export interface PortraitProps extends MarginProps {
|
|
7
|
+
/** An email address registered with Gravatar. */
|
|
8
|
+
gravatar?: string;
|
|
9
|
+
/** A custom image URL. */
|
|
10
|
+
src?: string;
|
|
7
11
|
/** The size of the Portrait. */
|
|
8
12
|
size?: PortraitSizes;
|
|
9
13
|
/** The `alt` HTML string. */
|
|
@@ -35,16 +39,5 @@ export interface PortraitBaseProps extends MarginProps {
|
|
|
35
39
|
/** Override font color of the Tooltip, provide any color from palette or any valid css color value. */
|
|
36
40
|
tooltipFontColor?: string;
|
|
37
41
|
}
|
|
38
|
-
export interface PortraitWithGravatar extends PortraitBaseProps {
|
|
39
|
-
/** An email address registered with Gravatar. */
|
|
40
|
-
gravatar?: string;
|
|
41
|
-
src?: never;
|
|
42
|
-
}
|
|
43
|
-
export interface PortraitWithSrc extends PortraitBaseProps {
|
|
44
|
-
/** A custom image URL. */
|
|
45
|
-
src?: string;
|
|
46
|
-
gravatar?: never;
|
|
47
|
-
}
|
|
48
|
-
export declare type PortraitProps = PortraitWithGravatar | PortraitWithSrc;
|
|
49
42
|
export declare const Portrait: ({ alt, darkBackground, gravatar, iconType, initials, shape, size, src, onClick, tooltipMessage, tooltipId, tooltipIsVisible, tooltipPosition, tooltipType, tooltipSize, tooltipBgColor, tooltipFontColor, ...rest }: PortraitProps) => React.JSX.Element;
|
|
50
43
|
export default Portrait;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
2
2
|
import React, { useEffect, useState, useContext } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import invariant from "invariant";
|
|
4
5
|
import Tooltip from "../tooltip";
|
|
5
6
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
6
7
|
import PortraitGravatar from "./portrait-gravatar.component";
|
|
@@ -34,6 +35,7 @@ export const Portrait = _ref => {
|
|
|
34
35
|
roundedCornersOptOut
|
|
35
36
|
} = useContext(RoundedCornersOptOutContext);
|
|
36
37
|
const defaultShape = roundedCornersOptOut ? "square" : "circle";
|
|
38
|
+
!!(src && gravatar) ? process.env.NODE_ENV !== "production" ? invariant(false, "The `src` prop cannot be used in conjunction with the `gravatar` prop." + " Please use one or the other.") : invariant(false) : void 0;
|
|
37
39
|
useEffect(() => {
|
|
38
40
|
setExternalError(false);
|
|
39
41
|
}, [gravatar, src]);
|
|
@@ -3,7 +3,11 @@ import { MarginProps } from "styled-system";
|
|
|
3
3
|
import { IconType } from "../icon";
|
|
4
4
|
export declare type PortraitShapes = "circle" | "square";
|
|
5
5
|
export declare type PortraitSizes = "XS" | "S" | "M" | "ML" | "L" | "XL" | "XXL";
|
|
6
|
-
export interface
|
|
6
|
+
export interface PortraitProps extends MarginProps {
|
|
7
|
+
/** An email address registered with Gravatar. */
|
|
8
|
+
gravatar?: string;
|
|
9
|
+
/** A custom image URL. */
|
|
10
|
+
src?: string;
|
|
7
11
|
/** The size of the Portrait. */
|
|
8
12
|
size?: PortraitSizes;
|
|
9
13
|
/** The `alt` HTML string. */
|
|
@@ -35,16 +39,5 @@ export interface PortraitBaseProps extends MarginProps {
|
|
|
35
39
|
/** Override font color of the Tooltip, provide any color from palette or any valid css color value. */
|
|
36
40
|
tooltipFontColor?: string;
|
|
37
41
|
}
|
|
38
|
-
export interface PortraitWithGravatar extends PortraitBaseProps {
|
|
39
|
-
/** An email address registered with Gravatar. */
|
|
40
|
-
gravatar?: string;
|
|
41
|
-
src?: never;
|
|
42
|
-
}
|
|
43
|
-
export interface PortraitWithSrc extends PortraitBaseProps {
|
|
44
|
-
/** A custom image URL. */
|
|
45
|
-
src?: string;
|
|
46
|
-
gravatar?: never;
|
|
47
|
-
}
|
|
48
|
-
export declare type PortraitProps = PortraitWithGravatar | PortraitWithSrc;
|
|
49
42
|
export declare const Portrait: ({ alt, darkBackground, gravatar, iconType, initials, shape, size, src, onClick, tooltipMessage, tooltipId, tooltipIsVisible, tooltipPosition, tooltipType, tooltipSize, tooltipBgColor, tooltipFontColor, ...rest }: PortraitProps) => React.JSX.Element;
|
|
50
43
|
export default Portrait;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.Portrait = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
9
10
|
var _tooltip = _interopRequireDefault(require("../tooltip"));
|
|
10
11
|
var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
|
|
11
12
|
var _portraitGravatar = _interopRequireDefault(require("./portrait-gravatar.component"));
|
|
@@ -43,6 +44,7 @@ const Portrait = _ref => {
|
|
|
43
44
|
roundedCornersOptOut
|
|
44
45
|
} = (0, _react.useContext)(_carbonProvider.NewValidationContext);
|
|
45
46
|
const defaultShape = roundedCornersOptOut ? "square" : "circle";
|
|
47
|
+
!!(src && gravatar) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "The `src` prop cannot be used in conjunction with the `gravatar` prop." + " Please use one or the other.") : (0, _invariant.default)(false) : void 0;
|
|
46
48
|
(0, _react.useEffect)(() => {
|
|
47
49
|
setExternalError(false);
|
|
48
50
|
}, [gravatar, src]);
|