@rehagro/ui 1.0.8 → 1.0.9

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
@@ -1956,6 +1956,394 @@ var Tag = forwardRef(function Tag2({
1956
1956
  }
1957
1957
  );
1958
1958
  });
1959
+ var statusClasses3 = {
1960
+ default: "rh-border-border focus-within:rh-ring-2 focus-within:rh-ring-ring focus-within:rh-ring-offset-2",
1961
+ error: "rh-border-danger focus-within:rh-ring-2 focus-within:rh-ring-danger focus-within:rh-ring-offset-2"
1962
+ };
1963
+ var sizeClasses9 = {
1964
+ sm: "rh-min-h-[36px] rh-text-sm rh-px-2 rh-py-1",
1965
+ md: "rh-h-[44px] rh-text-sm rh-px-2 rh-py-[6px]",
1966
+ lg: "rh-min-h-[52px] rh-text-base rh-px-3 rh-py-2"
1967
+ };
1968
+ var radiusClasses5 = {
1969
+ none: "rh-rounded-none",
1970
+ xxs: "rh-rounded-xxs",
1971
+ xs: "rh-rounded-xs",
1972
+ sm: "rh-rounded-sm",
1973
+ md: "rh-rounded-[8px]",
1974
+ lg: "rh-rounded-lg",
1975
+ xl: "rh-rounded-xl",
1976
+ full: "rh-rounded-full"
1977
+ };
1978
+ var helperStatusClasses3 = {
1979
+ default: "rh-text-text-muted",
1980
+ error: "rh-text-danger"
1981
+ };
1982
+ var tagSizeClasses = {
1983
+ sm: "rh-h-6 rh-text-xs rh-py-0.5 rh-px-1.5",
1984
+ md: "rh-h-[28px] rh-text-sm rh-py-[2px] rh-px-[6px]",
1985
+ lg: "rh-h-8 rh-text-sm rh-py-0.5 rh-px-2"
1986
+ };
1987
+ var deleteButtonSizeClasses = {
1988
+ sm: "rh-w-3 rh-h-3",
1989
+ md: "rh-w-[12px] rh-h-[12px]",
1990
+ lg: "rh-w-4 rh-h-4"
1991
+ };
1992
+ var addButtonSizeClasses = {
1993
+ sm: "rh-w-4 rh-h-4",
1994
+ md: "rh-w-5 rh-h-5",
1995
+ lg: "rh-w-5 rh-h-5"
1996
+ };
1997
+ var TagInput = forwardRef(
1998
+ function TagInput2({
1999
+ label,
2000
+ subtitle,
2001
+ options = [],
2002
+ value = [],
2003
+ onChange,
2004
+ placeholder,
2005
+ status = "default",
2006
+ size = "md",
2007
+ radius = "md",
2008
+ helperText,
2009
+ disabled,
2010
+ className = "",
2011
+ wrapperClassName = ""
2012
+ }, ref) {
2013
+ const inputId = React8.useId();
2014
+ const [isOpen, setIsOpen] = useState(false);
2015
+ const containerRef = useRef(null);
2016
+ useEffect(() => {
2017
+ const handleClickOutside = (event) => {
2018
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
2019
+ setIsOpen(false);
2020
+ }
2021
+ };
2022
+ document.addEventListener("mousedown", handleClickOutside);
2023
+ return () => document.removeEventListener("mousedown", handleClickOutside);
2024
+ }, []);
2025
+ const handleRemoveTag = (tagValue) => {
2026
+ if (disabled) return;
2027
+ onChange(value.filter((tag) => tag.value !== tagValue));
2028
+ };
2029
+ const handleToggleOption = (option) => {
2030
+ if (disabled) return;
2031
+ const isSelected = value.some((v) => v.value === option.value);
2032
+ if (isSelected) {
2033
+ onChange(value.filter((v) => v.value !== option.value));
2034
+ } else {
2035
+ onChange([...value, option]);
2036
+ }
2037
+ };
2038
+ const handleAddClick = () => {
2039
+ if (disabled) return;
2040
+ setIsOpen(!isOpen);
2041
+ };
2042
+ return /* @__PURE__ */ jsxs(
2043
+ "div",
2044
+ {
2045
+ ref: (node) => {
2046
+ if (typeof ref === "function") ref(node);
2047
+ else if (ref) ref.current = node;
2048
+ containerRef.current = node;
2049
+ },
2050
+ className: [
2051
+ "rh-flex rh-flex-col rh-gap-2 rh-font-sans rh-relative",
2052
+ wrapperClassName
2053
+ ].filter(Boolean).join(" "),
2054
+ children: [
2055
+ label && /* @__PURE__ */ jsxs(
2056
+ "label",
2057
+ {
2058
+ htmlFor: inputId,
2059
+ className: "rh-flex rh-items-baseline rh-gap-1",
2060
+ children: [
2061
+ /* @__PURE__ */ jsx("span", { className: "rh-text-sm rh-font-semibold rh-text-text", children: label }),
2062
+ subtitle && /* @__PURE__ */ jsx("span", { className: "rh-text-sm rh-text-text-muted", children: subtitle })
2063
+ ]
2064
+ }
2065
+ ),
2066
+ /* @__PURE__ */ jsxs(
2067
+ "div",
2068
+ {
2069
+ className: [
2070
+ "rh-flex rh-flex-row rh-items-center rh-justify-between rh-gap-2",
2071
+ "rh-border rh-bg-surface rh-font-sans",
2072
+ "rh-transition-colors rh-duration-150",
2073
+ statusClasses3[status],
2074
+ radiusClasses5[radius],
2075
+ sizeClasses9[size],
2076
+ disabled ? "rh-opacity-50 rh-cursor-not-allowed rh-bg-background" : "",
2077
+ className
2078
+ ].filter(Boolean).join(" "),
2079
+ children: [
2080
+ /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-flex-row rh-flex-wrap rh-items-center rh-gap-2 rh-flex-1", children: [
2081
+ value.length === 0 && placeholder && /* @__PURE__ */ jsx("span", { className: "rh-text-text-muted", children: placeholder }),
2082
+ value.map((tag) => /* @__PURE__ */ jsxs(
2083
+ "div",
2084
+ {
2085
+ className: [
2086
+ "rh-inline-flex rh-items-center rh-justify-center rh-gap-1",
2087
+ "rh-bg-gray-200 rh-border rh-border-gray-200 rh-rounded-[4px]",
2088
+ tagSizeClasses[size]
2089
+ ].join(" "),
2090
+ children: [
2091
+ /* @__PURE__ */ jsx("span", { className: "rh-font-semibold rh-text-gray-700", children: tag.label }),
2092
+ /* @__PURE__ */ jsx(
2093
+ "button",
2094
+ {
2095
+ type: "button",
2096
+ onClick: () => handleRemoveTag(tag.value),
2097
+ disabled,
2098
+ className: [
2099
+ "rh-flex rh-items-center rh-justify-center",
2100
+ "rh-bg-white rh-rounded-full",
2101
+ "rh-cursor-pointer hover:rh-bg-gray-100",
2102
+ "disabled:rh-cursor-not-allowed disabled:rh-opacity-50",
2103
+ deleteButtonSizeClasses[size]
2104
+ ].join(" "),
2105
+ "aria-label": `Remover ${tag.label}`,
2106
+ children: /* @__PURE__ */ jsx(
2107
+ "svg",
2108
+ {
2109
+ viewBox: "0 0 8 8",
2110
+ fill: "none",
2111
+ xmlns: "http://www.w3.org/2000/svg",
2112
+ className: "rh-w-[8px] rh-h-[8px]",
2113
+ children: /* @__PURE__ */ jsx(
2114
+ "path",
2115
+ {
2116
+ d: "M6 2L2 6M2 2L6 6",
2117
+ stroke: "#374151",
2118
+ strokeWidth: "1.5",
2119
+ strokeLinecap: "round",
2120
+ strokeLinejoin: "round"
2121
+ }
2122
+ )
2123
+ }
2124
+ )
2125
+ }
2126
+ )
2127
+ ]
2128
+ },
2129
+ tag.value
2130
+ ))
2131
+ ] }),
2132
+ /* @__PURE__ */ jsx(
2133
+ "button",
2134
+ {
2135
+ type: "button",
2136
+ onClick: handleAddClick,
2137
+ disabled,
2138
+ className: [
2139
+ "rh-flex rh-items-center rh-justify-center rh-shrink-0",
2140
+ "rh-text-text-muted hover:rh-text-text",
2141
+ "rh-cursor-pointer",
2142
+ "disabled:rh-cursor-not-allowed disabled:rh-opacity-50",
2143
+ addButtonSizeClasses[size]
2144
+ ].join(" "),
2145
+ "aria-label": "Adicionar",
2146
+ "aria-expanded": isOpen,
2147
+ children: /* @__PURE__ */ jsx(
2148
+ "svg",
2149
+ {
2150
+ viewBox: "0 0 20 20",
2151
+ fill: "none",
2152
+ xmlns: "http://www.w3.org/2000/svg",
2153
+ className: "rh-w-full rh-h-full",
2154
+ children: /* @__PURE__ */ jsx(
2155
+ "path",
2156
+ {
2157
+ d: "M10 4V16M4 10H16",
2158
+ stroke: "currentColor",
2159
+ strokeWidth: "2",
2160
+ strokeLinecap: "round",
2161
+ strokeLinejoin: "round"
2162
+ }
2163
+ )
2164
+ }
2165
+ )
2166
+ }
2167
+ )
2168
+ ]
2169
+ }
2170
+ ),
2171
+ isOpen && options.length > 0 && /* @__PURE__ */ jsx(
2172
+ "div",
2173
+ {
2174
+ className: [
2175
+ "rh-absolute rh-top-full rh-left-0 rh-right-0 rh-z-50",
2176
+ "rh-mt-1 rh-bg-surface rh-border rh-border-border",
2177
+ "rh-rounded-[8px] rh-shadow-lg rh-overflow-hidden"
2178
+ ].join(" "),
2179
+ children: /* @__PURE__ */ jsx("ul", { className: "rh-max-h-[200px] rh-overflow-y-auto", children: options.map((option) => {
2180
+ const isSelected = value.some((v) => v.value === option.value);
2181
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
2182
+ "button",
2183
+ {
2184
+ type: "button",
2185
+ onClick: () => handleToggleOption(option),
2186
+ className: [
2187
+ "rh-w-full rh-flex rh-items-center rh-justify-between",
2188
+ "rh-px-3 rh-py-3 rh-text-left",
2189
+ "rh-border-b rh-border-border/50 last:rh-border-b-0",
2190
+ "hover:rh-bg-gray-50 rh-transition-colors",
2191
+ isSelected ? "rh-text-text" : "rh-text-text-muted"
2192
+ ].join(" "),
2193
+ children: [
2194
+ /* @__PURE__ */ jsx("span", { className: "rh-text-sm rh-font-normal", children: option.label }),
2195
+ /* @__PURE__ */ jsx(
2196
+ "span",
2197
+ {
2198
+ className: [
2199
+ "rh-w-5 rh-h-5 rh-rounded rh-border-2 rh-flex rh-items-center rh-justify-center",
2200
+ isSelected ? "rh-bg-primary rh-border-primary" : "rh-bg-white rh-border-gray-300"
2201
+ ].join(" "),
2202
+ children: isSelected && /* @__PURE__ */ jsx(
2203
+ "svg",
2204
+ {
2205
+ viewBox: "0 0 12 12",
2206
+ fill: "none",
2207
+ xmlns: "http://www.w3.org/2000/svg",
2208
+ className: "rh-w-3 rh-h-3",
2209
+ children: /* @__PURE__ */ jsx(
2210
+ "path",
2211
+ {
2212
+ d: "M2 6L5 9L10 3",
2213
+ stroke: "white",
2214
+ strokeWidth: "2",
2215
+ strokeLinecap: "round",
2216
+ strokeLinejoin: "round"
2217
+ }
2218
+ )
2219
+ }
2220
+ )
2221
+ }
2222
+ )
2223
+ ]
2224
+ }
2225
+ ) }, option.value);
2226
+ }) })
2227
+ }
2228
+ ),
2229
+ helperText && /* @__PURE__ */ jsx(
2230
+ "span",
2231
+ {
2232
+ id: `${inputId}-helper`,
2233
+ className: [
2234
+ "rh-flex rh-items-center rh-gap-1 rh-text-xs",
2235
+ helperStatusClasses3[status]
2236
+ ].join(" "),
2237
+ children: helperText
2238
+ }
2239
+ )
2240
+ ]
2241
+ }
2242
+ );
2243
+ }
2244
+ );
2245
+ var ProgressBar = forwardRef(
2246
+ function ProgressBar2({
2247
+ value,
2248
+ label,
2249
+ size = "sm",
2250
+ showPercentage = true,
2251
+ barColor,
2252
+ bgColor,
2253
+ className = ""
2254
+ }, ref) {
2255
+ const clampedValue = Math.min(100, Math.max(0, value));
2256
+ if (size === "lg") {
2257
+ return /* @__PURE__ */ jsxs(
2258
+ "div",
2259
+ {
2260
+ ref,
2261
+ className: [
2262
+ "rh-flex rh-flex-col rh-items-start rh-gap-2 rh-font-sans",
2263
+ className
2264
+ ].filter(Boolean).join(" "),
2265
+ children: [
2266
+ /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-flex-row rh-justify-between rh-items-start rh-w-full", children: [
2267
+ label && /* @__PURE__ */ jsx(
2268
+ "span",
2269
+ {
2270
+ className: "rh-font-sora rh-font-bold rh-text-base rh-leading-6 rh-text-[#374151] rh-flex-1",
2271
+ children: label
2272
+ }
2273
+ ),
2274
+ showPercentage && /* @__PURE__ */ jsxs(
2275
+ "span",
2276
+ {
2277
+ className: "rh-font-inter rh-font-normal rh-text-sm rh-leading-5 rh-text-[#9CA3AF] rh-tracking-[0.025em] rh-text-right",
2278
+ children: [
2279
+ clampedValue,
2280
+ "%"
2281
+ ]
2282
+ }
2283
+ )
2284
+ ] }),
2285
+ /* @__PURE__ */ jsx(
2286
+ "div",
2287
+ {
2288
+ className: "rh-w-full rh-h-1 rh-rounded-[40px] rh-overflow-hidden",
2289
+ style: { backgroundColor: bgColor || "#E5E7EB" },
2290
+ children: /* @__PURE__ */ jsx(
2291
+ "div",
2292
+ {
2293
+ className: "rh-h-full rh-rounded-[40px] rh-transition-all rh-duration-300",
2294
+ style: {
2295
+ width: `${clampedValue}%`,
2296
+ backgroundColor: barColor || "#538CC6"
2297
+ }
2298
+ }
2299
+ )
2300
+ }
2301
+ )
2302
+ ]
2303
+ }
2304
+ );
2305
+ }
2306
+ return /* @__PURE__ */ jsxs(
2307
+ "div",
2308
+ {
2309
+ ref,
2310
+ className: [
2311
+ "rh-flex rh-flex-row rh-items-center rh-gap-2 rh-font-sans",
2312
+ className
2313
+ ].filter(Boolean).join(" "),
2314
+ children: [
2315
+ /* @__PURE__ */ jsx(
2316
+ "div",
2317
+ {
2318
+ className: "rh-flex-1 rh-h-1 rh-rounded-[40px] rh-overflow-hidden",
2319
+ style: { backgroundColor: bgColor || "#E5E7EB" },
2320
+ children: /* @__PURE__ */ jsx(
2321
+ "div",
2322
+ {
2323
+ className: "rh-h-full rh-rounded-[40px] rh-transition-all rh-duration-300",
2324
+ style: {
2325
+ width: `${clampedValue}%`,
2326
+ backgroundColor: barColor || "#538CC6"
2327
+ }
2328
+ }
2329
+ )
2330
+ }
2331
+ ),
2332
+ showPercentage && /* @__PURE__ */ jsxs(
2333
+ "span",
2334
+ {
2335
+ className: "rh-font-inter rh-font-normal rh-text-sm rh-leading-5 rh-text-[#9CA3AF] rh-tracking-[0.025em] rh-text-right rh-min-w-[40px]",
2336
+ children: [
2337
+ clampedValue,
2338
+ "%"
2339
+ ]
2340
+ }
2341
+ )
2342
+ ]
2343
+ }
2344
+ );
2345
+ }
2346
+ );
1959
2347
  var PRESET_COLORS4 = /* @__PURE__ */ new Set([
1960
2348
  "primary",
1961
2349
  "secondary",
@@ -1965,12 +2353,12 @@ var PRESET_COLORS4 = /* @__PURE__ */ new Set([
1965
2353
  "info"
1966
2354
  ]);
1967
2355
  var isPresetColor4 = (color) => PRESET_COLORS4.has(color);
1968
- var sizeClasses9 = {
2356
+ var sizeClasses10 = {
1969
2357
  sm: { container: "rh-h-8", button: "rh-px-2 rh-text-xs" },
1970
2358
  md: { container: "rh-h-9", button: "rh-px-3 rh-text-sm" },
1971
2359
  lg: { container: "rh-h-10", button: "rh-px-4 rh-text-sm" }
1972
2360
  };
1973
- var radiusClasses5 = {
2361
+ var radiusClasses6 = {
1974
2362
  none: "rh-rounded-none",
1975
2363
  xs: "rh-rounded-xs",
1976
2364
  sm: "rh-rounded-sm",
@@ -2003,8 +2391,8 @@ function ToggleGroupInner({
2003
2391
  className: [
2004
2392
  "rh-inline-flex rh-items-center rh-bg-muted rh-overflow-hidden",
2005
2393
  "rh-p-1 rh-gap-0.5",
2006
- radiusClasses5[radius],
2007
- sizeClasses9[size].container,
2394
+ radiusClasses6[radius],
2395
+ sizeClasses10[size].container,
2008
2396
  disabled ? "rh-opacity-50 rh-cursor-not-allowed" : "",
2009
2397
  className
2010
2398
  ].filter(Boolean).join(" "),
@@ -2026,8 +2414,8 @@ function ToggleGroupInner({
2026
2414
  "rh-border-0 rh-font-sans rh-font-medium",
2027
2415
  "rh-transition-all rh-duration-150",
2028
2416
  "focus-visible:rh-outline-none focus-visible:rh-ring-2 focus-visible:rh-ring-ring",
2029
- radiusClasses5[radius],
2030
- sizeClasses9[size].button,
2417
+ radiusClasses6[radius],
2418
+ sizeClasses10[size].button,
2031
2419
  isActive ? "rh-bg-surface rh-text-text rh-shadow-sm" : "rh-bg-transparent rh-text-text-muted",
2032
2420
  !isActive && !isDisabled ? "hover:rh-bg-surface/50" : "",
2033
2421
  isDisabled ? "rh-cursor-not-allowed rh-pointer-events-none" : "rh-cursor-pointer"
@@ -2050,7 +2438,7 @@ var variantClasses3 = {
2050
2438
  outlined: "rh-bg-surface rh-border rh-border-border rh-shadow-none",
2051
2439
  filled: "rh-bg-background rh-border-0 rh-shadow-none"
2052
2440
  };
2053
- var radiusClasses6 = {
2441
+ var radiusClasses7 = {
2054
2442
  none: "rh-rounded-none",
2055
2443
  xs: "rh-rounded-xs",
2056
2444
  sm: "rh-rounded-sm",
@@ -2085,7 +2473,7 @@ var Card = forwardRef(function Card2({
2085
2473
  className: [
2086
2474
  "rh-font-sans rh-transition-all rh-duration-150",
2087
2475
  variantClasses3[variant],
2088
- radiusClasses6[radius],
2476
+ radiusClasses7[radius],
2089
2477
  paddingClasses[padding],
2090
2478
  isInteractive ? "rh-cursor-pointer hover:rh-shadow-lg hover:rh-scale-[1.01] active:rh-scale-[0.99]" : "",
2091
2479
  disabled ? "rh-opacity-50 rh-cursor-not-allowed rh-pointer-events-none" : "",
@@ -2133,7 +2521,7 @@ var PRESET_COLORS5 = /* @__PURE__ */ new Set([
2133
2521
  "info"
2134
2522
  ]);
2135
2523
  var isPresetColor5 = (color) => PRESET_COLORS5.has(color);
2136
- var sizeClasses10 = {
2524
+ var sizeClasses11 = {
2137
2525
  xs: "rh-w-3 rh-h-3",
2138
2526
  sm: "rh-w-4 rh-h-4",
2139
2527
  md: "rh-w-6 rh-h-6",
@@ -2160,7 +2548,7 @@ var Spinner = forwardRef(function Spinner2({ size = "md", color = "primary", lab
2160
2548
  "aria-label": label,
2161
2549
  className: [
2162
2550
  "rh-inline-flex rh-items-center rh-justify-center",
2163
- sizeClasses10[size],
2551
+ sizeClasses11[size],
2164
2552
  colorClass,
2165
2553
  className
2166
2554
  ].filter(Boolean).join(" "),
@@ -2203,7 +2591,7 @@ var Spinner = forwardRef(function Spinner2({ size = "md", color = "primary", lab
2203
2591
  }
2204
2592
  );
2205
2593
  });
2206
- var sizeClasses11 = {
2594
+ var sizeClasses12 = {
2207
2595
  sm: { cell: "rh-px-2 rh-py-2 rh-text-xs", header: "rh-px-2 rh-py-2 rh-text-xs" },
2208
2596
  md: { cell: "rh-px-3 rh-py-3 rh-text-sm", header: "rh-px-3 rh-py-3 rh-text-xs" },
2209
2597
  lg: { cell: "rh-px-4 rh-py-4 rh-text-sm", header: "rh-px-4 rh-py-3 rh-text-sm" }
@@ -2283,7 +2671,7 @@ function TableInner({
2283
2671
  scope: "col",
2284
2672
  style: { width: column.width },
2285
2673
  className: [
2286
- sizeClasses11[size].header,
2674
+ sizeClasses12[size].header,
2287
2675
  alignClasses[column.align || "left"],
2288
2676
  "rh-font-semibold rh-text-text-muted rh-whitespace-nowrap",
2289
2677
  stickyHeader ? "rh-sticky rh-top-0 rh-bg-surface rh-z-10" : "",
@@ -2344,7 +2732,7 @@ function TableInner({
2344
2732
  "td",
2345
2733
  {
2346
2734
  className: [
2347
- sizeClasses11[size].cell,
2735
+ sizeClasses12[size].cell,
2348
2736
  alignClasses[column.align || "left"],
2349
2737
  "rh-text-text"
2350
2738
  ].filter(Boolean).join(" "),
@@ -2530,6 +2918,6 @@ var GridItem = forwardRef(
2530
2918
  }
2531
2919
  );
2532
2920
 
2533
- 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 };
2921
+ export { Avatar, Button, Card, CardContent, CardFooter, CardHeader, Checkbox, CloseIcon, Container, DeleteIcon, EditIcon, ErrorIcon, GridContainer, GridItem, IconButton, InfoIcon, NeutralIcon, PlusIcon, ProgressBar, RehagroProvider, SearchIcon, Select, Spinner, SuccessIcon, Table, Tag, TagInput, TextInput, Toast, ToastContainer, ToastProvider, ToggleGroup, Tooltip, WarningIcon, useToast };
2534
2922
  //# sourceMappingURL=index.mjs.map
2535
2923
  //# sourceMappingURL=index.mjs.map