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