@wow-two-beta/ui 0.0.39 → 0.0.41

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.
@@ -148,7 +148,7 @@ Image.displayName = "Image";
148
148
 
149
149
  // src/display/avatar/Avatar.variants.ts
150
150
  var avatarVariants = tv({
151
- base: "inline-flex shrink-0 select-none items-center justify-center overflow-hidden rounded-full bg-muted text-muted-foreground font-medium",
151
+ base: "inline-flex shrink-0 select-none items-center justify-center overflow-hidden font-medium",
152
152
  variants: {
153
153
  size: {
154
154
  xs: "h-6 w-6 text-xs",
@@ -161,13 +161,81 @@ var avatarVariants = tv({
161
161
  shape: {
162
162
  circle: "rounded-full",
163
163
  square: "rounded-md"
164
+ },
165
+ tone: {
166
+ // 'none' is used when autoColor takes over — prevents theme tokens from competing in the cascade.
167
+ none: "",
168
+ neutral: "bg-muted text-muted-foreground",
169
+ primary: "bg-primary-soft text-primary-soft-foreground",
170
+ danger: "bg-destructive-soft text-destructive-soft-foreground",
171
+ success: "bg-success-soft text-success-soft-foreground",
172
+ warning: "bg-warning-soft text-warning-soft-foreground"
173
+ },
174
+ bgStyle: {
175
+ solid: "",
176
+ // Gradient class composed in compoundVariants × tone.
177
+ gradient: ""
178
+ },
179
+ ring: {
180
+ none: "",
181
+ neutral: "ring-2 ring-offset-2 ring-border ring-offset-background",
182
+ primary: "ring-2 ring-offset-2 ring-primary ring-offset-background",
183
+ danger: "ring-2 ring-offset-2 ring-destructive ring-offset-background",
184
+ success: "ring-2 ring-offset-2 ring-success ring-offset-background",
185
+ warning: "ring-2 ring-offset-2 ring-warning ring-offset-background"
186
+ },
187
+ isLoading: {
188
+ true: "animate-pulse !bg-muted text-transparent",
189
+ false: ""
164
190
  }
165
191
  },
192
+ compoundVariants: [
193
+ // gradient × tone
194
+ { bgStyle: "gradient", tone: "neutral", class: "bg-gradient-to-br from-muted to-muted/40" },
195
+ { bgStyle: "gradient", tone: "primary", class: "bg-gradient-to-br from-primary-soft to-primary text-primary-foreground" },
196
+ { bgStyle: "gradient", tone: "danger", class: "bg-gradient-to-br from-destructive-soft to-destructive text-destructive-foreground" },
197
+ { bgStyle: "gradient", tone: "success", class: "bg-gradient-to-br from-success-soft to-success text-success-foreground" },
198
+ { bgStyle: "gradient", tone: "warning", class: "bg-gradient-to-br from-warning-soft to-warning text-warning-foreground" }
199
+ ],
166
200
  defaultVariants: {
167
201
  size: "md",
168
- shape: "circle"
202
+ shape: "circle",
203
+ tone: "neutral",
204
+ bgStyle: "solid",
205
+ ring: "none",
206
+ isLoading: false
169
207
  }
170
208
  });
209
+ var COMPONENT_NAME = "Avatar";
210
+ var AUTO_COLOR_PALETTE = [
211
+ "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100",
212
+ "bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-100",
213
+ "bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-100",
214
+ "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100",
215
+ "bg-lime-100 text-lime-800 dark:bg-lime-900 dark:text-lime-100",
216
+ "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100",
217
+ "bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-100",
218
+ "bg-teal-100 text-teal-800 dark:bg-teal-900 dark:text-teal-100",
219
+ "bg-cyan-100 text-cyan-800 dark:bg-cyan-900 dark:text-cyan-100",
220
+ "bg-sky-100 text-sky-800 dark:bg-sky-900 dark:text-sky-100",
221
+ "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-100",
222
+ "bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-100",
223
+ "bg-violet-100 text-violet-800 dark:bg-violet-900 dark:text-violet-100",
224
+ "bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-100",
225
+ "bg-fuchsia-100 text-fuchsia-800 dark:bg-fuchsia-900 dark:text-fuchsia-100",
226
+ "bg-pink-100 text-pink-800 dark:bg-pink-900 dark:text-pink-100",
227
+ "bg-rose-100 text-rose-800 dark:bg-rose-900 dark:text-rose-100"
228
+ ];
229
+ function hashName(name) {
230
+ let h = 0;
231
+ for (let i = 0; i < name.length; i++) {
232
+ h = h * 31 + name.charCodeAt(i) | 0;
233
+ }
234
+ return Math.abs(h);
235
+ }
236
+ function pickAutoColor(name) {
237
+ return AUTO_COLOR_PALETTE[hashName(name) % AUTO_COLOR_PALETTE.length];
238
+ }
171
239
  function getInitials(name) {
172
240
  const parts = name.trim().split(/\s+/);
173
241
  if (parts.length === 0) return "";
@@ -176,14 +244,36 @@ function getInitials(name) {
176
244
  return (first + last).toUpperCase();
177
245
  }
178
246
  var Avatar = forwardRef(
179
- ({ src, name = "", fallback, alt, className, size, shape, ...props }, ref) => {
247
+ ({
248
+ src,
249
+ name = "",
250
+ fallback,
251
+ alt,
252
+ autoColor,
253
+ tone,
254
+ bgStyle,
255
+ ring,
256
+ isLoading,
257
+ size,
258
+ shape,
259
+ className,
260
+ ...props
261
+ }, ref) => {
180
262
  const [errored, setErrored] = useState(false);
181
- const showImage = src && !errored;
263
+ const showImage = !!src && !errored && !isLoading;
264
+ const autoColorClass = autoColor && name && bgStyle !== "gradient" && (tone === void 0 || tone === "neutral") ? pickAutoColor(name) : void 0;
265
+ const effectiveTone = autoColorClass ? "none" : tone;
182
266
  return /* @__PURE__ */ jsx(
183
267
  "span",
184
268
  {
185
269
  ref,
186
- className: cn(avatarVariants({ size, shape }), className),
270
+ className: cn(
271
+ avatarVariants({ size, shape, tone: effectiveTone, bgStyle, ring, isLoading }),
272
+ autoColorClass,
273
+ className
274
+ ),
275
+ "data-loading": isLoading ? "true" : void 0,
276
+ "aria-busy": isLoading ? true : void 0,
187
277
  ...props,
188
278
  children: showImage ? /* @__PURE__ */ jsx(
189
279
  "img",
@@ -198,7 +288,7 @@ var Avatar = forwardRef(
198
288
  );
199
289
  }
200
290
  );
201
- Avatar.displayName = "Avatar";
291
+ Avatar.displayName = COMPONENT_NAME;
202
292
 
203
293
  // src/display/badge/Badge.variants.ts
204
294
  var badgeVariants = tv({
@@ -5456,5 +5546,5 @@ var ActivityFeed = ActivityFeedInner;
5456
5546
  ActivityFeed.Item = ActivityItem;
5457
5547
 
5458
5548
  export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActivityFeed, ActivityItem, AnimatedNumber, AnnotationMarker, AudioPlayer, AudioWaveform, Avatar, AvatarGroup, Badge, BadgeOverlay, Card, Carousel, CarouselDot, CarouselDots, CarouselNext, CarouselPrev, CarouselSlide, CarouselSlides, CarouselViewport, ChatBubble, Code, Collapsible, CollapsibleContent, CollapsibleTrigger, Comment, CommentThread, Confetti, CountBadge, CountUp, DataGrid, DataTable, DaySeparator, DescriptionList, DiffViewer, EmptyState, EventCalendar, Gantt, GradientText, Heading, HeatmapCalendar, Highlight, Image, InfoRow, KeyboardShortcut, List, ListItem, Mark, Marquee, MessageList, NodeEditor, NotificationDot, PDFViewer, Quote, ReactionBar, ScheduleView, ScrollReveal, SectionHeader, Separator, Snippet, Sparkline, Stat, Status, SwipeActions, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeaderCell, TableRow, Tabs, TabsList, TabsPanel, TabsTab, Text, ThreadView, Tilt, Timeline, TimelineDescription, TimelineItem, TimelineTitle, Tooltip, Tree, TreeGroup, TreeItem, Typewriter, VideoPlayer, avatarVariants, badgeVariants, codeVariants, headingVariants, textVariants };
5459
- //# sourceMappingURL=chunk-6QEYZJGE.js.map
5460
- //# sourceMappingURL=chunk-6QEYZJGE.js.map
5549
+ //# sourceMappingURL=chunk-F6R2IOQV.js.map
5550
+ //# sourceMappingURL=chunk-F6R2IOQV.js.map