@caqophony/ui 0.9.7 → 0.9.8

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 CHANGED
@@ -25,9 +25,11 @@ The package is ESM-only. Subpath types (`@caqophony/ui/charts`) resolve through
25
25
  the `exports` map, so TypeScript needs `moduleResolution` of `bundler` (or
26
26
  `node16`/`nodenext`).
27
27
 
28
- `DiceBearAvatar` renders an image from `api.dicebear.com` at runtime, so it
29
- makes a network request from the user's browser; do not use it where that is
30
- unacceptable.
28
+ `DiceBearAvatar` builds its SVG in the browser with DiceBear's own library
29
+ (`@dicebear/core` and one `@dicebear/<style>` package per style), so it makes
30
+ no request to `api.dicebear.com`. Each style is loaded only when an avatar of
31
+ that style is drawn. Some styles' artwork is licensed CC BY 4.0 and needs
32
+ credit; each style package's header names its licence.
31
33
 
32
34
  ## Styles (Tailwind v4)
33
35
 
package/dist/index.d.mts CHANGED
@@ -428,16 +428,22 @@ interface ConfirmDialogProps {
428
428
  }
429
429
  declare function ConfirmDialog({ title, message, confirmLabel, onConfirm, onCancel, isLoading, confirmTestId, cancelTestId, dialogTestId, cancelLabel, confirmVariant, className, error, }: ConfirmDialogProps): react_jsx_runtime.JSX.Element;
430
430
 
431
+ /**
432
+ * DiceBear avatars drawn in the app, with no request to a third-party host
433
+ * (#7507).
434
+ *
435
+ * Each style is its own package, loaded only when an avatar of that style is
436
+ * drawn, so a page that draws none loads none. `@dicebear/core` builds the
437
+ * SVG from the seed; the same seed and style always give the same image.
438
+ *
439
+ * Authored by Caqophony
440
+ */
431
441
  /** Supported DiceBear avatar styles */
432
442
  type DiceBearStyle = 'adventurer' | 'adventurer-neutral' | 'avataaars' | 'avataaars-neutral' | 'big-ears' | 'big-ears-neutral' | 'bottts' | 'bottts-neutral' | 'croodles' | 'croodles-neutral' | 'fun-emoji' | 'icons' | 'identicon' | 'initials' | 'lorelei' | 'lorelei-neutral' | 'micah' | 'miniavs' | 'notionists' | 'notionists-neutral' | 'open-peeps' | 'personas' | 'pixel-art' | 'pixel-art-neutral' | 'rings' | 'shapes' | 'thumbs';
443
+
433
444
  declare const avatarVariants: (props?: ({
434
445
  size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | null | undefined;
435
446
  } & class_variance_authority_types.ClassProp) | undefined) => string;
436
- /**
437
- * Build a DiceBear avatar URL from a seed and style.
438
- * Deterministic — same seed + style always produces the same avatar.
439
- */
440
- declare function buildDiceBearUrl(seed: string, style?: DiceBearStyle): string;
441
447
  interface DiceBearAvatarProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof avatarVariants> {
442
448
  /** Seed string for deterministic avatar generation (e.g. agent ID or name) */
443
449
  seed: string;
@@ -2316,4 +2322,4 @@ declare function cn(...inputs: ClassValue[]): string;
2316
2322
 
2317
2323
  declare function useDebounce<T>(value: T, ms: number): T;
2318
2324
 
2319
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionCard, type ActionCardProps, ActionPanel, type ActionPanelProps, ActivityFeed, ActivityFeedItem, type ActivityFeedItemProps, type ActivityFeedProps, Alert, type AlertProps, AppShell, type AppShellProps, AvatarGroup, AvatarGroupItem, type AvatarGroupItemProps, type AvatarGroupProps, Button, ButtonGroup, ButtonGroupItem, type ButtonGroupItemProps, type ButtonGroupProps, type ButtonProps, Calendar, type CalendarEvent, type CalendarProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroup, type CheckboxGroupOption, type CheckboxGroupProps, type CheckboxProps, ClampedList, type ClampedListProps, CollapsibleSidebar, Combobox, type ComboboxOption, type ComboboxProps, CommandPalette, type CommandPaletteProps, type CommandPaletteResult, ConfirmDialog, type ConfirmDialogProps, Container, type ContainerProps, DataTable, type DataTableProps, DatePicker, type DatePickerProps, DescriptionItem, type DescriptionItemProps, DescriptionList, type DescriptionListProps, DiceBearAvatar, type DiceBearAvatarProps, type DiceBearStyle, DistributionChip, type DistributionChipProps, Divider, type DividerProps, Drawer, DrawerBody, DrawerFooter, DrawerHeader, type DrawerProps, EMPTY_VALUE_GLYPH, EmptyState, type EmptyStateProps, EmptyValue, type EmptyValueProps, type FieldSize, FilterChip, type FilterChipProps, FormError, type FormErrorProps, FormField, FormFieldGroup, type FormFieldGroupProps, type FormFieldProps, FormLayout, type FormLayoutProps, FormLayoutSection, type FormLayoutSectionProps, FormSection, type FormSectionProps, FormSuccess, type FormSuccessProps, GlobalErrorContent, type GlobalErrorContentProps, GridList, GridListItem, type GridListItemProps, type GridListProps, HorizontalCard, type HorizontalCardProps, HoverCard, type HoverCardProps, INTENT_SUBTLE_STYLES, IconName, IconSize, ImageCard, type ImageCardProps, Input, InputGroup, type InputGroupProps, type InputProps, IntentBadge, type IntentBadgeIntent, type IntentBadgeProps, IntentIcon, type IntentIconProps, Label, type LabelProps, MediaObject, type MediaObjectProps, ModalBody, ModalDialog, type ModalDialogProps, ModalFooter, ModalHeader, type NavItem, Navbar, NavbarLink, type NavbarLinkProps, type NavbarProps, NotificationBanner, type NotificationBannerProps, NotificationPanel, NotificationPanelItem, type NotificationPanelItemProps, type NotificationPanelProps, OverflowMenu, type OverflowMenuItem, type OverflowMenuProps, PageContent, type PageContentProps, PageGutter, type PageGutterProps, PageHeading, type PageHeadingProps, Pagination, PaginationButton, type PaginationProps, Popover, type PopoverProps, Progress, type ProgressIntent, type ProgressProps, RadioGroup, type RadioGroupOption, type RadioGroupProps, SCROLL_HINT_X, SectionCard, type SectionCardProps, SectionHeading, type SectionHeadingProps, Select, type SelectOption, type SelectProps, SidePanelLayout, type SidePanelLayoutProps, type NavItem as SidebarNavItem, SimpleAccordion, SkeletonBar, type SkeletonBarProps, SkeletonCard, SkeletonCardGrid, type SkeletonCardGridProps, type SkeletonCardProps, SkeletonDetail, type SkeletonDetailProps, SkeletonRow, type SkeletonRowProps, SkeletonTable, type SkeletonTableProps, Spinner, type SpinnerProps, StackedList, StackedListItem, type StackedListItemProps, type StackedListProps, type Stage, StageList, type StageListProps, StatCardExtended, type StatCardExtendedProps, StatGroup, type StatGroupProps, Stepper, type StepperProps, StepperStep, type StepperStepProps, StickyActionBar, type StickyActionBarProps, Switch, type SwitchProps, TabBar, TabBarItem, type TabBarItemProps, type TabBarProps, TabbedCard, type TabbedCardProps, TableBody, TableCaption, TableCell, type TableCellProps, TableHeader, TableRow, type TableRowProps, Textarea, type TextareaProps, Toggle, ToggleGroup, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, avatarVariants, buildDiceBearUrl, buttonVariants, cn, fieldVariants, getPageRange, isEmptyValue, useDebounce, useSidebar };
2325
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionCard, type ActionCardProps, ActionPanel, type ActionPanelProps, ActivityFeed, ActivityFeedItem, type ActivityFeedItemProps, type ActivityFeedProps, Alert, type AlertProps, AppShell, type AppShellProps, AvatarGroup, AvatarGroupItem, type AvatarGroupItemProps, type AvatarGroupProps, Button, ButtonGroup, ButtonGroupItem, type ButtonGroupItemProps, type ButtonGroupProps, type ButtonProps, Calendar, type CalendarEvent, type CalendarProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, CheckboxGroup, type CheckboxGroupOption, type CheckboxGroupProps, type CheckboxProps, ClampedList, type ClampedListProps, CollapsibleSidebar, Combobox, type ComboboxOption, type ComboboxProps, CommandPalette, type CommandPaletteProps, type CommandPaletteResult, ConfirmDialog, type ConfirmDialogProps, Container, type ContainerProps, DataTable, type DataTableProps, DatePicker, type DatePickerProps, DescriptionItem, type DescriptionItemProps, DescriptionList, type DescriptionListProps, DiceBearAvatar, type DiceBearAvatarProps, type DiceBearStyle, DistributionChip, type DistributionChipProps, Divider, type DividerProps, Drawer, DrawerBody, DrawerFooter, DrawerHeader, type DrawerProps, EMPTY_VALUE_GLYPH, EmptyState, type EmptyStateProps, EmptyValue, type EmptyValueProps, type FieldSize, FilterChip, type FilterChipProps, FormError, type FormErrorProps, FormField, FormFieldGroup, type FormFieldGroupProps, type FormFieldProps, FormLayout, type FormLayoutProps, FormLayoutSection, type FormLayoutSectionProps, FormSection, type FormSectionProps, FormSuccess, type FormSuccessProps, GlobalErrorContent, type GlobalErrorContentProps, GridList, GridListItem, type GridListItemProps, type GridListProps, HorizontalCard, type HorizontalCardProps, HoverCard, type HoverCardProps, INTENT_SUBTLE_STYLES, IconName, IconSize, ImageCard, type ImageCardProps, Input, InputGroup, type InputGroupProps, type InputProps, IntentBadge, type IntentBadgeIntent, type IntentBadgeProps, IntentIcon, type IntentIconProps, Label, type LabelProps, MediaObject, type MediaObjectProps, ModalBody, ModalDialog, type ModalDialogProps, ModalFooter, ModalHeader, type NavItem, Navbar, NavbarLink, type NavbarLinkProps, type NavbarProps, NotificationBanner, type NotificationBannerProps, NotificationPanel, NotificationPanelItem, type NotificationPanelItemProps, type NotificationPanelProps, OverflowMenu, type OverflowMenuItem, type OverflowMenuProps, PageContent, type PageContentProps, PageGutter, type PageGutterProps, PageHeading, type PageHeadingProps, Pagination, PaginationButton, type PaginationProps, Popover, type PopoverProps, Progress, type ProgressIntent, type ProgressProps, RadioGroup, type RadioGroupOption, type RadioGroupProps, SCROLL_HINT_X, SectionCard, type SectionCardProps, SectionHeading, type SectionHeadingProps, Select, type SelectOption, type SelectProps, SidePanelLayout, type SidePanelLayoutProps, type NavItem as SidebarNavItem, SimpleAccordion, SkeletonBar, type SkeletonBarProps, SkeletonCard, SkeletonCardGrid, type SkeletonCardGridProps, type SkeletonCardProps, SkeletonDetail, type SkeletonDetailProps, SkeletonRow, type SkeletonRowProps, SkeletonTable, type SkeletonTableProps, Spinner, type SpinnerProps, StackedList, StackedListItem, type StackedListItemProps, type StackedListProps, type Stage, StageList, type StageListProps, StatCardExtended, type StatCardExtendedProps, StatGroup, type StatGroupProps, Stepper, type StepperProps, StepperStep, type StepperStepProps, StickyActionBar, type StickyActionBarProps, Switch, type SwitchProps, TabBar, TabBarItem, type TabBarItemProps, type TabBarProps, TabbedCard, type TabbedCardProps, TableBody, TableCaption, TableCell, type TableCellProps, TableHeader, TableRow, type TableRowProps, Textarea, type TextareaProps, Toggle, ToggleGroup, type ToggleGroupProps, type ToggleProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, avatarVariants, buttonVariants, cn, fieldVariants, getPageRange, isEmptyValue, useDebounce, useSidebar };
package/dist/index.js CHANGED
@@ -1239,6 +1239,44 @@ function ConfirmDialog({
1239
1239
  // src/dicebear-avatar.tsx
1240
1240
  import * as React7 from "react";
1241
1241
  import { cva as cva2 } from "class-variance-authority";
1242
+
1243
+ // src/dicebear-svg.ts
1244
+ import { createAvatar } from "@dicebear/core";
1245
+ var STYLE_LOADERS = {
1246
+ adventurer: () => import("@dicebear/adventurer"),
1247
+ "adventurer-neutral": () => import("@dicebear/adventurer-neutral"),
1248
+ avataaars: () => import("@dicebear/avataaars"),
1249
+ "avataaars-neutral": () => import("@dicebear/avataaars-neutral"),
1250
+ "big-ears": () => import("@dicebear/big-ears"),
1251
+ "big-ears-neutral": () => import("@dicebear/big-ears-neutral"),
1252
+ bottts: () => import("@dicebear/bottts"),
1253
+ "bottts-neutral": () => import("@dicebear/bottts-neutral"),
1254
+ croodles: () => import("@dicebear/croodles"),
1255
+ "croodles-neutral": () => import("@dicebear/croodles-neutral"),
1256
+ "fun-emoji": () => import("@dicebear/fun-emoji"),
1257
+ icons: () => import("@dicebear/icons"),
1258
+ identicon: () => import("@dicebear/identicon"),
1259
+ initials: () => import("@dicebear/initials"),
1260
+ lorelei: () => import("@dicebear/lorelei"),
1261
+ "lorelei-neutral": () => import("@dicebear/lorelei-neutral"),
1262
+ micah: () => import("@dicebear/micah"),
1263
+ miniavs: () => import("@dicebear/miniavs"),
1264
+ notionists: () => import("@dicebear/notionists"),
1265
+ "notionists-neutral": () => import("@dicebear/notionists-neutral"),
1266
+ "open-peeps": () => import("@dicebear/open-peeps"),
1267
+ personas: () => import("@dicebear/personas"),
1268
+ "pixel-art": () => import("@dicebear/pixel-art"),
1269
+ "pixel-art-neutral": () => import("@dicebear/pixel-art-neutral"),
1270
+ rings: () => import("@dicebear/rings"),
1271
+ shapes: () => import("@dicebear/shapes"),
1272
+ thumbs: () => import("@dicebear/thumbs")
1273
+ };
1274
+ async function diceBearDataUri(seed, style) {
1275
+ const loaded = await STYLE_LOADERS[style]();
1276
+ return createAvatar(loaded, { seed }).toDataUri();
1277
+ }
1278
+
1279
+ // src/dicebear-avatar.tsx
1242
1280
  import { jsx as jsx11 } from "react/jsx-runtime";
1243
1281
  var avatarVariants = cva2(
1244
1282
  "relative inline-flex shrink-0 overflow-hidden rounded-full bg-muted dark:bg-muted",
@@ -1258,11 +1296,6 @@ var avatarVariants = cva2(
1258
1296
  }
1259
1297
  }
1260
1298
  );
1261
- var DICEBEAR_BASE_URL = "https://api.dicebear.com/9.x";
1262
- function buildDiceBearUrl(seed, style = "adventurer-neutral") {
1263
- const encodedSeed = encodeURIComponent(seed);
1264
- return `${DICEBEAR_BASE_URL}/${style}/svg?seed=${encodedSeed}`;
1265
- }
1266
1299
  var DiceBearAvatar = React7.forwardRef(
1267
1300
  ({
1268
1301
  seed,
@@ -1273,10 +1306,23 @@ var DiceBearAvatar = React7.forwardRef(
1273
1306
  className,
1274
1307
  ...props
1275
1308
  }, ref) => {
1309
+ const [src, setSrc] = React7.useState(null);
1276
1310
  const [hasError, setHasError] = React7.useState(false);
1277
- const url = buildDiceBearUrl(seed, avatarStyle);
1278
1311
  React7.useEffect(() => {
1312
+ let live = true;
1313
+ setSrc(null);
1279
1314
  setHasError(false);
1315
+ diceBearDataUri(seed, avatarStyle).then(
1316
+ (uri) => {
1317
+ if (live) setSrc(uri);
1318
+ },
1319
+ () => {
1320
+ if (live) setHasError(true);
1321
+ }
1322
+ );
1323
+ return () => {
1324
+ live = false;
1325
+ };
1280
1326
  }, [seed, avatarStyle]);
1281
1327
  return /* @__PURE__ */ jsx11(
1282
1328
  "div",
@@ -1284,10 +1330,10 @@ var DiceBearAvatar = React7.forwardRef(
1284
1330
  ref,
1285
1331
  className: cn(avatarVariants({ size }), className),
1286
1332
  ...props,
1287
- children: hasError ? fallback ? /* @__PURE__ */ jsx11("div", { className: "flex h-full w-full items-center justify-center text-xs font-medium text-muted-foreground dark:text-muted-foreground", children: fallback }) : /* @__PURE__ */ jsx11("div", { className: "text-primary-text dark:text-primary-text flex h-full w-full items-center justify-center bg-primary/10 text-xs font-medium dark:bg-primary/10", children: seed.charAt(0).toUpperCase() }) : /* @__PURE__ */ jsx11(
1333
+ children: hasError ? fallback ? /* @__PURE__ */ jsx11("div", { className: "flex h-full w-full items-center justify-center text-xs font-medium text-muted-foreground dark:text-muted-foreground", children: fallback }) : /* @__PURE__ */ jsx11("div", { className: "text-primary-text dark:text-primary-text flex h-full w-full items-center justify-center bg-primary/10 text-xs font-medium dark:bg-primary/10", children: seed.charAt(0).toUpperCase() }) : src === null ? null : /* @__PURE__ */ jsx11(
1288
1334
  "img",
1289
1335
  {
1290
- src: url,
1336
+ src,
1291
1337
  alt,
1292
1338
  className: "h-full w-full object-cover",
1293
1339
  onError: () => setHasError(true)
@@ -2240,6 +2286,11 @@ var ALIGN_CLASSES = {
2240
2286
  center: "left-1/2 -translate-x-1/2",
2241
2287
  end: "right-0"
2242
2288
  };
2289
+ var SIDE_ALIGN_CLASSES = {
2290
+ start: "top-0",
2291
+ center: "top-1/2 -translate-y-1/2",
2292
+ end: "bottom-0"
2293
+ };
2243
2294
  var Popover = React14.forwardRef(
2244
2295
  ({
2245
2296
  className,
@@ -2284,7 +2335,7 @@ var Popover = React14.forwardRef(
2284
2335
  className: cn(
2285
2336
  "z-popover absolute w-72 rounded-lg border border-border bg-card p-4 shadow-lg",
2286
2337
  SIDE_CLASSES[side],
2287
- (side === "top" || side === "bottom") && ALIGN_CLASSES[align]
2338
+ side === "top" || side === "bottom" ? ALIGN_CLASSES[align] : SIDE_ALIGN_CLASSES[align]
2288
2339
  ),
2289
2340
  children
2290
2341
  }
@@ -5673,7 +5724,6 @@ export {
5673
5724
  TooltipProvider,
5674
5725
  TooltipTrigger,
5675
5726
  avatarVariants,
5676
- buildDiceBearUrl,
5677
5727
  buttonVariants,
5678
5728
  cn,
5679
5729
  fieldVariants,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caqophony/ui",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "Generic, optional React UI reuse library (Gossamer tokens). Centrally maintained by Caqophony.",
5
5
  "license": "MIT",
6
6
  "author": "Caqophony",
@@ -62,6 +62,34 @@
62
62
  "LICENSE"
63
63
  ],
64
64
  "dependencies": {
65
+ "@dicebear/adventurer": "9.4.3",
66
+ "@dicebear/adventurer-neutral": "9.4.3",
67
+ "@dicebear/avataaars": "9.4.3",
68
+ "@dicebear/avataaars-neutral": "9.4.3",
69
+ "@dicebear/big-ears": "9.4.3",
70
+ "@dicebear/big-ears-neutral": "9.4.3",
71
+ "@dicebear/bottts": "9.4.3",
72
+ "@dicebear/bottts-neutral": "9.4.3",
73
+ "@dicebear/core": "9.4.3",
74
+ "@dicebear/croodles": "9.4.3",
75
+ "@dicebear/croodles-neutral": "9.4.3",
76
+ "@dicebear/fun-emoji": "9.4.3",
77
+ "@dicebear/icons": "9.4.3",
78
+ "@dicebear/identicon": "9.4.3",
79
+ "@dicebear/initials": "9.4.3",
80
+ "@dicebear/lorelei": "9.4.3",
81
+ "@dicebear/lorelei-neutral": "9.4.3",
82
+ "@dicebear/micah": "9.4.3",
83
+ "@dicebear/miniavs": "9.4.3",
84
+ "@dicebear/notionists": "9.4.3",
85
+ "@dicebear/notionists-neutral": "9.4.3",
86
+ "@dicebear/open-peeps": "9.4.3",
87
+ "@dicebear/personas": "9.4.3",
88
+ "@dicebear/pixel-art": "9.4.3",
89
+ "@dicebear/pixel-art-neutral": "9.4.3",
90
+ "@dicebear/rings": "9.4.3",
91
+ "@dicebear/shapes": "9.4.3",
92
+ "@dicebear/thumbs": "9.4.3",
65
93
  "@radix-ui/react-slot": "^1.1.0",
66
94
  "@radix-ui/react-switch": "^1.1.1",
67
95
  "@radix-ui/react-tooltip": "^1.1.3",