@rehagro/ui 1.0.49 → 1.0.51
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.d.mts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +91 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -14
- package/dist/index.mjs.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/native.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -470,6 +470,8 @@ type SelectBaseProps = {
|
|
|
470
470
|
radius?: SelectRadius;
|
|
471
471
|
/** Helper/error message displayed below the select */
|
|
472
472
|
helperText?: React__default.ReactNode;
|
|
473
|
+
/** Whether to use radio buttons instead of checkboxes */
|
|
474
|
+
radio?: boolean;
|
|
473
475
|
/** Whether the select is disabled */
|
|
474
476
|
disabled?: boolean;
|
|
475
477
|
/** Custom class for the trigger container */
|
|
@@ -513,20 +515,35 @@ type DateSelectValue = {
|
|
|
513
515
|
};
|
|
514
516
|
type DateSelectProps = DateSelectBaseProps;
|
|
515
517
|
type DateSelectBaseProps = {
|
|
518
|
+
/** Text displayed above the field */
|
|
516
519
|
label?: string;
|
|
520
|
+
/** Secondary text next to the label; use "*" to render a red asterisk */
|
|
517
521
|
subtitle?: string;
|
|
522
|
+
/** Text displayed when no date is selected */
|
|
518
523
|
placeholder?: string;
|
|
524
|
+
/** Visual state of the field: "default" (default) or "error" */
|
|
519
525
|
status?: SelectStatus;
|
|
526
|
+
/** Field size: "sm" | "md" | "lg" */
|
|
520
527
|
size?: SelectSize;
|
|
528
|
+
/** Border radius of the field */
|
|
521
529
|
radius?: SelectRadius;
|
|
530
|
+
/** Helper or error message displayed below the field */
|
|
522
531
|
helperText?: React__default.ReactNode;
|
|
532
|
+
/** Disables the field, preventing any interaction */
|
|
523
533
|
disabled?: boolean;
|
|
534
|
+
/** CSS class applied to the inner trigger element */
|
|
524
535
|
className?: string;
|
|
536
|
+
/** CSS class applied to the outer wrapper element */
|
|
525
537
|
wrapperClassName?: string;
|
|
538
|
+
/** Controlled value of the selected date */
|
|
526
539
|
value?: DateSelectValue;
|
|
540
|
+
/** Uncontrolled initial value of the selected date */
|
|
527
541
|
defaultValue?: DateSelectValue;
|
|
542
|
+
/** Callback fired when the selected date changes */
|
|
528
543
|
onChange?: (value: DateSelectValue) => void;
|
|
544
|
+
/** Start year of the range shown in the picker */
|
|
529
545
|
startYear?: number;
|
|
546
|
+
/** End year of the range shown in the picker */
|
|
530
547
|
endYear?: number;
|
|
531
548
|
/** Custom background color for the trigger button */
|
|
532
549
|
backgroundColor?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -470,6 +470,8 @@ type SelectBaseProps = {
|
|
|
470
470
|
radius?: SelectRadius;
|
|
471
471
|
/** Helper/error message displayed below the select */
|
|
472
472
|
helperText?: React__default.ReactNode;
|
|
473
|
+
/** Whether to use radio buttons instead of checkboxes */
|
|
474
|
+
radio?: boolean;
|
|
473
475
|
/** Whether the select is disabled */
|
|
474
476
|
disabled?: boolean;
|
|
475
477
|
/** Custom class for the trigger container */
|
|
@@ -513,20 +515,35 @@ type DateSelectValue = {
|
|
|
513
515
|
};
|
|
514
516
|
type DateSelectProps = DateSelectBaseProps;
|
|
515
517
|
type DateSelectBaseProps = {
|
|
518
|
+
/** Text displayed above the field */
|
|
516
519
|
label?: string;
|
|
520
|
+
/** Secondary text next to the label; use "*" to render a red asterisk */
|
|
517
521
|
subtitle?: string;
|
|
522
|
+
/** Text displayed when no date is selected */
|
|
518
523
|
placeholder?: string;
|
|
524
|
+
/** Visual state of the field: "default" (default) or "error" */
|
|
519
525
|
status?: SelectStatus;
|
|
526
|
+
/** Field size: "sm" | "md" | "lg" */
|
|
520
527
|
size?: SelectSize;
|
|
528
|
+
/** Border radius of the field */
|
|
521
529
|
radius?: SelectRadius;
|
|
530
|
+
/** Helper or error message displayed below the field */
|
|
522
531
|
helperText?: React__default.ReactNode;
|
|
532
|
+
/** Disables the field, preventing any interaction */
|
|
523
533
|
disabled?: boolean;
|
|
534
|
+
/** CSS class applied to the inner trigger element */
|
|
524
535
|
className?: string;
|
|
536
|
+
/** CSS class applied to the outer wrapper element */
|
|
525
537
|
wrapperClassName?: string;
|
|
538
|
+
/** Controlled value of the selected date */
|
|
526
539
|
value?: DateSelectValue;
|
|
540
|
+
/** Uncontrolled initial value of the selected date */
|
|
527
541
|
defaultValue?: DateSelectValue;
|
|
542
|
+
/** Callback fired when the selected date changes */
|
|
528
543
|
onChange?: (value: DateSelectValue) => void;
|
|
544
|
+
/** Start year of the range shown in the picker */
|
|
529
545
|
startYear?: number;
|
|
546
|
+
/** End year of the range shown in the picker */
|
|
530
547
|
endYear?: number;
|
|
531
548
|
/** Custom background color for the trigger button */
|
|
532
549
|
backgroundColor?: string;
|
package/dist/index.js
CHANGED
|
@@ -1586,6 +1586,19 @@ var CheckIcon2 = ({ className }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
1586
1586
|
)
|
|
1587
1587
|
}
|
|
1588
1588
|
);
|
|
1589
|
+
var RadioIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1590
|
+
"span",
|
|
1591
|
+
{
|
|
1592
|
+
className: [
|
|
1593
|
+
"rh-inline-flex rh-items-center rh-justify-center",
|
|
1594
|
+
"rh-w-4 rh-h-4 rh-shrink-0",
|
|
1595
|
+
"rh-border rh-rounded-full rh-transition-colors rh-duration-150",
|
|
1596
|
+
isSelected ? "rh-border-primary" : "rh-border-border rh-bg-surface"
|
|
1597
|
+
].filter(Boolean).join(" "),
|
|
1598
|
+
"aria-hidden": "true",
|
|
1599
|
+
children: isSelected && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rh-w-2.5 rh-h-2.5 rh-rounded-full rh-bg-primary" })
|
|
1600
|
+
}
|
|
1601
|
+
);
|
|
1589
1602
|
var Select = React9.forwardRef(function Select2(props, ref) {
|
|
1590
1603
|
const {
|
|
1591
1604
|
options,
|
|
@@ -1596,6 +1609,7 @@ var Select = React9.forwardRef(function Select2(props, ref) {
|
|
|
1596
1609
|
size = "md",
|
|
1597
1610
|
radius = "xs",
|
|
1598
1611
|
helperText,
|
|
1612
|
+
radio = false,
|
|
1599
1613
|
disabled = false,
|
|
1600
1614
|
className = "",
|
|
1601
1615
|
wrapperClassName = "",
|
|
@@ -1859,7 +1873,7 @@ var Select = React9.forwardRef(function Select2(props, ref) {
|
|
|
1859
1873
|
].filter(Boolean).join(" "),
|
|
1860
1874
|
children: [
|
|
1861
1875
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "rh-flex-1 rh-truncate rh-text-text", children: option.label }),
|
|
1862
|
-
multiple ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1876
|
+
radio ? /* @__PURE__ */ jsxRuntime.jsx(RadioIcon, { isSelected }) : multiple ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1863
1877
|
"span",
|
|
1864
1878
|
{
|
|
1865
1879
|
className: [
|
|
@@ -2047,6 +2061,7 @@ var DateSelect = React9.forwardRef(
|
|
|
2047
2061
|
const helperId = React9__default.default.useId();
|
|
2048
2062
|
const [isOpen, setIsOpen] = React9.useState(false);
|
|
2049
2063
|
const [isHelperDismissed, setIsHelperDismissed] = React9.useState(false);
|
|
2064
|
+
const [dropdownAlign, setDropdownAlign] = React9.useState("left");
|
|
2050
2065
|
const [internalValue, setInternalValue] = React9.useState(
|
|
2051
2066
|
props.defaultValue ?? { mode: "day" }
|
|
2052
2067
|
);
|
|
@@ -2063,8 +2078,9 @@ var DateSelect = React9.forwardRef(
|
|
|
2063
2078
|
const [yearGridStart, setYearGridStart] = React9.useState(
|
|
2064
2079
|
Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 12) * 12
|
|
2065
2080
|
);
|
|
2066
|
-
const wrapperRef =
|
|
2067
|
-
const innerRef =
|
|
2081
|
+
const wrapperRef = React9.useRef(null);
|
|
2082
|
+
const innerRef = React9.useRef(null);
|
|
2083
|
+
const dropdownRef = React9.useRef(null);
|
|
2068
2084
|
React9__default.default.useImperativeHandle(ref, () => innerRef.current);
|
|
2069
2085
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
2070
2086
|
const yearStart = startYear ?? currentYear - 10;
|
|
@@ -2098,7 +2114,22 @@ var DateSelect = React9.forwardRef(
|
|
|
2098
2114
|
if (!isControlled) setInternalValue(newValue);
|
|
2099
2115
|
props.onChange?.(newValue);
|
|
2100
2116
|
};
|
|
2101
|
-
const
|
|
2117
|
+
const handleMonthClear = () => {
|
|
2118
|
+
const newValue = { mode: "month" };
|
|
2119
|
+
if (!isControlled) setInternalValue(newValue);
|
|
2120
|
+
props.onChange?.(newValue);
|
|
2121
|
+
};
|
|
2122
|
+
const handleDayClear = () => {
|
|
2123
|
+
const newValue = { mode: "day" };
|
|
2124
|
+
if (!isControlled) setInternalValue(newValue);
|
|
2125
|
+
props.onChange?.(newValue);
|
|
2126
|
+
};
|
|
2127
|
+
const handleYearClear = () => {
|
|
2128
|
+
const newValue = { mode: "year" };
|
|
2129
|
+
if (!isControlled) setInternalValue(newValue);
|
|
2130
|
+
props.onChange?.(newValue);
|
|
2131
|
+
};
|
|
2132
|
+
const displayText = React9.useMemo(() => {
|
|
2102
2133
|
if (value.mode === "year" && value.year) return value.year.toString();
|
|
2103
2134
|
if (value.mode === "month" && value.year != null)
|
|
2104
2135
|
return `${MONTHS_SHORT[value.month || 0]} ${value.year}`;
|
|
@@ -2109,7 +2140,7 @@ var DateSelect = React9.forwardRef(
|
|
|
2109
2140
|
}
|
|
2110
2141
|
return null;
|
|
2111
2142
|
}, [value]);
|
|
2112
|
-
|
|
2143
|
+
React9.useEffect(() => {
|
|
2113
2144
|
if (!isOpen) return;
|
|
2114
2145
|
const handleClickOutside = (e) => {
|
|
2115
2146
|
if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
|
|
@@ -2119,7 +2150,7 @@ var DateSelect = React9.forwardRef(
|
|
|
2119
2150
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2120
2151
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2121
2152
|
}, [isOpen]);
|
|
2122
|
-
|
|
2153
|
+
React9.useEffect(() => {
|
|
2123
2154
|
if (!isOpen) return;
|
|
2124
2155
|
const handleEscape = (e) => {
|
|
2125
2156
|
if (e.key === "Escape") {
|
|
@@ -2130,6 +2161,18 @@ var DateSelect = React9.forwardRef(
|
|
|
2130
2161
|
document.addEventListener("keydown", handleEscape);
|
|
2131
2162
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
2132
2163
|
}, [isOpen]);
|
|
2164
|
+
React9.useEffect(() => {
|
|
2165
|
+
if (!isOpen || !innerRef.current || !dropdownRef.current) return;
|
|
2166
|
+
const triggerRect = innerRef.current.getBoundingClientRect();
|
|
2167
|
+
const dropdownWidth = activeMode === "interval" ? 720 : 385;
|
|
2168
|
+
const spaceLeft = triggerRect.left;
|
|
2169
|
+
const spaceRight = window.innerWidth - triggerRect.right;
|
|
2170
|
+
if (spaceLeft < dropdownWidth && spaceRight >= dropdownWidth) {
|
|
2171
|
+
setDropdownAlign("right");
|
|
2172
|
+
} else {
|
|
2173
|
+
setDropdownAlign("left");
|
|
2174
|
+
}
|
|
2175
|
+
}, [isOpen, activeMode]);
|
|
2133
2176
|
const getDaysInMonth2 = (year, month) => new Date(year, month + 1, 0).getDate();
|
|
2134
2177
|
const getFirstDayOfMonth2 = (year, month) => new Date(year, month, 1).getDay();
|
|
2135
2178
|
const isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
@@ -2206,7 +2249,18 @@ var DateSelect = React9.forwardRef(
|
|
|
2206
2249
|
},
|
|
2207
2250
|
year
|
|
2208
2251
|
);
|
|
2209
|
-
}) })
|
|
2252
|
+
}) }),
|
|
2253
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-items-center rh-justify-between rh-pt-3 rh-mt-3 rh-border-t rh-border-border/30", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2254
|
+
"button",
|
|
2255
|
+
{
|
|
2256
|
+
onClick: handleYearClear,
|
|
2257
|
+
className: "rh-flex rh-items-center rh-gap-1.5 rh-text-sm rh-text-text rh-font-medium rh-px-2 rh-py-1.5 rh-rounded-sm hover:rh-bg-background rh-transition-colors rh-duration-150",
|
|
2258
|
+
children: [
|
|
2259
|
+
/* @__PURE__ */ jsxRuntime.jsx(EraserIcon, { className: "rh-w-4 rh-h-4" }),
|
|
2260
|
+
"Limpar"
|
|
2261
|
+
]
|
|
2262
|
+
}
|
|
2263
|
+
) })
|
|
2210
2264
|
] });
|
|
2211
2265
|
const renderMonthGrid = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-p-1", children: [
|
|
2212
2266
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-between", children: [
|
|
@@ -2254,7 +2308,18 @@ var DateSelect = React9.forwardRef(
|
|
|
2254
2308
|
},
|
|
2255
2309
|
month
|
|
2256
2310
|
);
|
|
2257
|
-
}) })
|
|
2311
|
+
}) }),
|
|
2312
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-items-center rh-justify-between rh-pt-3 rh-mt-3 rh-border-t rh-border-border/30", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2313
|
+
"button",
|
|
2314
|
+
{
|
|
2315
|
+
onClick: handleMonthClear,
|
|
2316
|
+
className: "rh-flex rh-items-center rh-gap-1.5 rh-text-sm rh-text-text rh-font-medium rh-px-2 rh-py-1.5 rh-rounded-sm hover:rh-bg-background rh-transition-colors rh-duration-150",
|
|
2317
|
+
children: [
|
|
2318
|
+
/* @__PURE__ */ jsxRuntime.jsx(EraserIcon, { className: "rh-w-4 rh-h-4" }),
|
|
2319
|
+
"Limpar"
|
|
2320
|
+
]
|
|
2321
|
+
}
|
|
2322
|
+
) })
|
|
2258
2323
|
] });
|
|
2259
2324
|
const renderIntervalNav = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2260
2325
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-gap-4 rh-p-1", children: [
|
|
@@ -2512,7 +2577,18 @@ var DateSelect = React9.forwardRef(
|
|
|
2512
2577
|
},
|
|
2513
2578
|
i
|
|
2514
2579
|
)) }),
|
|
2515
|
-
renderDayGrid(selectedYear, selectedMonth)
|
|
2580
|
+
renderDayGrid(selectedYear, selectedMonth),
|
|
2581
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-items-center rh-justify-between rh-pt-3 rh-mt-3 rh-border-t rh-border-border/30", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2582
|
+
"button",
|
|
2583
|
+
{
|
|
2584
|
+
onClick: handleDayClear,
|
|
2585
|
+
className: "rh-flex rh-items-center rh-gap-1.5 rh-text-sm rh-text-text rh-font-medium rh-px-2 rh-py-1.5 rh-rounded-sm hover:rh-bg-background rh-transition-colors rh-duration-150",
|
|
2586
|
+
children: [
|
|
2587
|
+
/* @__PURE__ */ jsxRuntime.jsx(EraserIcon, { className: "rh-w-4 rh-h-4" }),
|
|
2588
|
+
"Limpar"
|
|
2589
|
+
]
|
|
2590
|
+
}
|
|
2591
|
+
) })
|
|
2516
2592
|
] });
|
|
2517
2593
|
case "month":
|
|
2518
2594
|
return renderMonthGrid();
|
|
@@ -2632,11 +2708,13 @@ var DateSelect = React9.forwardRef(
|
|
|
2632
2708
|
isOpen && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2633
2709
|
"div",
|
|
2634
2710
|
{
|
|
2711
|
+
ref: dropdownRef,
|
|
2635
2712
|
className: [
|
|
2636
2713
|
"rh-absolute rh-z-50 rh-mt-1 rh-p-5",
|
|
2637
2714
|
"rh-bg-surface rh-rounded-md",
|
|
2638
2715
|
dropdownRadiusClasses2[radius],
|
|
2639
|
-
activeMode === "interval" ? "rh-w-[720px]" : "rh-w-[385px]"
|
|
2716
|
+
activeMode === "interval" ? "rh-w-[720px]" : "rh-w-[385px]",
|
|
2717
|
+
dropdownAlign === "left" ? "rh-right-0" : "rh-left-0"
|
|
2640
2718
|
].filter(Boolean).join(" "),
|
|
2641
2719
|
style: {
|
|
2642
2720
|
top: "100%",
|
|
@@ -4271,7 +4349,7 @@ function TableInner({
|
|
|
4271
4349
|
style: bodyStyleInline,
|
|
4272
4350
|
className: [
|
|
4273
4351
|
"rh-border-b rh-border-border rh-transition-colors",
|
|
4274
|
-
"hover:rh-bg-background",
|
|
4352
|
+
"hover:rh-bg-background/50",
|
|
4275
4353
|
variant === "striped" && index % 2 === 1 ? "rh-bg-background/50" : ""
|
|
4276
4354
|
].filter(Boolean).join(" "),
|
|
4277
4355
|
children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4293,7 +4371,7 @@ function TableInner({
|
|
|
4293
4371
|
onChange: (value) => column.onEditChange?.(row, index, value),
|
|
4294
4372
|
className: "rh-w-full rh-h-full"
|
|
4295
4373
|
}
|
|
4296
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: column.render(row, index) }),
|
|
4374
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: { width: "100%" }, children: column.render(row, index) }),
|
|
4297
4375
|
column.actionIcon && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4298
4376
|
"span",
|
|
4299
4377
|
{
|
|
@@ -4312,7 +4390,7 @@ function TableInner({
|
|
|
4312
4390
|
},
|
|
4313
4391
|
rowKey(row, index)
|
|
4314
4392
|
)),
|
|
4315
|
-
addRowButton && !loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-border hover:rh-bg-background/
|
|
4393
|
+
addRowButton && !loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-border hover:rh-bg-background/50 rh-rounde-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4316
4394
|
"td",
|
|
4317
4395
|
{
|
|
4318
4396
|
colSpan,
|