@cerberus-design/react 0.8.1-next-a0decf7 → 0.8.1-next-97f2c1c

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.
@@ -6,6 +6,7 @@ import { Announcements } from '@dnd-kit/core';
6
6
  import { applyModifiers } from '@dnd-kit/core';
7
7
  import { AutoScrollActivator } from '@dnd-kit/core';
8
8
  import { AutoScrollOptions } from '@dnd-kit/core';
9
+ import { AvatarVariantProps } from '@cerberus/styled-system/recipes';
9
10
  import { ButtonHTMLAttributes } from 'react';
10
11
  import { ButtonVariantProps } from '@cerberus/styled-system/recipes';
11
12
  import { CancelDrop } from '@dnd-kit/core';
@@ -157,6 +158,49 @@ export { AutoScrollActivator }
157
158
 
158
159
  export { AutoScrollOptions }
159
160
 
161
+ /**
162
+ * The Avatar component is used to represent a user or entity. It will show an image if src provided, otherwise it will show the ariaLabel of the ariaLabel. If the ariaLabel is empty, it will show a `defineIcons().avatar` icon.
163
+ * @definition [Avatar docs](https://cerberus.digitalu.design/react/avatar)
164
+ * @example
165
+ * ```tsx
166
+ * <Avatar
167
+ * ariaLabel="Protector Cerberus"
168
+ * src="https://cerberus.digitalu.design/logo.svg"
169
+ * />
170
+ * ```
171
+ */
172
+ declare function Avatar(props: AvatarProps): JSX_2.Element;
173
+ export { Avatar }
174
+ export { Avatar as Avatar_alias_1 }
175
+
176
+ declare type AvatarAsProps = {
177
+ as: ReactNode;
178
+ ariaLabel?: never;
179
+ src?: never;
180
+ width?: never;
181
+ height?: never;
182
+ };
183
+ export { AvatarAsProps }
184
+ export { AvatarAsProps as AvatarAsProps_alias_1 }
185
+
186
+ /**
187
+ * This module contains the Avatar component.
188
+ * @module
189
+ */
190
+ declare type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> & {
191
+ ariaLabel: string;
192
+ as?: never;
193
+ src: string;
194
+ width?: number;
195
+ height?: number;
196
+ };
197
+ export { AvatarImageProps }
198
+ export { AvatarImageProps as AvatarImageProps_alias_1 }
199
+
200
+ declare type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> & AvatarVariantProps) & (AvatarImageProps | AvatarAsProps);
201
+ export { AvatarProps }
202
+ export { AvatarProps as AvatarProps_alias_1 }
203
+
160
204
  declare interface BaseNotificationDescriptionProps extends HTMLAttributes<HTMLParagraphElement> {
161
205
  }
162
206
  export { BaseNotificationDescriptionProps }
@@ -1,9 +1,12 @@
1
- import {
2
- ModalIcon
3
- } from "./chunk-VCR5C6Q3.js";
4
1
  import {
5
2
  Portal
6
3
  } from "./chunk-4CAT3FHV.js";
4
+ import {
5
+ ModalHeading
6
+ } from "./chunk-JB7IQ2BM.js";
7
+ import {
8
+ ModalIcon
9
+ } from "./chunk-VCR5C6Q3.js";
7
10
  import {
8
11
  Modal
9
12
  } from "./chunk-2UFNQM55.js";
@@ -13,9 +16,6 @@ import {
13
16
  import {
14
17
  ModalHeader
15
18
  } from "./chunk-QU7UV5DB.js";
16
- import {
17
- ModalHeading
18
- } from "./chunk-JB7IQ2BM.js";
19
19
  import {
20
20
  Button
21
21
  } from "./chunk-6F34A7NZ.js";
@@ -151,4 +151,4 @@ export {
151
151
  ConfirmModal,
152
152
  useConfirmModal
153
153
  };
154
- //# sourceMappingURL=chunk-GZY6CH7D.js.map
154
+ //# sourceMappingURL=chunk-3JF6LWXF.js.map
@@ -1,9 +1,12 @@
1
- import {
2
- ModalIcon
3
- } from "./chunk-VCR5C6Q3.js";
4
1
  import {
5
2
  Portal
6
3
  } from "./chunk-4CAT3FHV.js";
4
+ import {
5
+ ModalHeading
6
+ } from "./chunk-JB7IQ2BM.js";
7
+ import {
8
+ ModalIcon
9
+ } from "./chunk-VCR5C6Q3.js";
7
10
  import {
8
11
  Input
9
12
  } from "./chunk-53QBTZZF.js";
@@ -19,9 +22,6 @@ import {
19
22
  import {
20
23
  ModalHeader
21
24
  } from "./chunk-QU7UV5DB.js";
22
- import {
23
- ModalHeading
24
- } from "./chunk-JB7IQ2BM.js";
25
25
  import {
26
26
  Button
27
27
  } from "./chunk-6F34A7NZ.js";
@@ -204,4 +204,4 @@ export {
204
204
  PromptModal,
205
205
  usePromptModal
206
206
  };
207
- //# sourceMappingURL=chunk-S6CMAXQF.js.map
207
+ //# sourceMappingURL=chunk-HMYC7CR3.js.map
@@ -1,3 +1,6 @@
1
+ import {
2
+ Portal
3
+ } from "./chunk-4CAT3FHV.js";
1
4
  import {
2
5
  Notification
3
6
  } from "./chunk-EJIMJWPB.js";
@@ -7,9 +10,6 @@ import {
7
10
  import {
8
11
  NotificationHeading
9
12
  } from "./chunk-3C2DJSEE.js";
10
- import {
11
- Portal
12
- } from "./chunk-4CAT3FHV.js";
13
13
  import {
14
14
  Button
15
15
  } from "./chunk-6F34A7NZ.js";
@@ -119,4 +119,4 @@ export {
119
119
  NotificationCenter,
120
120
  useNotificationCenter
121
121
  };
122
- //# sourceMappingURL=chunk-VPWBSZAR.js.map
122
+ //# sourceMappingURL=chunk-OGAH7HBD.js.map
@@ -0,0 +1,84 @@
1
+ import {
2
+ Show
3
+ } from "./chunk-4O4QFF4S.js";
4
+
5
+ // src/components/Avatar.tsx
6
+ import { css, cx } from "@cerberus/styled-system/css";
7
+ import { circle } from "@cerberus/styled-system/patterns";
8
+ import {
9
+ avatar
10
+ } from "@cerberus/styled-system/recipes";
11
+ import { UserFilled } from "@cerberus/icons";
12
+ import { Fragment, jsx } from "react/jsx-runtime";
13
+ function Avatar(props) {
14
+ const { ariaLabel, as, gradient, size, src, width, height, ...nativeProps } = props;
15
+ const initials = (ariaLabel || "").split(" ").map((word) => word[0]).join("").slice(0, 2);
16
+ return /* @__PURE__ */ jsx(
17
+ "div",
18
+ {
19
+ ...nativeProps,
20
+ className: cx(
21
+ nativeProps.className,
22
+ avatar({ gradient, size }),
23
+ circle()
24
+ ),
25
+ children: /* @__PURE__ */ jsx(
26
+ Show,
27
+ {
28
+ when: Boolean(src) || Boolean(as),
29
+ fallback: /* @__PURE__ */ jsx(
30
+ Show,
31
+ {
32
+ when: Boolean(initials),
33
+ fallback: /* @__PURE__ */ jsx(
34
+ UserFilled,
35
+ {
36
+ size: iconSizeMap[size]
37
+ }
38
+ ),
39
+ children: /* @__PURE__ */ jsx(Fragment, { children: initials })
40
+ }
41
+ ),
42
+ children: /* @__PURE__ */ jsx(
43
+ Show,
44
+ {
45
+ when: Boolean(as),
46
+ fallback: /* @__PURE__ */ jsx(
47
+ "img",
48
+ {
49
+ alt: props.ariaLabel,
50
+ className: css({
51
+ h: "full",
52
+ objectFit: "cover",
53
+ w: "full"
54
+ }),
55
+ decoding: "async",
56
+ loading: "lazy",
57
+ src,
58
+ height,
59
+ width
60
+ }
61
+ ),
62
+ children: as
63
+ }
64
+ )
65
+ }
66
+ )
67
+ }
68
+ );
69
+ }
70
+ var iconSizeMap = {
71
+ xs: 16,
72
+ sm: 16,
73
+ md: 20,
74
+ lg: 34,
75
+ xl: 32,
76
+ "2xl": 32,
77
+ "3xl": 32,
78
+ "4xl": 32
79
+ };
80
+
81
+ export {
82
+ Avatar
83
+ };
84
+ //# sourceMappingURL=chunk-ZYXEVTIX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/Avatar.tsx"],"sourcesContent":["import { css, cx } from '@cerberus/styled-system/css'\nimport { circle } from '@cerberus/styled-system/patterns'\nimport {\n avatar,\n type AvatarVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { UserFilled } from '@cerberus/icons'\nimport type { HtmlHTMLAttributes, ReactNode } from 'react'\nimport { Show } from './Show'\n\n/**\n * This module contains the Avatar component.\n * @module\n */\n\nexport type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> & {\n ariaLabel: string\n as?: never\n src: string\n width?: number\n height?: number\n}\nexport type AvatarAsProps = {\n as: ReactNode\n ariaLabel?: never\n src?: never\n width?: never\n height?: never\n}\n\nexport type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &\n AvatarVariantProps) &\n (AvatarImageProps | AvatarAsProps)\n\n/**\n * The Avatar component is used to represent a user or entity. It will show an image if src provided, otherwise it will show the ariaLabel of the ariaLabel. If the ariaLabel is empty, it will show a `defineIcons().avatar` icon.\n * @definition [Avatar docs](https://cerberus.digitalu.design/react/avatar)\n * @example\n * ```tsx\n * <Avatar\n * ariaLabel=\"Protector Cerberus\"\n * src=\"https://cerberus.digitalu.design/logo.svg\"\n * />\n * ```\n */\nexport function Avatar(props: AvatarProps) {\n const { ariaLabel, as, gradient, size, src, width, height, ...nativeProps } =\n props\n const initials = (ariaLabel || '')\n .split(' ')\n .map((word) => word[0])\n .join('')\n .slice(0, 2)\n\n return (\n <div\n {...nativeProps}\n className={cx(\n nativeProps.className,\n avatar({ gradient, size }),\n circle(),\n )}\n >\n <Show\n when={Boolean(src) || Boolean(as)}\n fallback={\n <Show\n when={Boolean(initials)}\n fallback={\n <UserFilled\n size={iconSizeMap[size as keyof typeof iconSizeMap]}\n />\n }\n >\n <>{initials}</>\n </Show>\n }\n >\n <Show\n when={Boolean(as)}\n fallback={\n <img\n alt={props.ariaLabel}\n className={css({\n h: 'full',\n objectFit: 'cover',\n w: 'full',\n })}\n decoding=\"async\"\n loading=\"lazy\"\n src={src}\n height={height}\n width={width}\n />\n }\n >\n {as}\n </Show>\n </Show>\n </div>\n )\n}\n\nconst iconSizeMap = {\n xs: 16,\n sm: 16,\n md: 20,\n lg: 34,\n xl: 32,\n '2xl': 32,\n '3xl': 32,\n '4xl': 32,\n}\n"],"mappings":";;;;;AAAA,SAAS,KAAK,UAAU;AACxB,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,OAEK;AACP,SAAS,kBAAkB;AA+Db,SAKF,UALE;AAxBP,SAAS,OAAO,OAAoB;AACzC,QAAM,EAAE,WAAW,IAAI,UAAU,MAAM,KAAK,OAAO,QAAQ,GAAG,YAAY,IACxE;AACF,QAAM,YAAY,aAAa,IAC5B,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,EACrB,KAAK,EAAE,EACP,MAAM,GAAG,CAAC;AAEb,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,OAAO,EAAE,UAAU,KAAK,CAAC;AAAA,QACzB,OAAO;AAAA,MACT;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,QAAQ,GAAG,KAAK,QAAQ,EAAE;AAAA,UAChC,UACE;AAAA,YAAC;AAAA;AAAA,cACC,MAAM,QAAQ,QAAQ;AAAA,cACtB,UACE;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAM,YAAY,IAAgC;AAAA;AAAA,cACpD;AAAA,cAGF,0CAAG,oBAAS;AAAA;AAAA,UACd;AAAA,UAGF;AAAA,YAAC;AAAA;AAAA,cACC,MAAM,QAAQ,EAAE;AAAA,cAChB,UACE;AAAA,gBAAC;AAAA;AAAA,kBACC,KAAK,MAAM;AAAA,kBACX,WAAW,IAAI;AAAA,oBACb,GAAG;AAAA,oBACH,WAAW;AAAA,oBACX,GAAG;AAAA,kBACL,CAAC;AAAA,kBACD,UAAS;AAAA,kBACT,SAAQ;AAAA,kBACR;AAAA,kBACA;AAAA,kBACA;AAAA;AAAA,cACF;AAAA,cAGD;AAAA;AAAA,UACH;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ Avatar
3
+ } from "../chunk-ZYXEVTIX.js";
4
+ import "../chunk-4O4QFF4S.js";
5
+ export {
6
+ Avatar
7
+ };
8
+ //# sourceMappingURL=Avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  ConfirmModal,
4
4
  useConfirmModal
5
- } from "../chunk-GZY6CH7D.js";
6
- import "../chunk-VCR5C6Q3.js";
5
+ } from "../chunk-3JF6LWXF.js";
7
6
  import "../chunk-4CAT3FHV.js";
7
+ import "../chunk-JB7IQ2BM.js";
8
+ import "../chunk-VCR5C6Q3.js";
8
9
  import "../chunk-2UFNQM55.js";
9
10
  import "../chunk-4M4LCQ43.js";
10
11
  import "../chunk-QU7UV5DB.js";
11
- import "../chunk-JB7IQ2BM.js";
12
12
  import "../chunk-6F34A7NZ.js";
13
13
  import "../chunk-4O4QFF4S.js";
14
14
  import "../chunk-JIZQFTW6.js";
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  NotificationCenter,
4
4
  useNotificationCenter
5
- } from "../chunk-VPWBSZAR.js";
5
+ } from "../chunk-OGAH7HBD.js";
6
+ import "../chunk-4CAT3FHV.js";
6
7
  import "../chunk-EJIMJWPB.js";
7
8
  import "../chunk-HW76XVA3.js";
8
9
  import "../chunk-3C2DJSEE.js";
9
- import "../chunk-4CAT3FHV.js";
10
10
  import "../chunk-6F34A7NZ.js";
11
11
  import "../chunk-4O4QFF4S.js";
12
12
  import "../chunk-JIZQFTW6.js";
@@ -2,15 +2,15 @@
2
2
  import {
3
3
  PromptModal,
4
4
  usePromptModal
5
- } from "../chunk-S6CMAXQF.js";
6
- import "../chunk-VCR5C6Q3.js";
5
+ } from "../chunk-HMYC7CR3.js";
7
6
  import "../chunk-4CAT3FHV.js";
7
+ import "../chunk-JB7IQ2BM.js";
8
+ import "../chunk-VCR5C6Q3.js";
8
9
  import "../chunk-53QBTZZF.js";
9
10
  import "../chunk-2FK7NR7Y.js";
10
11
  import "../chunk-2UFNQM55.js";
11
12
  import "../chunk-4M4LCQ43.js";
12
13
  import "../chunk-QU7UV5DB.js";
13
- import "../chunk-JB7IQ2BM.js";
14
14
  import "../chunk-6F34A7NZ.js";
15
15
  import "../chunk-4O4QFF4S.js";
16
16
  import "../chunk-ZAU4JVLL.js";
@@ -1,11 +1,19 @@
1
+ import {
2
+ ConfirmModal,
3
+ useConfirmModal
4
+ } from "./chunk-3JF6LWXF.js";
1
5
  import {
2
6
  NotificationCenter,
3
7
  useNotificationCenter
4
- } from "./chunk-VPWBSZAR.js";
8
+ } from "./chunk-OGAH7HBD.js";
5
9
  import {
6
10
  PromptModal,
7
11
  usePromptModal
8
- } from "./chunk-S6CMAXQF.js";
12
+ } from "./chunk-HMYC7CR3.js";
13
+ import {
14
+ Table,
15
+ Tr
16
+ } from "./chunk-A5WYZVUR.js";
9
17
  import {
10
18
  Tag
11
19
  } from "./chunk-Z6IWNVPN.js";
@@ -28,9 +36,8 @@ import {
28
36
  Toggle
29
37
  } from "./chunk-ID3XWGLY.js";
30
38
  import {
31
- ConfirmModal,
32
- useConfirmModal
33
- } from "./chunk-GZY6CH7D.js";
39
+ Portal
40
+ } from "./chunk-4CAT3FHV.js";
34
41
  import {
35
42
  Radio
36
43
  } from "./chunk-PH64POOB.js";
@@ -48,9 +55,8 @@ import {
48
55
  TabPanel
49
56
  } from "./chunk-U72VPIZA.js";
50
57
  import {
51
- Table,
52
- Tr
53
- } from "./chunk-A5WYZVUR.js";
58
+ ModalHeading
59
+ } from "./chunk-JB7IQ2BM.js";
54
60
  import {
55
61
  ModalIcon
56
62
  } from "./chunk-VCR5C6Q3.js";
@@ -78,11 +84,18 @@ import {
78
84
  NotificationHeading
79
85
  } from "./chunk-3C2DJSEE.js";
80
86
  import {
81
- Portal
82
- } from "./chunk-4CAT3FHV.js";
87
+ FileStatus,
88
+ processStatus
89
+ } from "./chunk-7NX4RGDB.js";
90
+ import {
91
+ ProgressBar
92
+ } from "./chunk-TYTEREKZ.js";
83
93
  import {
84
94
  FileUploader
85
95
  } from "./chunk-TF3HRELU.js";
96
+ import {
97
+ IconButton
98
+ } from "./chunk-SLHX5K6I.js";
86
99
  import {
87
100
  Input
88
101
  } from "./chunk-53QBTZZF.js";
@@ -98,9 +111,6 @@ import {
98
111
  import {
99
112
  ModalHeader
100
113
  } from "./chunk-QU7UV5DB.js";
101
- import {
102
- ModalHeading
103
- } from "./chunk-JB7IQ2BM.js";
104
114
  import {
105
115
  MODE_KEY,
106
116
  THEME_KEY,
@@ -111,6 +121,9 @@ import {
111
121
  import {
112
122
  useToggle
113
123
  } from "./chunk-QEA6N6TN.js";
124
+ import {
125
+ Avatar
126
+ } from "./chunk-ZYXEVTIX.js";
114
127
  import {
115
128
  Button
116
129
  } from "./chunk-6F34A7NZ.js";
@@ -130,16 +143,6 @@ import {
130
143
  import {
131
144
  Show
132
145
  } from "./chunk-4O4QFF4S.js";
133
- import {
134
- FileStatus,
135
- processStatus
136
- } from "./chunk-7NX4RGDB.js";
137
- import {
138
- ProgressBar
139
- } from "./chunk-TYTEREKZ.js";
140
- import {
141
- IconButton
142
- } from "./chunk-SLHX5K6I.js";
143
146
  import {
144
147
  FieldMessage
145
148
  } from "./chunk-VGHVH2T3.js";
@@ -176,6 +179,7 @@ import {
176
179
  export * from "@dnd-kit/core";
177
180
  export {
178
181
  $cerberusIcons,
182
+ Avatar,
179
183
  Button,
180
184
  Checkbox,
181
185
  ConfirmModal,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/ModalIcon'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Select'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * This module is the entry point for the Cerberus React package.\n * @module\n */\n\n// components\n\nexport * from './components/Avatar'\nexport * from './components/Button'\nexport * from './components/Checkbox'\nexport * from './components/Droppable'\nexport * from './components/FieldMessage'\nexport * from './components/FeatureFlag'\nexport * from './components/FileStatus'\nexport * from './components/FileUploader'\nexport * from './components/IconButton'\nexport * from './components/Input'\nexport * from './components/Label'\nexport * from './components/Modal'\nexport * from './components/ModalHeader'\nexport * from './components/ModalHeading'\nexport * from './components/ModalDescription'\nexport * from './components/ModalIcon'\nexport * from './components/NavMenuTrigger'\nexport * from './components/NavMenuList'\nexport * from './components/NavMenuLink'\nexport * from './components/Notification'\nexport * from './components/NotificationHeading'\nexport * from './components/NotificationDescription'\nexport * from './components/Portal'\nexport * from './components/ProgressBar'\nexport * from './components/Radio'\nexport * from './components/Select'\nexport * from './components/Tab'\nexport * from './components/TabList'\nexport * from './components/TabPanel'\nexport * from './components/Table'\nexport * from './components/Thead'\nexport * from './components/Th'\nexport * from './components/Td'\nexport * from './components/Tbody'\nexport * from './components/Tag'\nexport * from './components/Textarea'\nexport * from './components/Toggle'\nexport * from './components/Show'\n\n// context\n\nexport * from './context/confirm-modal'\nexport * from './context/feature-flags'\nexport * from './context/field'\nexport * from './context/navMenu'\nexport * from './context/notification-center'\nexport * from './context/prompt-modal'\nexport * from './context/tabs'\nexport * from './context/theme'\n\n// hooks\n\nexport * from './hooks/useModal'\nexport * from './hooks/useTheme'\nexport * from './hooks/useToggle'\n\n// aria-helpers\n\nexport * from './aria-helpers/nav-menu.aria'\nexport * from './aria-helpers/tabs.aria'\nexport * from './aria-helpers/trap-focus.aria'\n\n// utils\n\nexport * from './config/defineIcons'\n\n// shared types\n\nexport * from './types'\n\n// 3rd party\n\nexport * from '@dnd-kit/core'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,cAAc;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerberus-design/react",
3
- "version": "0.8.1-next-a0decf7",
3
+ "version": "0.8.1-next-97f2c1c",
4
4
  "description": "The Cerberus Design React component library.",
5
5
  "browserslist": "> 0.25%, not dead",
6
6
  "sideEffects": false,
@@ -25,8 +25,8 @@
25
25
  "react": "^18",
26
26
  "react-dom": "^18",
27
27
  "tsup": "^8.1.0",
28
- "@cerberus-design/configs": "0.0.0",
29
- "@cerberus-design/styled-system": "0.8.1-next-a0decf7"
28
+ "@cerberus-design/styled-system": "0.8.1-next-97f2c1c",
29
+ "@cerberus-design/configs": "0.0.0"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"
@@ -0,0 +1,113 @@
1
+ import { css, cx } from '@cerberus/styled-system/css'
2
+ import { circle } from '@cerberus/styled-system/patterns'
3
+ import {
4
+ avatar,
5
+ type AvatarVariantProps,
6
+ } from '@cerberus/styled-system/recipes'
7
+ import { UserFilled } from '@cerberus/icons'
8
+ import type { HtmlHTMLAttributes, ReactNode } from 'react'
9
+ import { Show } from './Show'
10
+
11
+ /**
12
+ * This module contains the Avatar component.
13
+ * @module
14
+ */
15
+
16
+ export type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> & {
17
+ ariaLabel: string
18
+ as?: never
19
+ src: string
20
+ width?: number
21
+ height?: number
22
+ }
23
+ export type AvatarAsProps = {
24
+ as: ReactNode
25
+ ariaLabel?: never
26
+ src?: never
27
+ width?: never
28
+ height?: never
29
+ }
30
+
31
+ export type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &
32
+ AvatarVariantProps) &
33
+ (AvatarImageProps | AvatarAsProps)
34
+
35
+ /**
36
+ * The Avatar component is used to represent a user or entity. It will show an image if src provided, otherwise it will show the ariaLabel of the ariaLabel. If the ariaLabel is empty, it will show a `defineIcons().avatar` icon.
37
+ * @definition [Avatar docs](https://cerberus.digitalu.design/react/avatar)
38
+ * @example
39
+ * ```tsx
40
+ * <Avatar
41
+ * ariaLabel="Protector Cerberus"
42
+ * src="https://cerberus.digitalu.design/logo.svg"
43
+ * />
44
+ * ```
45
+ */
46
+ export function Avatar(props: AvatarProps) {
47
+ const { ariaLabel, as, gradient, size, src, width, height, ...nativeProps } =
48
+ props
49
+ const initials = (ariaLabel || '')
50
+ .split(' ')
51
+ .map((word) => word[0])
52
+ .join('')
53
+ .slice(0, 2)
54
+
55
+ return (
56
+ <div
57
+ {...nativeProps}
58
+ className={cx(
59
+ nativeProps.className,
60
+ avatar({ gradient, size }),
61
+ circle(),
62
+ )}
63
+ >
64
+ <Show
65
+ when={Boolean(src) || Boolean(as)}
66
+ fallback={
67
+ <Show
68
+ when={Boolean(initials)}
69
+ fallback={
70
+ <UserFilled
71
+ size={iconSizeMap[size as keyof typeof iconSizeMap]}
72
+ />
73
+ }
74
+ >
75
+ <>{initials}</>
76
+ </Show>
77
+ }
78
+ >
79
+ <Show
80
+ when={Boolean(as)}
81
+ fallback={
82
+ <img
83
+ alt={props.ariaLabel}
84
+ className={css({
85
+ h: 'full',
86
+ objectFit: 'cover',
87
+ w: 'full',
88
+ })}
89
+ decoding="async"
90
+ loading="lazy"
91
+ src={src}
92
+ height={height}
93
+ width={width}
94
+ />
95
+ }
96
+ >
97
+ {as}
98
+ </Show>
99
+ </Show>
100
+ </div>
101
+ )
102
+ }
103
+
104
+ const iconSizeMap = {
105
+ xs: 16,
106
+ sm: 16,
107
+ md: 20,
108
+ lg: 34,
109
+ xl: 32,
110
+ '2xl': 32,
111
+ '3xl': 32,
112
+ '4xl': 32,
113
+ }
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  // components
7
7
 
8
+ export * from './components/Avatar'
8
9
  export * from './components/Button'
9
10
  export * from './components/Checkbox'
10
11
  export * from './components/Droppable'