@rehagro/ui 0.1.2 → 0.1.4

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/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React8, { forwardRef, createContext, useState, useRef, useCallback, useEffect, useContext, useMemo } from 'react';
2
3
  import { jsxs, jsx } from 'react/jsx-runtime';
3
4
 
@@ -1678,6 +1679,60 @@ var Tooltip = forwardRef(
1678
1679
  );
1679
1680
  }
1680
1681
  );
1682
+ var sizeClasses7 = {
1683
+ sm: "rh-w-8 rh-h-8 rh-text-xs",
1684
+ md: "rh-w-10 rh-h-10 rh-text-sm",
1685
+ lg: "rh-w-12 rh-h-12 rh-text-base",
1686
+ xl: "rh-w-16 rh-h-16 rh-text-lg"
1687
+ };
1688
+ var imageSizeClasses = {
1689
+ sm: "rh-w-8 rh-h-8",
1690
+ md: "rh-w-10 rh-h-10",
1691
+ lg: "rh-w-12 rh-h-12",
1692
+ xl: "rh-w-16 rh-h-16"
1693
+ };
1694
+ var variantClasses3 = {
1695
+ circle: "rh-rounded-full",
1696
+ square: "rh-rounded-sm"
1697
+ };
1698
+ var Avatar = forwardRef(function Avatar2({
1699
+ src,
1700
+ alt = "",
1701
+ initials,
1702
+ size = "md",
1703
+ variant = "circle",
1704
+ className = "",
1705
+ ...rest
1706
+ }, ref) {
1707
+ const [imgError, setImgError] = useState(false);
1708
+ const showImage = src && !imgError;
1709
+ const fallbackLabel = initials ? initials.slice(0, 2).toUpperCase() : alt ? alt.split(" ").slice(0, 2).map((w) => w[0]).join("").toUpperCase() : "?";
1710
+ return /* @__PURE__ */ jsx(
1711
+ "div",
1712
+ {
1713
+ ref,
1714
+ role: showImage ? void 0 : "img",
1715
+ "aria-label": showImage ? void 0 : alt || initials,
1716
+ className: [
1717
+ "rh-inline-flex rh-items-center rh-justify-center rh-shrink-0 rh-overflow-hidden",
1718
+ "rh-bg-primary rh-text-surface rh-font-sans rh-font-medium rh-select-none",
1719
+ sizeClasses7[size],
1720
+ variantClasses3[variant],
1721
+ className
1722
+ ].filter(Boolean).join(" "),
1723
+ ...rest,
1724
+ children: showImage ? /* @__PURE__ */ jsx(
1725
+ "img",
1726
+ {
1727
+ src,
1728
+ alt,
1729
+ className: [imageSizeClasses[size], variantClasses3[variant], "rh-object-cover"].join(" "),
1730
+ onError: () => setImgError(true)
1731
+ }
1732
+ ) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: fallbackLabel })
1733
+ }
1734
+ );
1735
+ });
1681
1736
  var Container = forwardRef(
1682
1737
  function Container2({ fluid = false, className = "", children, ...rest }, ref) {
1683
1738
  return /* @__PURE__ */ jsx(
@@ -1847,6 +1902,6 @@ var GridItem = forwardRef(
1847
1902
  }
1848
1903
  );
1849
1904
 
1850
- export { Button, Checkbox, CloseIcon, Container, DeleteIcon, EditIcon, ErrorIcon, GridContainer, GridItem, IconButton, InfoIcon, NeutralIcon, PlusIcon, RehagroProvider, SearchIcon, Select, SuccessIcon, TextInput, Toast, ToastContainer, ToastProvider, Tooltip, WarningIcon, useToast };
1905
+ export { Avatar, Button, Checkbox, CloseIcon, Container, DeleteIcon, EditIcon, ErrorIcon, GridContainer, GridItem, IconButton, InfoIcon, NeutralIcon, PlusIcon, RehagroProvider, SearchIcon, Select, SuccessIcon, TextInput, Toast, ToastContainer, ToastProvider, Tooltip, WarningIcon, useToast };
1851
1906
  //# sourceMappingURL=index.mjs.map
1852
1907
  //# sourceMappingURL=index.mjs.map