@rehagro/ui 1.0.52 → 1.0.54
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 +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +181 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +181 -92
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -801,6 +801,7 @@ type CustomSelectOption = {
|
|
|
801
801
|
value: string;
|
|
802
802
|
label: string;
|
|
803
803
|
backgroundColor?: string;
|
|
804
|
+
textColor?: string;
|
|
804
805
|
};
|
|
805
806
|
|
|
806
807
|
type TableSize = "sm" | "md" | "lg";
|
|
@@ -828,14 +829,22 @@ type TableColumn<T> = {
|
|
|
828
829
|
actionIcon?: ColumnActionIcon<T>;
|
|
829
830
|
/** Whether this column is editable with a dropdown */
|
|
830
831
|
editable?: boolean;
|
|
831
|
-
/** Type of editable field: "select" (default) or "
|
|
832
|
-
type?: "select" | "date";
|
|
832
|
+
/** Type of editable field: "select" (default), "date", or "textInput" */
|
|
833
|
+
type?: "select" | "date" | "textInput";
|
|
833
834
|
/** List of choices for the editable dropdown (required for type="select") */
|
|
834
835
|
choices?: CustomSelectOption[];
|
|
836
|
+
/** Placeholder shown when there is no value */
|
|
837
|
+
editablePlaceholder?: string;
|
|
835
838
|
/** Function to get the current value for the editable field */
|
|
836
839
|
editableValue?: (row: T) => string;
|
|
837
840
|
/** Callback when the editable value changes */
|
|
838
841
|
onEditChange?: (row: T, index: number, value: string) => void;
|
|
842
|
+
/** Text color for editable field content (select/date/textInput). Can be fixed or derived from the row. */
|
|
843
|
+
editableTextColor?: string | ((row: T, index: number) => string | undefined);
|
|
844
|
+
/** Placeholder text color for editable field content. Can be fixed or derived from the row. */
|
|
845
|
+
editablePlaceholderColor?: string | ((row: T, index: number) => string | undefined);
|
|
846
|
+
/** Background color for editable field elements (value chip/control/calendar/input). Can be fixed or derived from the row. */
|
|
847
|
+
editableBackgroundColor?: string | ((row: T, index: number) => string | undefined);
|
|
839
848
|
};
|
|
840
849
|
type SortDirection = "asc" | "desc" | null;
|
|
841
850
|
type TableSort = {
|
package/dist/index.d.ts
CHANGED
|
@@ -801,6 +801,7 @@ type CustomSelectOption = {
|
|
|
801
801
|
value: string;
|
|
802
802
|
label: string;
|
|
803
803
|
backgroundColor?: string;
|
|
804
|
+
textColor?: string;
|
|
804
805
|
};
|
|
805
806
|
|
|
806
807
|
type TableSize = "sm" | "md" | "lg";
|
|
@@ -828,14 +829,22 @@ type TableColumn<T> = {
|
|
|
828
829
|
actionIcon?: ColumnActionIcon<T>;
|
|
829
830
|
/** Whether this column is editable with a dropdown */
|
|
830
831
|
editable?: boolean;
|
|
831
|
-
/** Type of editable field: "select" (default) or "
|
|
832
|
-
type?: "select" | "date";
|
|
832
|
+
/** Type of editable field: "select" (default), "date", or "textInput" */
|
|
833
|
+
type?: "select" | "date" | "textInput";
|
|
833
834
|
/** List of choices for the editable dropdown (required for type="select") */
|
|
834
835
|
choices?: CustomSelectOption[];
|
|
836
|
+
/** Placeholder shown when there is no value */
|
|
837
|
+
editablePlaceholder?: string;
|
|
835
838
|
/** Function to get the current value for the editable field */
|
|
836
839
|
editableValue?: (row: T) => string;
|
|
837
840
|
/** Callback when the editable value changes */
|
|
838
841
|
onEditChange?: (row: T, index: number, value: string) => void;
|
|
842
|
+
/** Text color for editable field content (select/date/textInput). Can be fixed or derived from the row. */
|
|
843
|
+
editableTextColor?: string | ((row: T, index: number) => string | undefined);
|
|
844
|
+
/** Placeholder text color for editable field content. Can be fixed or derived from the row. */
|
|
845
|
+
editablePlaceholderColor?: string | ((row: T, index: number) => string | undefined);
|
|
846
|
+
/** Background color for editable field elements (value chip/control/calendar/input). Can be fixed or derived from the row. */
|
|
847
|
+
editableBackgroundColor?: string | ((row: T, index: number) => string | undefined);
|
|
839
848
|
};
|
|
840
849
|
type SortDirection = "asc" | "desc" | null;
|
|
841
850
|
type TableSort = {
|
package/dist/index.js
CHANGED
|
@@ -2114,6 +2114,21 @@ var DateSelect = React9.forwardRef(
|
|
|
2114
2114
|
if (!isControlled) setInternalValue(newValue);
|
|
2115
2115
|
props.onChange?.(newValue);
|
|
2116
2116
|
};
|
|
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
|
+
};
|
|
2117
2132
|
const displayText = React9.useMemo(() => {
|
|
2118
2133
|
if (value.mode === "year" && value.year) return value.year.toString();
|
|
2119
2134
|
if (value.mode === "month" && value.year != null)
|
|
@@ -2234,7 +2249,18 @@ var DateSelect = React9.forwardRef(
|
|
|
2234
2249
|
},
|
|
2235
2250
|
year
|
|
2236
2251
|
);
|
|
2237
|
-
}) })
|
|
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
|
+
) })
|
|
2238
2264
|
] });
|
|
2239
2265
|
const renderMonthGrid = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-p-1", children: [
|
|
2240
2266
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-between", children: [
|
|
@@ -2282,7 +2308,18 @@ var DateSelect = React9.forwardRef(
|
|
|
2282
2308
|
},
|
|
2283
2309
|
month
|
|
2284
2310
|
);
|
|
2285
|
-
}) })
|
|
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
|
+
) })
|
|
2286
2323
|
] });
|
|
2287
2324
|
const renderIntervalNav = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2288
2325
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-gap-4 rh-p-1", children: [
|
|
@@ -2540,7 +2577,18 @@ var DateSelect = React9.forwardRef(
|
|
|
2540
2577
|
},
|
|
2541
2578
|
i
|
|
2542
2579
|
)) }),
|
|
2543
|
-
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
|
+
) })
|
|
2544
2592
|
] });
|
|
2545
2593
|
case "month":
|
|
2546
2594
|
return renderMonthGrid();
|
|
@@ -3730,7 +3778,7 @@ var DAYS_SHORT = ["D", "S", "T", "Q", "Q", "S", "S"];
|
|
|
3730
3778
|
var MONTHS_PT = [
|
|
3731
3779
|
"Janeiro",
|
|
3732
3780
|
"Fevereiro",
|
|
3733
|
-
"
|
|
3781
|
+
"Marco",
|
|
3734
3782
|
"Abril",
|
|
3735
3783
|
"Maio",
|
|
3736
3784
|
"Junho",
|
|
@@ -3771,6 +3819,17 @@ function getDaysInMonth(year, month) {
|
|
|
3771
3819
|
function getFirstDayOfMonth(year, month) {
|
|
3772
3820
|
return new Date(year, month, 1).getDay();
|
|
3773
3821
|
}
|
|
3822
|
+
function removeHexAlpha(color) {
|
|
3823
|
+
if (!color) return color;
|
|
3824
|
+
if (/^#[0-9a-fA-F]{4}$/.test(color)) {
|
|
3825
|
+
const [, r, g, b] = color;
|
|
3826
|
+
return `#${r}${r}${g}${g}${b}${b}`;
|
|
3827
|
+
}
|
|
3828
|
+
if (/^#[0-9a-fA-F]{8}$/.test(color)) {
|
|
3829
|
+
return color.slice(0, 7);
|
|
3830
|
+
}
|
|
3831
|
+
return color;
|
|
3832
|
+
}
|
|
3774
3833
|
var ChevronLeftIcon2 = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", className: "rh-w-5 rh-h-5", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3775
3834
|
"path",
|
|
3776
3835
|
{
|
|
@@ -3792,15 +3851,17 @@ var DatePickerDropdown = ({
|
|
|
3792
3851
|
selectedDate,
|
|
3793
3852
|
onSelect,
|
|
3794
3853
|
onClose,
|
|
3795
|
-
containerRef
|
|
3854
|
+
containerRef,
|
|
3855
|
+
backgroundColor,
|
|
3856
|
+
textColor
|
|
3796
3857
|
}) => {
|
|
3797
3858
|
const today = /* @__PURE__ */ new Date();
|
|
3859
|
+
const opaqueBackgroundColor = removeHexAlpha(backgroundColor);
|
|
3860
|
+
const calendarTextStyle = textColor ? { color: textColor } : void 0;
|
|
3798
3861
|
const [viewYear, setViewYear] = React9.useState(
|
|
3799
3862
|
selectedDate ? selectedDate.getFullYear() : today.getFullYear()
|
|
3800
3863
|
);
|
|
3801
|
-
const [viewMonth, setViewMonth] = React9.useState(
|
|
3802
|
-
selectedDate ? selectedDate.getMonth() : today.getMonth()
|
|
3803
|
-
);
|
|
3864
|
+
const [viewMonth, setViewMonth] = React9.useState(selectedDate ? selectedDate.getMonth() : today.getMonth());
|
|
3804
3865
|
const [tempDate, setTempDate] = React9.useState(selectedDate);
|
|
3805
3866
|
const dropdownRef = React9.useRef(null);
|
|
3806
3867
|
React9.useEffect(() => {
|
|
@@ -3831,12 +3892,8 @@ var DatePickerDropdown = ({
|
|
|
3831
3892
|
};
|
|
3832
3893
|
const daysInMonth = getDaysInMonth(viewYear, viewMonth);
|
|
3833
3894
|
const firstDay = getFirstDayOfMonth(viewYear, viewMonth);
|
|
3834
|
-
const prevMonthDays = getDaysInMonth(
|
|
3835
|
-
|
|
3836
|
-
viewMonth === 0 ? 11 : viewMonth - 1
|
|
3837
|
-
);
|
|
3838
|
-
const totalCells = firstDay + daysInMonth;
|
|
3839
|
-
const trailingCount = totalCells % 7 === 0 ? 0 : 7 - totalCells % 7;
|
|
3895
|
+
const prevMonthDays = getDaysInMonth(viewMonth === 0 ? viewYear - 1 : viewYear, viewMonth === 0 ? 11 : viewMonth - 1);
|
|
3896
|
+
const trailingCount = (firstDay + daysInMonth) % 7 === 0 ? 0 : 7 - (firstDay + daysInMonth) % 7;
|
|
3840
3897
|
const isSelected = (day) => !!tempDate && tempDate.getFullYear() === viewYear && tempDate.getMonth() === viewMonth && tempDate.getDate() === day;
|
|
3841
3898
|
return reactDom.createPortal(
|
|
3842
3899
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3845,6 +3902,8 @@ var DatePickerDropdown = ({
|
|
|
3845
3902
|
ref: dropdownRef,
|
|
3846
3903
|
style: {
|
|
3847
3904
|
...style,
|
|
3905
|
+
backgroundColor: opaqueBackgroundColor,
|
|
3906
|
+
color: textColor,
|
|
3848
3907
|
boxShadow: "0 0 9.6px 0 rgba(8, 11, 18, 0.08)",
|
|
3849
3908
|
width: 260
|
|
3850
3909
|
},
|
|
@@ -3855,6 +3914,7 @@ var DatePickerDropdown = ({
|
|
|
3855
3914
|
"button",
|
|
3856
3915
|
{
|
|
3857
3916
|
type: "button",
|
|
3917
|
+
style: calendarTextStyle,
|
|
3858
3918
|
onMouseDown: (e) => {
|
|
3859
3919
|
e.preventDefault();
|
|
3860
3920
|
prevMonth();
|
|
@@ -3863,7 +3923,7 @@ var DatePickerDropdown = ({
|
|
|
3863
3923
|
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon2, {})
|
|
3864
3924
|
}
|
|
3865
3925
|
),
|
|
3866
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rh-text-sm rh-font-medium rh-text-text", children: [
|
|
3926
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rh-text-sm rh-font-medium rh-text-text", style: calendarTextStyle, children: [
|
|
3867
3927
|
MONTHS_PT[viewMonth],
|
|
3868
3928
|
" - ",
|
|
3869
3929
|
viewYear
|
|
@@ -3872,6 +3932,7 @@ var DatePickerDropdown = ({
|
|
|
3872
3932
|
"button",
|
|
3873
3933
|
{
|
|
3874
3934
|
type: "button",
|
|
3935
|
+
style: calendarTextStyle,
|
|
3875
3936
|
onMouseDown: (e) => {
|
|
3876
3937
|
e.preventDefault();
|
|
3877
3938
|
nextMonth();
|
|
@@ -3885,31 +3946,14 @@ var DatePickerDropdown = ({
|
|
|
3885
3946
|
"div",
|
|
3886
3947
|
{
|
|
3887
3948
|
className: "rh-text-center rh-text-xs rh-text-text-muted rh-font-medium rh-py-1",
|
|
3949
|
+
style: calendarTextStyle,
|
|
3888
3950
|
children: d
|
|
3889
3951
|
},
|
|
3890
3952
|
i
|
|
3891
3953
|
)) }),
|
|
3892
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3893
|
-
"svg",
|
|
3894
|
-
{
|
|
3895
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3896
|
-
width: "100%",
|
|
3897
|
-
height: "1",
|
|
3898
|
-
viewBox: "0 0 350 1",
|
|
3899
|
-
fill: "none",
|
|
3900
|
-
className: "rh-mb-3",
|
|
3901
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 0.5H350", stroke: "#F5F5F5" })
|
|
3902
|
-
}
|
|
3903
|
-
),
|
|
3954
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "100%", height: "1", viewBox: "0 0 350 1", fill: "none", className: "rh-mb-3", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 0.5H350", stroke: "#F5F5F5" }) }),
|
|
3904
3955
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-grid rh-grid-cols-7 rh-gap-0", children: [
|
|
3905
|
-
Array.from({ length: firstDay }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3906
|
-
"div",
|
|
3907
|
-
{
|
|
3908
|
-
className: "rh-w-7 rh-h-7 rh-flex rh-items-center rh-justify-center rh-text-sm rh-text-text-muted rh-opacity-40",
|
|
3909
|
-
children: prevMonthDays - firstDay + i + 1
|
|
3910
|
-
},
|
|
3911
|
-
`prev-${i}`
|
|
3912
|
-
)),
|
|
3956
|
+
Array.from({ length: firstDay }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-7 rh-h-7 rh-flex rh-items-center rh-justify-center rh-text-sm rh-text-text-muted rh-opacity-40", style: calendarTextStyle, children: prevMonthDays - firstDay + i + 1 }, `prev-${i}`)),
|
|
3913
3957
|
Array.from({ length: daysInMonth }).map((_, i) => {
|
|
3914
3958
|
const day = i + 1;
|
|
3915
3959
|
const selected = isSelected(day);
|
|
@@ -3917,7 +3961,7 @@ var DatePickerDropdown = ({
|
|
|
3917
3961
|
"button",
|
|
3918
3962
|
{
|
|
3919
3963
|
type: "button",
|
|
3920
|
-
style: { backgroundColor: selected ? "#15607A" : "transparent" },
|
|
3964
|
+
style: { backgroundColor: selected ? "#15607A" : "transparent", ...calendarTextStyle },
|
|
3921
3965
|
onMouseDown: (e) => {
|
|
3922
3966
|
e.preventDefault();
|
|
3923
3967
|
setTempDate(new Date(viewYear, viewMonth, day));
|
|
@@ -3931,14 +3975,7 @@ var DatePickerDropdown = ({
|
|
|
3931
3975
|
day
|
|
3932
3976
|
);
|
|
3933
3977
|
}),
|
|
3934
|
-
Array.from({ length: trailingCount }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3935
|
-
"div",
|
|
3936
|
-
{
|
|
3937
|
-
className: "rh-w-7 rh-h-7 rh-flex rh-items-center rh-justify-center rh-text-sm rh-text-text-muted rh-opacity-40",
|
|
3938
|
-
children: i + 1
|
|
3939
|
-
},
|
|
3940
|
-
`next-${i}`
|
|
3941
|
-
))
|
|
3978
|
+
Array.from({ length: trailingCount }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-7 rh-h-7 rh-flex rh-items-center rh-justify-center rh-text-sm rh-text-text-muted rh-opacity-40", style: calendarTextStyle, children: i + 1 }, `next-${i}`))
|
|
3942
3979
|
] }),
|
|
3943
3980
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-justify-end rh-gap-2 rh-mt-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3944
3981
|
"button",
|
|
@@ -3946,9 +3983,7 @@ var DatePickerDropdown = ({
|
|
|
3946
3983
|
type: "button",
|
|
3947
3984
|
style: { backgroundColor: "#87A851" },
|
|
3948
3985
|
onClick: () => {
|
|
3949
|
-
if (tempDate)
|
|
3950
|
-
onSelect(tempDate);
|
|
3951
|
-
}
|
|
3986
|
+
if (tempDate) onSelect(tempDate);
|
|
3952
3987
|
onClose();
|
|
3953
3988
|
},
|
|
3954
3989
|
className: "rh-text-sm rh-font-medium rh-px-4 rh-py-1.5 rh-rounded-lg rh-transition-colors rh-duration-150 rh-bg-success rh-text-surface",
|
|
@@ -3966,11 +4001,29 @@ var CustomSelect = ({
|
|
|
3966
4001
|
value,
|
|
3967
4002
|
onChange,
|
|
3968
4003
|
className = "",
|
|
4004
|
+
placeholder,
|
|
4005
|
+
textColor,
|
|
4006
|
+
placeholderColor,
|
|
4007
|
+
backgroundColor,
|
|
3969
4008
|
type = "select"
|
|
3970
4009
|
}) => {
|
|
3971
4010
|
const [isOpen, setIsOpen] = React9.useState(false);
|
|
3972
4011
|
const [dropdownStyle, setDropdownStyle] = React9.useState({});
|
|
3973
4012
|
const containerRef = React9.useRef(null);
|
|
4013
|
+
const textAreaRef = React9.useRef(null);
|
|
4014
|
+
const resizeTextArea = React9__default.default.useCallback(() => {
|
|
4015
|
+
if (type !== "textInput" || !textAreaRef.current) return;
|
|
4016
|
+
const textarea = textAreaRef.current;
|
|
4017
|
+
textarea.style.height = "auto";
|
|
4018
|
+
if (textarea.value) {
|
|
4019
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
4020
|
+
return;
|
|
4021
|
+
}
|
|
4022
|
+
const previousValue = textarea.value;
|
|
4023
|
+
textarea.value = placeholder || "";
|
|
4024
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
4025
|
+
textarea.value = previousValue;
|
|
4026
|
+
}, [type, placeholder]);
|
|
3974
4027
|
const calcPosition = () => {
|
|
3975
4028
|
if (!containerRef.current) return {};
|
|
3976
4029
|
const rect = containerRef.current.getBoundingClientRect();
|
|
@@ -3999,6 +4052,9 @@ var CustomSelect = ({
|
|
|
3999
4052
|
window.removeEventListener("resize", close);
|
|
4000
4053
|
};
|
|
4001
4054
|
}, [isOpen]);
|
|
4055
|
+
React9.useEffect(() => {
|
|
4056
|
+
resizeTextArea();
|
|
4057
|
+
}, [resizeTextArea, value]);
|
|
4002
4058
|
const selectedOption = options.find((opt) => opt.value === value);
|
|
4003
4059
|
React9.useEffect(() => {
|
|
4004
4060
|
if (type !== "select") return;
|
|
@@ -4014,29 +4070,52 @@ var CustomSelect = ({
|
|
|
4014
4070
|
}, [isOpen, type]);
|
|
4015
4071
|
const selectedDate = type === "date" ? parseDate(value) : null;
|
|
4016
4072
|
const handleDateSelect = (date) => {
|
|
4017
|
-
if (date)
|
|
4018
|
-
onChange(formatISO(date));
|
|
4019
|
-
}
|
|
4073
|
+
if (date) onChange(formatISO(date));
|
|
4020
4074
|
setIsOpen(false);
|
|
4021
4075
|
};
|
|
4022
|
-
const
|
|
4023
|
-
const
|
|
4076
|
+
const hasValue = value != null && value !== "";
|
|
4077
|
+
const displayLabel = type === "date" ? selectedDate ? formatDisplay(selectedDate) : hasValue ? value : placeholder || "-" : selectedOption?.label || (hasValue ? value : placeholder || "");
|
|
4078
|
+
const displayBg = type === "date" ? backgroundColor : selectedOption?.backgroundColor || backgroundColor;
|
|
4079
|
+
const displayTextColor = type === "date" ? textColor : selectedOption?.textColor || (hasValue ? textColor : placeholderColor) || (displayBg ? "white" : "inherit");
|
|
4080
|
+
if (type === "textInput") {
|
|
4081
|
+
const inputTextColor = textColor || "#111827";
|
|
4082
|
+
const inputPlaceholderColor = placeholderColor || "#9CA3AF";
|
|
4083
|
+
const textInputWrapperClassName = className.replace(/\brh-h-full\b/g, "").trim();
|
|
4084
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: `rh-relative rh-h-full rh-flex rh-items-center ${textInputWrapperClassName}`, children: [
|
|
4085
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4086
|
+
"textarea",
|
|
4087
|
+
{
|
|
4088
|
+
ref: textAreaRef,
|
|
4089
|
+
value,
|
|
4090
|
+
placeholder,
|
|
4091
|
+
rows: 1,
|
|
4092
|
+
onInput: (e) => {
|
|
4093
|
+
onChange(e.currentTarget.value);
|
|
4094
|
+
resizeTextArea();
|
|
4095
|
+
},
|
|
4096
|
+
style: {
|
|
4097
|
+
color: inputTextColor,
|
|
4098
|
+
backgroundColor: backgroundColor || "transparent"
|
|
4099
|
+
},
|
|
4100
|
+
className: "rh-table-textarea rh-flex rh-items-center rh-leading-[20px] rh-py-[7px] rh-w-full rh-min-h-[40px] rh-text-sm rh-px-1 rh-border rh-bg-surface rh-rounded-xs rh-border-transparent rh-line-height-[20px] rh-outline-none rh-resize-none rh-overflow-hidden hover:rh-border-primary focus:rh-border-primary focus:rh-ring-2 focus:rh-ring-gray-200"
|
|
4101
|
+
}
|
|
4102
|
+
),
|
|
4103
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `.rh-table-textarea::placeholder { color: ${inputPlaceholderColor}; }` })
|
|
4104
|
+
] });
|
|
4105
|
+
}
|
|
4024
4106
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: `rh-relative ${className}`, children: [
|
|
4025
4107
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4026
4108
|
"button",
|
|
4027
4109
|
{
|
|
4028
4110
|
type: "button",
|
|
4029
4111
|
onClick: openDropdown,
|
|
4030
|
-
|
|
4031
|
-
|
|
4112
|
+
style: { backgroundColor: backgroundColor || void 0 },
|
|
4113
|
+
className: "rh-w-full rh-min-h-[40px] rh-flex rh-items-center rh-border rh-bg-surface rh-rounded-sm rh-border-transparent rh-justify-between rh-py-2 hover:rh-border-primary hover:rh-ring-2 hover:rh-ring-gray-200 rh-cursor-pointer rh-text-left",
|
|
4114
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-px-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4032
4115
|
"span",
|
|
4033
4116
|
{
|
|
4034
|
-
className: "rh-
|
|
4035
|
-
style: {
|
|
4036
|
-
backgroundColor: displayBg || "transparent",
|
|
4037
|
-
fontFamily: "Inter, sans-serif",
|
|
4038
|
-
color: displayBg ? "white" : "inherit"
|
|
4039
|
-
},
|
|
4117
|
+
className: "rh-text-[14px] rh-px-2 rh-py-0.5 rh-rounded-xl rh-whitespace-normal rh-break-words",
|
|
4118
|
+
style: { backgroundColor: displayBg || "transparent", fontFamily: "Inter, sans-serif", color: displayTextColor },
|
|
4040
4119
|
children: displayLabel
|
|
4041
4120
|
}
|
|
4042
4121
|
) })
|
|
@@ -4046,11 +4125,8 @@ var CustomSelect = ({
|
|
|
4046
4125
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4047
4126
|
"div",
|
|
4048
4127
|
{
|
|
4049
|
-
style: {
|
|
4050
|
-
|
|
4051
|
-
boxShadow: "0 10px 20px 0 rgba(0, 0, 0, 0.05)"
|
|
4052
|
-
},
|
|
4053
|
-
className: "rh-bg-surface rh-border rh-border-border rh-rounded-xs rh-max-h-60 rh-overflow-auto rh-pr-3",
|
|
4128
|
+
style: { ...dropdownStyle, backgroundColor: backgroundColor || void 0, boxShadow: "0 10px 20px 0 rgba(0, 0, 0, 0.05)" },
|
|
4129
|
+
className: "rh-border rh-border-border rh-rounded-xs rh-max-h-60 rh-overflow-auto",
|
|
4054
4130
|
children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4055
4131
|
"button",
|
|
4056
4132
|
{
|
|
@@ -4060,32 +4136,23 @@ var CustomSelect = ({
|
|
|
4060
4136
|
onChange(option.value);
|
|
4061
4137
|
setIsOpen(false);
|
|
4062
4138
|
},
|
|
4063
|
-
className: "rh-flex rh-items-center rh-gap-2 rh-px-3 rh-py-2 rh-text-left hover:rh-bg-background/50 rh-cursor-pointer",
|
|
4139
|
+
className: "rh-flex rh-items-center rh-gap-2 rh-px-3 rh-py-2 rh-text-left hover:rh-bg-background/50 rh-w-full rh-cursor-pointer",
|
|
4064
4140
|
children: [
|
|
4065
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-4
|
|
4066
|
-
"
|
|
4141
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-4", children: option.value === value && /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "13", height: "10", viewBox: "0 0 13 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4142
|
+
"path",
|
|
4067
4143
|
{
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
viewBox: "0 0 13 10",
|
|
4071
|
-
fill: "none",
|
|
4072
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
4073
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4074
|
-
"path",
|
|
4075
|
-
{
|
|
4076
|
-
d: "M12.7826 1.2813L4.78255 9.2813C4.71287 9.35122 4.63008 9.4067 4.53891 9.44455C4.44775 9.48241 4.35001 9.50189 4.2513 9.50189C4.15259 9.50189 4.05485 9.48241 3.96369 9.44455C3.87252 9.4067 3.78973 9.35122 3.72005 9.2813L0.220051 5.7813C0.150286 5.71154 0.0949458 5.62871 0.0571893 5.53756C0.0194329 5.44641 1.03958e-09 5.34871 0 5.25005C-1.03958e-09 5.15139 0.0194329 5.05369 0.0571893 4.96254C0.0949458 4.87139 0.150286 4.78857 0.220051 4.7188C0.289816 4.64904 0.372638 4.5937 0.46379 4.55594C0.554942 4.51818 0.652639 4.49875 0.751301 4.49875C0.849963 4.49875 0.947659 4.51818 1.03881 4.55594C1.12996 4.5937 1.21279 4.64904 1.28255 4.7188L4.25193 7.68818L11.7213 0.220051C11.8622 0.0791546 12.0533 0 12.2526 0C12.4518 0 12.6429 0.0791546 12.7838 0.220051C12.9247 0.360947 13.0039 0.552044 13.0039 0.751301C13.0039 0.950559 12.9247 1.14165 12.7838 1.28255L12.7826 1.2813Z",
|
|
4077
|
-
fill: "#374151"
|
|
4078
|
-
}
|
|
4079
|
-
)
|
|
4144
|
+
d: "M12.7826 1.2813L4.78255 9.2813C4.71287 9.35122 4.63008 9.4067 4.53891 9.44455C4.44775 9.48241 4.35001 9.50189 4.2513 9.50189C4.15259 9.50189 4.05485 9.48241 3.96369 9.44455C3.87252 9.4067 3.78973 9.35122 3.72005 9.2813L0.220051 5.7813C0.150286 5.71154 0.0949458 5.62871 0.0571893 5.53756C0.0194329 5.44641 1.03958e-09 5.34871 0 5.25005C-1.03958e-09 5.15139 0.0194329 5.05369 0.0571893 4.96254C0.0949458 4.87139 0.150286 4.78857 0.220051 4.7188C0.289816 4.64904 0.372638 4.5937 0.46379 4.55594C0.554942 4.51818 0.652639 4.49875 0.751301 4.49875C0.849963 4.49875 0.947659 4.51818 1.03881 4.55594C1.12996 4.5937 1.21279 4.64904 1.28255 4.7188L4.25193 7.68818L11.7213 0.220051C11.8622 0.0791546 12.0533 0 12.2526 0C12.4518 0 12.6429 0.0791546 12.7838 0.220051C12.9247 0.360947 13.0039 0.552044 13.0039 0.751301C13.0039 0.950559 12.9247 1.14165 12.7838 1.28255L12.7826 1.2813Z",
|
|
4145
|
+
fill: "#374151"
|
|
4080
4146
|
}
|
|
4081
|
-
) }),
|
|
4147
|
+
) }) }),
|
|
4082
4148
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4083
4149
|
"span",
|
|
4084
4150
|
{
|
|
4085
|
-
className: "rh-
|
|
4151
|
+
className: "rh-p-0.5 rh-px-2 rh-rounded-xl rh-text-white rh-text-[14px] rh-whitespace-normal rh-break-words",
|
|
4086
4152
|
style: {
|
|
4087
|
-
backgroundColor: option.backgroundColor || "transparent",
|
|
4088
|
-
fontFamily: "Inter, sans-serif"
|
|
4153
|
+
backgroundColor: option.backgroundColor || backgroundColor || "transparent",
|
|
4154
|
+
fontFamily: "Inter, sans-serif",
|
|
4155
|
+
color: option.textColor || textColor || (option.backgroundColor || backgroundColor ? "white" : "inherit")
|
|
4089
4156
|
},
|
|
4090
4157
|
children: option.label
|
|
4091
4158
|
}
|
|
@@ -4105,7 +4172,9 @@ var CustomSelect = ({
|
|
|
4105
4172
|
selectedDate,
|
|
4106
4173
|
onSelect: handleDateSelect,
|
|
4107
4174
|
onClose: () => setIsOpen(false),
|
|
4108
|
-
containerRef
|
|
4175
|
+
containerRef,
|
|
4176
|
+
backgroundColor,
|
|
4177
|
+
textColor
|
|
4109
4178
|
}
|
|
4110
4179
|
)
|
|
4111
4180
|
] });
|
|
@@ -4214,9 +4283,27 @@ function TableInner({
|
|
|
4214
4283
|
const rowPaddingStyle = getRowPaddingStyle();
|
|
4215
4284
|
const isEditableCell = (column) => {
|
|
4216
4285
|
if (!column.editable || !column.editableValue) return false;
|
|
4217
|
-
if (column.type === "date") return true;
|
|
4286
|
+
if (column.type === "date" || column.type === "textInput") return true;
|
|
4218
4287
|
return !!column.choices;
|
|
4219
4288
|
};
|
|
4289
|
+
const getEditableTextColor = (column, row, index) => {
|
|
4290
|
+
if (typeof column.editableTextColor === "function") {
|
|
4291
|
+
return column.editableTextColor(row, index);
|
|
4292
|
+
}
|
|
4293
|
+
return column.editableTextColor;
|
|
4294
|
+
};
|
|
4295
|
+
const getEditableBackgroundColor = (column, row, index) => {
|
|
4296
|
+
if (typeof column.editableBackgroundColor === "function") {
|
|
4297
|
+
return column.editableBackgroundColor(row, index);
|
|
4298
|
+
}
|
|
4299
|
+
return column.editableBackgroundColor;
|
|
4300
|
+
};
|
|
4301
|
+
const getEditablePlaceholderColor = (column, row, index) => {
|
|
4302
|
+
if (typeof column.editablePlaceholderColor === "function") {
|
|
4303
|
+
return column.editablePlaceholderColor(row, index);
|
|
4304
|
+
}
|
|
4305
|
+
return column.editablePlaceholderColor;
|
|
4306
|
+
};
|
|
4220
4307
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-full rh-rounded rh-overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4221
4308
|
"table",
|
|
4222
4309
|
{
|
|
@@ -4301,7 +4388,7 @@ function TableInner({
|
|
|
4301
4388
|
style: bodyStyleInline,
|
|
4302
4389
|
className: [
|
|
4303
4390
|
"rh-border-b rh-border-border rh-transition-colors",
|
|
4304
|
-
"hover:rh-bg-background",
|
|
4391
|
+
"hover:rh-bg-background/50",
|
|
4305
4392
|
variant === "striped" && index % 2 === 1 ? "rh-bg-background/50" : ""
|
|
4306
4393
|
].filter(Boolean).join(" "),
|
|
4307
4394
|
children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4320,10 +4407,14 @@ function TableInner({
|
|
|
4320
4407
|
type: column.type ?? "select",
|
|
4321
4408
|
options: column.choices,
|
|
4322
4409
|
value: column.editableValue(row),
|
|
4410
|
+
placeholder: column.editablePlaceholder,
|
|
4411
|
+
textColor: getEditableTextColor(column, row, index),
|
|
4412
|
+
placeholderColor: getEditablePlaceholderColor(column, row, index),
|
|
4413
|
+
backgroundColor: getEditableBackgroundColor(column, row, index),
|
|
4323
4414
|
onChange: (value) => column.onEditChange?.(row, index, value),
|
|
4324
4415
|
className: "rh-w-full rh-h-full"
|
|
4325
4416
|
}
|
|
4326
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: column.render(row, index) }),
|
|
4417
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: { width: "100%" }, children: column.render(row, index) }),
|
|
4327
4418
|
column.actionIcon && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4328
4419
|
"span",
|
|
4329
4420
|
{
|
|
@@ -4342,14 +4433,12 @@ function TableInner({
|
|
|
4342
4433
|
},
|
|
4343
4434
|
rowKey(row, index)
|
|
4344
4435
|
)),
|
|
4345
|
-
addRowButton && !loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-border hover:rh-bg-background/50 rh-
|
|
4436
|
+
addRowButton && !loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-border hover:rh-bg-background/50 rh-cursor-pointer rh-py-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4346
4437
|
"td",
|
|
4347
4438
|
{
|
|
4348
4439
|
colSpan,
|
|
4349
|
-
style: rowPaddingStyle,
|
|
4350
4440
|
className: [
|
|
4351
|
-
|
|
4352
|
-
"rh-text-center rh-cursor-pointer rh-text-[#9CA3AF] rh-font-medium"
|
|
4441
|
+
"rh-text-center rh-cursor-pointer rh-text-[#9CA3AF] rh-font-medium rh-px-4 rh-py-3 rh-rounded-b"
|
|
4353
4442
|
].filter(Boolean).join(" "),
|
|
4354
4443
|
onClick: onAddRow,
|
|
4355
4444
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-center rh-gap-2 rh-h-6 rh-font-bold rh-text-sm", children: [
|