@rehagro/ui 1.0.2 → 1.0.3
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/colors.types-7nLOoy6r.d.mts +4 -0
- package/dist/colors.types-7nLOoy6r.d.ts +4 -0
- package/dist/index.d.mts +15 -11
- package/dist/index.d.ts +15 -11
- package/dist/index.js +102 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -23
- package/dist/index.mjs.map +1 -1
- package/dist/native.d.mts +50 -4
- package/dist/native.d.ts +50 -4
- package/dist/native.js +166 -10
- package/dist/native.js.map +1 -1
- package/dist/native.mjs +166 -11
- package/dist/native.mjs.map +1 -1
- package/dist/styles.css +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16,6 +16,8 @@ var TOKEN_MAP = {
|
|
|
16
16
|
warningHover: { var: "--rh-warning-hover", isColor: true },
|
|
17
17
|
success: { var: "--rh-success", isColor: true },
|
|
18
18
|
successHover: { var: "--rh-success-hover", isColor: true },
|
|
19
|
+
info: { var: "--rh-info", isColor: true },
|
|
20
|
+
infoHover: { var: "--rh-info-hover", isColor: true },
|
|
19
21
|
text: { var: "--rh-text", isColor: true },
|
|
20
22
|
textMuted: { var: "--rh-text-muted", isColor: true },
|
|
21
23
|
surface: { var: "--rh-surface", isColor: true },
|
|
@@ -631,29 +633,46 @@ function toRgbTriplet2(value) {
|
|
|
631
633
|
if (parts.length === 3 && parts.every((p) => !Number.isNaN(Number(p)))) return value.trim();
|
|
632
634
|
return void 0;
|
|
633
635
|
}
|
|
636
|
+
var PRESET_COLORS = /* @__PURE__ */ new Set([
|
|
637
|
+
"primary",
|
|
638
|
+
"secondary",
|
|
639
|
+
"danger",
|
|
640
|
+
"warning",
|
|
641
|
+
"success",
|
|
642
|
+
"info"
|
|
643
|
+
]);
|
|
644
|
+
var isPresetColor = (c) => PRESET_COLORS.has(c);
|
|
634
645
|
var variantColorClasses = {
|
|
635
646
|
solid: {
|
|
636
647
|
primary: "rh-bg-primary rh-text-surface rh-border-primary hover:rh-bg-primary-hover hover:rh-border-primary-hover",
|
|
637
648
|
secondary: "rh-bg-secondary rh-text-surface rh-border-secondary hover:rh-bg-secondary-hover hover:rh-border-secondary-hover",
|
|
638
649
|
danger: "rh-bg-danger rh-text-surface rh-border-danger hover:rh-bg-danger-hover hover:rh-border-danger-hover",
|
|
639
650
|
warning: "rh-bg-warning rh-text-surface rh-border-warning hover:rh-bg-warning-hover hover:rh-border-warning-hover",
|
|
640
|
-
success: "rh-bg-success rh-text-surface rh-border-success hover:rh-bg-success-hover hover:rh-border-success-hover"
|
|
651
|
+
success: "rh-bg-success rh-text-surface rh-border-success hover:rh-bg-success-hover hover:rh-border-success-hover",
|
|
652
|
+
info: "rh-bg-info rh-text-surface rh-border-info hover:rh-bg-info-hover hover:rh-border-info-hover"
|
|
641
653
|
},
|
|
642
654
|
outline: {
|
|
643
655
|
primary: "rh-bg-transparent rh-text-primary rh-border-primary hover:rh-bg-primary hover:rh-text-surface",
|
|
644
656
|
secondary: "rh-bg-transparent rh-text-secondary rh-border-secondary hover:rh-bg-secondary hover:rh-text-surface",
|
|
645
657
|
danger: "rh-bg-transparent rh-text-danger rh-border-danger hover:rh-bg-danger hover:rh-text-surface",
|
|
646
658
|
warning: "rh-bg-transparent rh-text-warning rh-border-warning hover:rh-bg-warning hover:rh-text-surface",
|
|
647
|
-
success: "rh-bg-transparent rh-text-success rh-border-success hover:rh-bg-success hover:rh-text-surface"
|
|
659
|
+
success: "rh-bg-transparent rh-text-success rh-border-success hover:rh-bg-success hover:rh-text-surface",
|
|
660
|
+
info: "rh-bg-transparent rh-text-info rh-border-info hover:rh-bg-info hover:rh-text-surface"
|
|
648
661
|
},
|
|
649
662
|
ghost: {
|
|
650
663
|
primary: "rh-bg-transparent rh-text-primary rh-border-transparent hover:rh-bg-primary/10",
|
|
651
664
|
secondary: "rh-bg-transparent rh-text-secondary rh-border-transparent hover:rh-bg-secondary/10",
|
|
652
665
|
danger: "rh-bg-transparent rh-text-danger rh-border-transparent hover:rh-bg-danger/10",
|
|
653
666
|
warning: "rh-bg-transparent rh-text-warning rh-border-transparent hover:rh-bg-warning/10",
|
|
654
|
-
success: "rh-bg-transparent rh-text-success rh-border-transparent hover:rh-bg-success/10"
|
|
667
|
+
success: "rh-bg-transparent rh-text-success rh-border-transparent hover:rh-bg-success/10",
|
|
668
|
+
info: "rh-bg-transparent rh-text-info rh-border-transparent hover:rh-bg-info/10"
|
|
655
669
|
}
|
|
656
670
|
};
|
|
671
|
+
function getArbitraryColorStyle(variant, color) {
|
|
672
|
+
if (variant === "solid") return { backgroundColor: color, borderColor: color, color: "#fff" };
|
|
673
|
+
if (variant === "outline") return { borderColor: color, color };
|
|
674
|
+
return { color, borderColor: "transparent" };
|
|
675
|
+
}
|
|
657
676
|
var sizeClasses = {
|
|
658
677
|
sm: "rh-text-sm rh-px-3 rh-py-1.5",
|
|
659
678
|
md: "rh-text-sm rh-px-4 rh-py-2",
|
|
@@ -685,24 +704,28 @@ var Button = forwardRef(function Button2({
|
|
|
685
704
|
...rest
|
|
686
705
|
}, ref) {
|
|
687
706
|
const isDisabled = React8.useMemo(() => disabled || loading, [disabled, loading]);
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
707
|
+
const preset = isPresetColor(color);
|
|
708
|
+
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]);
|
|
693
716
|
return /* @__PURE__ */ jsxs(
|
|
694
717
|
"button",
|
|
695
718
|
{
|
|
696
719
|
ref,
|
|
697
720
|
disabled: isDisabled,
|
|
698
721
|
"aria-busy": loading || void 0,
|
|
699
|
-
style:
|
|
722
|
+
style: computedStyle,
|
|
700
723
|
className: [
|
|
701
724
|
"rh-inline-flex rh-items-center rh-justify-center rh-gap-2",
|
|
702
725
|
"rh-border rh-font-sans rh-font-medium",
|
|
703
726
|
"rh-transition-colors rh-duration-150",
|
|
704
727
|
"focus-visible:rh-outline-none focus-visible:rh-ring-2 focus-visible:rh-ring-ring focus-visible:rh-ring-offset-2",
|
|
705
|
-
variantColorClasses[variant][color],
|
|
728
|
+
preset ? variantColorClasses[variant][color] : "hover:rh-brightness-90",
|
|
706
729
|
sizeClasses[size],
|
|
707
730
|
radiusClasses[radius],
|
|
708
731
|
isDisabled ? "rh-opacity-50 rh-cursor-not-allowed rh-pointer-events-none" : "",
|
|
@@ -748,29 +771,46 @@ var Button = forwardRef(function Button2({
|
|
|
748
771
|
}
|
|
749
772
|
);
|
|
750
773
|
});
|
|
774
|
+
var PRESET_COLORS2 = /* @__PURE__ */ new Set([
|
|
775
|
+
"primary",
|
|
776
|
+
"secondary",
|
|
777
|
+
"danger",
|
|
778
|
+
"warning",
|
|
779
|
+
"success",
|
|
780
|
+
"info"
|
|
781
|
+
]);
|
|
782
|
+
var isPresetColor2 = (c) => PRESET_COLORS2.has(c);
|
|
751
783
|
var variantColorClasses2 = {
|
|
752
784
|
solid: {
|
|
753
785
|
primary: "rh-bg-primary rh-text-surface rh-border-primary hover:rh-bg-primary-hover hover:rh-border-primary-hover",
|
|
786
|
+
secondary: "rh-bg-secondary rh-text-surface rh-border-secondary hover:rh-bg-secondary-hover hover:rh-border-secondary-hover",
|
|
754
787
|
danger: "rh-bg-danger rh-text-surface rh-border-danger hover:rh-bg-danger-hover hover:rh-border-danger-hover",
|
|
755
788
|
warning: "rh-bg-warning rh-text-surface rh-border-warning hover:rh-bg-warning-hover hover:rh-border-warning-hover",
|
|
756
789
|
success: "rh-bg-success rh-text-surface rh-border-success hover:rh-bg-success-hover hover:rh-border-success-hover",
|
|
757
|
-
|
|
790
|
+
info: "rh-bg-info rh-text-surface rh-border-info hover:rh-bg-info-hover hover:rh-border-info-hover"
|
|
758
791
|
},
|
|
759
792
|
outline: {
|
|
760
793
|
primary: "rh-bg-transparent rh-text-primary rh-border-primary hover:rh-bg-primary hover:rh-text-surface",
|
|
794
|
+
secondary: "rh-bg-transparent rh-text-secondary rh-border-secondary hover:rh-bg-secondary hover:rh-text-surface",
|
|
761
795
|
danger: "rh-bg-transparent rh-text-danger rh-border-danger hover:rh-bg-danger hover:rh-text-surface",
|
|
762
796
|
warning: "rh-bg-transparent rh-text-warning rh-border-warning hover:rh-bg-warning hover:rh-text-surface",
|
|
763
797
|
success: "rh-bg-transparent rh-text-success rh-border-success hover:rh-bg-success hover:rh-text-surface",
|
|
764
|
-
|
|
798
|
+
info: "rh-bg-transparent rh-text-info rh-border-info hover:rh-bg-info hover:rh-text-surface"
|
|
765
799
|
},
|
|
766
800
|
ghost: {
|
|
767
801
|
primary: "rh-bg-transparent rh-text-primary rh-border-transparent hover:rh-bg-primary/10",
|
|
802
|
+
secondary: "rh-bg-transparent rh-text-secondary rh-border-transparent hover:rh-bg-secondary/10",
|
|
768
803
|
danger: "rh-bg-transparent rh-text-danger rh-border-transparent hover:rh-bg-danger/10",
|
|
769
804
|
warning: "rh-bg-transparent rh-text-warning rh-border-transparent hover:rh-bg-warning/10",
|
|
770
805
|
success: "rh-bg-transparent rh-text-success rh-border-transparent hover:rh-bg-success/10",
|
|
771
|
-
|
|
806
|
+
info: "rh-bg-transparent rh-text-info rh-border-transparent hover:rh-bg-info/10"
|
|
772
807
|
}
|
|
773
808
|
};
|
|
809
|
+
function getArbitraryColorStyle2(variant, color) {
|
|
810
|
+
if (variant === "solid") return { backgroundColor: color, borderColor: color, color: "#fff" };
|
|
811
|
+
if (variant === "outline") return { borderColor: color, color };
|
|
812
|
+
return { color, borderColor: "transparent" };
|
|
813
|
+
}
|
|
774
814
|
var sizeClasses2 = {
|
|
775
815
|
sm: "rh-h-8 rh-w-8 rh-text-sm",
|
|
776
816
|
md: "rh-h-10 rh-w-10 rh-text-base",
|
|
@@ -794,22 +834,29 @@ var IconButton = forwardRef(function IconButton2({
|
|
|
794
834
|
loading = false,
|
|
795
835
|
disabled,
|
|
796
836
|
className = "",
|
|
837
|
+
style,
|
|
797
838
|
children,
|
|
798
839
|
...rest
|
|
799
840
|
}, ref) {
|
|
800
841
|
const isDisabled = disabled || loading;
|
|
842
|
+
const preset = isPresetColor2(color);
|
|
843
|
+
const computedStyle = React8.useMemo(
|
|
844
|
+
() => preset ? style ?? {} : { ...style, ...getArbitraryColorStyle2(variant, color) },
|
|
845
|
+
[preset, color, variant, style]
|
|
846
|
+
);
|
|
801
847
|
return /* @__PURE__ */ jsx(
|
|
802
848
|
"button",
|
|
803
849
|
{
|
|
804
850
|
ref,
|
|
805
851
|
disabled: isDisabled,
|
|
806
852
|
"aria-busy": loading || void 0,
|
|
853
|
+
style: computedStyle,
|
|
807
854
|
className: [
|
|
808
855
|
"rh-inline-flex rh-items-center rh-justify-center",
|
|
809
856
|
"rh-border rh-font-sans",
|
|
810
857
|
"rh-transition-colors rh-duration-150",
|
|
811
858
|
"focus-visible:rh-outline-none focus-visible:rh-ring-2 focus-visible:rh-ring-ring focus-visible:rh-ring-offset-2",
|
|
812
|
-
variantColorClasses2[variant][color],
|
|
859
|
+
preset ? variantColorClasses2[variant][color] : "hover:rh-brightness-90",
|
|
813
860
|
sizeClasses2[size],
|
|
814
861
|
radiusClasses2[radius],
|
|
815
862
|
isDisabled ? "rh-opacity-50 rh-cursor-not-allowed rh-pointer-events-none" : "",
|
|
@@ -1770,21 +1817,46 @@ var Avatar = forwardRef(function Avatar2({ src, alt = "", initials, size = "md",
|
|
|
1770
1817
|
}
|
|
1771
1818
|
);
|
|
1772
1819
|
});
|
|
1773
|
-
var
|
|
1774
|
-
|
|
1820
|
+
var PRESET_COLORS3 = /* @__PURE__ */ new Set([
|
|
1821
|
+
"primary",
|
|
1822
|
+
"secondary",
|
|
1823
|
+
"danger",
|
|
1824
|
+
"warning",
|
|
1825
|
+
"success",
|
|
1826
|
+
"info"
|
|
1827
|
+
]);
|
|
1828
|
+
var isPresetColor3 = (color) => PRESET_COLORS3.has(color);
|
|
1775
1829
|
var activePresetClasses = {
|
|
1776
1830
|
primary: "rh-bg-primary rh-text-surface rh-border-primary",
|
|
1777
1831
|
secondary: "rh-bg-secondary rh-text-surface rh-border-secondary",
|
|
1778
1832
|
danger: "rh-bg-danger rh-text-surface rh-border-danger",
|
|
1779
1833
|
warning: "rh-bg-warning rh-text-surface rh-border-warning",
|
|
1780
|
-
success: "rh-bg-success rh-text-surface rh-border-success"
|
|
1834
|
+
success: "rh-bg-success rh-text-surface rh-border-success",
|
|
1835
|
+
info: "rh-bg-info rh-text-surface rh-border-info"
|
|
1781
1836
|
};
|
|
1782
1837
|
var inactivePresetClasses = {
|
|
1783
1838
|
primary: "rh-bg-primary/10 rh-text-primary rh-border-primary/30",
|
|
1784
1839
|
secondary: "rh-bg-secondary/10 rh-text-secondary rh-border-secondary/30",
|
|
1785
1840
|
danger: "rh-bg-danger/10 rh-text-danger rh-border-danger/30",
|
|
1786
1841
|
warning: "rh-bg-warning/10 rh-text-warning rh-border-warning/30",
|
|
1787
|
-
success: "rh-bg-success/10 rh-text-success rh-border-success/30"
|
|
1842
|
+
success: "rh-bg-success/10 rh-text-success rh-border-success/30",
|
|
1843
|
+
info: "rh-bg-info/10 rh-text-info rh-border-info/30"
|
|
1844
|
+
};
|
|
1845
|
+
var hoverActivePresetClasses = {
|
|
1846
|
+
primary: "hover:rh-bg-primary-hover hover:rh-border-primary-hover",
|
|
1847
|
+
secondary: "hover:rh-bg-secondary-hover hover:rh-border-secondary-hover",
|
|
1848
|
+
danger: "hover:rh-bg-danger-hover hover:rh-border-danger-hover",
|
|
1849
|
+
warning: "hover:rh-bg-warning-hover hover:rh-border-warning-hover",
|
|
1850
|
+
success: "hover:rh-bg-success-hover hover:rh-border-success-hover",
|
|
1851
|
+
info: "hover:rh-bg-info-hover hover:rh-border-info-hover"
|
|
1852
|
+
};
|
|
1853
|
+
var hoverInactivePresetClasses = {
|
|
1854
|
+
primary: "hover:rh-bg-primary/20 hover:rh-border-primary/50",
|
|
1855
|
+
secondary: "hover:rh-bg-secondary/20 hover:rh-border-secondary/50",
|
|
1856
|
+
danger: "hover:rh-bg-danger/20 hover:rh-border-danger/50",
|
|
1857
|
+
warning: "hover:rh-bg-warning/20 hover:rh-border-warning/50",
|
|
1858
|
+
success: "hover:rh-bg-success/20 hover:rh-border-success/50",
|
|
1859
|
+
info: "hover:rh-bg-info/20 hover:rh-border-info/50"
|
|
1788
1860
|
};
|
|
1789
1861
|
var sizeClasses8 = {
|
|
1790
1862
|
sm: "rh-text-xs rh-px-2 rh-py-0.5 rh-gap-1",
|
|
@@ -1809,27 +1881,34 @@ var Tag = forwardRef(function Tag2({
|
|
|
1809
1881
|
leftIcon,
|
|
1810
1882
|
rightIcon,
|
|
1811
1883
|
className = "",
|
|
1884
|
+
disabled,
|
|
1812
1885
|
style,
|
|
1813
1886
|
children,
|
|
1814
1887
|
...rest
|
|
1815
1888
|
}, ref) {
|
|
1816
|
-
const preset =
|
|
1889
|
+
const preset = isPresetColor3(color);
|
|
1890
|
+
const clickable = !!rest.onClick && !disabled;
|
|
1817
1891
|
const colorClasses = preset ? active ? activePresetClasses[color] : inactivePresetClasses[color] : "";
|
|
1892
|
+
const hoverClasses = clickable && preset ? active ? hoverActivePresetClasses[color] : hoverInactivePresetClasses[color] : clickable ? "hover:rh-brightness-95" : "";
|
|
1818
1893
|
const customStyles = preset ? {} : getCustomColorStyles(color, active);
|
|
1819
1894
|
return /* @__PURE__ */ jsxs(
|
|
1820
1895
|
"span",
|
|
1821
1896
|
{
|
|
1822
1897
|
ref,
|
|
1823
|
-
role:
|
|
1824
|
-
tabIndex:
|
|
1825
|
-
"aria-pressed":
|
|
1898
|
+
role: clickable ? "button" : void 0,
|
|
1899
|
+
tabIndex: clickable ? 0 : void 0,
|
|
1900
|
+
"aria-pressed": clickable ? active : void 0,
|
|
1901
|
+
"aria-disabled": disabled || void 0,
|
|
1826
1902
|
className: [
|
|
1827
1903
|
"rh-inline-flex rh-items-center rh-font-sans rh-font-medium rh-rounded-full",
|
|
1828
1904
|
"rh-border rh-whitespace-nowrap rh-select-none",
|
|
1829
1905
|
"rh-transition-colors rh-duration-150",
|
|
1830
|
-
|
|
1906
|
+
"rh-cursor-pointer",
|
|
1907
|
+
clickable ? "rh-cursor-pointer" : "",
|
|
1831
1908
|
sizeClasses8[size],
|
|
1832
1909
|
colorClasses,
|
|
1910
|
+
hoverClasses,
|
|
1911
|
+
disabled ? "rh-opacity-50 rh-cursor-not-allowed rh-pointer-events-none" : "",
|
|
1833
1912
|
className
|
|
1834
1913
|
].filter(Boolean).join(" "),
|
|
1835
1914
|
style: { ...customStyles, ...style },
|