@rehagro/ui 1.0.49 → 1.0.50
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 +38 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -9
- 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.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import React9, { forwardRef, createContext, useState, useRef,
|
|
2
|
+
import React9, { forwardRef, createContext, useState, useRef, useMemo, useEffect, useCallback, useContext } from 'react';
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
|
|
@@ -1580,6 +1580,19 @@ var CheckIcon2 = ({ className }) => /* @__PURE__ */ jsx(
|
|
|
1580
1580
|
)
|
|
1581
1581
|
}
|
|
1582
1582
|
);
|
|
1583
|
+
var RadioIcon = ({ isSelected }) => /* @__PURE__ */ jsx(
|
|
1584
|
+
"span",
|
|
1585
|
+
{
|
|
1586
|
+
className: [
|
|
1587
|
+
"rh-inline-flex rh-items-center rh-justify-center",
|
|
1588
|
+
"rh-w-4 rh-h-4 rh-shrink-0",
|
|
1589
|
+
"rh-border rh-rounded-full rh-transition-colors rh-duration-150",
|
|
1590
|
+
isSelected ? "rh-border-primary" : "rh-border-border rh-bg-surface"
|
|
1591
|
+
].filter(Boolean).join(" "),
|
|
1592
|
+
"aria-hidden": "true",
|
|
1593
|
+
children: isSelected && /* @__PURE__ */ jsx("span", { className: "rh-w-2.5 rh-h-2.5 rh-rounded-full rh-bg-primary" })
|
|
1594
|
+
}
|
|
1595
|
+
);
|
|
1583
1596
|
var Select = forwardRef(function Select2(props, ref) {
|
|
1584
1597
|
const {
|
|
1585
1598
|
options,
|
|
@@ -1590,6 +1603,7 @@ var Select = forwardRef(function Select2(props, ref) {
|
|
|
1590
1603
|
size = "md",
|
|
1591
1604
|
radius = "xs",
|
|
1592
1605
|
helperText,
|
|
1606
|
+
radio = false,
|
|
1593
1607
|
disabled = false,
|
|
1594
1608
|
className = "",
|
|
1595
1609
|
wrapperClassName = "",
|
|
@@ -1853,7 +1867,7 @@ var Select = forwardRef(function Select2(props, ref) {
|
|
|
1853
1867
|
].filter(Boolean).join(" "),
|
|
1854
1868
|
children: [
|
|
1855
1869
|
/* @__PURE__ */ jsx("span", { className: "rh-flex-1 rh-truncate rh-text-text", children: option.label }),
|
|
1856
|
-
multiple ? /* @__PURE__ */ jsx(
|
|
1870
|
+
radio ? /* @__PURE__ */ jsx(RadioIcon, { isSelected }) : multiple ? /* @__PURE__ */ jsx(
|
|
1857
1871
|
"span",
|
|
1858
1872
|
{
|
|
1859
1873
|
className: [
|
|
@@ -2041,6 +2055,7 @@ var DateSelect = forwardRef(
|
|
|
2041
2055
|
const helperId = React9.useId();
|
|
2042
2056
|
const [isOpen, setIsOpen] = useState(false);
|
|
2043
2057
|
const [isHelperDismissed, setIsHelperDismissed] = useState(false);
|
|
2058
|
+
const [dropdownAlign, setDropdownAlign] = useState("left");
|
|
2044
2059
|
const [internalValue, setInternalValue] = useState(
|
|
2045
2060
|
props.defaultValue ?? { mode: "day" }
|
|
2046
2061
|
);
|
|
@@ -2057,8 +2072,9 @@ var DateSelect = forwardRef(
|
|
|
2057
2072
|
const [yearGridStart, setYearGridStart] = useState(
|
|
2058
2073
|
Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 12) * 12
|
|
2059
2074
|
);
|
|
2060
|
-
const wrapperRef =
|
|
2061
|
-
const innerRef =
|
|
2075
|
+
const wrapperRef = useRef(null);
|
|
2076
|
+
const innerRef = useRef(null);
|
|
2077
|
+
const dropdownRef = useRef(null);
|
|
2062
2078
|
React9.useImperativeHandle(ref, () => innerRef.current);
|
|
2063
2079
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
2064
2080
|
const yearStart = startYear ?? currentYear - 10;
|
|
@@ -2092,7 +2108,7 @@ var DateSelect = forwardRef(
|
|
|
2092
2108
|
if (!isControlled) setInternalValue(newValue);
|
|
2093
2109
|
props.onChange?.(newValue);
|
|
2094
2110
|
};
|
|
2095
|
-
const displayText =
|
|
2111
|
+
const displayText = useMemo(() => {
|
|
2096
2112
|
if (value.mode === "year" && value.year) return value.year.toString();
|
|
2097
2113
|
if (value.mode === "month" && value.year != null)
|
|
2098
2114
|
return `${MONTHS_SHORT[value.month || 0]} ${value.year}`;
|
|
@@ -2103,7 +2119,7 @@ var DateSelect = forwardRef(
|
|
|
2103
2119
|
}
|
|
2104
2120
|
return null;
|
|
2105
2121
|
}, [value]);
|
|
2106
|
-
|
|
2122
|
+
useEffect(() => {
|
|
2107
2123
|
if (!isOpen) return;
|
|
2108
2124
|
const handleClickOutside = (e) => {
|
|
2109
2125
|
if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
|
|
@@ -2113,7 +2129,7 @@ var DateSelect = forwardRef(
|
|
|
2113
2129
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2114
2130
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2115
2131
|
}, [isOpen]);
|
|
2116
|
-
|
|
2132
|
+
useEffect(() => {
|
|
2117
2133
|
if (!isOpen) return;
|
|
2118
2134
|
const handleEscape = (e) => {
|
|
2119
2135
|
if (e.key === "Escape") {
|
|
@@ -2124,6 +2140,18 @@ var DateSelect = forwardRef(
|
|
|
2124
2140
|
document.addEventListener("keydown", handleEscape);
|
|
2125
2141
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
2126
2142
|
}, [isOpen]);
|
|
2143
|
+
useEffect(() => {
|
|
2144
|
+
if (!isOpen || !innerRef.current || !dropdownRef.current) return;
|
|
2145
|
+
const triggerRect = innerRef.current.getBoundingClientRect();
|
|
2146
|
+
const dropdownWidth = activeMode === "interval" ? 720 : 385;
|
|
2147
|
+
const spaceLeft = triggerRect.left;
|
|
2148
|
+
const spaceRight = window.innerWidth - triggerRect.right;
|
|
2149
|
+
if (spaceLeft < dropdownWidth && spaceRight >= dropdownWidth) {
|
|
2150
|
+
setDropdownAlign("right");
|
|
2151
|
+
} else {
|
|
2152
|
+
setDropdownAlign("left");
|
|
2153
|
+
}
|
|
2154
|
+
}, [isOpen, activeMode]);
|
|
2127
2155
|
const getDaysInMonth2 = (year, month) => new Date(year, month + 1, 0).getDate();
|
|
2128
2156
|
const getFirstDayOfMonth2 = (year, month) => new Date(year, month, 1).getDay();
|
|
2129
2157
|
const isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
@@ -2626,11 +2654,13 @@ var DateSelect = forwardRef(
|
|
|
2626
2654
|
isOpen && /* @__PURE__ */ jsxs(
|
|
2627
2655
|
"div",
|
|
2628
2656
|
{
|
|
2657
|
+
ref: dropdownRef,
|
|
2629
2658
|
className: [
|
|
2630
2659
|
"rh-absolute rh-z-50 rh-mt-1 rh-p-5",
|
|
2631
2660
|
"rh-bg-surface rh-rounded-md",
|
|
2632
2661
|
dropdownRadiusClasses2[radius],
|
|
2633
|
-
activeMode === "interval" ? "rh-w-[720px]" : "rh-w-[385px]"
|
|
2662
|
+
activeMode === "interval" ? "rh-w-[720px]" : "rh-w-[385px]",
|
|
2663
|
+
dropdownAlign === "left" ? "rh-right-0" : "rh-left-0"
|
|
2634
2664
|
].filter(Boolean).join(" "),
|
|
2635
2665
|
style: {
|
|
2636
2666
|
top: "100%",
|
|
@@ -4306,7 +4336,7 @@ function TableInner({
|
|
|
4306
4336
|
},
|
|
4307
4337
|
rowKey(row, index)
|
|
4308
4338
|
)),
|
|
4309
|
-
addRowButton && !loading && /* @__PURE__ */ jsx("tr", { className: "rh-border-border hover:rh-bg-background/
|
|
4339
|
+
addRowButton && !loading && /* @__PURE__ */ jsx("tr", { className: "rh-border-border hover:rh-bg-background/50 rh-rounde-lg", children: /* @__PURE__ */ jsx(
|
|
4310
4340
|
"td",
|
|
4311
4341
|
{
|
|
4312
4342
|
colSpan,
|