@rehagro/ui 1.0.5 → 1.0.7

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,5 +1,5 @@
1
1
  "use client";
2
- import React8, { forwardRef, createContext, useState, useRef, useCallback, useEffect, useContext, useMemo } from 'react';
2
+ import React8, { forwardRef, createContext, useState, useRef, useCallback, useEffect, useMemo, useContext } from 'react';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
 
5
5
  // src/provider/RehagroProvider.tsx
@@ -694,6 +694,7 @@ var Button = forwardRef(function Button2({
694
694
  radius = "sm",
695
695
  color = "primary",
696
696
  hoverColor,
697
+ hoverStyle,
697
698
  loading = false,
698
699
  disabled,
699
700
  leftIcon,
@@ -706,13 +707,15 @@ var Button = forwardRef(function Button2({
706
707
  const isDisabled = React8.useMemo(() => disabled || loading, [disabled, loading]);
707
708
  const preset = isPresetColor(color);
708
709
  const computedStyle = React8.useMemo(() => {
709
- if (preset) {
710
- if (!hoverColor) return style ?? {};
711
- const triplet = toRgbTriplet2(hoverColor);
712
- return { ...style, [`--rh-${color}-hover`]: triplet ?? hoverColor };
713
- }
714
- return { ...style, ...getArbitraryColorStyle(variant, color) };
715
- }, [preset, color, variant, hoverColor, style]);
710
+ const baseStyle = preset ? hoverColor ? { [`--rh-${color}-hover`]: toRgbTriplet2(hoverColor) ?? hoverColor } : {} : getArbitraryColorStyle(variant, color);
711
+ const hoverVars = hoverStyle ? {
712
+ "--btn-hover-bg": hoverStyle.backgroundColor,
713
+ "--btn-hover-border": hoverStyle.borderColor,
714
+ "--btn-hover-color": hoverStyle.color
715
+ } : {};
716
+ return { ...style, ...baseStyle, ...hoverVars };
717
+ }, [preset, color, variant, hoverColor, hoverStyle, style]);
718
+ const hasCustomHover = Boolean(hoverStyle);
716
719
  return /* @__PURE__ */ jsxs(
717
720
  "button",
718
721
  {
@@ -725,7 +728,9 @@ var Button = forwardRef(function Button2({
725
728
  "rh-border rh-font-sans rh-font-medium",
726
729
  "rh-transition-colors rh-duration-150",
727
730
  "focus-visible:rh-outline-none focus-visible:rh-ring-2 focus-visible:rh-ring-ring focus-visible:rh-ring-offset-2",
728
- preset ? variantColorClasses[variant][color] : "hover:rh-brightness-90",
731
+ preset && !hasCustomHover ? variantColorClasses[variant][color] : "",
732
+ !preset && !hasCustomHover ? "hover:rh-brightness-90" : "",
733
+ hasCustomHover ? "btn-custom-hover" : "",
729
734
  sizeClasses[size],
730
735
  radiusClasses[radius],
731
736
  isDisabled ? "rh-opacity-50 rh-cursor-not-allowed rh-pointer-events-none" : "",
@@ -898,8 +903,8 @@ var IconButton = forwardRef(function IconButton2({
898
903
  );
899
904
  });
900
905
  var statusClasses = {
901
- default: "rh-border-border focus-within:rh-ring-2 focus-within:rh-ring-ring focus-within:rh-ring-offset-2",
902
- error: "rh-border-danger focus-within:rh-ring-2 focus-within:rh-ring-danger focus-within:rh-ring-offset-2"
906
+ default: "rh-border-border focus-within:rh-ring-2 focus-within:rh-ring-ring",
907
+ error: "rh-border-danger focus-within:rh-ring-2 focus-within:rh-ring-danger"
903
908
  };
904
909
  var sizeClasses3 = {
905
910
  sm: "rh-h-input-sm rh-text-sm rh-px-input-x-sm",
@@ -925,113 +930,101 @@ var helperStatusClasses = {
925
930
  default: "rh-text-text-muted",
926
931
  error: "rh-text-danger"
927
932
  };
928
- var TextInput = forwardRef(
929
- function TextInput2({
930
- label,
931
- subtitle,
932
- status = "default",
933
- size = "md",
934
- radius = "xs",
935
- leftIcon,
936
- rightIcon,
937
- helperText,
938
- disabled,
939
- className = "",
940
- wrapperClassName = "",
941
- id,
942
- ...rest
943
- }, ref) {
944
- const inputId = id || React8.useId();
945
- return /* @__PURE__ */ jsxs(
946
- "div",
947
- {
948
- className: [
949
- "rh-flex rh-flex-col rh-gap-1 rh-font-sans",
950
- wrapperClassName
951
- ].filter(Boolean).join(" "),
952
- children: [
953
- label && /* @__PURE__ */ jsxs(
954
- "label",
955
- {
956
- htmlFor: inputId,
957
- className: "rh-flex rh-items-baseline rh-gap-1",
958
- children: [
959
- /* @__PURE__ */ jsx("span", { className: "rh-text-sm rh-font-medium rh-text-text", children: label }),
960
- subtitle && /* @__PURE__ */ jsx("span", { className: "rh-text-sm rh-text-text-muted", children: subtitle })
961
- ]
962
- }
963
- ),
964
- /* @__PURE__ */ jsxs(
965
- "div",
966
- {
967
- className: [
968
- "rh-flex rh-items-center rh-gap-2",
969
- "rh-border rh-bg-surface rh-font-sans",
970
- "rh-transition-colors rh-duration-150",
971
- statusClasses[status],
972
- radiusClasses3[radius],
973
- sizeClasses3[size],
974
- disabled ? "rh-opacity-50 rh-cursor-not-allowed rh-bg-background" : "",
975
- className
976
- ].filter(Boolean).join(" "),
977
- children: [
978
- leftIcon && /* @__PURE__ */ jsx(
979
- "span",
980
- {
981
- className: [
982
- "rh-inline-flex rh-shrink-0 rh-text-text-muted",
983
- iconSizeClasses[size]
984
- ].join(" "),
985
- "aria-hidden": "true",
986
- children: leftIcon
987
- }
988
- ),
989
- /* @__PURE__ */ jsx(
990
- "input",
991
- {
992
- ref,
993
- id: inputId,
994
- disabled,
995
- "aria-invalid": status === "error" || void 0,
996
- "aria-describedby": helperText ? `${inputId}-helper` : void 0,
997
- className: [
998
- "rh-flex-1 rh-bg-transparent rh-outline-none",
999
- "rh-text-text placeholder:rh-text-text-muted",
1000
- disabled ? "rh-cursor-not-allowed" : ""
1001
- ].filter(Boolean).join(" "),
1002
- ...rest
1003
- }
1004
- ),
1005
- rightIcon && /* @__PURE__ */ jsx(
1006
- "span",
1007
- {
1008
- className: [
1009
- "rh-inline-flex rh-shrink-0 rh-text-text-muted",
1010
- iconSizeClasses[size]
1011
- ].join(" "),
1012
- "aria-hidden": "true",
1013
- children: rightIcon
1014
- }
1015
- )
1016
- ]
1017
- }
1018
- ),
1019
- helperText && /* @__PURE__ */ jsx(
1020
- "span",
1021
- {
1022
- id: `${inputId}-helper`,
1023
- className: [
1024
- "rh-flex rh-items-center rh-gap-1 rh-text-xs",
1025
- helperStatusClasses[status]
1026
- ].join(" "),
1027
- children: helperText
1028
- }
1029
- )
1030
- ]
1031
- }
1032
- );
1033
- }
1034
- );
933
+ var TextInput = forwardRef(function TextInput2({
934
+ label,
935
+ subtitle,
936
+ status = "default",
937
+ size = "md",
938
+ radius = "xs",
939
+ leftIcon,
940
+ rightIcon,
941
+ helperText,
942
+ disabled,
943
+ className = "",
944
+ wrapperClassName = "",
945
+ id,
946
+ ...rest
947
+ }, ref) {
948
+ const inputId = id || React8.useId();
949
+ return /* @__PURE__ */ jsxs(
950
+ "div",
951
+ {
952
+ className: ["rh-flex rh-flex-col rh-gap-[0.5rem] rh-font-sans", wrapperClassName].filter(Boolean).join(" "),
953
+ children: [
954
+ label && /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: "rh-flex rh-items-baseline rh-gap-1", children: [
955
+ /* @__PURE__ */ jsx("span", { className: "rh-text-sm rh-font-medium rh-text-text", children: label }),
956
+ subtitle && /* @__PURE__ */ jsx("span", { className: "rh-text-sm rh-text-text-muted", children: subtitle })
957
+ ] }),
958
+ /* @__PURE__ */ jsxs(
959
+ "div",
960
+ {
961
+ className: [
962
+ "rh-flex rh-items-center rh-gap-2",
963
+ "rh-border rh-bg-surface rh-font-sans",
964
+ "rh-transition-colors rh-duration-150",
965
+ statusClasses[status],
966
+ radiusClasses3[radius],
967
+ sizeClasses3[size],
968
+ disabled ? "rh-opacity-50 rh-cursor-not-allowed rh-bg-background" : "",
969
+ className
970
+ ].filter(Boolean).join(" "),
971
+ children: [
972
+ leftIcon && /* @__PURE__ */ jsx(
973
+ "span",
974
+ {
975
+ className: [
976
+ "rh-inline-flex rh-shrink-0 rh-text-text-muted",
977
+ iconSizeClasses[size]
978
+ ].join(" "),
979
+ "aria-hidden": "true",
980
+ children: leftIcon
981
+ }
982
+ ),
983
+ /* @__PURE__ */ jsx(
984
+ "input",
985
+ {
986
+ ref,
987
+ id: inputId,
988
+ disabled,
989
+ "aria-invalid": status === "error" || void 0,
990
+ "aria-describedby": helperText ? `${inputId}-helper` : void 0,
991
+ className: [
992
+ "rh-flex-1 rh-bg-transparent rh-outline-none",
993
+ "rh-text-text placeholder:rh-text-text-muted",
994
+ disabled ? "rh-cursor-not-allowed" : ""
995
+ ].filter(Boolean).join(" "),
996
+ ...rest
997
+ }
998
+ ),
999
+ rightIcon && /* @__PURE__ */ jsx(
1000
+ "span",
1001
+ {
1002
+ className: [
1003
+ "rh-inline-flex rh-shrink-0 rh-text-text-muted",
1004
+ iconSizeClasses[size]
1005
+ ].join(" "),
1006
+ "aria-hidden": "true",
1007
+ children: rightIcon
1008
+ }
1009
+ )
1010
+ ]
1011
+ }
1012
+ ),
1013
+ helperText && /* @__PURE__ */ jsx(
1014
+ "span",
1015
+ {
1016
+ id: `${inputId}-helper`,
1017
+ className: [
1018
+ "rh-flex rh-items-center rh-gap-1 rh-text-xs",
1019
+ helperStatusClasses[status]
1020
+ ].join(" "),
1021
+ children: helperText
1022
+ }
1023
+ )
1024
+ ]
1025
+ }
1026
+ );
1027
+ });
1035
1028
  var sizeClasses4 = {
1036
1029
  sm: "rh-h-4 rh-w-4",
1037
1030
  md: "rh-h-5 rh-w-5",
@@ -1771,6 +1764,33 @@ var Tooltip = forwardRef(
1771
1764
  );
1772
1765
  }
1773
1766
  );
1767
+ var AVATAR_COLORS = [
1768
+ { bg: "#FBF1E6", text: "#D6822D" },
1769
+ // Laranja
1770
+ { bg: "#EDF3FA", text: "#538CC6" },
1771
+ // Azul
1772
+ { bg: "#F3E5F5", text: "#9C27B0" },
1773
+ // Roxo
1774
+ { bg: "#E8F5E9", text: "#4CAF50" },
1775
+ // Verde
1776
+ { bg: "#FFF3E0", text: "#FF9800" },
1777
+ // Amarelo
1778
+ { bg: "#FFEBEE", text: "#F44336" },
1779
+ // Vermelho
1780
+ { bg: "#E3F2FD", text: "#2196F3" },
1781
+ // Azul claro
1782
+ { bg: "#F3E5F5", text: "#673AB7" },
1783
+ // Violeta
1784
+ { bg: "#E0F2F1", text: "#009688" },
1785
+ // Teal
1786
+ { bg: "#FBE9E7", text: "#FF5722" }
1787
+ // Deep Orange
1788
+ ];
1789
+ function getAvatarColors(name) {
1790
+ const hash = name.split("").reduce((acc, char) => acc + char.charCodeAt(0), 0);
1791
+ const index = hash % AVATAR_COLORS.length;
1792
+ return AVATAR_COLORS[index];
1793
+ }
1774
1794
  var sizeClasses7 = {
1775
1795
  sm: "rh-w-8 rh-h-8 rh-text-xs",
1776
1796
  md: "rh-w-10 rh-h-10 rh-text-sm",
@@ -1787,9 +1807,14 @@ var variantClasses2 = {
1787
1807
  circle: "rh-rounded-full",
1788
1808
  square: "rh-rounded-sm"
1789
1809
  };
1790
- var Avatar = forwardRef(function Avatar2({ src, alt = "", initials, size = "md", variant = "circle", className = "", ...rest }, ref) {
1810
+ var Avatar = forwardRef(function Avatar2({ src, alt = "", initials, size = "md", variant = "circle", colorFromName = false, className = "", style, ...rest }, ref) {
1791
1811
  const [imgError, setImgError] = useState(false);
1792
1812
  const showImage = src && !imgError;
1813
+ const avatarColors = useMemo(() => {
1814
+ if (!colorFromName) return null;
1815
+ const name = initials || alt || "";
1816
+ return name ? getAvatarColors(name) : null;
1817
+ }, [colorFromName, initials, alt]);
1793
1818
  const fallbackLabel = initials ? initials.slice(0, 2).toUpperCase() : alt ? alt.split(" ").slice(0, 2).map((w) => w[0]).join("").toUpperCase() : "?";
1794
1819
  return /* @__PURE__ */ jsx(
1795
1820
  "div",
@@ -1799,11 +1824,16 @@ var Avatar = forwardRef(function Avatar2({ src, alt = "", initials, size = "md",
1799
1824
  "aria-label": showImage ? void 0 : alt || initials,
1800
1825
  className: [
1801
1826
  "rh-inline-flex rh-items-center rh-justify-center rh-shrink-0 rh-overflow-hidden",
1802
- "rh-bg-primary rh-text-surface rh-font-sans rh-font-medium rh-select-none",
1827
+ avatarColors ? "" : "rh-bg-primary rh-text-surface",
1828
+ "rh-font-sans rh-font-medium rh-select-none",
1803
1829
  sizeClasses7[size],
1804
1830
  variantClasses2[variant],
1805
1831
  className
1806
1832
  ].filter(Boolean).join(" "),
1833
+ style: {
1834
+ ...avatarColors && { backgroundColor: avatarColors.bg, color: avatarColors.text },
1835
+ ...style
1836
+ },
1807
1837
  ...rest,
1808
1838
  children: showImage ? /* @__PURE__ */ jsx(
1809
1839
  "img",
@@ -1967,8 +1997,8 @@ function ToggleGroupInner({
1967
1997
  ref,
1968
1998
  role: "group",
1969
1999
  className: [
1970
- "rh-inline-flex rh-items-center rh-border rh-border-border rh-bg-surface rh-overflow-hidden",
1971
- "rh-p-0.5",
2000
+ "rh-inline-flex rh-items-center rh-bg-muted rh-overflow-hidden",
2001
+ "rh-p-1 rh-gap-0.5",
1972
2002
  radiusClasses5[radius],
1973
2003
  sizeClasses9[size].container,
1974
2004
  disabled ? "rh-opacity-50 rh-cursor-not-allowed" : "",
@@ -1989,13 +2019,13 @@ function ToggleGroupInner({
1989
2019
  onClick: () => !isDisabled && onChange(option.value),
1990
2020
  className: [
1991
2021
  "rh-flex rh-items-center rh-justify-center rh-h-full",
1992
- "rh-border-0 rh-bg-transparent rh-font-sans rh-font-medium",
1993
- "rh-transition-colors rh-duration-150",
2022
+ "rh-border-0 rh-font-sans rh-font-medium",
2023
+ "rh-transition-all rh-duration-150",
1994
2024
  "focus-visible:rh-outline-none focus-visible:rh-ring-2 focus-visible:rh-ring-ring",
1995
2025
  radiusClasses5[radius],
1996
2026
  sizeClasses9[size].button,
1997
- isActive && preset ? `rh-bg-border rh-text-text` : "",
1998
- !isActive ? "rh-text-text-muted hover:rh-bg-border/50" : "",
2027
+ isActive ? "rh-bg-surface rh-text-text rh-shadow-sm" : "rh-bg-transparent rh-text-text-muted",
2028
+ !isActive && !isDisabled ? "hover:rh-bg-surface/50" : "",
1999
2029
  isDisabled ? "rh-cursor-not-allowed rh-pointer-events-none" : "rh-cursor-pointer"
2000
2030
  ].filter(Boolean).join(" "),
2001
2031
  style: isActive && !preset ? getActiveStyles(color, preset) : void 0,
@@ -2191,6 +2221,7 @@ function TableInner({
2191
2221
  emptyContent = "Nenhum dado encontrado",
2192
2222
  loadingContent,
2193
2223
  stickyHeader = false,
2224
+ headerStyle,
2194
2225
  className = "",
2195
2226
  ...rest
2196
2227
  }, ref) {
@@ -2242,7 +2273,7 @@ function TableInner({
2242
2273
  ].filter(Boolean).join(" "),
2243
2274
  ...rest,
2244
2275
  children: [
2245
- /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: "rh-border-b rh-border-border", children: columns.map((column) => /* @__PURE__ */ jsx(
2276
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: "rh-border-b rh-border-border", style: headerStyle, children: columns.map((column) => /* @__PURE__ */ jsx(
2246
2277
  "th",
2247
2278
  {
2248
2279
  scope: "col",