@pingux/astro 2.244.1-alpha.0 → 2.245.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.
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { AvatarProps } from '../../types/avatar';
3
+ import { IconProps, IconTypeExtended } from '../../types/icon';
4
+ export interface ItemAvatarProps {
5
+ /** The icon to render inside the avatar. */
6
+ icon?: IconTypeExtended;
7
+ /** Props to spread onto the inner icon. */
8
+ iconProps?: Omit<IconProps, 'title'>;
9
+ /** The accessible name for the inner icon. */
10
+ title?: {
11
+ name: string;
12
+ };
13
+ /** Seeds the avatar color; exact two-tone color-name matches render that color directly. */
14
+ colorId?: string;
15
+ /** Seeds the avatar color when colorId is not provided. */
16
+ avatarDefaultText?: string;
17
+ /** Replaces the icon with these initials. */
18
+ avatarInitials?: string;
19
+ /** Renders the avatar round instead of square. */
20
+ isIconRound?: boolean;
21
+ /** Props to spread onto the avatar; children are managed by the component. */
22
+ avatarProps?: Omit<AvatarProps, 'children'>;
23
+ }
24
+ declare const ItemAvatar: React.ForwardRefExoticComponent<ItemAvatarProps & React.RefAttributes<HTMLImageElement>>;
25
+ export default ItemAvatar;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _ = require("../..");
11
+ var _getAvatarColor = require("./getAvatarColor");
12
+ var _react2 = require("@emotion/react");
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ const ItemAvatar = /*#__PURE__*/(0, _react.forwardRef)(({
15
+ icon,
16
+ iconProps,
17
+ title,
18
+ colorId,
19
+ avatarDefaultText,
20
+ avatarInitials,
21
+ isIconRound,
22
+ avatarProps
23
+ }, ref) => {
24
+ const initials = avatarInitials || undefined;
25
+ const {
26
+ colorName,
27
+ isTwoTone
28
+ } = (0, _getAvatarColor.getAvatarColor)(colorId, avatarDefaultText);
29
+ const {
30
+ sx: consumerSx,
31
+ ...restAvatarProps
32
+ } = avatarProps || {};
33
+ const twoToneSx = isTwoTone ? {
34
+ backgroundColor: `iconWrapper.wrapper.${colorName}`,
35
+ color: `iconWrapper.icon.${colorName}`
36
+ } : undefined;
37
+ const mergedSx = {
38
+ ...twoToneSx,
39
+ ...consumerSx
40
+ };
41
+ return (0, _react2.jsx)(_.Avatar, (0, _extends2.default)({
42
+ ref: ref,
43
+ size: "sm",
44
+ isSquare: !isIconRound,
45
+ defaultText: initials || avatarDefaultText,
46
+ color: colorName,
47
+ sx: mergedSx
48
+ }, restAvatarProps), icon && !initials && (0, _react2.jsx)(_.Icon, (0, _extends2.default)({
49
+ icon: icon,
50
+ size: "sm",
51
+ title: title,
52
+ color: colorName ? `iconWrapper.icon.${colorName}` : undefined
53
+ }, iconProps)));
54
+ });
55
+ ItemAvatar.displayName = 'ItemAvatar';
56
+ var _default = exports.default = ItemAvatar;
@@ -11,32 +11,41 @@ var _interactions = require("@react-aria/interactions");
11
11
  var _ = require("../..");
12
12
  var _hooks = require("../../hooks");
13
13
  var _pendoID = require("../../utils/devUtils/constants/pendoID");
14
+ var _ItemAvatar = _interopRequireDefault(require("./ItemAvatar"));
14
15
  var _react2 = require("@emotion/react");
15
16
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
17
  const LIST_ITEM_ICON = exports.LIST_ITEM_ICON = '-list-item-icon';
17
18
  const displayName = 'ListViewItem';
18
- const ListViewItem = /*#__PURE__*/(0, _react.forwardRef)(({
19
- children,
20
- className,
21
- data,
22
- iconProps,
23
- iconWrapperProps,
24
- isHovered,
25
- isSelected,
26
- linkProps,
27
- onHoverChange,
28
- onHoverEnd,
29
- onHoverStart,
30
- slots,
31
- colorId,
32
- ...others
33
- }, ref) => {
19
+ const ListViewItem = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
20
+ const {
21
+ children,
22
+ className,
23
+ data,
24
+ iconProps,
25
+ // Deprecated: kept so it never leaks onto the DOM; color/colorId/iconProps
26
+ // are still honored below. Warns in development.
27
+ iconWrapperProps,
28
+ isHovered,
29
+ isSelected,
30
+ linkProps,
31
+ onHoverChange,
32
+ onHoverEnd,
33
+ onHoverStart,
34
+ slots,
35
+ colorId,
36
+ avatarProps,
37
+ avatarInitials,
38
+ isIconRound,
39
+ ...others
40
+ } = props;
34
41
  const {
35
42
  icon,
36
43
  image,
37
44
  subtext,
38
- text
45
+ text,
46
+ avatarDefaultText
39
47
  } = data;
48
+ (0, _hooks.usePropWarning)(props, 'iconWrapperProps', 'colorId');
40
49
  const shouldUseDefaultHover = isHovered === undefined;
41
50
  const {
42
51
  hoverProps,
@@ -62,21 +71,21 @@ const ListViewItem = /*#__PURE__*/(0, _react.forwardRef)(({
62
71
  isOnyx
63
72
  }
64
73
  } = (0, _hooks.useGetTheme)();
65
- const renderIcon = icon && (isOnyx ? (0, _react2.jsx)(_.IconWrapper, (0, _extends2.default)({
74
+ const renderIcon = icon && (isOnyx ? (0, _react2.jsx)(_ItemAvatar.default, {
66
75
  icon: icon,
67
- size: "sm",
68
76
  title: {
69
77
  name: `${text}${LIST_ITEM_ICON}`
70
78
  },
71
- isCircle: true,
72
- colorId: colorId || others.id
73
- }, iconWrapperProps, {
79
+ colorId: iconWrapperProps?.color || iconWrapperProps?.colorId || colorId,
80
+ avatarDefaultText: avatarDefaultText,
81
+ avatarInitials: avatarInitials,
82
+ isIconRound: isIconRound,
83
+ avatarProps: avatarProps,
74
84
  iconProps: {
75
- size: 'sm',
76
85
  ...iconProps,
77
86
  ...iconWrapperProps?.iconProps
78
87
  }
79
- })) : (0, _react2.jsx)(_.Box, {
88
+ }) : (0, _react2.jsx)(_.Box, {
80
89
  width: "25px",
81
90
  variant: "listViewItem.iconContainer"
82
91
  }, (0, _react2.jsx)(_.Icon, (0, _extends2.default)({
@@ -101,10 +110,20 @@ const ListViewItem = /*#__PURE__*/(0, _react.forwardRef)(({
101
110
  alt: image.alt,
102
111
  "aria-label": image['aria-label']
103
112
  })));
113
+ const renderNoIconAvatar = isOnyx && !icon && !image && (avatarInitials || avatarDefaultText) && (0, _react2.jsx)(_ItemAvatar.default, {
114
+ title: {
115
+ name: `${text}${LIST_ITEM_ICON}`
116
+ },
117
+ colorId: colorId,
118
+ avatarDefaultText: avatarDefaultText,
119
+ avatarInitials: avatarInitials,
120
+ isIconRound: isIconRound,
121
+ avatarProps: avatarProps
122
+ });
104
123
  const renderData = (0, _react2.jsx)(_.Box, {
105
124
  isRow: true,
106
125
  alignItems: "center"
107
- }, slots?.leftOfData || renderIcon || renderImage, (0, _react2.jsx)(_.Box, {
126
+ }, slots?.leftOfData || renderIcon || renderImage || renderNoIconAvatar, (0, _react2.jsx)(_.Box, {
108
127
  variant: getWrapperVariant()
109
128
  }, text && (0, _react2.jsx)(_.Text, {
110
129
  variant: "listViewItemText"
@@ -0,0 +1,5 @@
1
+ export interface AvatarColor {
2
+ colorName?: string;
3
+ isTwoTone?: boolean;
4
+ }
5
+ export declare const getAvatarColor: (colorId?: string, avatarDefaultText?: string) => AvatarColor;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getAvatarColor = void 0;
8
+ var _twoTone = require("../../styles/themes/next-gen/colors/twoTone");
9
+ var _constants = require("../Avatar/constants");
10
+ var _getColorFromUuid = _interopRequireDefault(require("../Avatar/getColorFromUuid"));
11
+ const getAvatarColor = (colorId, avatarDefaultText) => {
12
+ if (colorId && _twoTone.twotoneColorNames.includes(colorId)) {
13
+ return {
14
+ colorName: colorId,
15
+ isTwoTone: true
16
+ };
17
+ }
18
+ const seed = colorId || avatarDefaultText;
19
+ if (seed) {
20
+ return {
21
+ colorName: (0, _getColorFromUuid.default)(seed, _constants.avatarColors)
22
+ };
23
+ }
24
+ return {
25
+ colorName: undefined
26
+ };
27
+ };
28
+ exports.getAvatarColor = getAvatarColor;
@@ -5,6 +5,19 @@ export declare const SharedItemArgTypes: {
5
5
  type: string;
6
6
  };
7
7
  };
8
+ isIconRound: any;
9
+ avatarInitials: {
10
+ description: string;
11
+ control: {
12
+ type: string;
13
+ };
14
+ };
15
+ avatarProps: {
16
+ description: string;
17
+ control: {
18
+ type: string;
19
+ };
20
+ };
8
21
  data: {
9
22
  description: string;
10
23
  type: {
@@ -14,7 +14,11 @@ const descriptions = {
14
14
  isPanelHeader: 'A boolean that will adapt the styling of ListIteme to be used as the PanelHeader',
15
15
  slots: 'Provides a way to insert markup in specified places.',
16
16
  linkProps: 'When present, provides meta click functionality',
17
- colorId: 'Identifier used to deterministically derive the avatar color when no explicit color is set.'
17
+ colorId: 'When the value exactly matches a two-tone color name (for example cyan or lightBlue), the avatar renders with that color. Any other value falls back to deterministic color interpolation seeded by the value.',
18
+ isIconRound: 'Renders the icon avatar round instead of square. Defaults to false.',
19
+ avatarInitials: 'Initials rendered inside the avatar in place of the icon.',
20
+ avatarProps: 'Props forwarded to the underlying avatar element. children is managed by the component.',
21
+ avatarDefaultText: 'Text used to seed avatar color interpolation when colorId is not provided.'
18
22
  };
19
23
  const SharedItemArgTypes = exports.SharedItemArgTypes = {
20
24
  colorId: {
@@ -23,10 +27,26 @@ const SharedItemArgTypes = exports.SharedItemArgTypes = {
23
27
  type: 'text'
24
28
  }
25
29
  },
30
+ isIconRound: {
31
+ ..._docArgTypes.booleanArg,
32
+ description: descriptions.isIconRound
33
+ },
34
+ avatarInitials: {
35
+ description: descriptions.avatarInitials,
36
+ control: {
37
+ type: 'text'
38
+ }
39
+ },
40
+ avatarProps: {
41
+ description: descriptions.avatarProps,
42
+ control: {
43
+ type: 'object'
44
+ }
45
+ },
26
46
  data: {
27
47
  description: descriptions.data,
28
48
  type: {
29
- summary: '{ icon, image, text, subtext }'
49
+ summary: '{ icon, image, text, subtext, avatarDefaultText }'
30
50
  },
31
51
  control: {
32
52
  type: 'none'
@@ -10,11 +10,14 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _hooks = require("../../hooks");
12
12
  var _index = require("../../index");
13
+ var _ItemAvatar = _interopRequireDefault(require("../ListViewItem/ItemAvatar"));
13
14
  var _react2 = require("@emotion/react");
14
15
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
16
  const PANEL_HEADER_ICON = exports.PANEL_HEADER_ICON = '-panel-header-icon';
16
17
  const PanelHeader = /*#__PURE__*/(0, _react.forwardRef)(({
17
18
  avatarProps,
19
+ avatarInitials,
20
+ isIconRound,
18
21
  children,
19
22
  className,
20
23
  colorId,
@@ -53,26 +56,30 @@ const PanelHeader = /*#__PURE__*/(0, _react.forwardRef)(({
53
56
  }));
54
57
  const renderOnyxIcon = icon && (0, _react2.jsx)(_index.Box, {
55
58
  mr: "md"
56
- }, (0, _react2.jsx)(_index.IconWrapper, (0, _extends2.default)({
59
+ }, (0, _react2.jsx)(_ItemAvatar.default, {
57
60
  icon: icon,
58
- size: "sm",
59
61
  title: {
60
62
  name: `${text}${PANEL_HEADER_ICON}`
61
63
  },
62
- isCircle: true,
63
- colorId: colorId || avatarDefaultText
64
- }, avatarProps, {
65
- iconProps: {
66
- size: 'sm',
67
- ...iconProps
68
- }
69
- })));
70
- const renderAvatar = (0, _react2.jsx)(_index.Avatar, (0, _extends2.default)({
71
- size: "sm",
72
64
  colorId: colorId,
73
- defaultText: avatarDefaultText,
65
+ avatarDefaultText: avatarDefaultText,
66
+ avatarInitials: avatarInitials,
67
+ isIconRound: isIconRound,
68
+ avatarProps: avatarProps,
69
+ iconProps: iconProps
70
+ }));
71
+ const renderAvatar = (0, _react2.jsx)(_index.Box, {
74
72
  mr: "md"
75
- }, avatarProps));
73
+ }, (0, _react2.jsx)(_ItemAvatar.default, {
74
+ title: {
75
+ name: `${text}${PANEL_HEADER_ICON}`
76
+ },
77
+ colorId: colorId,
78
+ avatarDefaultText: avatarDefaultText,
79
+ avatarInitials: avatarInitials,
80
+ isIconRound: isIconRound,
81
+ avatarProps: avatarProps
82
+ }));
76
83
  const renderOnyxImage = !icon && image?.src && (0, _react2.jsx)(_index.Box, {
77
84
  mr: "md"
78
85
  }, (0, _react2.jsx)(_index.Image, {
@@ -25,6 +25,7 @@ export declare const astroBlacklistStory: {
25
25
  Card: string[];
26
26
  ListView: string[];
27
27
  ListViewItem: string[];
28
+ PanelHeader: string[];
28
29
  MaterialSymbolIcon: string[];
29
30
  Modal: string[];
30
31
  };
@@ -30,7 +30,8 @@ const astroBlacklistStory = exports.astroBlacklistStory = {
30
30
  Loader: ['Circular', 'Custom Circular'],
31
31
  Card: ['With Shadow'],
32
32
  ListView: ['Onyx Default Empty State', 'Custom Render Empty State'],
33
- ListViewItem: ['With Expandable Item'],
33
+ ListViewItem: ['With Expandable Item', 'Is Round', 'With Avatar Initials'],
34
+ PanelHeader: ['Is Round', 'With Avatar Initials'],
34
35
  MaterialSymbolIcon: ['Default', 'Sizes', 'Commonly Used'],
35
36
  Modal: ['With Full Page']
36
37
  };
@@ -1,5 +1,6 @@
1
1
  import type { ComponentType, ReactNode } from 'react';
2
2
  import { TestingAttributes } from './shared/test';
3
+ import { AvatarProps } from './avatar';
3
4
  import { BoxProps } from './box';
4
5
  import { ButtonProps } from './button';
5
6
  import { IconProps } from './icon';
@@ -18,6 +19,8 @@ export interface ListViewItemData {
18
19
  };
19
20
  text?: string;
20
21
  subtext?: string;
22
+ /** Seeds the avatar color when `colorId` is not provided (Onyx theme). */
23
+ avatarDefaultText?: string;
21
24
  }
22
25
  export interface ListViewItemSlots {
23
26
  leftOfData?: ReactNode;
@@ -46,6 +49,13 @@ export interface ListViewItemProps extends BoxProps, HoverProps, TestingAttribut
46
49
  linkProps?: ListViewItemLinkProps;
47
50
  /** Deterministically derives the avatar color when no explicit color is set. */
48
51
  colorId?: string;
52
+ /** Props forwarded to the underlying avatar element (Onyx theme);
53
+ * `children` is managed by the component. */
54
+ avatarProps?: Omit<AvatarProps, 'children'>;
55
+ /** Initials rendered inside the avatar in place of the icon (Onyx theme). */
56
+ avatarInitials?: string;
57
+ /** Renders the icon avatar round instead of square (Onyx theme). */
58
+ isIconRound?: boolean;
49
59
  /** Shows a separator border under the item. */
50
60
  hasSeparator?: boolean;
51
61
  children?: ReactNode;
@@ -0,0 +1,48 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import { Avatar, Icon } from '../..';
4
+ import { getAvatarColor } from './getAvatarColor';
5
+ import { jsx as ___EmotionJSX } from "@emotion/react";
6
+ const ItemAvatar = /*#__PURE__*/forwardRef(({
7
+ icon,
8
+ iconProps,
9
+ title,
10
+ colorId,
11
+ avatarDefaultText,
12
+ avatarInitials,
13
+ isIconRound,
14
+ avatarProps
15
+ }, ref) => {
16
+ const initials = avatarInitials || undefined;
17
+ const {
18
+ colorName,
19
+ isTwoTone
20
+ } = getAvatarColor(colorId, avatarDefaultText);
21
+ const {
22
+ sx: consumerSx,
23
+ ...restAvatarProps
24
+ } = avatarProps || {};
25
+ const twoToneSx = isTwoTone ? {
26
+ backgroundColor: `iconWrapper.wrapper.${colorName}`,
27
+ color: `iconWrapper.icon.${colorName}`
28
+ } : undefined;
29
+ const mergedSx = {
30
+ ...twoToneSx,
31
+ ...consumerSx
32
+ };
33
+ return ___EmotionJSX(Avatar, _extends({
34
+ ref: ref,
35
+ size: "sm",
36
+ isSquare: !isIconRound,
37
+ defaultText: initials || avatarDefaultText,
38
+ color: colorName,
39
+ sx: mergedSx
40
+ }, restAvatarProps), icon && !initials && ___EmotionJSX(Icon, _extends({
41
+ icon: icon,
42
+ size: "sm",
43
+ title: title,
44
+ color: colorName ? `iconWrapper.icon.${colorName}` : undefined
45
+ }, iconProps)));
46
+ });
47
+ ItemAvatar.displayName = 'ItemAvatar';
48
+ export default ItemAvatar;
@@ -1,34 +1,43 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
2
  import React, { forwardRef } from 'react';
3
3
  import { useHover } from '@react-aria/interactions';
4
- import { Box, Icon, IconWrapper, Image, Text } from '../..';
5
- import { useGetTheme, useStatusClasses } from '../../hooks';
4
+ import { Box, Icon, Image, Text } from '../..';
5
+ import { useGetTheme, usePropWarning, useStatusClasses } from '../../hooks';
6
6
  import { getPendoID } from '../../utils/devUtils/constants/pendoID';
7
+ import ItemAvatar from './ItemAvatar';
7
8
  import { jsx as ___EmotionJSX } from "@emotion/react";
8
9
  export const LIST_ITEM_ICON = '-list-item-icon';
9
10
  const displayName = 'ListViewItem';
10
- const ListViewItem = /*#__PURE__*/forwardRef(({
11
- children,
12
- className,
13
- data,
14
- iconProps,
15
- iconWrapperProps,
16
- isHovered,
17
- isSelected,
18
- linkProps,
19
- onHoverChange,
20
- onHoverEnd,
21
- onHoverStart,
22
- slots,
23
- colorId,
24
- ...others
25
- }, ref) => {
11
+ const ListViewItem = /*#__PURE__*/forwardRef((props, ref) => {
12
+ const {
13
+ children,
14
+ className,
15
+ data,
16
+ iconProps,
17
+ // Deprecated: kept so it never leaks onto the DOM; color/colorId/iconProps
18
+ // are still honored below. Warns in development.
19
+ iconWrapperProps,
20
+ isHovered,
21
+ isSelected,
22
+ linkProps,
23
+ onHoverChange,
24
+ onHoverEnd,
25
+ onHoverStart,
26
+ slots,
27
+ colorId,
28
+ avatarProps,
29
+ avatarInitials,
30
+ isIconRound,
31
+ ...others
32
+ } = props;
26
33
  const {
27
34
  icon,
28
35
  image,
29
36
  subtext,
30
- text
37
+ text,
38
+ avatarDefaultText
31
39
  } = data;
40
+ usePropWarning(props, 'iconWrapperProps', 'colorId');
32
41
  const shouldUseDefaultHover = isHovered === undefined;
33
42
  const {
34
43
  hoverProps,
@@ -54,21 +63,21 @@ const ListViewItem = /*#__PURE__*/forwardRef(({
54
63
  isOnyx
55
64
  }
56
65
  } = useGetTheme();
57
- const renderIcon = icon && (isOnyx ? ___EmotionJSX(IconWrapper, _extends({
66
+ const renderIcon = icon && (isOnyx ? ___EmotionJSX(ItemAvatar, {
58
67
  icon: icon,
59
- size: "sm",
60
68
  title: {
61
69
  name: `${text}${LIST_ITEM_ICON}`
62
70
  },
63
- isCircle: true,
64
- colorId: colorId || others.id
65
- }, iconWrapperProps, {
71
+ colorId: iconWrapperProps?.color || iconWrapperProps?.colorId || colorId,
72
+ avatarDefaultText: avatarDefaultText,
73
+ avatarInitials: avatarInitials,
74
+ isIconRound: isIconRound,
75
+ avatarProps: avatarProps,
66
76
  iconProps: {
67
- size: 'sm',
68
77
  ...iconProps,
69
78
  ...iconWrapperProps?.iconProps
70
79
  }
71
- })) : ___EmotionJSX(Box, {
80
+ }) : ___EmotionJSX(Box, {
72
81
  width: "25px",
73
82
  variant: "listViewItem.iconContainer"
74
83
  }, ___EmotionJSX(Icon, _extends({
@@ -93,10 +102,20 @@ const ListViewItem = /*#__PURE__*/forwardRef(({
93
102
  alt: image.alt,
94
103
  "aria-label": image['aria-label']
95
104
  })));
105
+ const renderNoIconAvatar = isOnyx && !icon && !image && (avatarInitials || avatarDefaultText) && ___EmotionJSX(ItemAvatar, {
106
+ title: {
107
+ name: `${text}${LIST_ITEM_ICON}`
108
+ },
109
+ colorId: colorId,
110
+ avatarDefaultText: avatarDefaultText,
111
+ avatarInitials: avatarInitials,
112
+ isIconRound: isIconRound,
113
+ avatarProps: avatarProps
114
+ });
96
115
  const renderData = ___EmotionJSX(Box, {
97
116
  isRow: true,
98
117
  alignItems: "center"
99
- }, slots?.leftOfData || renderIcon || renderImage, ___EmotionJSX(Box, {
118
+ }, slots?.leftOfData || renderIcon || renderImage || renderNoIconAvatar, ___EmotionJSX(Box, {
100
119
  variant: getWrapperVariant()
101
120
  }, text && ___EmotionJSX(Text, {
102
121
  variant: "listViewItemText"
@@ -0,0 +1,20 @@
1
+ import { twotoneColorNames } from '../../styles/themes/next-gen/colors/twoTone';
2
+ import { avatarColors } from '../Avatar/constants';
3
+ import getColorFromUUID from '../Avatar/getColorFromUuid';
4
+ export const getAvatarColor = (colorId, avatarDefaultText) => {
5
+ if (colorId && twotoneColorNames.includes(colorId)) {
6
+ return {
7
+ colorName: colorId,
8
+ isTwoTone: true
9
+ };
10
+ }
11
+ const seed = colorId || avatarDefaultText;
12
+ if (seed) {
13
+ return {
14
+ colorName: getColorFromUUID(seed, avatarColors)
15
+ };
16
+ }
17
+ return {
18
+ colorName: undefined
19
+ };
20
+ };
@@ -8,7 +8,11 @@ const descriptions = {
8
8
  isPanelHeader: 'A boolean that will adapt the styling of ListIteme to be used as the PanelHeader',
9
9
  slots: 'Provides a way to insert markup in specified places.',
10
10
  linkProps: 'When present, provides meta click functionality',
11
- colorId: 'Identifier used to deterministically derive the avatar color when no explicit color is set.'
11
+ colorId: 'When the value exactly matches a two-tone color name (for example cyan or lightBlue), the avatar renders with that color. Any other value falls back to deterministic color interpolation seeded by the value.',
12
+ isIconRound: 'Renders the icon avatar round instead of square. Defaults to false.',
13
+ avatarInitials: 'Initials rendered inside the avatar in place of the icon.',
14
+ avatarProps: 'Props forwarded to the underlying avatar element. children is managed by the component.',
15
+ avatarDefaultText: 'Text used to seed avatar color interpolation when colorId is not provided.'
12
16
  };
13
17
  export const SharedItemArgTypes = {
14
18
  colorId: {
@@ -17,10 +21,26 @@ export const SharedItemArgTypes = {
17
21
  type: 'text'
18
22
  }
19
23
  },
24
+ isIconRound: {
25
+ ...booleanArg,
26
+ description: descriptions.isIconRound
27
+ },
28
+ avatarInitials: {
29
+ description: descriptions.avatarInitials,
30
+ control: {
31
+ type: 'text'
32
+ }
33
+ },
34
+ avatarProps: {
35
+ description: descriptions.avatarProps,
36
+ control: {
37
+ type: 'object'
38
+ }
39
+ },
20
40
  data: {
21
41
  description: descriptions.data,
22
42
  type: {
23
- summary: '{ icon, image, text, subtext }'
43
+ summary: '{ icon, image, text, subtext, avatarDefaultText }'
24
44
  },
25
45
  control: {
26
46
  type: 'none'
@@ -3,10 +3,13 @@ import React, { forwardRef } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { useGetTheme } from '../../hooks';
5
5
  import { Avatar, Box, CopyText, Icon, IconWrapper, Image, Text } from '../../index';
6
+ import ItemAvatar from '../ListViewItem/ItemAvatar';
6
7
  import { jsx as ___EmotionJSX } from "@emotion/react";
7
8
  export const PANEL_HEADER_ICON = '-panel-header-icon';
8
9
  const PanelHeader = /*#__PURE__*/forwardRef(({
9
10
  avatarProps,
11
+ avatarInitials,
12
+ isIconRound,
10
13
  children,
11
14
  className,
12
15
  colorId,
@@ -45,26 +48,30 @@ const PanelHeader = /*#__PURE__*/forwardRef(({
45
48
  }));
46
49
  const renderOnyxIcon = icon && ___EmotionJSX(Box, {
47
50
  mr: "md"
48
- }, ___EmotionJSX(IconWrapper, _extends({
51
+ }, ___EmotionJSX(ItemAvatar, {
49
52
  icon: icon,
50
- size: "sm",
51
53
  title: {
52
54
  name: `${text}${PANEL_HEADER_ICON}`
53
55
  },
54
- isCircle: true,
55
- colorId: colorId || avatarDefaultText
56
- }, avatarProps, {
57
- iconProps: {
58
- size: 'sm',
59
- ...iconProps
60
- }
61
- })));
62
- const renderAvatar = ___EmotionJSX(Avatar, _extends({
63
- size: "sm",
64
56
  colorId: colorId,
65
- defaultText: avatarDefaultText,
57
+ avatarDefaultText: avatarDefaultText,
58
+ avatarInitials: avatarInitials,
59
+ isIconRound: isIconRound,
60
+ avatarProps: avatarProps,
61
+ iconProps: iconProps
62
+ }));
63
+ const renderAvatar = ___EmotionJSX(Box, {
66
64
  mr: "md"
67
- }, avatarProps));
65
+ }, ___EmotionJSX(ItemAvatar, {
66
+ title: {
67
+ name: `${text}${PANEL_HEADER_ICON}`
68
+ },
69
+ colorId: colorId,
70
+ avatarDefaultText: avatarDefaultText,
71
+ avatarInitials: avatarInitials,
72
+ isIconRound: isIconRound,
73
+ avatarProps: avatarProps
74
+ }));
68
75
  const renderOnyxImage = !icon && image?.src && ___EmotionJSX(Box, {
69
76
  mr: "md"
70
77
  }, ___EmotionJSX(Image, {
@@ -24,7 +24,8 @@ export const astroBlacklistStory = {
24
24
  Loader: ['Circular', 'Custom Circular'],
25
25
  Card: ['With Shadow'],
26
26
  ListView: ['Onyx Default Empty State', 'Custom Render Empty State'],
27
- ListViewItem: ['With Expandable Item'],
27
+ ListViewItem: ['With Expandable Item', 'Is Round', 'With Avatar Initials'],
28
+ PanelHeader: ['Is Round', 'With Avatar Initials'],
28
29
  MaterialSymbolIcon: ['Default', 'Sizes', 'Commonly Used'],
29
30
  Modal: ['With Full Page']
30
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.244.1-alpha.0",
3
+ "version": "2.245.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",