@wow-two-beta/ui 0.0.39 → 0.0.40

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,79 @@ var avatarVariants = tv({
161
161
  shape: {
162
162
  circle: "rounded-full",
163
163
  square: "rounded-md"
164
+ },
165
+ tone: {
166
+ neutral: "bg-muted text-muted-foreground",
167
+ primary: "bg-primary-soft text-primary-soft-foreground",
168
+ danger: "bg-destructive-soft text-destructive-soft-foreground",
169
+ success: "bg-success-soft text-success-soft-foreground",
170
+ warning: "bg-warning-soft text-warning-soft-foreground"
171
+ },
172
+ bgStyle: {
173
+ solid: "",
174
+ // Gradient class composed in compoundVariants × tone.
175
+ gradient: ""
176
+ },
177
+ ring: {
178
+ none: "",
179
+ neutral: "ring-2 ring-offset-2 ring-border ring-offset-background",
180
+ primary: "ring-2 ring-offset-2 ring-primary ring-offset-background",
181
+ danger: "ring-2 ring-offset-2 ring-destructive ring-offset-background",
182
+ success: "ring-2 ring-offset-2 ring-success ring-offset-background",
183
+ warning: "ring-2 ring-offset-2 ring-warning ring-offset-background"
184
+ },
185
+ isLoading: {
186
+ true: "animate-pulse !bg-muted text-transparent",
187
+ false: ""
164
188
  }
165
189
  },
190
+ compoundVariants: [
191
+ // gradient × tone
192
+ { bgStyle: "gradient", tone: "neutral", class: "bg-gradient-to-br from-muted to-muted/40" },
193
+ { bgStyle: "gradient", tone: "primary", class: "bg-gradient-to-br from-primary-soft to-primary text-primary-foreground" },
194
+ { bgStyle: "gradient", tone: "danger", class: "bg-gradient-to-br from-destructive-soft to-destructive text-destructive-foreground" },
195
+ { bgStyle: "gradient", tone: "success", class: "bg-gradient-to-br from-success-soft to-success text-success-foreground" },
196
+ { bgStyle: "gradient", tone: "warning", class: "bg-gradient-to-br from-warning-soft to-warning text-warning-foreground" }
197
+ ],
166
198
  defaultVariants: {
167
199
  size: "md",
168
- shape: "circle"
200
+ shape: "circle",
201
+ tone: "neutral",
202
+ bgStyle: "solid",
203
+ ring: "none",
204
+ isLoading: false
169
205
  }
170
206
  });
207
+ var COMPONENT_NAME = "Avatar";
208
+ var AUTO_COLOR_PALETTE = [
209
+ "bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-200",
210
+ "bg-orange-100 text-orange-700 dark:bg-orange-900/40 dark:text-orange-200",
211
+ "bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-200",
212
+ "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-200",
213
+ "bg-lime-100 text-lime-700 dark:bg-lime-900/40 dark:text-lime-200",
214
+ "bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-200",
215
+ "bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-200",
216
+ "bg-teal-100 text-teal-700 dark:bg-teal-900/40 dark:text-teal-200",
217
+ "bg-cyan-100 text-cyan-700 dark:bg-cyan-900/40 dark:text-cyan-200",
218
+ "bg-sky-100 text-sky-700 dark:bg-sky-900/40 dark:text-sky-200",
219
+ "bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-200",
220
+ "bg-indigo-100 text-indigo-700 dark:bg-indigo-900/40 dark:text-indigo-200",
221
+ "bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-200",
222
+ "bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-200",
223
+ "bg-fuchsia-100 text-fuchsia-700 dark:bg-fuchsia-900/40 dark:text-fuchsia-200",
224
+ "bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-200",
225
+ "bg-rose-100 text-rose-700 dark:bg-rose-900/40 dark:text-rose-200"
226
+ ];
227
+ function hashName(name) {
228
+ let h = 0;
229
+ for (let i = 0; i < name.length; i++) {
230
+ h = h * 31 + name.charCodeAt(i) | 0;
231
+ }
232
+ return Math.abs(h);
233
+ }
234
+ function pickAutoColor(name) {
235
+ return AUTO_COLOR_PALETTE[hashName(name) % AUTO_COLOR_PALETTE.length];
236
+ }
171
237
  function getInitials(name) {
172
238
  const parts = name.trim().split(/\s+/);
173
239
  if (parts.length === 0) return "";
@@ -176,14 +242,35 @@ function getInitials(name) {
176
242
  return (first + last).toUpperCase();
177
243
  }
178
244
  var Avatar = forwardRef(
179
- ({ src, name = "", fallback, alt, className, size, shape, ...props }, ref) => {
245
+ ({
246
+ src,
247
+ name = "",
248
+ fallback,
249
+ alt,
250
+ autoColor,
251
+ tone,
252
+ bgStyle,
253
+ ring,
254
+ isLoading,
255
+ size,
256
+ shape,
257
+ className,
258
+ ...props
259
+ }, ref) => {
180
260
  const [errored, setErrored] = useState(false);
181
- const showImage = src && !errored;
261
+ const showImage = !!src && !errored && !isLoading;
262
+ const autoColorClass = autoColor && name && bgStyle !== "gradient" && (tone === void 0 || tone === "neutral") ? pickAutoColor(name) : void 0;
182
263
  return /* @__PURE__ */ jsx(
183
264
  "span",
184
265
  {
185
266
  ref,
186
- className: cn(avatarVariants({ size, shape }), className),
267
+ className: cn(
268
+ avatarVariants({ size, shape, tone, bgStyle, ring, isLoading }),
269
+ autoColorClass,
270
+ className
271
+ ),
272
+ "data-loading": isLoading ? "true" : void 0,
273
+ "aria-busy": isLoading ? true : void 0,
187
274
  ...props,
188
275
  children: showImage ? /* @__PURE__ */ jsx(
189
276
  "img",
@@ -198,7 +285,7 @@ var Avatar = forwardRef(
198
285
  );
199
286
  }
200
287
  );
201
- Avatar.displayName = "Avatar";
288
+ Avatar.displayName = COMPONENT_NAME;
202
289
 
203
290
  // src/display/badge/Badge.variants.ts
204
291
  var badgeVariants = tv({
@@ -5456,5 +5543,5 @@ var ActivityFeed = ActivityFeedInner;
5456
5543
  ActivityFeed.Item = ActivityItem;
5457
5544
 
5458
5545
  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
5546
+ //# sourceMappingURL=chunk-Y34APXNX.js.map
5547
+ //# sourceMappingURL=chunk-Y34APXNX.js.map