facehash 0.0.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.
package/README.md ADDED
@@ -0,0 +1,329 @@
1
+ # facehash
2
+
3
+ Deterministic avatar faces from any string. Zero dependencies, unstyled, React 18/19 compatible.
4
+
5
+ Following the [shadcn/ui](https://ui.shadcn.com/) philosophy: **unstyled, composable, and yours to customize**.
6
+
7
+ <p align="center">
8
+ <img src="https://cossistant.com/facehash-preview.png" alt="facehash examples" width="600" />
9
+ </p>
10
+
11
+ ## Features
12
+
13
+ - **Deterministic** - Same string always generates the same face
14
+ - **Unstyled** - Zero CSS included, bring your own Tailwind/CSS
15
+ - **Composable** - Use standalone or as part of Avatar compound component
16
+ - **Dark mode ready** - Built-in light/dark color palette support
17
+ - **Accessible** - Proper ARIA attributes included
18
+ - **Tiny** - Zero dependencies (React is a peer dep)
19
+ - **TypeScript** - Full type safety
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install facehash
25
+ # or
26
+ pnpm add facehash
27
+ # or
28
+ bun add facehash
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ### Standalone FacehashAvatar
34
+
35
+ The simplest way to get started - just a fun face!
36
+
37
+ ```tsx
38
+ import { FacehashAvatar } from "facehash";
39
+
40
+ function App() {
41
+ return (
42
+ <FacehashAvatar
43
+ name="John Doe"
44
+ className="w-10 h-10 rounded-full"
45
+ />
46
+ );
47
+ }
48
+ ```
49
+
50
+ ### With Avatar Compound Component
51
+
52
+ For image avatars with FacehashAvatar as fallback:
53
+
54
+ ```tsx
55
+ import { Avatar, AvatarImage, AvatarFallback } from "facehash";
56
+
57
+ function UserAvatar({ user }) {
58
+ return (
59
+ <Avatar className="w-10 h-10 rounded-full overflow-hidden">
60
+ <AvatarImage src={user.avatarUrl} alt={user.name} />
61
+ <AvatarFallback name={user.name} facehash />
62
+ </Avatar>
63
+ );
64
+ }
65
+ ```
66
+
67
+ ## Usage Examples
68
+
69
+ ### Basic Styling with Tailwind
70
+
71
+ ```tsx
72
+ <FacehashAvatar
73
+ name="Jane Smith"
74
+ className="w-12 h-12 rounded-xl bg-gray-100 dark:bg-gray-800"
75
+ />
76
+ ```
77
+
78
+ ### Custom Color Palette
79
+
80
+ ```tsx
81
+ <FacehashAvatar
82
+ name="Alex Johnson"
83
+ colors={["#264653", "#2a9d8f", "#e9c46a", "#f4a261", "#e76f51"]}
84
+ className="w-16 h-16 rounded-full"
85
+ />
86
+ ```
87
+
88
+ ### Light/Dark Mode Colors
89
+
90
+ ```tsx
91
+ <FacehashAvatar
92
+ name="Sam Wilson"
93
+ colorsLight={["#fce7f3", "#fef3c7", "#dbeafe"]}
94
+ colorsDark={["#db2777", "#d97706", "#2563eb"]}
95
+ colorScheme="auto" // Uses CSS prefers-color-scheme
96
+ className="w-10 h-10 rounded-full"
97
+ />
98
+ ```
99
+
100
+ ### Without 3D Effect
101
+
102
+ ```tsx
103
+ <FacehashAvatar
104
+ name="Chris Brown"
105
+ enable3D={false}
106
+ className="w-10 h-10 rounded-lg"
107
+ />
108
+ ```
109
+
110
+ ### Without Initial Letter
111
+
112
+ ```tsx
113
+ <FacehashAvatar
114
+ name="Taylor Swift"
115
+ showInitial={false}
116
+ className="w-10 h-10 rounded-full"
117
+ />
118
+ ```
119
+
120
+ ### Avatar with Initials Fallback
121
+
122
+ ```tsx
123
+ <Avatar className="w-10 h-10 rounded-full bg-gray-200">
124
+ <AvatarImage src="/photo.jpg" alt="User" />
125
+ <AvatarFallback name="John Doe" className="text-sm font-medium" />
126
+ </Avatar>
127
+ ```
128
+
129
+ ### Avatar with Custom Fallback
130
+
131
+ ```tsx
132
+ import { User } from "lucide-react";
133
+
134
+ <Avatar className="w-10 h-10 rounded-full bg-gray-200">
135
+ <AvatarImage src="/photo.jpg" alt="User" />
136
+ <AvatarFallback>
137
+ <User className="w-5 h-5 text-gray-500" />
138
+ </AvatarFallback>
139
+ </Avatar>
140
+ ```
141
+
142
+ ### Delayed Fallback (Prevent Flash)
143
+
144
+ ```tsx
145
+ <Avatar className="w-10 h-10 rounded-full">
146
+ <AvatarImage src="/slow-loading-image.jpg" />
147
+ <AvatarFallback name="John" facehash delayMs={600} />
148
+ </Avatar>
149
+ ```
150
+
151
+ ## Styling with CSS
152
+
153
+ ### Using CSS Variables (Dark Mode)
154
+
155
+ When using `colorScheme="auto"`, the component sets CSS custom properties:
156
+
157
+ ```css
158
+ /* Apply the background based on color scheme */
159
+ [data-facehash-avatar][data-color-scheme="auto"] {
160
+ background-color: var(--facehash-avatar-bg-light);
161
+ }
162
+
163
+ @media (prefers-color-scheme: dark) {
164
+ [data-facehash-avatar][data-color-scheme="auto"] {
165
+ background-color: var(--facehash-avatar-bg-dark);
166
+ }
167
+ }
168
+ ```
169
+
170
+ ### Using Data Attributes
171
+
172
+ All components expose data attributes for styling:
173
+
174
+ ```css
175
+ /* Root avatar */
176
+ [data-avatar] { }
177
+ [data-avatar][data-state="loading"] { }
178
+ [data-avatar][data-state="loaded"] { }
179
+ [data-avatar][data-state="error"] { }
180
+
181
+ /* Facehash avatar */
182
+ [data-facehash-avatar] { }
183
+ [data-facehash-avatar-face] { }
184
+ [data-facehash-avatar-initial] { }
185
+
186
+ /* Image and fallback */
187
+ [data-avatar-image] { }
188
+ [data-avatar-fallback] { }
189
+ ```
190
+
191
+ ## API Reference
192
+
193
+ ### FacehashAvatar
194
+
195
+ | Prop | Type | Default | Description |
196
+ |------|------|---------|-------------|
197
+ | `name` | `string` | Required | Name used to generate deterministic avatar |
198
+ | `colors` | `string[]` | Tailwind colors | Base color palette |
199
+ | `colorsLight` | `string[]` | Light variants | Colors for light mode |
200
+ | `colorsDark` | `string[]` | Dark variants | Colors for dark mode |
201
+ | `colorScheme` | `"light" \| "dark" \| "auto"` | `"auto"` | Color scheme to use |
202
+ | `showInitial` | `boolean` | `true` | Show first letter below face |
203
+ | `enable3D` | `boolean` | `true` | Enable 3D sphere rotation effect |
204
+
205
+ ### Avatar
206
+
207
+ | Prop | Type | Default | Description |
208
+ |------|------|---------|-------------|
209
+ | `asChild` | `boolean` | `false` | Render as child element (Slot pattern) |
210
+
211
+ ### AvatarImage
212
+
213
+ | Prop | Type | Default | Description |
214
+ |------|------|---------|-------------|
215
+ | `src` | `string \| null` | - | Image source URL |
216
+ | `alt` | `string` | `""` | Alt text for accessibility |
217
+ | `onLoadingStatusChange` | `(status) => void` | - | Callback on status change |
218
+
219
+ ### AvatarFallback
220
+
221
+ | Prop | Type | Default | Description |
222
+ |------|------|---------|-------------|
223
+ | `name` | `string` | `""` | Name for initials/FacehashAvatar |
224
+ | `facehash` | `boolean` | `false` | Use FacehashAvatar instead of initials |
225
+ | `facehashProps` | `FacehashAvatarProps` | - | Props to pass to FacehashAvatar |
226
+ | `delayMs` | `number` | `0` | Delay before showing fallback |
227
+ | `children` | `ReactNode` | - | Custom fallback content |
228
+
229
+ ## Exports
230
+
231
+ ```tsx
232
+ // Components
233
+ import {
234
+ FacehashAvatar,
235
+ Avatar,
236
+ AvatarImage,
237
+ AvatarFallback,
238
+ } from "facehash";
239
+
240
+ // Face components (for custom compositions)
241
+ import {
242
+ RoundFace,
243
+ CrossFace,
244
+ LineFace,
245
+ CurvedFace,
246
+ FACES,
247
+ } from "facehash";
248
+
249
+ // Utilities
250
+ import {
251
+ stringHash,
252
+ DEFAULT_COLORS,
253
+ DEFAULT_COLORS_LIGHT,
254
+ DEFAULT_COLORS_DARK,
255
+ } from "facehash";
256
+
257
+ // Hooks
258
+ import { useAvatarContext } from "facehash";
259
+ ```
260
+
261
+ ## Recipes
262
+
263
+ ### Next.js App Router
264
+
265
+ ```tsx
266
+ // components/user-avatar.tsx
267
+ "use client";
268
+
269
+ import { Avatar, AvatarImage, AvatarFallback } from "facehash";
270
+
271
+ export function UserAvatar({ user }: { user: { name: string; image?: string } }) {
272
+ return (
273
+ <Avatar className="relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full">
274
+ {user.image && <AvatarImage src={user.image} alt={user.name} />}
275
+ <AvatarFallback
276
+ name={user.name}
277
+ facehash
278
+ className="flex h-full w-full items-center justify-center"
279
+ />
280
+ </Avatar>
281
+ );
282
+ }
283
+ ```
284
+
285
+ ### Tailwind with Ring
286
+
287
+ ```tsx
288
+ <Avatar className="h-10 w-10 rounded-full ring-2 ring-white dark:ring-gray-900">
289
+ <AvatarImage src={url} />
290
+ <AvatarFallback name="John Doe" facehash />
291
+ </Avatar>
292
+ ```
293
+
294
+ ### Avatar Group
295
+
296
+ ```tsx
297
+ function AvatarGroup({ users }) {
298
+ return (
299
+ <div className="flex -space-x-2">
300
+ {users.map((user) => (
301
+ <Avatar
302
+ key={user.id}
303
+ className="h-8 w-8 rounded-full ring-2 ring-white"
304
+ >
305
+ <AvatarImage src={user.avatar} />
306
+ <AvatarFallback name={user.name} facehash />
307
+ </Avatar>
308
+ ))}
309
+ </div>
310
+ );
311
+ }
312
+ ```
313
+
314
+ ## Browser Support
315
+
316
+ - Chrome 88+
317
+ - Firefox 78+
318
+ - Safari 14+
319
+ - Edge 88+
320
+
321
+ ## Credits
322
+
323
+ Built with love by the [Cossistant](https://cossistant.com) team.
324
+
325
+ Inspired by [Boring Avatars](https://boringavatars.com/) by Josep Martins.
326
+
327
+ ## License
328
+
329
+ MIT
package/index.d.ts ADDED
@@ -0,0 +1,261 @@
1
+ import * as React from "react";
2
+
3
+ //#region src/facehash.d.ts
4
+ type Intensity3D = "none" | "subtle" | "medium" | "dramatic";
5
+ type Variant = "gradient" | "solid";
6
+ interface FacehashProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
7
+ /**
8
+ * String to generate a deterministic face from.
9
+ * Same string always produces the same face.
10
+ */
11
+ name: string;
12
+ /**
13
+ * Size in pixels or CSS units.
14
+ * @default 40
15
+ */
16
+ size?: number | string;
17
+ /**
18
+ * Background style.
19
+ * - "gradient": Adds gradient overlay (default)
20
+ * - "solid": Plain background color
21
+ * @default "gradient"
22
+ */
23
+ variant?: Variant;
24
+ /**
25
+ * 3D effect intensity.
26
+ * @default "dramatic"
27
+ */
28
+ intensity3d?: Intensity3D;
29
+ /**
30
+ * Enable hover interaction.
31
+ * When true, face "looks straight" on hover.
32
+ * @default true
33
+ */
34
+ interactive?: boolean;
35
+ /**
36
+ * Show first letter of name below the face.
37
+ * @default true
38
+ */
39
+ showInitial?: boolean;
40
+ /**
41
+ * Hex color array for inline styles.
42
+ * Use this OR colorClasses, not both.
43
+ */
44
+ colors?: string[];
45
+ /**
46
+ * Tailwind class array for background colors.
47
+ * Example: ["bg-pink-500 dark:bg-pink-600", "bg-blue-500 dark:bg-blue-600"]
48
+ * Use this OR colors, not both.
49
+ */
50
+ colorClasses?: string[];
51
+ /**
52
+ * Custom gradient overlay class (Tailwind).
53
+ * When provided, replaces the default pure CSS gradient.
54
+ * Only used when variant="gradient".
55
+ */
56
+ gradientOverlayClass?: string;
57
+ }
58
+ /**
59
+ * Facehash - Deterministic avatar faces from any string.
60
+ *
61
+ * @example
62
+ * ```tsx
63
+ * // With Tailwind classes
64
+ * <Facehash
65
+ * name="John"
66
+ * colorClasses={["bg-pink-500", "bg-blue-500"]}
67
+ * />
68
+ *
69
+ * // With hex colors
70
+ * <Facehash
71
+ * name="John"
72
+ * colors={["#ec4899", "#3b82f6"]}
73
+ * />
74
+ *
75
+ * // Plain color (no gradient)
76
+ * <Facehash name="John" variant="solid" />
77
+ * ```
78
+ */
79
+ declare const Facehash: React.ForwardRefExoticComponent<FacehashProps & React.RefAttributes<HTMLDivElement>>;
80
+ //#endregion
81
+ //#region src/avatar.d.ts
82
+ type ImageLoadingStatus$1 = "idle" | "loading" | "loaded" | "error";
83
+ type AvatarContextValue = {
84
+ imageLoadingStatus: ImageLoadingStatus$1;
85
+ onImageLoadingStatusChange: (status: ImageLoadingStatus$1) => void;
86
+ };
87
+ /**
88
+ * Hook to access the Avatar context.
89
+ * Throws an error if used outside of Avatar.
90
+ */
91
+ declare const useAvatarContext: () => AvatarContextValue;
92
+ type AvatarProps = React.HTMLAttributes<HTMLSpanElement> & {
93
+ /**
94
+ * Render as a different element using the asChild pattern.
95
+ * When true, Avatar renders its child and merges props.
96
+ */
97
+ asChild?: boolean;
98
+ };
99
+ /**
100
+ * Root avatar component that provides context for image loading state.
101
+ *
102
+ * @example
103
+ * ```tsx
104
+ * <Avatar className="w-10 h-10 rounded-full overflow-hidden">
105
+ * <AvatarImage src="/photo.jpg" alt="John" />
106
+ * <AvatarFallback name="John Doe" />
107
+ * </Avatar>
108
+ * ```
109
+ */
110
+ declare const Avatar: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
111
+ /**
112
+ * Render as a different element using the asChild pattern.
113
+ * When true, Avatar renders its child and merges props.
114
+ */
115
+ asChild?: boolean;
116
+ } & React.RefAttributes<HTMLSpanElement>>;
117
+ //#endregion
118
+ //#region src/avatar-fallback.d.ts
119
+ type AvatarFallbackProps = Omit<React.HTMLAttributes<HTMLSpanElement>, "children"> & {
120
+ /**
121
+ * The name to derive initials and Facehash from.
122
+ */
123
+ name?: string;
124
+ /**
125
+ * Delay in milliseconds before showing the fallback.
126
+ * Useful to prevent flashing when images load quickly.
127
+ * @default 0
128
+ */
129
+ delayMs?: number;
130
+ /**
131
+ * Custom children to render instead of initials or Facehash.
132
+ */
133
+ children?: React.ReactNode;
134
+ /**
135
+ * Use the Facehash component as fallback instead of initials.
136
+ * @default true
137
+ */
138
+ facehash?: boolean;
139
+ /**
140
+ * Props to pass to the Facehash component.
141
+ */
142
+ facehashProps?: Omit<FacehashProps, "name">;
143
+ };
144
+ /**
145
+ * Fallback component that displays when the image fails to load.
146
+ * Uses Facehash by default, can show initials or custom content.
147
+ *
148
+ * @example
149
+ * ```tsx
150
+ * // With Facehash (default)
151
+ * <AvatarFallback name="John Doe" />
152
+ *
153
+ * // With initials
154
+ * <AvatarFallback name="John Doe" facehash={false} />
155
+ *
156
+ * // With custom content
157
+ * <AvatarFallback>
158
+ * <UserIcon />
159
+ * </AvatarFallback>
160
+ * ```
161
+ */
162
+ declare const AvatarFallback: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLSpanElement>, "children"> & {
163
+ /**
164
+ * The name to derive initials and Facehash from.
165
+ */
166
+ name?: string;
167
+ /**
168
+ * Delay in milliseconds before showing the fallback.
169
+ * Useful to prevent flashing when images load quickly.
170
+ * @default 0
171
+ */
172
+ delayMs?: number;
173
+ /**
174
+ * Custom children to render instead of initials or Facehash.
175
+ */
176
+ children?: React.ReactNode;
177
+ /**
178
+ * Use the Facehash component as fallback instead of initials.
179
+ * @default true
180
+ */
181
+ facehash?: boolean;
182
+ /**
183
+ * Props to pass to the Facehash component.
184
+ */
185
+ facehashProps?: Omit<FacehashProps, "name">;
186
+ } & React.RefAttributes<HTMLSpanElement>>;
187
+ //#endregion
188
+ //#region src/avatar-image.d.ts
189
+ type ImageLoadingStatus = "idle" | "loading" | "loaded" | "error";
190
+ type AvatarImageProps = Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src"> & {
191
+ /**
192
+ * The image source URL. If empty or undefined, triggers error state.
193
+ */
194
+ src?: string | null;
195
+ /**
196
+ * Callback when the image loading status changes.
197
+ */
198
+ onLoadingStatusChange?: (status: ImageLoadingStatus) => void;
199
+ };
200
+ /**
201
+ * Image component that syncs its loading state with the Avatar context.
202
+ * Automatically hides when loading fails, allowing fallback to show.
203
+ *
204
+ * @example
205
+ * ```tsx
206
+ * <Avatar>
207
+ * <AvatarImage src="/photo.jpg" alt="User" />
208
+ * <AvatarFallback name="John Doe" />
209
+ * </Avatar>
210
+ * ```
211
+ */
212
+ declare const AvatarImage: React.ForwardRefExoticComponent<Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src"> & {
213
+ /**
214
+ * The image source URL. If empty or undefined, triggers error state.
215
+ */
216
+ src?: string | null;
217
+ /**
218
+ * Callback when the image loading status changes.
219
+ */
220
+ onLoadingStatusChange?: (status: ImageLoadingStatus) => void;
221
+ } & React.RefAttributes<HTMLImageElement>>;
222
+ //#endregion
223
+ //#region src/faces.d.ts
224
+ type FaceProps = {
225
+ className?: string;
226
+ style?: React.CSSProperties;
227
+ };
228
+ /**
229
+ * Round eyes face - simple circular eyes
230
+ */
231
+ declare const RoundFace: React.FC<FaceProps>;
232
+ /**
233
+ * Cross eyes face - X-shaped eyes
234
+ */
235
+ declare const CrossFace: React.FC<FaceProps>;
236
+ /**
237
+ * Line eyes face - horizontal line eyes
238
+ */
239
+ declare const LineFace: React.FC<FaceProps>;
240
+ /**
241
+ * Curved eyes face - sleepy/happy curved eyes
242
+ */
243
+ declare const CurvedFace: React.FC<FaceProps>;
244
+ /**
245
+ * All available face components
246
+ */
247
+ declare const FACES: readonly [React.FC<FaceProps>, React.FC<FaceProps>, React.FC<FaceProps>, React.FC<FaceProps>];
248
+ type FaceComponent = (typeof FACES)[number];
249
+ //#endregion
250
+ //#region src/utils/hash.d.ts
251
+ /**
252
+ * Generates a consistent numeric hash from a string.
253
+ * Used to deterministically select faces and colors for avatars.
254
+ *
255
+ * @param str - The input string to hash
256
+ * @returns A positive 32-bit integer hash
257
+ */
258
+ declare function stringHash(str: string): number;
259
+ //#endregion
260
+ export { Avatar, type AvatarContextValue, AvatarFallback, type AvatarFallbackProps, AvatarImage, type AvatarImageProps, type AvatarProps, CrossFace, CurvedFace, FACES, type FaceComponent, type FaceProps, Facehash, type FacehashProps, type Intensity3D, LineFace, RoundFace, type Variant, stringHash, useAvatarContext };
261
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/facehash.tsx","../src/avatar.tsx","../src/avatar-fallback.tsx","../src/avatar-image.tsx","../src/faces.tsx","../src/utils/hash.ts"],"sourcesContent":[],"mappings":";;;KAQY,WAAA;KACA,OAAA;AADA,UAGK,aAAA,SACR,IAJc,CAIT,KAAA,CAAM,cAJG,CAIY,cAJZ,CAAA,EAAA,UAAA,CAAA,CAAA;EACX;AAEZ;;;EAoBW,IAAA,EAAA,MAAA;EAMI;;;AA4Gf;E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;AAUY,cGyFC,KHzFU,EAAA,SAAwB,CGyF7B,KAAA,CAAA,EHzFQ,CGyFR,SHzFc,CAAA,EGyFd,KAAA,CAAA,EHzF4B,CGyF5B,SHzF4B,CAAA,EGyF5B,KAAA,CAAA,EHzF4B,CGyF5B,SHzF4B,CAAA,EGyF5B,KAAA,CAAA,EHzF4B,CGyF5B,SHzF4B,CAAA,CAAA;AAmBjC,KGwED,aAAA,GHjCX,CAAA,OGiCmC,KHjCnC,CAAA,CAAA,MAAA,CAAA;;;;;;AD3ED;AACA;AAEA;;AACoB,iBKLJ,UAAA,CLKI,GAAA,EAAA,MAAA,CAAA,EAAA,MAAA"}
package/index.js ADDED
@@ -0,0 +1,529 @@
1
+ import * as React from "react";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+
4
+ //#region src/faces.tsx
5
+ /**
6
+ * Round eyes face - simple circular eyes
7
+ */
8
+ const RoundFace = ({ className, style }) => /* @__PURE__ */ jsxs("svg", {
9
+ "aria-hidden": "true",
10
+ className,
11
+ fill: "none",
12
+ style,
13
+ viewBox: "0 0 63 15",
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ children: [
16
+ /* @__PURE__ */ jsx("title", { children: "Round Eyes" }),
17
+ /* @__PURE__ */ jsx("path", {
18
+ d: "M62.4 7.2C62.4 11.1765 59.1765 14.4 55.2 14.4C51.2236 14.4 48 11.1765 48 7.2C48 3.22355 51.2236 0 55.2 0C59.1765 0 62.4 3.22355 62.4 7.2Z",
19
+ fill: "currentColor"
20
+ }),
21
+ /* @__PURE__ */ jsx("path", {
22
+ d: "M14.4 7.2C14.4 11.1765 11.1765 14.4 7.2 14.4C3.22355 14.4 0 11.1765 0 7.2C0 3.22355 3.22355 0 7.2 0C11.1765 0 14.4 3.22355 14.4 7.2Z",
23
+ fill: "currentColor"
24
+ })
25
+ ]
26
+ });
27
+ /**
28
+ * Cross eyes face - X-shaped eyes
29
+ */
30
+ const CrossFace = ({ className, style }) => /* @__PURE__ */ jsxs("svg", {
31
+ "aria-hidden": "true",
32
+ className,
33
+ fill: "none",
34
+ style,
35
+ viewBox: "0 0 71 23",
36
+ xmlns: "http://www.w3.org/2000/svg",
37
+ children: [
38
+ /* @__PURE__ */ jsx("title", { children: "Cross Eyes" }),
39
+ /* @__PURE__ */ jsx("path", {
40
+ d: "M11.5 0C12.9411 0 13.6619 0.000460386 14.1748 0.354492C14.3742 0.49213 14.547 0.664882 14.6846 0.864258C15.0384 1.37711 15.0391 2.09739 15.0391 3.53809V7.96094H19.4619C20.9027 7.96094 21.6229 7.9615 22.1357 8.31543C22.3352 8.45308 22.5079 8.62578 22.6455 8.8252C22.9995 9.3381 23 10.0589 23 11.5C23 12.9408 22.9995 13.661 22.6455 14.1738C22.5079 14.3733 22.3352 14.5459 22.1357 14.6836C21.6229 15.0375 20.9027 15.0381 19.4619 15.0381H15.0391V19.4619C15.0391 20.9026 15.0384 21.6229 14.6846 22.1357C14.547 22.3351 14.3742 22.5079 14.1748 22.6455C13.6619 22.9995 12.9411 23 11.5 23C10.0592 23 9.33903 22.9994 8.82617 22.6455C8.62674 22.5079 8.45309 22.3352 8.31543 22.1357C7.96175 21.6229 7.96191 20.9024 7.96191 19.4619V15.0381H3.53809C2.0973 15.0381 1.37711 15.0375 0.864258 14.6836C0.664834 14.5459 0.492147 14.3733 0.354492 14.1738C0.000498831 13.661 -5.88036e-08 12.9408 0 11.5C6.2999e-08 10.0589 0.000460356 9.3381 0.354492 8.8252C0.492144 8.62578 0.664842 8.45308 0.864258 8.31543C1.37711 7.9615 2.09731 7.96094 3.53809 7.96094H7.96191V3.53809C7.96191 2.09765 7.96175 1.37709 8.31543 0.864258C8.45309 0.664828 8.62674 0.492149 8.82617 0.354492C9.33903 0.000555366 10.0592 1.62347e-09 11.5 0Z",
41
+ fill: "currentColor"
42
+ }),
43
+ /* @__PURE__ */ jsx("path", {
44
+ d: "M58.7695 0C60.2107 0 60.9314 0.000460386 61.4443 0.354492C61.6437 0.49213 61.8165 0.664882 61.9541 0.864258C62.308 1.37711 62.3086 2.09739 62.3086 3.53809V7.96094H66.7314C68.1722 7.96094 68.8924 7.9615 69.4053 8.31543C69.6047 8.45308 69.7774 8.62578 69.915 8.8252C70.2691 9.3381 70.2695 10.0589 70.2695 11.5C70.2695 12.9408 70.269 13.661 69.915 14.1738C69.7774 14.3733 69.6047 14.5459 69.4053 14.6836C68.8924 15.0375 68.1722 15.0381 66.7314 15.0381H62.3086V19.4619C62.3086 20.9026 62.308 21.6229 61.9541 22.1357C61.8165 22.3351 61.6437 22.5079 61.4443 22.6455C60.9314 22.9995 60.2107 23 58.7695 23C57.3287 23 56.6086 22.9994 56.0957 22.6455C55.8963 22.5079 55.7226 22.3352 55.585 22.1357C55.2313 21.6229 55.2314 20.9024 55.2314 19.4619V15.0381H50.8076C49.3668 15.0381 48.6466 15.0375 48.1338 14.6836C47.9344 14.5459 47.7617 14.3733 47.624 14.1738C47.27 13.661 47.2695 12.9408 47.2695 11.5C47.2695 10.0589 47.27 9.3381 47.624 8.8252C47.7617 8.62578 47.9344 8.45308 48.1338 8.31543C48.6466 7.9615 49.3668 7.96094 50.8076 7.96094H55.2314V3.53809C55.2314 2.09765 55.2313 1.37709 55.585 0.864258C55.7226 0.664828 55.8963 0.492149 56.0957 0.354492C56.6086 0.000555366 57.3287 1.62347e-09 58.7695 0Z",
45
+ fill: "currentColor"
46
+ })
47
+ ]
48
+ });
49
+ /**
50
+ * Line eyes face - horizontal line eyes
51
+ */
52
+ const LineFace = ({ className, style }) => /* @__PURE__ */ jsxs("svg", {
53
+ "aria-hidden": "true",
54
+ className,
55
+ fill: "none",
56
+ style,
57
+ viewBox: "0 0 82 8",
58
+ xmlns: "http://www.w3.org/2000/svg",
59
+ children: [
60
+ /* @__PURE__ */ jsx("title", { children: "Line Eyes" }),
61
+ /* @__PURE__ */ jsx("path", {
62
+ d: "M3.53125 0.164063C4.90133 0.164063 5.58673 0.163893 6.08301 0.485352C6.31917 0.638428 6.52075 0.840012 6.67383 1.07617C6.99555 1.57252 6.99512 2.25826 6.99512 3.62891C6.99512 4.99911 6.99536 5.68438 6.67383 6.18066C6.52075 6.41682 6.31917 6.61841 6.08301 6.77148C5.58672 7.09305 4.90147 7.09277 3.53125 7.09277C2.16062 7.09277 1.47486 7.09319 0.978516 6.77148C0.742356 6.61841 0.540772 6.41682 0.387695 6.18066C0.0662401 5.68439 0.0664063 4.999 0.0664063 3.62891C0.0664063 2.25838 0.0660571 1.57251 0.387695 1.07617C0.540772 0.840012 0.742356 0.638428 0.978516 0.485352C1.47485 0.163744 2.16076 0.164063 3.53125 0.164063Z",
63
+ fill: "currentColor"
64
+ }),
65
+ /* @__PURE__ */ jsx("path", {
66
+ d: "M25.1836 0.164063C26.5542 0.164063 27.24 0.163638 27.7363 0.485352C27.9724 0.638384 28.1731 0.8401 28.3262 1.07617C28.6479 1.57252 28.6484 2.25825 28.6484 3.62891C28.6484 4.99931 28.6478 5.68436 28.3262 6.18066C28.1731 6.41678 27.9724 6.61842 27.7363 6.77148C27.24 7.09321 26.5542 7.09277 25.1836 7.09277H11.3262C9.95557 7.09277 9.26978 7.09317 8.77344 6.77148C8.53728 6.61841 8.33569 6.41682 8.18262 6.18066C7.86115 5.68438 7.86133 4.99902 7.86133 3.62891C7.86133 2.25835 7.86096 1.57251 8.18262 1.07617C8.33569 0.840012 8.53728 0.638428 8.77344 0.485352C9.26977 0.163768 9.95572 0.164063 11.3262 0.164063H25.1836Z",
67
+ fill: "currentColor"
68
+ }),
69
+ /* @__PURE__ */ jsx("path", {
70
+ d: "M78.2034 7.09325C76.8333 7.09325 76.1479 7.09342 75.6516 6.77197C75.4155 6.61889 75.2139 6.4173 75.0608 6.18114C74.7391 5.6848 74.7395 4.99905 74.7395 3.62841C74.7395 2.2582 74.7393 1.57294 75.0608 1.07665C75.2139 0.840493 75.4155 0.638909 75.6516 0.485832C76.1479 0.164271 76.8332 0.164543 78.2034 0.164543C79.574 0.164543 80.2598 0.164122 80.7561 0.485832C80.9923 0.638909 81.1939 0.840493 81.347 1.07665C81.6684 1.57293 81.6682 2.25831 81.6682 3.62841C81.6682 4.99894 81.6686 5.68481 81.347 6.18114C81.1939 6.4173 80.9923 6.61889 80.7561 6.77197C80.2598 7.09357 79.5739 7.09325 78.2034 7.09325Z",
71
+ fill: "currentColor"
72
+ }),
73
+ /* @__PURE__ */ jsx("path", {
74
+ d: "M56.5511 7.09325C55.1804 7.09325 54.4947 7.09368 53.9983 6.77197C53.7622 6.61893 53.5615 6.41722 53.4085 6.18114C53.0868 5.6848 53.0862 4.99907 53.0862 3.62841C53.0862 2.258 53.0868 1.57296 53.4085 1.07665C53.5615 0.840539 53.7622 0.638898 53.9983 0.485832C54.4947 0.164105 55.1804 0.164543 56.5511 0.164543H70.4085C71.7791 0.164543 72.4649 0.164146 72.9612 0.485832C73.1974 0.638909 73.399 0.840493 73.552 1.07665C73.8735 1.57293 73.8733 2.25829 73.8733 3.62841C73.8733 4.99896 73.8737 5.68481 73.552 6.18114C73.399 6.4173 73.1974 6.61889 72.9612 6.77197C72.4649 7.09355 71.7789 7.09325 70.4085 7.09325H56.5511Z",
75
+ fill: "currentColor"
76
+ })
77
+ ]
78
+ });
79
+ /**
80
+ * Curved eyes face - sleepy/happy curved eyes
81
+ */
82
+ const CurvedFace = ({ className, style }) => /* @__PURE__ */ jsxs("svg", {
83
+ "aria-hidden": "true",
84
+ className,
85
+ fill: "none",
86
+ style,
87
+ viewBox: "0 0 63 9",
88
+ xmlns: "http://www.w3.org/2000/svg",
89
+ children: [
90
+ /* @__PURE__ */ jsx("title", { children: "Curved Eyes" }),
91
+ /* @__PURE__ */ jsx("path", {
92
+ d: "M0 5.06511C0 4.94513 0 4.88513 0.00771184 4.79757C0.0483059 4.33665 0.341025 3.76395 0.690821 3.46107C0.757274 3.40353 0.783996 3.38422 0.837439 3.34559C2.40699 2.21129 6.03888 0 10.5 0C14.9611 0 18.593 2.21129 20.1626 3.34559C20.216 3.38422 20.2427 3.40353 20.3092 3.46107C20.659 3.76395 20.9517 4.33665 20.9923 4.79757C21 4.88513 21 4.94513 21 5.06511C21 6.01683 21 6.4927 20.9657 6.6754C20.7241 7.96423 19.8033 8.55941 18.5289 8.25054C18.3483 8.20676 17.8198 7.96876 16.7627 7.49275C14.975 6.68767 12.7805 6 10.5 6C8.21954 6 6.02504 6.68767 4.23727 7.49275C3.18025 7.96876 2.65174 8.20676 2.47108 8.25054C1.19668 8.55941 0.275917 7.96423 0.0342566 6.6754C0 6.4927 0 6.01683 0 5.06511Z",
93
+ fill: "currentColor"
94
+ }),
95
+ /* @__PURE__ */ jsx("path", {
96
+ d: "M42 5.06511C42 4.94513 42 4.88513 42.0077 4.79757C42.0483 4.33665 42.341 3.76395 42.6908 3.46107C42.7573 3.40353 42.784 3.38422 42.8374 3.34559C44.407 2.21129 48.0389 0 52.5 0C56.9611 0 60.593 2.21129 62.1626 3.34559C62.216 3.38422 62.2427 3.40353 62.3092 3.46107C62.659 3.76395 62.9517 4.33665 62.9923 4.79757C63 4.88513 63 4.94513 63 5.06511C63 6.01683 63 6.4927 62.9657 6.6754C62.7241 7.96423 61.8033 8.55941 60.5289 8.25054C60.3483 8.20676 59.8198 7.96876 58.7627 7.49275C56.975 6.68767 54.7805 6 52.5 6C50.2195 6 48.025 6.68767 46.2373 7.49275C45.1802 7.96876 44.6517 8.20676 44.4711 8.25054C43.1967 8.55941 42.2759 7.96423 42.0343 6.6754C42 6.4927 42 6.01683 42 5.06511Z",
97
+ fill: "currentColor"
98
+ })
99
+ ]
100
+ });
101
+ /**
102
+ * All available face components
103
+ */
104
+ const FACES = [
105
+ RoundFace,
106
+ CrossFace,
107
+ LineFace,
108
+ CurvedFace
109
+ ];
110
+
111
+ //#endregion
112
+ //#region src/utils/hash.ts
113
+ /**
114
+ * Generates a consistent numeric hash from a string.
115
+ * Used to deterministically select faces and colors for avatars.
116
+ *
117
+ * @param str - The input string to hash
118
+ * @returns A positive 32-bit integer hash
119
+ */
120
+ function stringHash(str) {
121
+ let hash = 0;
122
+ for (let i = 0; i < str.length; i++) {
123
+ const char = str.charCodeAt(i);
124
+ hash = (hash << 5) - hash + char;
125
+ hash &= hash;
126
+ }
127
+ return Math.abs(hash);
128
+ }
129
+
130
+ //#endregion
131
+ //#region src/facehash.tsx
132
+ const INTENSITY_PRESETS = {
133
+ none: {
134
+ rotateRange: 0,
135
+ translateZ: 0,
136
+ perspective: "none"
137
+ },
138
+ subtle: {
139
+ rotateRange: 5,
140
+ translateZ: 4,
141
+ perspective: "800px"
142
+ },
143
+ medium: {
144
+ rotateRange: 10,
145
+ translateZ: 8,
146
+ perspective: "500px"
147
+ },
148
+ dramatic: {
149
+ rotateRange: 15,
150
+ translateZ: 12,
151
+ perspective: "300px"
152
+ }
153
+ };
154
+ const SPHERE_POSITIONS = [
155
+ {
156
+ x: -1,
157
+ y: 1
158
+ },
159
+ {
160
+ x: 1,
161
+ y: 1
162
+ },
163
+ {
164
+ x: 1,
165
+ y: 0
166
+ },
167
+ {
168
+ x: 0,
169
+ y: 1
170
+ },
171
+ {
172
+ x: -1,
173
+ y: 0
174
+ },
175
+ {
176
+ x: 0,
177
+ y: 0
178
+ },
179
+ {
180
+ x: 0,
181
+ y: -1
182
+ },
183
+ {
184
+ x: -1,
185
+ y: -1
186
+ },
187
+ {
188
+ x: 1,
189
+ y: -1
190
+ }
191
+ ];
192
+ const DEFAULT_GRADIENT_STYLE = { background: "radial-gradient(ellipse 100% 100% at 50% 50%, rgba(255,255,255,0.15) 0%, transparent 60%)" };
193
+ /**
194
+ * Facehash - Deterministic avatar faces from any string.
195
+ *
196
+ * @example
197
+ * ```tsx
198
+ * // With Tailwind classes
199
+ * <Facehash
200
+ * name="John"
201
+ * colorClasses={["bg-pink-500", "bg-blue-500"]}
202
+ * />
203
+ *
204
+ * // With hex colors
205
+ * <Facehash
206
+ * name="John"
207
+ * colors={["#ec4899", "#3b82f6"]}
208
+ * />
209
+ *
210
+ * // Plain color (no gradient)
211
+ * <Facehash name="John" variant="solid" />
212
+ * ```
213
+ */
214
+ const Facehash = React.forwardRef(({ name, size = 40, variant = "gradient", intensity3d = "dramatic", interactive = true, showInitial = true, colors, colorClasses, gradientOverlayClass, className, style, onMouseEnter, onMouseLeave, ...props }, ref) => {
215
+ const [isHovered, setIsHovered] = React.useState(false);
216
+ const { FaceComponent, colorIndex, rotation } = React.useMemo(() => {
217
+ const hash = stringHash(name);
218
+ const faceIndex = hash % FACES.length;
219
+ const _colorIndex = hash % (colorClasses?.length ?? colors?.length ?? 1);
220
+ const position = SPHERE_POSITIONS[hash % SPHERE_POSITIONS.length] ?? {
221
+ x: 0,
222
+ y: 0
223
+ };
224
+ return {
225
+ FaceComponent: FACES[faceIndex] ?? FACES[0],
226
+ colorIndex: _colorIndex,
227
+ rotation: position
228
+ };
229
+ }, [
230
+ name,
231
+ colors?.length,
232
+ colorClasses?.length
233
+ ]);
234
+ const preset = INTENSITY_PRESETS[intensity3d];
235
+ const transform = React.useMemo(() => {
236
+ if (intensity3d === "none") return;
237
+ return `rotateX(${isHovered && interactive ? 0 : rotation.x * preset.rotateRange}deg) rotateY(${isHovered && interactive ? 0 : rotation.y * preset.rotateRange}deg) translateZ(${preset.translateZ}px)`;
238
+ }, [
239
+ intensity3d,
240
+ isHovered,
241
+ interactive,
242
+ rotation,
243
+ preset
244
+ ]);
245
+ const sizeValue = typeof size === "number" ? `${size}px` : size;
246
+ const initial = name.charAt(0).toUpperCase();
247
+ const bgColorClass = colorClasses?.[colorIndex];
248
+ const bgColorHex = colors?.[colorIndex];
249
+ const handleMouseEnter = React.useCallback((e) => {
250
+ if (interactive) setIsHovered(true);
251
+ onMouseEnter?.(e);
252
+ }, [interactive, onMouseEnter]);
253
+ const handleMouseLeave = React.useCallback((e) => {
254
+ if (interactive) setIsHovered(false);
255
+ onMouseLeave?.(e);
256
+ }, [interactive, onMouseLeave]);
257
+ return /* @__PURE__ */ jsxs("div", {
258
+ className: [bgColorClass, className].filter(Boolean).join(" "),
259
+ "data-facehash": "",
260
+ "data-interactive": interactive || void 0,
261
+ onMouseEnter: handleMouseEnter,
262
+ onMouseLeave: handleMouseLeave,
263
+ ref,
264
+ style: {
265
+ width: sizeValue,
266
+ height: sizeValue,
267
+ position: "relative",
268
+ display: "flex",
269
+ alignItems: "center",
270
+ justifyContent: "center",
271
+ overflow: "hidden",
272
+ containerType: "size",
273
+ ...intensity3d !== "none" && {
274
+ perspective: preset.perspective,
275
+ transformStyle: "preserve-3d"
276
+ },
277
+ ...bgColorHex && !bgColorClass && { backgroundColor: bgColorHex },
278
+ ...style
279
+ },
280
+ ...props,
281
+ children: [variant === "gradient" && /* @__PURE__ */ jsx("div", {
282
+ className: gradientOverlayClass,
283
+ "data-facehash-gradient": "",
284
+ style: {
285
+ position: "absolute",
286
+ inset: 0,
287
+ pointerEvents: "none",
288
+ zIndex: 1,
289
+ ...gradientOverlayClass ? {} : DEFAULT_GRADIENT_STYLE
290
+ }
291
+ }), /* @__PURE__ */ jsxs("div", {
292
+ "data-facehash-face": "",
293
+ style: {
294
+ position: "absolute",
295
+ inset: 0,
296
+ display: "flex",
297
+ flexDirection: "column",
298
+ alignItems: "center",
299
+ justifyContent: "center",
300
+ zIndex: 2,
301
+ transform,
302
+ transformStyle: intensity3d !== "none" ? "preserve-3d" : void 0,
303
+ transition: interactive ? "transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)" : void 0,
304
+ color: "#000000"
305
+ },
306
+ children: [/* @__PURE__ */ jsx(FaceComponent, { style: {
307
+ width: "60%",
308
+ height: "auto",
309
+ maxWidth: "90%",
310
+ maxHeight: "40%"
311
+ } }), showInitial && /* @__PURE__ */ jsx("span", {
312
+ "data-facehash-initial": "",
313
+ style: {
314
+ marginTop: "8%",
315
+ fontSize: "26cqw",
316
+ lineHeight: 1,
317
+ fontFamily: "monospace",
318
+ fontWeight: "bold"
319
+ },
320
+ children: initial
321
+ })]
322
+ })]
323
+ });
324
+ });
325
+ Facehash.displayName = "Facehash";
326
+
327
+ //#endregion
328
+ //#region src/avatar.tsx
329
+ const AvatarContext = React.createContext(null);
330
+ /**
331
+ * Hook to access the Avatar context.
332
+ * Throws an error if used outside of Avatar.
333
+ */
334
+ const useAvatarContext = () => {
335
+ const context = React.useContext(AvatarContext);
336
+ if (!context) throw new Error("Avatar compound components must be rendered within an Avatar component");
337
+ return context;
338
+ };
339
+ /**
340
+ * Root avatar component that provides context for image loading state.
341
+ *
342
+ * @example
343
+ * ```tsx
344
+ * <Avatar className="w-10 h-10 rounded-full overflow-hidden">
345
+ * <AvatarImage src="/photo.jpg" alt="John" />
346
+ * <AvatarFallback name="John Doe" />
347
+ * </Avatar>
348
+ * ```
349
+ */
350
+ const Avatar = React.forwardRef(({ children, className, style, asChild = false, ...props }, ref) => {
351
+ const [imageLoadingStatus, setImageLoadingStatus] = React.useState("idle");
352
+ const contextValue = React.useMemo(() => ({
353
+ imageLoadingStatus,
354
+ onImageLoadingStatusChange: setImageLoadingStatus
355
+ }), [imageLoadingStatus]);
356
+ const Element = asChild ? React.Fragment : "span";
357
+ const elementProps = asChild ? {} : {
358
+ ref,
359
+ className,
360
+ style: {
361
+ position: "relative",
362
+ display: "flex",
363
+ alignItems: "center",
364
+ justifyContent: "center",
365
+ flexShrink: 0,
366
+ overflow: "hidden",
367
+ ...style
368
+ },
369
+ "data-avatar": "",
370
+ "data-state": imageLoadingStatus,
371
+ ...props
372
+ };
373
+ return /* @__PURE__ */ jsx(AvatarContext.Provider, {
374
+ value: contextValue,
375
+ children: /* @__PURE__ */ jsx(Element, {
376
+ ...elementProps,
377
+ children
378
+ })
379
+ });
380
+ });
381
+ Avatar.displayName = "Avatar";
382
+
383
+ //#endregion
384
+ //#region src/avatar-fallback.tsx
385
+ const WHITESPACE_REGEX = /\s+/;
386
+ /**
387
+ * Extracts initials from a name string.
388
+ */
389
+ function getInitials(name) {
390
+ const parts = name.trim().split(WHITESPACE_REGEX);
391
+ if (parts.length === 0) return "";
392
+ if (parts.length === 1) return parts[0]?.charAt(0).toUpperCase() || "";
393
+ return ((parts[0]?.charAt(0) || "") + (parts.at(-1)?.charAt(0) || "")).toUpperCase();
394
+ }
395
+ /**
396
+ * Fallback component that displays when the image fails to load.
397
+ * Uses Facehash by default, can show initials or custom content.
398
+ *
399
+ * @example
400
+ * ```tsx
401
+ * // With Facehash (default)
402
+ * <AvatarFallback name="John Doe" />
403
+ *
404
+ * // With initials
405
+ * <AvatarFallback name="John Doe" facehash={false} />
406
+ *
407
+ * // With custom content
408
+ * <AvatarFallback>
409
+ * <UserIcon />
410
+ * </AvatarFallback>
411
+ * ```
412
+ */
413
+ const AvatarFallback = React.forwardRef(({ name = "", delayMs = 0, children, facehash = true, facehashProps, className, style, ...props }, ref) => {
414
+ const { imageLoadingStatus } = useAvatarContext();
415
+ const [canRender, setCanRender] = React.useState(delayMs === 0);
416
+ React.useEffect(() => {
417
+ if (delayMs > 0) {
418
+ const timerId = window.setTimeout(() => setCanRender(true), delayMs);
419
+ return () => window.clearTimeout(timerId);
420
+ }
421
+ }, [delayMs]);
422
+ const initials = React.useMemo(() => getInitials(name), [name]);
423
+ if (!(canRender && imageLoadingStatus !== "loaded" && imageLoadingStatus !== "loading")) return null;
424
+ if (children) return /* @__PURE__ */ jsx("span", {
425
+ className,
426
+ "data-avatar-fallback": "",
427
+ ref,
428
+ style: {
429
+ display: "flex",
430
+ alignItems: "center",
431
+ justifyContent: "center",
432
+ width: "100%",
433
+ height: "100%",
434
+ ...style
435
+ },
436
+ ...props,
437
+ children
438
+ });
439
+ if (facehash) return /* @__PURE__ */ jsx(Facehash, {
440
+ className,
441
+ "data-avatar-fallback": "",
442
+ name,
443
+ ref,
444
+ size: "100%",
445
+ ...facehashProps,
446
+ style: { ...style },
447
+ ...props
448
+ });
449
+ return /* @__PURE__ */ jsx("span", {
450
+ className,
451
+ "data-avatar-fallback": "",
452
+ ref,
453
+ style: {
454
+ display: "flex",
455
+ alignItems: "center",
456
+ justifyContent: "center",
457
+ width: "100%",
458
+ height: "100%",
459
+ ...style
460
+ },
461
+ ...props,
462
+ children: initials
463
+ });
464
+ });
465
+ AvatarFallback.displayName = "AvatarFallback";
466
+
467
+ //#endregion
468
+ //#region src/avatar-image.tsx
469
+ /**
470
+ * Image component that syncs its loading state with the Avatar context.
471
+ * Automatically hides when loading fails, allowing fallback to show.
472
+ *
473
+ * @example
474
+ * ```tsx
475
+ * <Avatar>
476
+ * <AvatarImage src="/photo.jpg" alt="User" />
477
+ * <AvatarFallback name="John Doe" />
478
+ * </Avatar>
479
+ * ```
480
+ */
481
+ const AvatarImage = React.forwardRef(({ src, alt = "", className, style, onLoadingStatusChange, ...props }, ref) => {
482
+ const { imageLoadingStatus, onImageLoadingStatusChange } = useAvatarContext();
483
+ const imageRef = React.useRef(null);
484
+ React.useImperativeHandle(ref, () => imageRef.current);
485
+ const updateStatus = React.useCallback((status) => {
486
+ onImageLoadingStatusChange(status);
487
+ onLoadingStatusChange?.(status);
488
+ }, [onImageLoadingStatusChange, onLoadingStatusChange]);
489
+ React.useLayoutEffect(() => {
490
+ if (!src) {
491
+ updateStatus("error");
492
+ return;
493
+ }
494
+ let isMounted = true;
495
+ const image = new Image();
496
+ const setStatus = (status) => {
497
+ if (!isMounted) return;
498
+ updateStatus(status);
499
+ };
500
+ setStatus("loading");
501
+ image.onload = () => setStatus("loaded");
502
+ image.onerror = () => setStatus("error");
503
+ image.src = src;
504
+ return () => {
505
+ isMounted = false;
506
+ };
507
+ }, [src, updateStatus]);
508
+ if (imageLoadingStatus !== "loaded") return null;
509
+ return /* @__PURE__ */ jsx("img", {
510
+ alt,
511
+ className,
512
+ "data-avatar-image": "",
513
+ ref: imageRef,
514
+ src: src ?? void 0,
515
+ style: {
516
+ aspectRatio: "1 / 1",
517
+ width: "100%",
518
+ height: "100%",
519
+ objectFit: "cover",
520
+ ...style
521
+ },
522
+ ...props
523
+ });
524
+ });
525
+ AvatarImage.displayName = "AvatarImage";
526
+
527
+ //#endregion
528
+ export { Avatar, AvatarFallback, AvatarImage, CrossFace, CurvedFace, FACES, Facehash, LineFace, RoundFace, stringHash, useAvatarContext };
529
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["RoundFace: React.FC<FaceProps>","CrossFace: React.FC<FaceProps>","LineFace: React.FC<FaceProps>","CurvedFace: React.FC<FaceProps>","DEFAULT_GRADIENT_STYLE: React.CSSProperties","contextValue: AvatarContextValue"],"sources":["../src/faces.tsx","../src/utils/hash.ts","../src/facehash.tsx","../src/avatar.tsx","../src/avatar-fallback.tsx","../src/avatar-image.tsx"],"sourcesContent":["import type * as React from \"react\";\n\nexport type FaceProps = {\n\tclassName?: string;\n\tstyle?: React.CSSProperties;\n};\n\n/**\n * Round eyes face - simple circular eyes\n */\nexport const RoundFace: React.FC<FaceProps> = ({ className, style }) => (\n\t<svg\n\t\taria-hidden=\"true\"\n\t\tclassName={className}\n\t\tfill=\"none\"\n\t\tstyle={style}\n\t\tviewBox=\"0 0 63 15\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t>\n\t\t<title>Round Eyes</title>\n\t\t<path\n\t\t\td=\"M62.4 7.2C62.4 11.1765 59.1765 14.4 55.2 14.4C51.2236 14.4 48 11.1765 48 7.2C48 3.22355 51.2236 0 55.2 0C59.1765 0 62.4 3.22355 62.4 7.2Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t\t<path\n\t\t\td=\"M14.4 7.2C14.4 11.1765 11.1765 14.4 7.2 14.4C3.22355 14.4 0 11.1765 0 7.2C0 3.22355 3.22355 0 7.2 0C11.1765 0 14.4 3.22355 14.4 7.2Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t</svg>\n);\n\n/**\n * Cross eyes face - X-shaped eyes\n */\nexport const CrossFace: React.FC<FaceProps> = ({ className, style }) => (\n\t<svg\n\t\taria-hidden=\"true\"\n\t\tclassName={className}\n\t\tfill=\"none\"\n\t\tstyle={style}\n\t\tviewBox=\"0 0 71 23\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t>\n\t\t<title>Cross Eyes</title>\n\t\t<path\n\t\t\td=\"M11.5 0C12.9411 0 13.6619 0.000460386 14.1748 0.354492C14.3742 0.49213 14.547 0.664882 14.6846 0.864258C15.0384 1.37711 15.0391 2.09739 15.0391 3.53809V7.96094H19.4619C20.9027 7.96094 21.6229 7.9615 22.1357 8.31543C22.3352 8.45308 22.5079 8.62578 22.6455 8.8252C22.9995 9.3381 23 10.0589 23 11.5C23 12.9408 22.9995 13.661 22.6455 14.1738C22.5079 14.3733 22.3352 14.5459 22.1357 14.6836C21.6229 15.0375 20.9027 15.0381 19.4619 15.0381H15.0391V19.4619C15.0391 20.9026 15.0384 21.6229 14.6846 22.1357C14.547 22.3351 14.3742 22.5079 14.1748 22.6455C13.6619 22.9995 12.9411 23 11.5 23C10.0592 23 9.33903 22.9994 8.82617 22.6455C8.62674 22.5079 8.45309 22.3352 8.31543 22.1357C7.96175 21.6229 7.96191 20.9024 7.96191 19.4619V15.0381H3.53809C2.0973 15.0381 1.37711 15.0375 0.864258 14.6836C0.664834 14.5459 0.492147 14.3733 0.354492 14.1738C0.000498831 13.661 -5.88036e-08 12.9408 0 11.5C6.2999e-08 10.0589 0.000460356 9.3381 0.354492 8.8252C0.492144 8.62578 0.664842 8.45308 0.864258 8.31543C1.37711 7.9615 2.09731 7.96094 3.53809 7.96094H7.96191V3.53809C7.96191 2.09765 7.96175 1.37709 8.31543 0.864258C8.45309 0.664828 8.62674 0.492149 8.82617 0.354492C9.33903 0.000555366 10.0592 1.62347e-09 11.5 0Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t\t<path\n\t\t\td=\"M58.7695 0C60.2107 0 60.9314 0.000460386 61.4443 0.354492C61.6437 0.49213 61.8165 0.664882 61.9541 0.864258C62.308 1.37711 62.3086 2.09739 62.3086 3.53809V7.96094H66.7314C68.1722 7.96094 68.8924 7.9615 69.4053 8.31543C69.6047 8.45308 69.7774 8.62578 69.915 8.8252C70.2691 9.3381 70.2695 10.0589 70.2695 11.5C70.2695 12.9408 70.269 13.661 69.915 14.1738C69.7774 14.3733 69.6047 14.5459 69.4053 14.6836C68.8924 15.0375 68.1722 15.0381 66.7314 15.0381H62.3086V19.4619C62.3086 20.9026 62.308 21.6229 61.9541 22.1357C61.8165 22.3351 61.6437 22.5079 61.4443 22.6455C60.9314 22.9995 60.2107 23 58.7695 23C57.3287 23 56.6086 22.9994 56.0957 22.6455C55.8963 22.5079 55.7226 22.3352 55.585 22.1357C55.2313 21.6229 55.2314 20.9024 55.2314 19.4619V15.0381H50.8076C49.3668 15.0381 48.6466 15.0375 48.1338 14.6836C47.9344 14.5459 47.7617 14.3733 47.624 14.1738C47.27 13.661 47.2695 12.9408 47.2695 11.5C47.2695 10.0589 47.27 9.3381 47.624 8.8252C47.7617 8.62578 47.9344 8.45308 48.1338 8.31543C48.6466 7.9615 49.3668 7.96094 50.8076 7.96094H55.2314V3.53809C55.2314 2.09765 55.2313 1.37709 55.585 0.864258C55.7226 0.664828 55.8963 0.492149 56.0957 0.354492C56.6086 0.000555366 57.3287 1.62347e-09 58.7695 0Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t</svg>\n);\n\n/**\n * Line eyes face - horizontal line eyes\n */\nexport const LineFace: React.FC<FaceProps> = ({ className, style }) => (\n\t<svg\n\t\taria-hidden=\"true\"\n\t\tclassName={className}\n\t\tfill=\"none\"\n\t\tstyle={style}\n\t\tviewBox=\"0 0 82 8\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t>\n\t\t<title>Line Eyes</title>\n\t\t<path\n\t\t\td=\"M3.53125 0.164063C4.90133 0.164063 5.58673 0.163893 6.08301 0.485352C6.31917 0.638428 6.52075 0.840012 6.67383 1.07617C6.99555 1.57252 6.99512 2.25826 6.99512 3.62891C6.99512 4.99911 6.99536 5.68438 6.67383 6.18066C6.52075 6.41682 6.31917 6.61841 6.08301 6.77148C5.58672 7.09305 4.90147 7.09277 3.53125 7.09277C2.16062 7.09277 1.47486 7.09319 0.978516 6.77148C0.742356 6.61841 0.540772 6.41682 0.387695 6.18066C0.0662401 5.68439 0.0664063 4.999 0.0664063 3.62891C0.0664063 2.25838 0.0660571 1.57251 0.387695 1.07617C0.540772 0.840012 0.742356 0.638428 0.978516 0.485352C1.47485 0.163744 2.16076 0.164063 3.53125 0.164063Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t\t<path\n\t\t\td=\"M25.1836 0.164063C26.5542 0.164063 27.24 0.163638 27.7363 0.485352C27.9724 0.638384 28.1731 0.8401 28.3262 1.07617C28.6479 1.57252 28.6484 2.25825 28.6484 3.62891C28.6484 4.99931 28.6478 5.68436 28.3262 6.18066C28.1731 6.41678 27.9724 6.61842 27.7363 6.77148C27.24 7.09321 26.5542 7.09277 25.1836 7.09277H11.3262C9.95557 7.09277 9.26978 7.09317 8.77344 6.77148C8.53728 6.61841 8.33569 6.41682 8.18262 6.18066C7.86115 5.68438 7.86133 4.99902 7.86133 3.62891C7.86133 2.25835 7.86096 1.57251 8.18262 1.07617C8.33569 0.840012 8.53728 0.638428 8.77344 0.485352C9.26977 0.163768 9.95572 0.164063 11.3262 0.164063H25.1836Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t\t<path\n\t\t\td=\"M78.2034 7.09325C76.8333 7.09325 76.1479 7.09342 75.6516 6.77197C75.4155 6.61889 75.2139 6.4173 75.0608 6.18114C74.7391 5.6848 74.7395 4.99905 74.7395 3.62841C74.7395 2.2582 74.7393 1.57294 75.0608 1.07665C75.2139 0.840493 75.4155 0.638909 75.6516 0.485832C76.1479 0.164271 76.8332 0.164543 78.2034 0.164543C79.574 0.164543 80.2598 0.164122 80.7561 0.485832C80.9923 0.638909 81.1939 0.840493 81.347 1.07665C81.6684 1.57293 81.6682 2.25831 81.6682 3.62841C81.6682 4.99894 81.6686 5.68481 81.347 6.18114C81.1939 6.4173 80.9923 6.61889 80.7561 6.77197C80.2598 7.09357 79.5739 7.09325 78.2034 7.09325Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t\t<path\n\t\t\td=\"M56.5511 7.09325C55.1804 7.09325 54.4947 7.09368 53.9983 6.77197C53.7622 6.61893 53.5615 6.41722 53.4085 6.18114C53.0868 5.6848 53.0862 4.99907 53.0862 3.62841C53.0862 2.258 53.0868 1.57296 53.4085 1.07665C53.5615 0.840539 53.7622 0.638898 53.9983 0.485832C54.4947 0.164105 55.1804 0.164543 56.5511 0.164543H70.4085C71.7791 0.164543 72.4649 0.164146 72.9612 0.485832C73.1974 0.638909 73.399 0.840493 73.552 1.07665C73.8735 1.57293 73.8733 2.25829 73.8733 3.62841C73.8733 4.99896 73.8737 5.68481 73.552 6.18114C73.399 6.4173 73.1974 6.61889 72.9612 6.77197C72.4649 7.09355 71.7789 7.09325 70.4085 7.09325H56.5511Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t</svg>\n);\n\n/**\n * Curved eyes face - sleepy/happy curved eyes\n */\nexport const CurvedFace: React.FC<FaceProps> = ({ className, style }) => (\n\t<svg\n\t\taria-hidden=\"true\"\n\t\tclassName={className}\n\t\tfill=\"none\"\n\t\tstyle={style}\n\t\tviewBox=\"0 0 63 9\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t>\n\t\t<title>Curved Eyes</title>\n\t\t<path\n\t\t\td=\"M0 5.06511C0 4.94513 0 4.88513 0.00771184 4.79757C0.0483059 4.33665 0.341025 3.76395 0.690821 3.46107C0.757274 3.40353 0.783996 3.38422 0.837439 3.34559C2.40699 2.21129 6.03888 0 10.5 0C14.9611 0 18.593 2.21129 20.1626 3.34559C20.216 3.38422 20.2427 3.40353 20.3092 3.46107C20.659 3.76395 20.9517 4.33665 20.9923 4.79757C21 4.88513 21 4.94513 21 5.06511C21 6.01683 21 6.4927 20.9657 6.6754C20.7241 7.96423 19.8033 8.55941 18.5289 8.25054C18.3483 8.20676 17.8198 7.96876 16.7627 7.49275C14.975 6.68767 12.7805 6 10.5 6C8.21954 6 6.02504 6.68767 4.23727 7.49275C3.18025 7.96876 2.65174 8.20676 2.47108 8.25054C1.19668 8.55941 0.275917 7.96423 0.0342566 6.6754C0 6.4927 0 6.01683 0 5.06511Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t\t<path\n\t\t\td=\"M42 5.06511C42 4.94513 42 4.88513 42.0077 4.79757C42.0483 4.33665 42.341 3.76395 42.6908 3.46107C42.7573 3.40353 42.784 3.38422 42.8374 3.34559C44.407 2.21129 48.0389 0 52.5 0C56.9611 0 60.593 2.21129 62.1626 3.34559C62.216 3.38422 62.2427 3.40353 62.3092 3.46107C62.659 3.76395 62.9517 4.33665 62.9923 4.79757C63 4.88513 63 4.94513 63 5.06511C63 6.01683 63 6.4927 62.9657 6.6754C62.7241 7.96423 61.8033 8.55941 60.5289 8.25054C60.3483 8.20676 59.8198 7.96876 58.7627 7.49275C56.975 6.68767 54.7805 6 52.5 6C50.2195 6 48.025 6.68767 46.2373 7.49275C45.1802 7.96876 44.6517 8.20676 44.4711 8.25054C43.1967 8.55941 42.2759 7.96423 42.0343 6.6754C42 6.4927 42 6.01683 42 5.06511Z\"\n\t\t\tfill=\"currentColor\"\n\t\t/>\n\t</svg>\n);\n\n/**\n * All available face components\n */\nexport const FACES = [RoundFace, CrossFace, LineFace, CurvedFace] as const;\n\nexport type FaceComponent = (typeof FACES)[number];\n","/**\n * Generates a consistent numeric hash from a string.\n * Used to deterministically select faces and colors for avatars.\n *\n * @param str - The input string to hash\n * @returns A positive 32-bit integer hash\n */\nexport function stringHash(str: string): number {\n\tlet hash = 0;\n\tfor (let i = 0; i < str.length; i++) {\n\t\tconst char = str.charCodeAt(i);\n\t\thash = (hash << 5) - hash + char;\n\t\thash &= hash; // Convert to 32bit integer\n\t}\n\treturn Math.abs(hash);\n}\n","import * as React from \"react\";\nimport { FACES } from \"./faces\";\nimport { stringHash } from \"./utils/hash\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type Intensity3D = \"none\" | \"subtle\" | \"medium\" | \"dramatic\";\nexport type Variant = \"gradient\" | \"solid\";\n\nexport interface FacehashProps\n\textends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n\t/**\n\t * String to generate a deterministic face from.\n\t * Same string always produces the same face.\n\t */\n\tname: string;\n\n\t/**\n\t * Size in pixels or CSS units.\n\t * @default 40\n\t */\n\tsize?: number | string;\n\n\t/**\n\t * Background style.\n\t * - \"gradient\": Adds gradient overlay (default)\n\t * - \"solid\": Plain background color\n\t * @default \"gradient\"\n\t */\n\tvariant?: Variant;\n\n\t/**\n\t * 3D effect intensity.\n\t * @default \"dramatic\"\n\t */\n\tintensity3d?: Intensity3D;\n\n\t/**\n\t * Enable hover interaction.\n\t * When true, face \"looks straight\" on hover.\n\t * @default true\n\t */\n\tinteractive?: boolean;\n\n\t/**\n\t * Show first letter of name below the face.\n\t * @default true\n\t */\n\tshowInitial?: boolean;\n\n\t/**\n\t * Hex color array for inline styles.\n\t * Use this OR colorClasses, not both.\n\t */\n\tcolors?: string[];\n\n\t/**\n\t * Tailwind class array for background colors.\n\t * Example: [\"bg-pink-500 dark:bg-pink-600\", \"bg-blue-500 dark:bg-blue-600\"]\n\t * Use this OR colors, not both.\n\t */\n\tcolorClasses?: string[];\n\n\t/**\n\t * Custom gradient overlay class (Tailwind).\n\t * When provided, replaces the default pure CSS gradient.\n\t * Only used when variant=\"gradient\".\n\t */\n\tgradientOverlayClass?: string;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nconst INTENSITY_PRESETS = {\n\tnone: {\n\t\trotateRange: 0,\n\t\ttranslateZ: 0,\n\t\tperspective: \"none\",\n\t},\n\tsubtle: {\n\t\trotateRange: 5,\n\t\ttranslateZ: 4,\n\t\tperspective: \"800px\",\n\t},\n\tmedium: {\n\t\trotateRange: 10,\n\t\ttranslateZ: 8,\n\t\tperspective: \"500px\",\n\t},\n\tdramatic: {\n\t\trotateRange: 15,\n\t\ttranslateZ: 12,\n\t\tperspective: \"300px\",\n\t},\n} as const;\n\nconst SPHERE_POSITIONS = [\n\t{ x: -1, y: 1 }, // down-right\n\t{ x: 1, y: 1 }, // up-right\n\t{ x: 1, y: 0 }, // up\n\t{ x: 0, y: 1 }, // right\n\t{ x: -1, y: 0 }, // down\n\t{ x: 0, y: 0 }, // center\n\t{ x: 0, y: -1 }, // left\n\t{ x: -1, y: -1 }, // down-left\n\t{ x: 1, y: -1 }, // up-left\n] as const;\n\n// Default gradient as pure CSS (works without Tailwind)\n// Matches: bg-[radial-gradient(ellipse_100%_100%_at_50%_50%,_COLOR_0%,_transparent_60%)]\n// Light mode: white glow in center, Dark mode: dark overlay in center\nconst DEFAULT_GRADIENT_STYLE: React.CSSProperties = {\n\tbackground:\n\t\t\"radial-gradient(ellipse 100% 100% at 50% 50%, rgba(255,255,255,0.15) 0%, transparent 60%)\",\n};\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Facehash - Deterministic avatar faces from any string.\n *\n * @example\n * ```tsx\n * // With Tailwind classes\n * <Facehash\n * name=\"John\"\n * colorClasses={[\"bg-pink-500\", \"bg-blue-500\"]}\n * />\n *\n * // With hex colors\n * <Facehash\n * name=\"John\"\n * colors={[\"#ec4899\", \"#3b82f6\"]}\n * />\n *\n * // Plain color (no gradient)\n * <Facehash name=\"John\" variant=\"solid\" />\n * ```\n */\nexport const Facehash = React.forwardRef<HTMLDivElement, FacehashProps>(\n\t(\n\t\t{\n\t\t\tname,\n\t\t\tsize = 40,\n\t\t\tvariant = \"gradient\",\n\t\t\tintensity3d = \"dramatic\",\n\t\t\tinteractive = true,\n\t\t\tshowInitial = true,\n\t\t\tcolors,\n\t\t\tcolorClasses,\n\t\t\tgradientOverlayClass,\n\t\t\tclassName,\n\t\t\tstyle,\n\t\t\tonMouseEnter,\n\t\t\tonMouseLeave,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst [isHovered, setIsHovered] = React.useState(false);\n\n\t\t// Generate deterministic values from name\n\t\tconst { FaceComponent, colorIndex, rotation } = React.useMemo(() => {\n\t\t\tconst hash = stringHash(name);\n\t\t\tconst faceIndex = hash % FACES.length;\n\t\t\tconst colorsLength = colorClasses?.length ?? colors?.length ?? 1;\n\t\t\tconst _colorIndex = hash % colorsLength;\n\t\t\tconst positionIndex = hash % SPHERE_POSITIONS.length;\n\t\t\tconst position = SPHERE_POSITIONS[positionIndex] ?? { x: 0, y: 0 };\n\n\t\t\treturn {\n\t\t\t\tFaceComponent: FACES[faceIndex] ?? FACES[0],\n\t\t\t\tcolorIndex: _colorIndex,\n\t\t\t\trotation: position,\n\t\t\t};\n\t\t}, [name, colors?.length, colorClasses?.length]);\n\n\t\t// Get intensity preset\n\t\tconst preset = INTENSITY_PRESETS[intensity3d];\n\n\t\t// Calculate 3D transform\n\t\tconst transform = React.useMemo(() => {\n\t\t\tif (intensity3d === \"none\") {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst rotateX =\n\t\t\t\tisHovered && interactive ? 0 : rotation.x * preset.rotateRange;\n\t\t\tconst rotateY =\n\t\t\t\tisHovered && interactive ? 0 : rotation.y * preset.rotateRange;\n\n\t\t\treturn `rotateX(${rotateX}deg) rotateY(${rotateY}deg) translateZ(${preset.translateZ}px)`;\n\t\t}, [intensity3d, isHovered, interactive, rotation, preset]);\n\n\t\t// Size style\n\t\tconst sizeValue = typeof size === \"number\" ? `${size}px` : size;\n\n\t\t// Initial letter\n\t\tconst initial = name.charAt(0).toUpperCase();\n\n\t\t// Background: either hex color (inline) or class\n\t\tconst bgColorClass = colorClasses?.[colorIndex];\n\t\tconst bgColorHex = colors?.[colorIndex];\n\n\t\t// Event handlers\n\t\tconst handleMouseEnter = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLDivElement>) => {\n\t\t\t\tif (interactive) {\n\t\t\t\t\tsetIsHovered(true);\n\t\t\t\t}\n\t\t\t\tonMouseEnter?.(e);\n\t\t\t},\n\t\t\t[interactive, onMouseEnter]\n\t\t);\n\n\t\tconst handleMouseLeave = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLDivElement>) => {\n\t\t\t\tif (interactive) {\n\t\t\t\t\tsetIsHovered(false);\n\t\t\t\t}\n\t\t\t\tonMouseLeave?.(e);\n\t\t\t},\n\t\t\t[interactive, onMouseLeave]\n\t\t);\n\n\t\treturn (\n\t\t\t// biome-ignore lint/a11y/noNoninteractiveElementInteractions: Hover effect is purely cosmetic\n\t\t\t// biome-ignore lint/a11y/noStaticElementInteractions: This is a decorative avatar component\n\t\t\t<div\n\t\t\t\tclassName={[bgColorClass, className].filter(Boolean).join(\" \")}\n\t\t\t\tdata-facehash=\"\"\n\t\t\t\tdata-interactive={interactive || undefined}\n\t\t\t\tonMouseEnter={handleMouseEnter}\n\t\t\t\tonMouseLeave={handleMouseLeave}\n\t\t\t\tref={ref}\n\t\t\t\tstyle={{\n\t\t\t\t\t// Size\n\t\t\t\t\twidth: sizeValue,\n\t\t\t\t\theight: sizeValue,\n\t\t\t\t\t// Layout\n\t\t\t\t\tposition: \"relative\",\n\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\tjustifyContent: \"center\",\n\t\t\t\t\toverflow: \"hidden\",\n\t\t\t\t\t// Container for cqw units\n\t\t\t\t\tcontainerType: \"size\",\n\t\t\t\t\t// 3D setup\n\t\t\t\t\t...(intensity3d !== \"none\" && {\n\t\t\t\t\t\tperspective: preset.perspective,\n\t\t\t\t\t\ttransformStyle: \"preserve-3d\",\n\t\t\t\t\t}),\n\t\t\t\t\t// Background color (hex) - only if no colorClasses\n\t\t\t\t\t...(bgColorHex && !bgColorClass && { backgroundColor: bgColorHex }),\n\t\t\t\t\t// User styles (last to allow overrides)\n\t\t\t\t\t...style,\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{/* Gradient overlay */}\n\t\t\t\t{variant === \"gradient\" && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={gradientOverlayClass}\n\t\t\t\t\t\tdata-facehash-gradient=\"\"\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t\tinset: 0,\n\t\t\t\t\t\t\tpointerEvents: \"none\",\n\t\t\t\t\t\t\tzIndex: 1,\n\t\t\t\t\t\t\t// Use default pure CSS gradient if no class provided\n\t\t\t\t\t\t\t...(gradientOverlayClass ? {} : DEFAULT_GRADIENT_STYLE),\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t{/* Face container with 3D transform */}\n\t\t\t\t<div\n\t\t\t\t\tdata-facehash-face=\"\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\tinset: 0,\n\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\tflexDirection: \"column\",\n\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\tjustifyContent: \"center\",\n\t\t\t\t\t\tzIndex: 2,\n\t\t\t\t\t\ttransform,\n\t\t\t\t\t\ttransformStyle: intensity3d !== \"none\" ? \"preserve-3d\" : undefined,\n\t\t\t\t\t\ttransition: interactive\n\t\t\t\t\t\t\t? \"transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)\"\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t// Default to black text/icons for contrast on colored backgrounds\n\t\t\t\t\t\tcolor: \"#000000\",\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{/* Face SVG */}\n\t\t\t\t\t<FaceComponent\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\twidth: \"60%\",\n\t\t\t\t\t\t\theight: \"auto\",\n\t\t\t\t\t\t\tmaxWidth: \"90%\",\n\t\t\t\t\t\t\tmaxHeight: \"40%\",\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{/* Initial letter */}\n\t\t\t\t\t{showInitial && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tdata-facehash-initial=\"\"\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\tmarginTop: \"8%\",\n\t\t\t\t\t\t\t\tfontSize: \"26cqw\",\n\t\t\t\t\t\t\t\tlineHeight: 1,\n\t\t\t\t\t\t\t\tfontFamily: \"monospace\",\n\t\t\t\t\t\t\t\tfontWeight: \"bold\",\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{initial}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nFacehash.displayName = \"Facehash\";\n","import * as React from \"react\";\n\ntype ImageLoadingStatus = \"idle\" | \"loading\" | \"loaded\" | \"error\";\n\nexport type AvatarContextValue = {\n\timageLoadingStatus: ImageLoadingStatus;\n\tonImageLoadingStatusChange: (status: ImageLoadingStatus) => void;\n};\n\nconst AvatarContext = React.createContext<AvatarContextValue | null>(null);\n\n/**\n * Hook to access the Avatar context.\n * Throws an error if used outside of Avatar.\n */\nexport const useAvatarContext = () => {\n\tconst context = React.useContext(AvatarContext);\n\tif (!context) {\n\t\tthrow new Error(\n\t\t\t\"Avatar compound components must be rendered within an Avatar component\"\n\t\t);\n\t}\n\treturn context;\n};\n\nexport type AvatarProps = React.HTMLAttributes<HTMLSpanElement> & {\n\t/**\n\t * Render as a different element using the asChild pattern.\n\t * When true, Avatar renders its child and merges props.\n\t */\n\tasChild?: boolean;\n};\n\n/**\n * Root avatar component that provides context for image loading state.\n *\n * @example\n * ```tsx\n * <Avatar className=\"w-10 h-10 rounded-full overflow-hidden\">\n * <AvatarImage src=\"/photo.jpg\" alt=\"John\" />\n * <AvatarFallback name=\"John Doe\" />\n * </Avatar>\n * ```\n */\nexport const Avatar = React.forwardRef<HTMLSpanElement, AvatarProps>(\n\t({ children, className, style, asChild = false, ...props }, ref) => {\n\t\tconst [imageLoadingStatus, setImageLoadingStatus] =\n\t\t\tReact.useState<ImageLoadingStatus>(\"idle\");\n\n\t\tconst contextValue: AvatarContextValue = React.useMemo(\n\t\t\t() => ({\n\t\t\t\timageLoadingStatus,\n\t\t\t\tonImageLoadingStatusChange: setImageLoadingStatus,\n\t\t\t}),\n\t\t\t[imageLoadingStatus]\n\t\t);\n\n\t\tconst Element = asChild ? React.Fragment : \"span\";\n\t\tconst elementProps = asChild\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tref,\n\t\t\t\t\tclassName,\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\tposition: \"relative\" as const,\n\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\tjustifyContent: \"center\",\n\t\t\t\t\t\tflexShrink: 0,\n\t\t\t\t\t\toverflow: \"hidden\",\n\t\t\t\t\t\t...style,\n\t\t\t\t\t},\n\t\t\t\t\t\"data-avatar\": \"\",\n\t\t\t\t\t\"data-state\": imageLoadingStatus,\n\t\t\t\t\t...props,\n\t\t\t\t};\n\n\t\treturn (\n\t\t\t<AvatarContext.Provider value={contextValue}>\n\t\t\t\t<Element {...elementProps}>{children}</Element>\n\t\t\t</AvatarContext.Provider>\n\t\t);\n\t}\n);\n\nAvatar.displayName = \"Avatar\";\n","import * as React from \"react\";\nimport { useAvatarContext } from \"./avatar\";\nimport { Facehash, type FacehashProps } from \"./facehash\";\n\nconst WHITESPACE_REGEX = /\\s+/;\n\nexport type AvatarFallbackProps = Omit<\n\tReact.HTMLAttributes<HTMLSpanElement>,\n\t\"children\"\n> & {\n\t/**\n\t * The name to derive initials and Facehash from.\n\t */\n\tname?: string;\n\n\t/**\n\t * Delay in milliseconds before showing the fallback.\n\t * Useful to prevent flashing when images load quickly.\n\t * @default 0\n\t */\n\tdelayMs?: number;\n\n\t/**\n\t * Custom children to render instead of initials or Facehash.\n\t */\n\tchildren?: React.ReactNode;\n\n\t/**\n\t * Use the Facehash component as fallback instead of initials.\n\t * @default true\n\t */\n\tfacehash?: boolean;\n\n\t/**\n\t * Props to pass to the Facehash component.\n\t */\n\tfacehashProps?: Omit<FacehashProps, \"name\">;\n};\n\n/**\n * Extracts initials from a name string.\n */\nfunction getInitials(name: string): string {\n\tconst parts = name.trim().split(WHITESPACE_REGEX);\n\tif (parts.length === 0) {\n\t\treturn \"\";\n\t}\n\tif (parts.length === 1) {\n\t\treturn parts[0]?.charAt(0).toUpperCase() || \"\";\n\t}\n\n\tconst firstInitial = parts[0]?.charAt(0) || \"\";\n\tconst lastInitial = parts.at(-1)?.charAt(0) || \"\";\n\treturn (firstInitial + lastInitial).toUpperCase();\n}\n\n/**\n * Fallback component that displays when the image fails to load.\n * Uses Facehash by default, can show initials or custom content.\n *\n * @example\n * ```tsx\n * // With Facehash (default)\n * <AvatarFallback name=\"John Doe\" />\n *\n * // With initials\n * <AvatarFallback name=\"John Doe\" facehash={false} />\n *\n * // With custom content\n * <AvatarFallback>\n * <UserIcon />\n * </AvatarFallback>\n * ```\n */\nexport const AvatarFallback = React.forwardRef<\n\tHTMLSpanElement,\n\tAvatarFallbackProps\n>(\n\t(\n\t\t{\n\t\t\tname = \"\",\n\t\t\tdelayMs = 0,\n\t\t\tchildren,\n\t\t\tfacehash = true,\n\t\t\tfacehashProps,\n\t\t\tclassName,\n\t\t\tstyle,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst { imageLoadingStatus } = useAvatarContext();\n\t\tconst [canRender, setCanRender] = React.useState(delayMs === 0);\n\n\t\tReact.useEffect(() => {\n\t\t\tif (delayMs > 0) {\n\t\t\t\tconst timerId = window.setTimeout(() => setCanRender(true), delayMs);\n\t\t\t\treturn () => window.clearTimeout(timerId);\n\t\t\t}\n\t\t}, [delayMs]);\n\n\t\tconst initials = React.useMemo(() => getInitials(name), [name]);\n\n\t\tconst shouldRender =\n\t\t\tcanRender &&\n\t\t\timageLoadingStatus !== \"loaded\" &&\n\t\t\timageLoadingStatus !== \"loading\";\n\n\t\tif (!shouldRender) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Custom children take precedence\n\t\tif (children) {\n\t\t\treturn (\n\t\t\t\t<span\n\t\t\t\t\tclassName={className}\n\t\t\t\t\tdata-avatar-fallback=\"\"\n\t\t\t\t\tref={ref}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\t\tjustifyContent: \"center\",\n\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\theight: \"100%\",\n\t\t\t\t\t\t...style,\n\t\t\t\t\t}}\n\t\t\t\t\t{...props}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</span>\n\t\t\t);\n\t\t}\n\n\t\t// Facehash mode (default)\n\t\tif (facehash) {\n\t\t\treturn (\n\t\t\t\t<Facehash\n\t\t\t\t\tclassName={className}\n\t\t\t\t\tdata-avatar-fallback=\"\"\n\t\t\t\t\tname={name}\n\t\t\t\t\tref={ref as React.Ref<HTMLDivElement>}\n\t\t\t\t\tsize=\"100%\"\n\t\t\t\t\t{...facehashProps}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\t...style,\n\t\t\t\t\t}}\n\t\t\t\t\t{...props}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\t// Initials mode\n\t\treturn (\n\t\t\t<span\n\t\t\t\tclassName={className}\n\t\t\t\tdata-avatar-fallback=\"\"\n\t\t\t\tref={ref}\n\t\t\t\tstyle={{\n\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\talignItems: \"center\",\n\t\t\t\t\tjustifyContent: \"center\",\n\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\theight: \"100%\",\n\t\t\t\t\t...style,\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{initials}\n\t\t\t</span>\n\t\t);\n\t}\n);\n\nAvatarFallback.displayName = \"AvatarFallback\";\n","import * as React from \"react\";\nimport { useAvatarContext } from \"./avatar\";\n\ntype ImageLoadingStatus = \"idle\" | \"loading\" | \"loaded\" | \"error\";\n\nexport type AvatarImageProps = Omit<\n\tReact.ImgHTMLAttributes<HTMLImageElement>,\n\t\"src\"\n> & {\n\t/**\n\t * The image source URL. If empty or undefined, triggers error state.\n\t */\n\tsrc?: string | null;\n\n\t/**\n\t * Callback when the image loading status changes.\n\t */\n\tonLoadingStatusChange?: (status: ImageLoadingStatus) => void;\n};\n\n/**\n * Image component that syncs its loading state with the Avatar context.\n * Automatically hides when loading fails, allowing fallback to show.\n *\n * @example\n * ```tsx\n * <Avatar>\n * <AvatarImage src=\"/photo.jpg\" alt=\"User\" />\n * <AvatarFallback name=\"John Doe\" />\n * </Avatar>\n * ```\n */\nexport const AvatarImage = React.forwardRef<HTMLImageElement, AvatarImageProps>(\n\t(\n\t\t{ src, alt = \"\", className, style, onLoadingStatusChange, ...props },\n\t\tref\n\t) => {\n\t\tconst { imageLoadingStatus, onImageLoadingStatusChange } =\n\t\t\tuseAvatarContext();\n\n\t\tconst imageRef = React.useRef<HTMLImageElement>(null);\n\t\t// biome-ignore lint/style/noNonNullAssertion: ref is guaranteed to be set\n\t\tReact.useImperativeHandle(ref, () => imageRef.current!);\n\n\t\tconst updateStatus = React.useCallback(\n\t\t\t(status: ImageLoadingStatus) => {\n\t\t\t\tonImageLoadingStatusChange(status);\n\t\t\t\tonLoadingStatusChange?.(status);\n\t\t\t},\n\t\t\t[onImageLoadingStatusChange, onLoadingStatusChange]\n\t\t);\n\n\t\tReact.useLayoutEffect(() => {\n\t\t\tif (!src) {\n\t\t\t\tupdateStatus(\"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet isMounted = true;\n\t\t\tconst image = new Image();\n\n\t\t\tconst setStatus = (status: ImageLoadingStatus) => {\n\t\t\t\tif (!isMounted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tupdateStatus(status);\n\t\t\t};\n\n\t\t\tsetStatus(\"loading\");\n\n\t\t\timage.onload = () => setStatus(\"loaded\");\n\t\t\timage.onerror = () => setStatus(\"error\");\n\t\t\timage.src = src;\n\n\t\t\treturn () => {\n\t\t\t\tisMounted = false;\n\t\t\t};\n\t\t}, [src, updateStatus]);\n\n\t\tif (imageLoadingStatus !== \"loaded\") {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t// biome-ignore lint/performance/noImgElement: This is a library component, not a Next.js app\n\t\t\t// biome-ignore lint/nursery/useImageSize: Size is controlled by parent container\n\t\t\t<img\n\t\t\t\talt={alt}\n\t\t\t\tclassName={className}\n\t\t\t\tdata-avatar-image=\"\"\n\t\t\t\tref={imageRef}\n\t\t\t\tsrc={src ?? undefined}\n\t\t\t\tstyle={{\n\t\t\t\t\taspectRatio: \"1 / 1\",\n\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\theight: \"100%\",\n\t\t\t\t\tobjectFit: \"cover\",\n\t\t\t\t\t...style,\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t}\n);\n\nAvatarImage.displayName = \"AvatarImage\";\n"],"mappings":";;;;;;;AAUA,MAAaA,aAAkC,EAAE,WAAW,YAC3D,qBAAC;CACA,eAAY;CACD;CACX,MAAK;CACE;CACP,SAAQ;CACR,OAAM;;EAEN,oBAAC,qBAAM,eAAkB;EACzB,oBAAC;GACA,GAAE;GACF,MAAK;IACJ;EACF,oBAAC;GACA,GAAE;GACF,MAAK;IACJ;;EACG;;;;AAMP,MAAaC,aAAkC,EAAE,WAAW,YAC3D,qBAAC;CACA,eAAY;CACD;CACX,MAAK;CACE;CACP,SAAQ;CACR,OAAM;;EAEN,oBAAC,qBAAM,eAAkB;EACzB,oBAAC;GACA,GAAE;GACF,MAAK;IACJ;EACF,oBAAC;GACA,GAAE;GACF,MAAK;IACJ;;EACG;;;;AAMP,MAAaC,YAAiC,EAAE,WAAW,YAC1D,qBAAC;CACA,eAAY;CACD;CACX,MAAK;CACE;CACP,SAAQ;CACR,OAAM;;EAEN,oBAAC,qBAAM,cAAiB;EACxB,oBAAC;GACA,GAAE;GACF,MAAK;IACJ;EACF,oBAAC;GAC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,aAAa,CAAC;AAEvB,KAAI,uBAAuB,SAC1B,QAAO;AAGR,QAGC,oBAAC;EACK;EACM;EACX,qBAAkB;EAClB,KAAK;EACL,KAAK,OAAO;EACZ,OAAO;GACN,aAAa;GACb,OAAO;GACP,QAAQ;GACR,WAAW;GACX,GAAG;GACH;EACD,GAAI;GACH;EAGJ;AAED,YAAY,cAAc"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "facehash",
3
+ "type": "module",
4
+ "version": "0.0.2",
5
+ "private": false,
6
+ "author": "Cossistant team",
7
+ "description": "Deterministic avatar faces from any string. Lightweight, interactive, pure CSS. Works with any framework.",
8
+ "keywords": [
9
+ "facehash",
10
+ "avatar",
11
+ "react",
12
+ "react-avatar",
13
+ "deterministic",
14
+ "generative",
15
+ "profile-picture",
16
+ "profile-avatar",
17
+ "identicon",
18
+ "hash",
19
+ "face",
20
+ "3d",
21
+ "interactive",
22
+ "gradient",
23
+ "typescript",
24
+ "accessible",
25
+ "headless",
26
+ "unstyled",
27
+ "css",
28
+ "tailwind",
29
+ "boring-avatars",
30
+ "dicebear",
31
+ "jdenticon",
32
+ "gravatar-alternative",
33
+ "user-avatar",
34
+ "default-avatar"
35
+ ],
36
+ "bugs": {
37
+ "url": "https://github.com/cossistantcom/cossistant/issues"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/cossistantcom/cossistant.git",
42
+ "directory": "packages/facehash"
43
+ },
44
+ "license": "MIT",
45
+ "homepage": "https://cossistant.com",
46
+ "exports": {
47
+ ".": {
48
+ "types": "./index.d.ts",
49
+ "import": "./index.js"
50
+ }
51
+ },
52
+ "main": "./index.js",
53
+ "module": "./index.js",
54
+ "types": "./index.d.ts",
55
+ "peerDependencies": {
56
+ "react": ">=18 <20",
57
+ "react-dom": ">=18 <20",
58
+ "@types/react": ""
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "@types/react": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "publishConfig": {
66
+ "access": "public"
67
+ }
68
+ }