@rehagro/ui 1.0.3 → 1.0.5

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.js CHANGED
@@ -1894,7 +1894,7 @@ var Tag = React8.forwardRef(function Tag2({
1894
1894
  }, ref) {
1895
1895
  const preset = isPresetColor3(color);
1896
1896
  const clickable = !!rest.onClick && !disabled;
1897
- const colorClasses = preset ? active ? activePresetClasses[color] : inactivePresetClasses[color] : "";
1897
+ const colorClasses2 = preset ? active ? activePresetClasses[color] : inactivePresetClasses[color] : "";
1898
1898
  const hoverClasses = clickable && preset ? active ? hoverActivePresetClasses[color] : hoverInactivePresetClasses[color] : clickable ? "hover:rh-brightness-95" : "";
1899
1899
  const customStyles = preset ? {} : getCustomColorStyles(color, active);
1900
1900
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1912,7 +1912,7 @@ var Tag = React8.forwardRef(function Tag2({
1912
1912
  "rh-cursor-pointer",
1913
1913
  clickable ? "rh-cursor-pointer" : "",
1914
1914
  sizeClasses8[size],
1915
- colorClasses,
1915
+ colorClasses2,
1916
1916
  hoverClasses,
1917
1917
  disabled ? "rh-opacity-50 rh-cursor-not-allowed rh-pointer-events-none" : "",
1918
1918
  className
@@ -1928,6 +1928,410 @@ var Tag = React8.forwardRef(function Tag2({
1928
1928
  }
1929
1929
  );
1930
1930
  });
1931
+ var PRESET_COLORS4 = /* @__PURE__ */ new Set([
1932
+ "primary",
1933
+ "secondary",
1934
+ "danger",
1935
+ "warning",
1936
+ "success",
1937
+ "info"
1938
+ ]);
1939
+ var isPresetColor4 = (color) => PRESET_COLORS4.has(color);
1940
+ var sizeClasses9 = {
1941
+ sm: { container: "rh-h-8", button: "rh-px-2 rh-text-xs" },
1942
+ md: { container: "rh-h-9", button: "rh-px-3 rh-text-sm" },
1943
+ lg: { container: "rh-h-10", button: "rh-px-4 rh-text-sm" }
1944
+ };
1945
+ var radiusClasses5 = {
1946
+ none: "rh-rounded-none",
1947
+ xs: "rh-rounded-xs",
1948
+ sm: "rh-rounded-sm",
1949
+ md: "rh-rounded-md",
1950
+ lg: "rh-rounded-lg",
1951
+ xl: "rh-rounded-xl",
1952
+ full: "rh-rounded-full"
1953
+ };
1954
+ function getActiveStyles(color, isPreset) {
1955
+ if (isPreset) return {};
1956
+ return { backgroundColor: color, color: "#fff" };
1957
+ }
1958
+ function ToggleGroupInner({
1959
+ options,
1960
+ value,
1961
+ onChange,
1962
+ size = "md",
1963
+ radius = "full",
1964
+ color = "primary",
1965
+ disabled = false,
1966
+ className = "",
1967
+ ...rest
1968
+ }, ref) {
1969
+ const preset = isPresetColor4(color);
1970
+ return /* @__PURE__ */ jsxRuntime.jsx(
1971
+ "div",
1972
+ {
1973
+ ref,
1974
+ role: "group",
1975
+ className: [
1976
+ "rh-inline-flex rh-items-center rh-border rh-border-border rh-bg-surface rh-overflow-hidden",
1977
+ "rh-p-0.5",
1978
+ radiusClasses5[radius],
1979
+ sizeClasses9[size].container,
1980
+ disabled ? "rh-opacity-50 rh-cursor-not-allowed" : "",
1981
+ className
1982
+ ].filter(Boolean).join(" "),
1983
+ ...rest,
1984
+ children: options.map((option) => {
1985
+ const isActive = value === option.value;
1986
+ const isDisabled = disabled || option.disabled;
1987
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1988
+ "button",
1989
+ {
1990
+ type: "button",
1991
+ role: "radio",
1992
+ "aria-checked": isActive,
1993
+ "aria-label": option["aria-label"],
1994
+ disabled: isDisabled,
1995
+ onClick: () => !isDisabled && onChange(option.value),
1996
+ className: [
1997
+ "rh-flex rh-items-center rh-justify-center rh-h-full",
1998
+ "rh-border-0 rh-bg-transparent rh-font-sans rh-font-medium",
1999
+ "rh-transition-colors rh-duration-150",
2000
+ "focus-visible:rh-outline-none focus-visible:rh-ring-2 focus-visible:rh-ring-ring",
2001
+ radiusClasses5[radius],
2002
+ sizeClasses9[size].button,
2003
+ isActive && preset ? `rh-bg-border rh-text-text` : "",
2004
+ !isActive ? "rh-text-text-muted hover:rh-bg-border/50" : "",
2005
+ isDisabled ? "rh-cursor-not-allowed rh-pointer-events-none" : "rh-cursor-pointer"
2006
+ ].filter(Boolean).join(" "),
2007
+ style: isActive && !preset ? getActiveStyles(color, preset) : void 0,
2008
+ children: [
2009
+ option.icon,
2010
+ option.label
2011
+ ]
2012
+ },
2013
+ option.value
2014
+ );
2015
+ })
2016
+ }
2017
+ );
2018
+ }
2019
+ var ToggleGroup = React8.forwardRef(ToggleGroupInner);
2020
+ var variantClasses3 = {
2021
+ elevated: "rh-bg-surface rh-shadow-md rh-border-0",
2022
+ outlined: "rh-bg-surface rh-border rh-border-border rh-shadow-none",
2023
+ filled: "rh-bg-background rh-border-0 rh-shadow-none"
2024
+ };
2025
+ var radiusClasses6 = {
2026
+ none: "rh-rounded-none",
2027
+ xs: "rh-rounded-xs",
2028
+ sm: "rh-rounded-sm",
2029
+ md: "rh-rounded-md",
2030
+ lg: "rh-rounded-lg",
2031
+ xl: "rh-rounded-xl"
2032
+ };
2033
+ var paddingClasses = {
2034
+ none: "rh-p-0",
2035
+ sm: "rh-p-3",
2036
+ md: "rh-p-4",
2037
+ lg: "rh-p-6"
2038
+ };
2039
+ var Card = React8.forwardRef(function Card2({
2040
+ variant = "outlined",
2041
+ radius = "sm",
2042
+ padding = "md",
2043
+ clickable = false,
2044
+ disabled = false,
2045
+ className = "",
2046
+ children,
2047
+ ...rest
2048
+ }, ref) {
2049
+ const isInteractive = clickable && !disabled;
2050
+ return /* @__PURE__ */ jsxRuntime.jsx(
2051
+ "div",
2052
+ {
2053
+ ref,
2054
+ role: clickable ? "button" : void 0,
2055
+ tabIndex: isInteractive ? 0 : void 0,
2056
+ "aria-disabled": disabled || void 0,
2057
+ className: [
2058
+ "rh-font-sans rh-transition-all rh-duration-150",
2059
+ variantClasses3[variant],
2060
+ radiusClasses6[radius],
2061
+ paddingClasses[padding],
2062
+ isInteractive ? "rh-cursor-pointer hover:rh-shadow-lg hover:rh-scale-[1.01] active:rh-scale-[0.99]" : "",
2063
+ disabled ? "rh-opacity-50 rh-cursor-not-allowed rh-pointer-events-none" : "",
2064
+ className
2065
+ ].filter(Boolean).join(" "),
2066
+ ...rest,
2067
+ children
2068
+ }
2069
+ );
2070
+ });
2071
+ var CardHeader = React8.forwardRef(function CardHeader2({ className = "", children, ...rest }, ref) {
2072
+ return /* @__PURE__ */ jsxRuntime.jsx(
2073
+ "div",
2074
+ {
2075
+ ref,
2076
+ className: ["rh-flex rh-items-center rh-justify-between rh-gap-4", className].filter(Boolean).join(" "),
2077
+ ...rest,
2078
+ children
2079
+ }
2080
+ );
2081
+ });
2082
+ var CardContent = React8.forwardRef(function CardContent2({ className = "", children, ...rest }, ref) {
2083
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: ["rh-mt-2", className].filter(Boolean).join(" "), ...rest, children });
2084
+ });
2085
+ var CardFooter = React8.forwardRef(function CardFooter2({ className = "", children, ...rest }, ref) {
2086
+ return /* @__PURE__ */ jsxRuntime.jsx(
2087
+ "div",
2088
+ {
2089
+ ref,
2090
+ className: [
2091
+ "rh-flex rh-items-center rh-justify-end rh-gap-2 rh-mt-4 rh-pt-4 rh-border-t rh-border-border",
2092
+ className
2093
+ ].filter(Boolean).join(" "),
2094
+ ...rest,
2095
+ children
2096
+ }
2097
+ );
2098
+ });
2099
+ var PRESET_COLORS5 = /* @__PURE__ */ new Set([
2100
+ "primary",
2101
+ "secondary",
2102
+ "danger",
2103
+ "warning",
2104
+ "success",
2105
+ "info"
2106
+ ]);
2107
+ var isPresetColor5 = (color) => PRESET_COLORS5.has(color);
2108
+ var sizeClasses10 = {
2109
+ xs: "rh-w-3 rh-h-3",
2110
+ sm: "rh-w-4 rh-h-4",
2111
+ md: "rh-w-6 rh-h-6",
2112
+ lg: "rh-w-8 rh-h-8",
2113
+ xl: "rh-w-12 rh-h-12"
2114
+ };
2115
+ var colorClasses = {
2116
+ primary: "rh-text-primary",
2117
+ secondary: "rh-text-secondary",
2118
+ danger: "rh-text-danger",
2119
+ warning: "rh-text-warning",
2120
+ success: "rh-text-success",
2121
+ info: "rh-text-info"
2122
+ };
2123
+ var Spinner = React8.forwardRef(function Spinner2({ size = "md", color = "primary", label = "Carregando...", className = "", style, ...rest }, ref) {
2124
+ const preset = isPresetColor5(color);
2125
+ const colorClass = preset ? colorClasses[color] : "";
2126
+ const customStyle = preset ? style : { ...style, color };
2127
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2128
+ "div",
2129
+ {
2130
+ ref,
2131
+ role: "status",
2132
+ "aria-label": label,
2133
+ className: [
2134
+ "rh-inline-flex rh-items-center rh-justify-center",
2135
+ sizeClasses10[size],
2136
+ colorClass,
2137
+ className
2138
+ ].filter(Boolean).join(" "),
2139
+ style: customStyle,
2140
+ ...rest,
2141
+ children: [
2142
+ /* @__PURE__ */ jsxRuntime.jsxs(
2143
+ "svg",
2144
+ {
2145
+ className: "rh-animate-spin",
2146
+ xmlns: "http://www.w3.org/2000/svg",
2147
+ fill: "none",
2148
+ viewBox: "0 0 24 24",
2149
+ "aria-hidden": "true",
2150
+ children: [
2151
+ /* @__PURE__ */ jsxRuntime.jsx(
2152
+ "circle",
2153
+ {
2154
+ className: "rh-opacity-25",
2155
+ cx: "12",
2156
+ cy: "12",
2157
+ r: "10",
2158
+ stroke: "currentColor",
2159
+ strokeWidth: "4"
2160
+ }
2161
+ ),
2162
+ /* @__PURE__ */ jsxRuntime.jsx(
2163
+ "path",
2164
+ {
2165
+ className: "rh-opacity-75",
2166
+ fill: "currentColor",
2167
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
2168
+ }
2169
+ )
2170
+ ]
2171
+ }
2172
+ ),
2173
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rh-sr-only", children: label })
2174
+ ]
2175
+ }
2176
+ );
2177
+ });
2178
+ var sizeClasses11 = {
2179
+ sm: { cell: "rh-px-2 rh-py-2 rh-text-xs", header: "rh-px-2 rh-py-2 rh-text-xs" },
2180
+ md: { cell: "rh-px-3 rh-py-3 rh-text-sm", header: "rh-px-3 rh-py-3 rh-text-xs" },
2181
+ lg: { cell: "rh-px-4 rh-py-4 rh-text-sm", header: "rh-px-4 rh-py-3 rh-text-sm" }
2182
+ };
2183
+ var alignClasses = {
2184
+ left: "rh-text-left",
2185
+ center: "rh-text-center",
2186
+ right: "rh-text-right"
2187
+ };
2188
+ function TableInner({
2189
+ columns,
2190
+ data,
2191
+ rowKey,
2192
+ size = "md",
2193
+ variant = "default",
2194
+ sort,
2195
+ onSortChange,
2196
+ loading = false,
2197
+ emptyContent = "Nenhum dado encontrado",
2198
+ loadingContent,
2199
+ stickyHeader = false,
2200
+ className = "",
2201
+ ...rest
2202
+ }, ref) {
2203
+ const handleSort = (column) => {
2204
+ if (!column.sortable || !onSortChange) return;
2205
+ const newDirection = sort?.key === column.key ? sort.direction === "asc" ? "desc" : sort.direction === "desc" ? null : "asc" : "asc";
2206
+ onSortChange({ key: column.key, direction: newDirection });
2207
+ };
2208
+ const renderSortIcon = (column) => {
2209
+ if (!column.sortable) return null;
2210
+ const isAsc = sort?.key === column.key && sort.direction === "asc";
2211
+ const isDesc = sort?.key === column.key && sort.direction === "desc";
2212
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rh-ml-1 rh-inline-flex rh-flex-col rh-gap-0.5", children: [
2213
+ /* @__PURE__ */ jsxRuntime.jsx(
2214
+ "svg",
2215
+ {
2216
+ width: "8",
2217
+ height: "5",
2218
+ viewBox: "0 0 8 5",
2219
+ fill: "none",
2220
+ xmlns: "http://www.w3.org/2000/svg",
2221
+ className: isAsc ? "rh-text-primary" : "rh-text-text-muted",
2222
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 0L7.4641 4.5H0.535898L4 0Z", fill: "currentColor" })
2223
+ }
2224
+ ),
2225
+ /* @__PURE__ */ jsxRuntime.jsx(
2226
+ "svg",
2227
+ {
2228
+ width: "8",
2229
+ height: "5",
2230
+ viewBox: "0 0 8 5",
2231
+ fill: "none",
2232
+ xmlns: "http://www.w3.org/2000/svg",
2233
+ className: isDesc ? "rh-text-primary" : "rh-text-text-muted",
2234
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 5L0.535898 0.5H7.4641L4 5Z", fill: "currentColor" })
2235
+ }
2236
+ )
2237
+ ] });
2238
+ };
2239
+ const isEmpty = !loading && data.length === 0;
2240
+ const colSpan = columns.length;
2241
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-full rh-overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs(
2242
+ "table",
2243
+ {
2244
+ ref,
2245
+ className: [
2246
+ "rh-w-full rh-border-collapse rh-font-sans",
2247
+ className
2248
+ ].filter(Boolean).join(" "),
2249
+ ...rest,
2250
+ children: [
2251
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-b rh-border-border", children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
2252
+ "th",
2253
+ {
2254
+ scope: "col",
2255
+ style: { width: column.width },
2256
+ className: [
2257
+ sizeClasses11[size].header,
2258
+ alignClasses[column.align || "left"],
2259
+ "rh-font-semibold rh-text-text-muted rh-whitespace-nowrap",
2260
+ stickyHeader ? "rh-sticky rh-top-0 rh-bg-surface rh-z-10" : "",
2261
+ column.sortable ? "rh-cursor-pointer rh-select-none hover:rh-text-text" : ""
2262
+ ].filter(Boolean).join(" "),
2263
+ onClick: () => handleSort(column),
2264
+ children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rh-inline-flex rh-items-center", children: [
2265
+ column.header,
2266
+ renderSortIcon(column)
2267
+ ] })
2268
+ },
2269
+ column.key
2270
+ )) }) }),
2271
+ /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
2272
+ loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan, className: "rh-text-center rh-py-8", children: loadingContent || /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-center rh-gap-2 rh-text-text-muted", children: [
2273
+ /* @__PURE__ */ jsxRuntime.jsxs(
2274
+ "svg",
2275
+ {
2276
+ className: "rh-animate-spin rh-h-5 rh-w-5",
2277
+ xmlns: "http://www.w3.org/2000/svg",
2278
+ fill: "none",
2279
+ viewBox: "0 0 24 24",
2280
+ children: [
2281
+ /* @__PURE__ */ jsxRuntime.jsx(
2282
+ "circle",
2283
+ {
2284
+ className: "rh-opacity-25",
2285
+ cx: "12",
2286
+ cy: "12",
2287
+ r: "10",
2288
+ stroke: "currentColor",
2289
+ strokeWidth: "4"
2290
+ }
2291
+ ),
2292
+ /* @__PURE__ */ jsxRuntime.jsx(
2293
+ "path",
2294
+ {
2295
+ className: "rh-opacity-75",
2296
+ fill: "currentColor",
2297
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
2298
+ }
2299
+ )
2300
+ ]
2301
+ }
2302
+ ),
2303
+ "Carregando..."
2304
+ ] }) }) }),
2305
+ isEmpty && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan, className: "rh-text-center rh-py-8 rh-text-text-muted", children: emptyContent }) }),
2306
+ !loading && data.map((row, index) => /* @__PURE__ */ jsxRuntime.jsx(
2307
+ "tr",
2308
+ {
2309
+ className: [
2310
+ "rh-border-b rh-border-border rh-transition-colors",
2311
+ "hover:rh-bg-background",
2312
+ variant === "striped" && index % 2 === 1 ? "rh-bg-background/50" : ""
2313
+ ].filter(Boolean).join(" "),
2314
+ children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
2315
+ "td",
2316
+ {
2317
+ className: [
2318
+ sizeClasses11[size].cell,
2319
+ alignClasses[column.align || "left"],
2320
+ "rh-text-text"
2321
+ ].filter(Boolean).join(" "),
2322
+ children: column.render(row, index)
2323
+ },
2324
+ column.key
2325
+ ))
2326
+ },
2327
+ rowKey(row, index)
2328
+ ))
2329
+ ] })
2330
+ ]
2331
+ }
2332
+ ) });
2333
+ }
2334
+ var Table = React8.forwardRef(TableInner);
1931
2335
  var Container = React8.forwardRef(
1932
2336
  function Container2({ fluid = false, className = "", children, ...rest }, ref) {
1933
2337
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -2099,6 +2503,10 @@ var GridItem = React8.forwardRef(
2099
2503
 
2100
2504
  exports.Avatar = Avatar;
2101
2505
  exports.Button = Button;
2506
+ exports.Card = Card;
2507
+ exports.CardContent = CardContent;
2508
+ exports.CardFooter = CardFooter;
2509
+ exports.CardHeader = CardHeader;
2102
2510
  exports.Checkbox = Checkbox;
2103
2511
  exports.CloseIcon = CloseIcon;
2104
2512
  exports.Container = Container;
@@ -2114,12 +2522,15 @@ exports.PlusIcon = PlusIcon;
2114
2522
  exports.RehagroProvider = RehagroProvider;
2115
2523
  exports.SearchIcon = SearchIcon;
2116
2524
  exports.Select = Select;
2525
+ exports.Spinner = Spinner;
2117
2526
  exports.SuccessIcon = SuccessIcon;
2527
+ exports.Table = Table;
2118
2528
  exports.Tag = Tag;
2119
2529
  exports.TextInput = TextInput;
2120
2530
  exports.Toast = Toast;
2121
2531
  exports.ToastContainer = ToastContainer;
2122
2532
  exports.ToastProvider = ToastProvider;
2533
+ exports.ToggleGroup = ToggleGroup;
2123
2534
  exports.Tooltip = Tooltip;
2124
2535
  exports.WarningIcon = WarningIcon;
2125
2536
  exports.useToast = useToast;