@carbon-labs/react-ui-shell 0.50.0 → 0.52.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.
Files changed (54) hide show
  1. package/README.md +1 -0
  2. package/es/components/Profile.d.ts +68 -0
  3. package/es/components/Profile.js +141 -0
  4. package/es/components/SideNavLinkPopover.d.ts +2 -2
  5. package/es/index.d.ts +7 -6
  6. package/es/index.js +2 -0
  7. package/es/node_modules/@carbon/ibm-products/es/_virtual/_commonjsHelpers.js +12 -0
  8. package/es/node_modules/@carbon/ibm-products/es/_virtual/_rollupPluginBabelHelpers.js +18 -0
  9. package/es/node_modules/@carbon/ibm-products/es/_virtual/index.js +14 -0
  10. package/es/node_modules/@carbon/ibm-products/es/_virtual/index2.js +12 -0
  11. package/es/node_modules/@carbon/ibm-products/es/components/TooltipTrigger/TooltipTrigger.js +63 -0
  12. package/es/node_modules/@carbon/ibm-products/es/components/UserAvatar/UserAvatar.js +170 -0
  13. package/es/node_modules/@carbon/ibm-products/es/components/_Canary/Canary.js +49 -0
  14. package/es/node_modules/@carbon/ibm-products/es/global/js/package-settings.js +245 -0
  15. package/es/node_modules/@carbon/ibm-products/es/global/js/utils/devtools.js +16 -0
  16. package/es/node_modules/@carbon/ibm-products/es/global/js/utils/pconsole.js +35 -0
  17. package/es/node_modules/@carbon/ibm-products/es/global/js/utils/props-helper.js +46 -0
  18. package/es/node_modules/@carbon/ibm-products/es/node_modules/object-assign/index.js +89 -0
  19. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/checkPropTypes.js +95 -0
  20. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/factoryWithThrowingShims.js +64 -0
  21. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/factoryWithTypeCheckers.js +561 -0
  22. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/index.js +32 -0
  23. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/lib/ReactPropTypesSecret.js +18 -0
  24. package/es/node_modules/@carbon/ibm-products/es/node_modules/prop-types/lib/has.js +17 -0
  25. package/es/node_modules/@carbon/ibm-products/es/settings.js +84 -0
  26. package/lib/components/Profile.d.ts +68 -0
  27. package/lib/components/Profile.js +148 -0
  28. package/lib/components/SideNavLinkPopover.d.ts +2 -2
  29. package/lib/index.d.ts +7 -6
  30. package/lib/index.js +2 -0
  31. package/lib/node_modules/@carbon/ibm-products/es/_virtual/_commonjsHelpers.js +14 -0
  32. package/lib/node_modules/@carbon/ibm-products/es/_virtual/_rollupPluginBabelHelpers.js +20 -0
  33. package/lib/node_modules/@carbon/ibm-products/es/_virtual/index.js +19 -0
  34. package/lib/node_modules/@carbon/ibm-products/es/_virtual/index2.js +14 -0
  35. package/lib/node_modules/@carbon/ibm-products/es/components/TooltipTrigger/TooltipTrigger.js +63 -0
  36. package/lib/node_modules/@carbon/ibm-products/es/components/UserAvatar/UserAvatar.js +170 -0
  37. package/lib/node_modules/@carbon/ibm-products/es/components/_Canary/Canary.js +51 -0
  38. package/lib/node_modules/@carbon/ibm-products/es/global/js/package-settings.js +251 -0
  39. package/lib/node_modules/@carbon/ibm-products/es/global/js/utils/devtools.js +20 -0
  40. package/lib/node_modules/@carbon/ibm-products/es/global/js/utils/pconsole.js +45 -0
  41. package/lib/node_modules/@carbon/ibm-products/es/global/js/utils/props-helper.js +48 -0
  42. package/lib/node_modules/@carbon/ibm-products/es/node_modules/object-assign/index.js +91 -0
  43. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/checkPropTypes.js +97 -0
  44. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/factoryWithThrowingShims.js +66 -0
  45. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/factoryWithTypeCheckers.js +563 -0
  46. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/index.js +34 -0
  47. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/lib/ReactPropTypesSecret.js +20 -0
  48. package/lib/node_modules/@carbon/ibm-products/es/node_modules/prop-types/lib/has.js +19 -0
  49. package/lib/node_modules/@carbon/ibm-products/es/settings.js +86 -0
  50. package/package.json +4 -3
  51. package/scss/styles/_header.scss +7 -0
  52. package/scss/styles/_profile.scss +63 -0
  53. package/scss/styles/_side-nav.scss +1 -0
  54. package/scss/ui-shell.scss +1 -0
package/README.md CHANGED
@@ -35,6 +35,7 @@ components are provided by `@carbon-labs/react-ui-shell`:
35
35
  - `HeaderPopoverActions`
36
36
  - `HeaderPopoverButton`
37
37
  - `HeaderPopoverContent`
38
+ - `Profile`
38
39
  - `SideNav`
39
40
  - `SideNavItems`
40
41
  - `SideNavLink`
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import React from 'react';
10
+ interface ProfileProps {
11
+ /**
12
+ * Provide an optional class to be applied to the containing node
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Custom children to be rendered within the popover of the Profile menu
17
+ */
18
+ children?: React.ReactNode;
19
+ /**
20
+ * Provide the Profile's label
21
+ */
22
+ label?: string;
23
+ /**
24
+ * Provide an optional icon to render in Profile.
25
+ */
26
+ renderIcon?: React.ReactNode;
27
+ }
28
+ declare const Profile: React.ForwardRefExoticComponent<ProfileProps & React.RefAttributes<HTMLDivElement>>;
29
+ interface ProfileUserInfoProps {
30
+ /**
31
+ * Provide an optional class to be applied to the containing node
32
+ */
33
+ className?: string;
34
+ /**
35
+ * Provide the user's email
36
+ */
37
+ email?: string;
38
+ /**
39
+ * When passing the name prop, either send the initials to be used or the user's full name. The first two capital letters of the user's name will be used as the name.
40
+ */
41
+ name: string;
42
+ }
43
+ declare const ProfileUserInfo: React.ForwardRefExoticComponent<ProfileUserInfoProps & React.RefAttributes<HTMLDivElement>>;
44
+ interface ProfileReadOnlyItem {
45
+ label: string;
46
+ title: string;
47
+ }
48
+ interface ProfileReadOnlyProps {
49
+ /**
50
+ * Provide an optional class to be applied to the containing node
51
+ */
52
+ className?: string;
53
+ /**
54
+ * List of read-only profile items
55
+ */
56
+ items?: ProfileReadOnlyItem[];
57
+ }
58
+ declare const ProfileReadOnly: React.ForwardRefExoticComponent<ProfileReadOnlyProps & React.RefAttributes<HTMLDivElement>>;
59
+ /**
60
+ * -------
61
+ * Exports
62
+ * -------
63
+ */
64
+ declare const Root: React.ForwardRefExoticComponent<ProfileProps & React.RefAttributes<HTMLDivElement>>;
65
+ declare const UserInfo: React.ForwardRefExoticComponent<ProfileUserInfoProps & React.RefAttributes<HTMLDivElement>>;
66
+ declare const ReadOnly: React.ForwardRefExoticComponent<ProfileReadOnlyProps & React.RefAttributes<HTMLDivElement>>;
67
+ export { Profile, ProfileUserInfo, ProfileReadOnly, Root, UserInfo, ReadOnly, };
68
+ export type { ProfileProps, ProfileUserInfoProps };
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js';
9
+ import cx from '../_virtual/index.js';
10
+ import PropTypes from 'prop-types';
11
+ import React from 'react';
12
+ import { usePrefix } from '../internal/usePrefix.js';
13
+ import { HeaderPopover, HeaderPopoverButton, HeaderPopoverContent } from './HeaderPopover.js';
14
+ import { UserAvatar } from '../node_modules/@carbon/ibm-products/es/components/UserAvatar/UserAvatar.js';
15
+
16
+ const Profile = /*#__PURE__*/React.forwardRef(function Profile(_ref) {
17
+ let {
18
+ className: customClassName,
19
+ label,
20
+ children,
21
+ renderIcon: IconElement
22
+ } = _ref;
23
+ const prefix = usePrefix();
24
+ const className = cx({
25
+ [`${prefix}-profile`]: true,
26
+ [customClassName]: !!customClassName
27
+ });
28
+ return /*#__PURE__*/React.createElement(HeaderPopover, {
29
+ align: "bottom-right",
30
+ className: className
31
+ }, /*#__PURE__*/React.createElement(HeaderPopoverButton, {
32
+ align: "bottom",
33
+ label: label
34
+ }, IconElement), /*#__PURE__*/React.createElement(HeaderPopoverContent, null, children));
35
+ });
36
+ Profile.displayName = 'Profile';
37
+ Profile.propTypes = {
38
+ /**
39
+ * Custom children to be rendered within the popover of the Profile menu
40
+ */
41
+ children: PropTypes.any,
42
+ /**
43
+ * Provide an optional class to be applied to the containing node
44
+ */
45
+ className: PropTypes.string,
46
+ /**
47
+ * Provide the Profile's label
48
+ */
49
+ label: PropTypes.string,
50
+ /**
51
+ * Provide an optional icon to render in Profile.
52
+ */
53
+ // @ts-expect-error - PropTypes are unable to cover this case.
54
+ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
55
+ };
56
+ const ProfileUserInfo = /*#__PURE__*/React.forwardRef(function ProfileUserInfo(_ref2) {
57
+ let {
58
+ className: customClassName,
59
+ name,
60
+ email,
61
+ ...rest
62
+ } = _ref2;
63
+ const prefix = usePrefix();
64
+ const className = cx({
65
+ [`${prefix}--profile-user-info`]: true,
66
+ [customClassName]: !!customClassName
67
+ });
68
+ return /*#__PURE__*/React.createElement("div", {
69
+ className: className
70
+ }, /*#__PURE__*/React.createElement(UserAvatar, _extends({
71
+ size: "lg",
72
+ name: name
73
+ }, rest)), /*#__PURE__*/React.createElement("div", {
74
+ className: `${prefix}--profile-user-info__text-wrapper`
75
+ }, /*#__PURE__*/React.createElement("div", {
76
+ className: `${prefix}--profile-user-info__name`
77
+ }, name), /*#__PURE__*/React.createElement("div", {
78
+ className: `${prefix}--profile-user-info__email`
79
+ }, email)));
80
+ });
81
+ ProfileUserInfo.displayName = 'ProfileUserInfo';
82
+ ProfileUserInfo.propTypes = {
83
+ /**
84
+ * Provide an optional class to be applied to the containing node
85
+ */
86
+ className: PropTypes.string,
87
+ /**
88
+ * Provide the user's email
89
+ */
90
+ email: PropTypes.string,
91
+ /**
92
+ * When passing the name prop, either send the initials to be used or the user's full name. The first two capital letters of the user's name will be used as the name.
93
+ */
94
+ name: PropTypes.string.isRequired
95
+ };
96
+ const ProfileReadOnly = /*#__PURE__*/React.forwardRef(function ProfileReadOnly(_ref3) {
97
+ let {
98
+ className: customClassName,
99
+ items
100
+ } = _ref3;
101
+ const prefix = usePrefix();
102
+ const className = cx({
103
+ [`${prefix}--profile-read-only`]: true,
104
+ [customClassName]: !!customClassName
105
+ });
106
+ return /*#__PURE__*/React.createElement("div", {
107
+ className: className
108
+ }, items?.map((item, index) => /*#__PURE__*/React.createElement("div", {
109
+ className: `${prefix}--profile-read-only__items`,
110
+ key: index
111
+ }, /*#__PURE__*/React.createElement("div", {
112
+ className: `${prefix}--profile-read-only__label`
113
+ }, item.label), /*#__PURE__*/React.createElement("div", {
114
+ className: `${prefix}--profile-read-only__title`
115
+ }, item.title))));
116
+ });
117
+ ProfileReadOnly.displayName = 'ProfileReadOnly';
118
+ ProfileReadOnly.propTypes = {
119
+ /**
120
+ * Provide an optional class to be applied to the containing node
121
+ */
122
+ className: PropTypes.string,
123
+ /**
124
+ * List of read-only profile items
125
+ */
126
+ items: PropTypes.array
127
+ };
128
+
129
+ /**
130
+ * -------
131
+ * Exports
132
+ * -------
133
+ */
134
+ const Root = Profile;
135
+ Root.displayName = 'Profile.Root';
136
+ const UserInfo = ProfileUserInfo;
137
+ UserInfo.displayName = 'ProfileUserInfo';
138
+ const ReadOnly = ProfileReadOnly;
139
+ ReadOnly.displayName = 'ProfileReadOnly';
140
+
141
+ export { Profile, ProfileReadOnly, ProfileUserInfo, ReadOnly, Root, UserInfo };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -62,7 +62,7 @@ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
62
62
  /**
63
63
  * Specify the size of the Button. Defaults to `md`.
64
64
  */
65
- size?: ButtonSize;
65
+ size?: Extract<ButtonSize, 'sm' | 'md' | 'lg'>;
66
66
  /**
67
67
  * Specify an optional className to be added to your Tooltip wrapper
68
68
  */
package/es/index.d.ts CHANGED
@@ -6,16 +6,17 @@
6
6
  * This source code is licensed under the Apache-2.0 license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
- export { SideNav, SIDE_NAV_TYPE } from './components/SideNav.js';
10
- export { SideNavItems } from './components/SideNavItems.js';
11
- export { SideNavLink } from './components/SideNavLink.js';
12
- export { SideNavLinkPopover } from './components/SideNavLinkPopover.js';
13
- export { SideNavMenu } from './components/SideNavMenu.js';
14
- export { SideNavMenuItem } from './components/SideNavMenuItem.js';
9
+ export { SideNav, SIDE_NAV_TYPE } from './components/SideNav';
10
+ export { SideNavItems } from './components/SideNavItems';
11
+ export { SideNavLink } from './components/SideNavLink';
12
+ export { SideNavLinkPopover } from './components/SideNavLinkPopover';
13
+ export { SideNavMenu } from './components/SideNavMenu';
14
+ export { SideNavMenuItem } from './components/SideNavMenuItem';
15
15
  export { HeaderContainer } from './components/HeaderContainer';
16
16
  export { HeaderPopover, HeaderPopoverActions, HeaderPopoverButton, HeaderPopoverContent, } from './components/HeaderPopover';
17
17
  export { HeaderPanel } from './components/HeaderPanel';
18
18
  export { SharkFinIcon } from './components/SharkFinIcon';
19
19
  export { HeaderDivider } from './components/HeaderDivider';
20
20
  export { TrialCountdown } from './components/TrialCountdown';
21
+ export * as Profile from './components/Profile';
21
22
  export { SideNavSlot } from './components/SideNavSlot';
package/es/index.js CHANGED
@@ -17,4 +17,6 @@ export { HeaderPanel } from './components/HeaderPanel.js';
17
17
  export { SharkFinIcon } from './components/SharkFinIcon.js';
18
18
  export { HeaderDivider } from './components/HeaderDivider.js';
19
19
  export { TrialCountdown } from './components/TrialCountdown.js';
20
+ import * as Profile from './components/Profile.js';
21
+ export { Profile };
20
22
  export { SideNavSlot } from './components/SideNavSlot.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ function getDefaultExportFromCjs(x) {
9
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
10
+ }
11
+
12
+ export { getDefaultExportFromCjs };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ function _extends() {
9
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
10
+ for (var e = 1; e < arguments.length; e++) {
11
+ var t = arguments[e];
12
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
13
+ }
14
+ return n;
15
+ }, _extends.apply(null, arguments);
16
+ }
17
+
18
+ export { _extends as extends };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
9
+ import { __require as requirePropTypes } from '../node_modules/prop-types/index.js';
10
+
11
+ var propTypesExports = /*@__PURE__*/requirePropTypes();
12
+ var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
13
+
14
+ export { PropTypes as default, propTypesExports as p };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ var propTypes = {
9
+ exports: {}
10
+ };
11
+
12
+ export { propTypes as __module };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React from 'react';
10
+ import PropTypes from '../../_virtual/index.js';
11
+ import cx from '../../../../../../_virtual/index.js';
12
+ import { pkg } from '../../settings.js';
13
+
14
+ // The block part of our conventional BEM class names (blockClass__E--M).
15
+ const blockClass = `${pkg.prefix}--tooltip-trigger`;
16
+ const componentName = 'TooltipTrigger';
17
+
18
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
19
+
20
+ /**
21
+ * This is an tooltip trigger as Carbon Tooltip requires an active element to work but provides
22
+ * no blanked button.
23
+ */
24
+ let TooltipTrigger = /*#__PURE__*/React.forwardRef((_ref, ref) => {
25
+ let {
26
+ children,
27
+ className,
28
+ // Collect any other property values passed in.
29
+ ...rest
30
+ } = _ref;
31
+ return /*#__PURE__*/React.createElement("button", _extends({
32
+ type: "button",
33
+ ref: ref
34
+ }, rest, {
35
+ className: cx(blockClass,
36
+ // Apply the block class to the main HTML element
37
+ className // Apply any supplied class names to the main HTML element.
38
+ )
39
+ }), children);
40
+ });
41
+
42
+ // Return a placeholder if not released and not enabled by feature flag.
43
+ TooltipTrigger = pkg.checkComponentEnabled(TooltipTrigger, componentName);
44
+
45
+ // The display name of the component, used by React. Note that displayName
46
+ // is used in preference to relying on function.name.
47
+ TooltipTrigger.displayName = componentName;
48
+
49
+ // The types and DocGen commentary for the component props,
50
+ // in alphabetical order (for consistency).
51
+ // See https://www.npmjs.com/package/prop-types#usage.
52
+ TooltipTrigger.propTypes = {
53
+ /**
54
+ * Child content of tooltip trigger
55
+ */
56
+ children: PropTypes.node,
57
+ /**
58
+ * Provide an optional class to be applied to the containing node.
59
+ */
60
+ className: PropTypes.string
61
+ };
62
+
63
+ export { TooltipTrigger };
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React from 'react';
10
+ import PropTypes from '../../_virtual/index.js';
11
+ import cx from '../../../../../../_virtual/index.js';
12
+ import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
13
+ import { pkg } from '../../settings.js';
14
+ import { usePrefix, Tooltip } from '@carbon/react';
15
+ import { User } from '@carbon/react/icons';
16
+ import '../../global/js/utils/props-helper.js';
17
+ import { TooltipTrigger } from '../TooltipTrigger/TooltipTrigger.js';
18
+
19
+ // Carbon and package components we use.
20
+ /* TODO: @import(s) of carbon components and other package components. */
21
+
22
+ // The block part of our conventional BEM class names (blockClass__E--M).
23
+ const blockClass = `${pkg.prefix}--user-avatar`;
24
+ const componentName = 'UserAvatar';
25
+
26
+ // NOTE: the component SCSS is not imported here: it is rolled up separately.
27
+
28
+ /**
29
+ * TODO: A description of the component.
30
+ */
31
+
32
+ let UserAvatar = /*#__PURE__*/React.forwardRef((_ref, ref) => {
33
+ let {
34
+ // The component props, in alphabetical order (for consistency).
35
+ backgroundColor = 'order-1-cyan',
36
+ className,
37
+ image,
38
+ imageDescription,
39
+ name,
40
+ /* TODO: add other props for UserAvatar, with default values if needed */
41
+ renderIcon: RenderIcon,
42
+ size = 'md',
43
+ tooltipText,
44
+ tooltipAlignment = 'bottom',
45
+ // Collect any other property values passed in.
46
+ ...rest
47
+ } = _ref;
48
+ const carbonPrefix = usePrefix();
49
+ const iconSize = {
50
+ sm: 16,
51
+ md: 20,
52
+ lg: 24,
53
+ xl: 32
54
+ };
55
+ const formatInitials = () => {
56
+ const parts = name?.split(' ') || [];
57
+ const firstChar = parts[0].charAt(0).toUpperCase();
58
+ const secondChar = parts[0].charAt(1).toUpperCase();
59
+ if (parts.length === 1) {
60
+ return firstChar + secondChar;
61
+ }
62
+ const lastChar = parts[parts.length - 1].charAt(0).toUpperCase();
63
+ const initials = [firstChar];
64
+ if (lastChar) {
65
+ initials.push(lastChar);
66
+ }
67
+ return ''.concat(...initials);
68
+ };
69
+ const getItem = () => {
70
+ const iconProps = {
71
+ size: iconSize[size]
72
+ };
73
+ if (image) {
74
+ return /*#__PURE__*/React.createElement("img", {
75
+ alt: imageDescription,
76
+ src: image,
77
+ className: `${blockClass}__photo ${blockClass}__photo--${size}`
78
+ });
79
+ }
80
+ if (RenderIcon) {
81
+ return /*#__PURE__*/React.createElement(RenderIcon, iconProps);
82
+ }
83
+ if (name) {
84
+ return formatInitials();
85
+ }
86
+ return /*#__PURE__*/React.createElement(User, iconProps);
87
+ };
88
+ const Avatar = () => /*#__PURE__*/React.createElement("div", _extends({}, rest, {
89
+ className: cx(blockClass,
90
+ // Apply the block class to the main HTML element
91
+ className,
92
+ // Apply any supplied class names to the main HTML element.
93
+ `${blockClass}--${backgroundColor}`, `${blockClass}--${size}`,
94
+ // example: `${blockClass}__template-string-class-${kind}-n-${size}`,
95
+ {
96
+ // switched classes dependant on props or state
97
+ // example: [`${blockClass}__here-if-small`]: size === 'sm',
98
+ }),
99
+ ref: ref
100
+ }, getDevtoolsProps(componentName)), getItem());
101
+ if (tooltipText) {
102
+ return /*#__PURE__*/React.createElement(Tooltip, {
103
+ align: tooltipAlignment,
104
+ label: tooltipText,
105
+ className: `${blockClass}__tooltip ${carbonPrefix}--icon-tooltip`
106
+ }, /*#__PURE__*/React.createElement(TooltipTrigger, null, /*#__PURE__*/React.createElement(Avatar, null)));
107
+ }
108
+ return /*#__PURE__*/React.createElement(Avatar, null);
109
+ });
110
+
111
+ // Return a placeholder if not released and not enabled by feature flag
112
+ UserAvatar = pkg.checkComponentEnabled(UserAvatar, componentName);
113
+
114
+ // The display name of the component, used by React. Note that displayName
115
+ // is used in preference to relying on function.name.
116
+ UserAvatar.displayName = componentName;
117
+
118
+ // The types and DocGen commentary for the component props,
119
+ // in alphabetical order (for consistency).
120
+ // See https://www.npmjs.com/package/prop-types#usage.
121
+ UserAvatar.propTypes = {
122
+ /**
123
+ * Provide the background color need to be set for UserAvatar. Background color will be set based on lighter or darker theme.
124
+ * For example: if you select order-5-purple, it will take $purple-60 for lighter theme and $purple-50 for darker theme.
125
+ */
126
+ backgroundColor: PropTypes.oneOf(['order-1-cyan', 'order-2-gray', 'order-3-green', 'order-4-magenta', 'order-5-purple', 'order-6-teal', 'order-7-cyan', 'order-8-gray', 'order-9-green', 'order-10-magenta', 'order-11-purple', 'order-12-teal']),
127
+ /**
128
+ * Provide an optional class to be applied to the containing node.
129
+ */
130
+ className: PropTypes.string,
131
+ /**
132
+ * When passing the image prop, supply a full path to the image to be displayed.
133
+ */
134
+ /**@ts-ignore */
135
+ image: PropTypes.string,
136
+ /**
137
+ * When passing the image prop use the imageDescription prop to describe the image for screen reader.
138
+ */
139
+ /**@ts-ignore */
140
+ imageDescription: PropTypes.string.isRequired.if(_ref2 => {
141
+ let {
142
+ image
143
+ } = _ref2;
144
+ return !!image;
145
+ }),
146
+ /**
147
+ * When passing the name prop, either send the initials to be used or the user's full name. The first two capital letters of the user's name will be used as the name.
148
+ */
149
+ name: PropTypes.string,
150
+ /**
151
+ * Provide a custom icon to use if you need to use an icon other than the default one
152
+ */
153
+ /**@ts-ignore */
154
+ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.string]),
155
+ /**
156
+ * Set the size of the avatar circle
157
+ */
158
+ size: PropTypes.oneOf(['xl', 'lg', 'md', 'sm']),
159
+ /**
160
+ * Specify how the trigger should align with the tooltip
161
+ */
162
+ tooltipAlignment: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
163
+ /**
164
+ * Pass in the display name to have it shown on hover
165
+ */
166
+ tooltipText: PropTypes.string
167
+ /* TODO: add types and DocGen for all props. */
168
+ };
169
+
170
+ export { UserAvatar };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright IBM Corp. 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React from 'react';
10
+ import PropTypes from '../../_virtual/index.js';
11
+ import cx from '../../../../../../_virtual/index.js';
12
+ import pkg from '../../global/js/package-settings.js';
13
+ import { CodeSnippet } from '@carbon/react';
14
+
15
+ var _p, _br, _p2, _br2, _p3;
16
+
17
+ // The block part of our conventional BEM class names (blockClass__E--M).
18
+ const blockClass = `${pkg.prefix}--canary`;
19
+
20
+ /**
21
+ * Canary component used when the component requested is not yet production
22
+ */
23
+ const Canary = (_ref /*, originalArgs*/) => {
24
+ let {
25
+ className,
26
+ componentName,
27
+ ...rest
28
+ } = _ref;
29
+ const instructions = `
30
+ import { pkg } from '@carbon/ibm-products';
31
+ // NOTE: must happen before component is first used
32
+ pkg.component.${componentName} = true;
33
+ `;
34
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
35
+ className: cx(blockClass, className)
36
+ }), /*#__PURE__*/React.createElement("h2", null, "This component ", /*#__PURE__*/React.createElement("strong", null, componentName), " is not ready yet."), _p || (_p = /*#__PURE__*/React.createElement("p", null, "To enable it, initialize package flags before the component is first used.")), _br || (_br = /*#__PURE__*/React.createElement("br", null)), _p2 || (_p2 = /*#__PURE__*/React.createElement("p", null, "e.g. in main.js")), /*#__PURE__*/React.createElement(CodeSnippet, {
37
+ type: "multi"
38
+ }, instructions), _br2 || (_br2 = /*#__PURE__*/React.createElement("br", null)), _p3 || (_p3 = /*#__PURE__*/React.createElement("p", null, "View a live example on", ' ', /*#__PURE__*/React.createElement("a", {
39
+ href: "https://codesandbox.io/s/example-component-olif5?file=/src/config.js"
40
+ }, "codesandbox"), ".")));
41
+ };
42
+ Canary.propTypes = {
43
+ /** Provide an optional class to be applied to the containing node */
44
+ className: PropTypes.string,
45
+ /** Name of the component that is not ready yet */
46
+ componentName: PropTypes.string.isRequired
47
+ };
48
+
49
+ export { Canary };