@rehagro/ui 1.0.47 → 1.0.48
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 +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +329 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +329 -28
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -275,6 +275,13 @@ type TextInputProps = Omit<React__default.InputHTMLAttributes<HTMLInputElement>,
|
|
|
275
275
|
* colors — those still come from `statusClasses`.
|
|
276
276
|
*/
|
|
277
277
|
borderColor?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Custom background color for the input container. Accepts any valid
|
|
280
|
+
* CSS color value (hex, rgb, CSS variable, etc). When provided,
|
|
281
|
+
* overrides the default `rh-bg-surface` background. Ignored when
|
|
282
|
+
* `disabled` is true to preserve the disabled visual style.
|
|
283
|
+
*/
|
|
284
|
+
backgroundColor?: string;
|
|
278
285
|
/**
|
|
279
286
|
* Border width token for the input container.
|
|
280
287
|
*
|
|
@@ -316,6 +323,13 @@ declare const TextInput: React__default.ForwardRefExoticComponent<Omit<React__de
|
|
|
316
323
|
* colors — those still come from `statusClasses`.
|
|
317
324
|
*/
|
|
318
325
|
borderColor?: string;
|
|
326
|
+
/**
|
|
327
|
+
* Custom background color for the input container. Accepts any valid
|
|
328
|
+
* CSS color value (hex, rgb, CSS variable, etc). When provided,
|
|
329
|
+
* overrides the default `rh-bg-surface` background. Ignored when
|
|
330
|
+
* `disabled` is true to preserve the disabled visual style.
|
|
331
|
+
*/
|
|
332
|
+
backgroundColor?: string;
|
|
319
333
|
/**
|
|
320
334
|
* Border width token for the input container.
|
|
321
335
|
*
|
|
@@ -462,6 +476,8 @@ type SelectBaseProps = {
|
|
|
462
476
|
className?: string;
|
|
463
477
|
/** Custom class for the outermost wrapper */
|
|
464
478
|
wrapperClassName?: string;
|
|
479
|
+
/** Custom background color for the trigger button */
|
|
480
|
+
backgroundColor?: string;
|
|
465
481
|
};
|
|
466
482
|
type SelectSingleProps = SelectBaseProps & {
|
|
467
483
|
/** Enables multi-select mode */
|
|
@@ -764,7 +780,9 @@ type TableColumn<T> = {
|
|
|
764
780
|
actionIcon?: ColumnActionIcon<T>;
|
|
765
781
|
/** Whether this column is editable with a dropdown */
|
|
766
782
|
editable?: boolean;
|
|
767
|
-
/**
|
|
783
|
+
/** Type of editable field: "select" (default) or "date" */
|
|
784
|
+
type?: "select" | "date";
|
|
785
|
+
/** List of choices for the editable dropdown (required for type="select") */
|
|
768
786
|
choices?: CustomSelectOption[];
|
|
769
787
|
/** Function to get the current value for the editable field */
|
|
770
788
|
editableValue?: (row: T) => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -275,6 +275,13 @@ type TextInputProps = Omit<React__default.InputHTMLAttributes<HTMLInputElement>,
|
|
|
275
275
|
* colors — those still come from `statusClasses`.
|
|
276
276
|
*/
|
|
277
277
|
borderColor?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Custom background color for the input container. Accepts any valid
|
|
280
|
+
* CSS color value (hex, rgb, CSS variable, etc). When provided,
|
|
281
|
+
* overrides the default `rh-bg-surface` background. Ignored when
|
|
282
|
+
* `disabled` is true to preserve the disabled visual style.
|
|
283
|
+
*/
|
|
284
|
+
backgroundColor?: string;
|
|
278
285
|
/**
|
|
279
286
|
* Border width token for the input container.
|
|
280
287
|
*
|
|
@@ -316,6 +323,13 @@ declare const TextInput: React__default.ForwardRefExoticComponent<Omit<React__de
|
|
|
316
323
|
* colors — those still come from `statusClasses`.
|
|
317
324
|
*/
|
|
318
325
|
borderColor?: string;
|
|
326
|
+
/**
|
|
327
|
+
* Custom background color for the input container. Accepts any valid
|
|
328
|
+
* CSS color value (hex, rgb, CSS variable, etc). When provided,
|
|
329
|
+
* overrides the default `rh-bg-surface` background. Ignored when
|
|
330
|
+
* `disabled` is true to preserve the disabled visual style.
|
|
331
|
+
*/
|
|
332
|
+
backgroundColor?: string;
|
|
319
333
|
/**
|
|
320
334
|
* Border width token for the input container.
|
|
321
335
|
*
|
|
@@ -462,6 +476,8 @@ type SelectBaseProps = {
|
|
|
462
476
|
className?: string;
|
|
463
477
|
/** Custom class for the outermost wrapper */
|
|
464
478
|
wrapperClassName?: string;
|
|
479
|
+
/** Custom background color for the trigger button */
|
|
480
|
+
backgroundColor?: string;
|
|
465
481
|
};
|
|
466
482
|
type SelectSingleProps = SelectBaseProps & {
|
|
467
483
|
/** Enables multi-select mode */
|
|
@@ -764,7 +780,9 @@ type TableColumn<T> = {
|
|
|
764
780
|
actionIcon?: ColumnActionIcon<T>;
|
|
765
781
|
/** Whether this column is editable with a dropdown */
|
|
766
782
|
editable?: boolean;
|
|
767
|
-
/**
|
|
783
|
+
/** Type of editable field: "select" (default) or "date" */
|
|
784
|
+
type?: "select" | "date";
|
|
785
|
+
/** List of choices for the editable dropdown (required for type="select") */
|
|
768
786
|
choices?: CustomSelectOption[];
|
|
769
787
|
/** Function to get the current value for the editable field */
|
|
770
788
|
editableValue?: (row: T) => string;
|
package/dist/index.js
CHANGED
|
@@ -1118,6 +1118,7 @@ var TextInput = React9.forwardRef(function TextInput2({
|
|
|
1118
1118
|
className = "",
|
|
1119
1119
|
wrapperClassName = "",
|
|
1120
1120
|
borderColor,
|
|
1121
|
+
backgroundColor,
|
|
1121
1122
|
borderWidth = "sm",
|
|
1122
1123
|
id,
|
|
1123
1124
|
...rest
|
|
@@ -1127,6 +1128,10 @@ var TextInput = React9.forwardRef(function TextInput2({
|
|
|
1127
1128
|
const [isHelperDismissed, setIsHelperDismissed] = React9__default.default.useState(false);
|
|
1128
1129
|
const { onChange, ...inputProps } = rest;
|
|
1129
1130
|
const visualStatus = helperText && isHelperDismissed ? "default" : status;
|
|
1131
|
+
const containerStyle = {
|
|
1132
|
+
...borderColor ? { borderColor } : {},
|
|
1133
|
+
...!disabled && backgroundColor ? { backgroundColor } : {}
|
|
1134
|
+
};
|
|
1130
1135
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1131
1136
|
"div",
|
|
1132
1137
|
{
|
|
@@ -1146,7 +1151,7 @@ var TextInput = React9.forwardRef(function TextInput2({
|
|
|
1146
1151
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1147
1152
|
"div",
|
|
1148
1153
|
{
|
|
1149
|
-
style:
|
|
1154
|
+
style: containerStyle,
|
|
1150
1155
|
className: [
|
|
1151
1156
|
"rh-flex rh-items-center rh-gap-2",
|
|
1152
1157
|
"rh-bg-surface rh-font-body",
|
|
@@ -1594,7 +1599,8 @@ var Select = React9.forwardRef(function Select2(props, ref) {
|
|
|
1594
1599
|
disabled = false,
|
|
1595
1600
|
className = "",
|
|
1596
1601
|
wrapperClassName = "",
|
|
1597
|
-
multiple = false
|
|
1602
|
+
multiple = false,
|
|
1603
|
+
backgroundColor
|
|
1598
1604
|
} = props;
|
|
1599
1605
|
const triggerId = React9__default.default.useId();
|
|
1600
1606
|
const listboxId = React9__default.default.useId();
|
|
@@ -1773,9 +1779,11 @@ var Select = React9.forwardRef(function Select2(props, ref) {
|
|
|
1773
1779
|
disabled,
|
|
1774
1780
|
onClick: () => !disabled && setIsOpen((o) => !o),
|
|
1775
1781
|
onKeyDown: handleKeyDown,
|
|
1782
|
+
style: backgroundColor ? { backgroundColor } : void 0,
|
|
1776
1783
|
className: [
|
|
1777
1784
|
"rh-group rh-flex rh-items-center rh-justify-between rh-gap-2",
|
|
1778
|
-
"rh-border rh-
|
|
1785
|
+
"rh-border rh-font-body",
|
|
1786
|
+
!backgroundColor && "rh-bg-surface",
|
|
1779
1787
|
"rh-transition-colors rh-duration-150",
|
|
1780
1788
|
"rh-text-left rh-w-full",
|
|
1781
1789
|
statusClasses2[visualStatus],
|
|
@@ -1799,7 +1807,7 @@ var Select = React9.forwardRef(function Select2(props, ref) {
|
|
|
1799
1807
|
ChevronIcon,
|
|
1800
1808
|
{
|
|
1801
1809
|
className: [
|
|
1802
|
-
"rh-w-
|
|
1810
|
+
"rh-w-4 rh-h-4 rh-shrink-0 rh-text-text-muted rh-transition-transform rh-duration-150 rh-bg-surface rh-rounded-xl",
|
|
1803
1811
|
isOpen ? "rh-rotate-180" : ""
|
|
1804
1812
|
].filter(Boolean).join(" ")
|
|
1805
1813
|
}
|
|
@@ -2918,24 +2926,282 @@ var Spinner = React9.forwardRef(function Spinner2({ size = "md", color = "primar
|
|
|
2918
2926
|
}
|
|
2919
2927
|
);
|
|
2920
2928
|
});
|
|
2921
|
-
var
|
|
2929
|
+
var DAYS_SHORT = ["D", "S", "T", "Q", "Q", "S", "S"];
|
|
2930
|
+
var MONTHS_PT = [
|
|
2931
|
+
"Janeiro",
|
|
2932
|
+
"Fevereiro",
|
|
2933
|
+
"Mar\xE7o",
|
|
2934
|
+
"Abril",
|
|
2935
|
+
"Maio",
|
|
2936
|
+
"Junho",
|
|
2937
|
+
"Julho",
|
|
2938
|
+
"Agosto",
|
|
2939
|
+
"Setembro",
|
|
2940
|
+
"Outubro",
|
|
2941
|
+
"Novembro",
|
|
2942
|
+
"Dezembro"
|
|
2943
|
+
];
|
|
2944
|
+
function parseDate(value) {
|
|
2945
|
+
if (!value) return null;
|
|
2946
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
2947
|
+
const [y, m, d] = value.split("-").map(Number);
|
|
2948
|
+
return new Date(y, m - 1, d);
|
|
2949
|
+
}
|
|
2950
|
+
if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
2951
|
+
const [d, m, y] = value.split("/").map(Number);
|
|
2952
|
+
return new Date(y, m - 1, d);
|
|
2953
|
+
}
|
|
2954
|
+
return null;
|
|
2955
|
+
}
|
|
2956
|
+
function formatISO(date) {
|
|
2957
|
+
const y = date.getFullYear();
|
|
2958
|
+
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
2959
|
+
const d = String(date.getDate()).padStart(2, "0");
|
|
2960
|
+
return `${y}-${m}-${d}`;
|
|
2961
|
+
}
|
|
2962
|
+
function formatDisplay(date) {
|
|
2963
|
+
const d = String(date.getDate()).padStart(2, "0");
|
|
2964
|
+
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
2965
|
+
const y = date.getFullYear();
|
|
2966
|
+
return `${d}/${m}/${y}`;
|
|
2967
|
+
}
|
|
2968
|
+
function getDaysInMonth(year, month) {
|
|
2969
|
+
return new Date(year, month + 1, 0).getDate();
|
|
2970
|
+
}
|
|
2971
|
+
function getFirstDayOfMonth(year, month) {
|
|
2972
|
+
return new Date(year, month, 1).getDay();
|
|
2973
|
+
}
|
|
2974
|
+
var ChevronLeftIcon = () => /* @__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(
|
|
2975
|
+
"path",
|
|
2976
|
+
{
|
|
2977
|
+
fillRule: "evenodd",
|
|
2978
|
+
d: "M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",
|
|
2979
|
+
clipRule: "evenodd"
|
|
2980
|
+
}
|
|
2981
|
+
) });
|
|
2982
|
+
var ChevronRightIcon = () => /* @__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(
|
|
2983
|
+
"path",
|
|
2984
|
+
{
|
|
2985
|
+
fillRule: "evenodd",
|
|
2986
|
+
d: "M7.21 14.77a.75.75 0 010-1.06L11.168 10 7.23 6.29a.75.75 0 011.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",
|
|
2987
|
+
clipRule: "evenodd"
|
|
2988
|
+
}
|
|
2989
|
+
) });
|
|
2990
|
+
var DatePickerDropdown = ({
|
|
2991
|
+
style,
|
|
2992
|
+
selectedDate,
|
|
2993
|
+
onSelect,
|
|
2994
|
+
onClose,
|
|
2995
|
+
containerRef
|
|
2996
|
+
}) => {
|
|
2997
|
+
const today = /* @__PURE__ */ new Date();
|
|
2998
|
+
const [viewYear, setViewYear] = React9.useState(
|
|
2999
|
+
selectedDate ? selectedDate.getFullYear() : today.getFullYear()
|
|
3000
|
+
);
|
|
3001
|
+
const [viewMonth, setViewMonth] = React9.useState(
|
|
3002
|
+
selectedDate ? selectedDate.getMonth() : today.getMonth()
|
|
3003
|
+
);
|
|
3004
|
+
const [tempDate, setTempDate] = React9.useState(selectedDate);
|
|
3005
|
+
const dropdownRef = React9.useRef(null);
|
|
3006
|
+
React9.useEffect(() => {
|
|
3007
|
+
const handleClickOutside = (e) => {
|
|
3008
|
+
const target = e.target;
|
|
3009
|
+
if (dropdownRef.current && !dropdownRef.current.contains(target) && containerRef.current && !containerRef.current.contains(target)) {
|
|
3010
|
+
onClose();
|
|
3011
|
+
}
|
|
3012
|
+
};
|
|
3013
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
3014
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
3015
|
+
}, [onClose, containerRef]);
|
|
3016
|
+
const prevMonth = () => {
|
|
3017
|
+
if (viewMonth === 0) {
|
|
3018
|
+
setViewMonth(11);
|
|
3019
|
+
setViewYear((y) => y - 1);
|
|
3020
|
+
} else {
|
|
3021
|
+
setViewMonth((m) => m - 1);
|
|
3022
|
+
}
|
|
3023
|
+
};
|
|
3024
|
+
const nextMonth = () => {
|
|
3025
|
+
if (viewMonth === 11) {
|
|
3026
|
+
setViewMonth(0);
|
|
3027
|
+
setViewYear((y) => y + 1);
|
|
3028
|
+
} else {
|
|
3029
|
+
setViewMonth((m) => m + 1);
|
|
3030
|
+
}
|
|
3031
|
+
};
|
|
3032
|
+
const daysInMonth = getDaysInMonth(viewYear, viewMonth);
|
|
3033
|
+
const firstDay = getFirstDayOfMonth(viewYear, viewMonth);
|
|
3034
|
+
const prevMonthDays = getDaysInMonth(
|
|
3035
|
+
viewMonth === 0 ? viewYear - 1 : viewYear,
|
|
3036
|
+
viewMonth === 0 ? 11 : viewMonth - 1
|
|
3037
|
+
);
|
|
3038
|
+
const totalCells = firstDay + daysInMonth;
|
|
3039
|
+
const trailingCount = totalCells % 7 === 0 ? 0 : 7 - totalCells % 7;
|
|
3040
|
+
const isSelected = (day) => !!tempDate && tempDate.getFullYear() === viewYear && tempDate.getMonth() === viewMonth && tempDate.getDate() === day;
|
|
3041
|
+
return reactDom.createPortal(
|
|
3042
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3043
|
+
"div",
|
|
3044
|
+
{
|
|
3045
|
+
ref: dropdownRef,
|
|
3046
|
+
style: {
|
|
3047
|
+
...style,
|
|
3048
|
+
boxShadow: "0 0 9.6px 0 rgba(8, 11, 18, 0.08)",
|
|
3049
|
+
width: 260
|
|
3050
|
+
},
|
|
3051
|
+
className: "rh-bg-surface rh-rounded-xs rh-p-5 rh-select-none rh-font-body",
|
|
3052
|
+
children: [
|
|
3053
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-between", children: [
|
|
3054
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3055
|
+
"button",
|
|
3056
|
+
{
|
|
3057
|
+
type: "button",
|
|
3058
|
+
onMouseDown: (e) => {
|
|
3059
|
+
e.preventDefault();
|
|
3060
|
+
prevMonth();
|
|
3061
|
+
},
|
|
3062
|
+
className: "rh-p-1 hover:rh-bg-background rh-rounded rh-cursor-pointer rh-text-text",
|
|
3063
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, {})
|
|
3064
|
+
}
|
|
3065
|
+
),
|
|
3066
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rh-text-sm rh-font-medium rh-text-text", children: [
|
|
3067
|
+
MONTHS_PT[viewMonth],
|
|
3068
|
+
" - ",
|
|
3069
|
+
viewYear
|
|
3070
|
+
] }),
|
|
3071
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3072
|
+
"button",
|
|
3073
|
+
{
|
|
3074
|
+
type: "button",
|
|
3075
|
+
onMouseDown: (e) => {
|
|
3076
|
+
e.preventDefault();
|
|
3077
|
+
nextMonth();
|
|
3078
|
+
},
|
|
3079
|
+
className: "rh-p-1 hover:rh-bg-background rh-rounded rh-cursor-pointer rh-text-text",
|
|
3080
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, {})
|
|
3081
|
+
}
|
|
3082
|
+
)
|
|
3083
|
+
] }),
|
|
3084
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-grid rh-grid-cols-7", children: DAYS_SHORT.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3085
|
+
"div",
|
|
3086
|
+
{
|
|
3087
|
+
className: "rh-text-center rh-text-xs rh-text-text-muted rh-font-medium rh-py-1",
|
|
3088
|
+
children: d
|
|
3089
|
+
},
|
|
3090
|
+
i
|
|
3091
|
+
)) }),
|
|
3092
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3093
|
+
"svg",
|
|
3094
|
+
{
|
|
3095
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3096
|
+
width: "100%",
|
|
3097
|
+
height: "1",
|
|
3098
|
+
viewBox: "0 0 350 1",
|
|
3099
|
+
fill: "none",
|
|
3100
|
+
className: "rh-mb-3",
|
|
3101
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 0.5H350", stroke: "#F5F5F5" })
|
|
3102
|
+
}
|
|
3103
|
+
),
|
|
3104
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-grid rh-grid-cols-7 rh-gap-0", children: [
|
|
3105
|
+
Array.from({ length: firstDay }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3106
|
+
"div",
|
|
3107
|
+
{
|
|
3108
|
+
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",
|
|
3109
|
+
children: prevMonthDays - firstDay + i + 1
|
|
3110
|
+
},
|
|
3111
|
+
`prev-${i}`
|
|
3112
|
+
)),
|
|
3113
|
+
Array.from({ length: daysInMonth }).map((_, i) => {
|
|
3114
|
+
const day = i + 1;
|
|
3115
|
+
const selected = isSelected(day);
|
|
3116
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3117
|
+
"button",
|
|
3118
|
+
{
|
|
3119
|
+
type: "button",
|
|
3120
|
+
style: { backgroundColor: selected ? "#15607A" : "transparent" },
|
|
3121
|
+
onMouseDown: (e) => {
|
|
3122
|
+
e.preventDefault();
|
|
3123
|
+
setTempDate(new Date(viewYear, viewMonth, day));
|
|
3124
|
+
},
|
|
3125
|
+
className: [
|
|
3126
|
+
"rh-w-7 rh-h-7 rh-flex rh-items-center rh-justify-center rh-text-sm rh-rounded-lg rh-transition-colors rh-duration-150 rh-cursor-pointer",
|
|
3127
|
+
selected ? "rh-text-surface" : "rh-text-text hover:rh-ring-1 hover:rh-ring-[#15607A] hover:rh-bg-transparent"
|
|
3128
|
+
].join(" "),
|
|
3129
|
+
children: day
|
|
3130
|
+
},
|
|
3131
|
+
day
|
|
3132
|
+
);
|
|
3133
|
+
}),
|
|
3134
|
+
Array.from({ length: trailingCount }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3135
|
+
"div",
|
|
3136
|
+
{
|
|
3137
|
+
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",
|
|
3138
|
+
children: i + 1
|
|
3139
|
+
},
|
|
3140
|
+
`next-${i}`
|
|
3141
|
+
))
|
|
3142
|
+
] }),
|
|
3143
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-justify-end rh-gap-2 rh-mt-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3144
|
+
"button",
|
|
3145
|
+
{
|
|
3146
|
+
type: "button",
|
|
3147
|
+
style: { backgroundColor: "#87A851" },
|
|
3148
|
+
onClick: () => {
|
|
3149
|
+
if (tempDate) {
|
|
3150
|
+
onSelect(tempDate);
|
|
3151
|
+
}
|
|
3152
|
+
onClose();
|
|
3153
|
+
},
|
|
3154
|
+
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",
|
|
3155
|
+
children: "Aplicar"
|
|
3156
|
+
}
|
|
3157
|
+
) })
|
|
3158
|
+
]
|
|
3159
|
+
}
|
|
3160
|
+
),
|
|
3161
|
+
document.body
|
|
3162
|
+
);
|
|
3163
|
+
};
|
|
3164
|
+
var CustomSelect = ({
|
|
3165
|
+
options = [],
|
|
3166
|
+
value,
|
|
3167
|
+
onChange,
|
|
3168
|
+
className = "",
|
|
3169
|
+
type = "select"
|
|
3170
|
+
}) => {
|
|
2922
3171
|
const [isOpen, setIsOpen] = React9.useState(false);
|
|
2923
3172
|
const [dropdownStyle, setDropdownStyle] = React9.useState({});
|
|
2924
3173
|
const containerRef = React9.useRef(null);
|
|
2925
|
-
const
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
}
|
|
2935
|
-
|
|
3174
|
+
const calcPosition = () => {
|
|
3175
|
+
if (!containerRef.current) return {};
|
|
3176
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
3177
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
3178
|
+
const spaceAbove = rect.top;
|
|
3179
|
+
const DROPDOWN_HEIGHT = 320;
|
|
3180
|
+
const openUpward = spaceBelow < DROPDOWN_HEIGHT && spaceAbove > spaceBelow;
|
|
3181
|
+
return {
|
|
3182
|
+
position: "fixed",
|
|
3183
|
+
...openUpward ? { bottom: window.innerHeight - rect.top + 4 } : { top: rect.bottom + 4 },
|
|
3184
|
+
left: rect.left,
|
|
3185
|
+
zIndex: 2
|
|
3186
|
+
};
|
|
3187
|
+
};
|
|
3188
|
+
const openDropdown = () => {
|
|
3189
|
+
if (!isOpen) setDropdownStyle(calcPosition());
|
|
2936
3190
|
setIsOpen((prev) => !prev);
|
|
2937
3191
|
};
|
|
2938
3192
|
React9.useEffect(() => {
|
|
3193
|
+
if (!isOpen) return;
|
|
3194
|
+
const close = () => setIsOpen(false);
|
|
3195
|
+
window.addEventListener("scroll", close, { capture: true, passive: true });
|
|
3196
|
+
window.addEventListener("resize", close, { passive: true });
|
|
3197
|
+
return () => {
|
|
3198
|
+
window.removeEventListener("scroll", close, { capture: true });
|
|
3199
|
+
window.removeEventListener("resize", close);
|
|
3200
|
+
};
|
|
3201
|
+
}, [isOpen]);
|
|
3202
|
+
const selectedOption = options.find((opt) => opt.value === value);
|
|
3203
|
+
React9.useEffect(() => {
|
|
3204
|
+
if (type !== "select") return;
|
|
2939
3205
|
const handleClickOutside = (e) => {
|
|
2940
3206
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
2941
3207
|
setIsOpen(false);
|
|
@@ -2945,29 +3211,38 @@ var CustomSelect = ({ options, value, onChange, className = "" }) => {
|
|
|
2945
3211
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2946
3212
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2947
3213
|
}
|
|
2948
|
-
}, [isOpen]);
|
|
3214
|
+
}, [isOpen, type]);
|
|
3215
|
+
const selectedDate = type === "date" ? parseDate(value) : null;
|
|
3216
|
+
const handleDateSelect = (date) => {
|
|
3217
|
+
if (date) {
|
|
3218
|
+
onChange(formatISO(date));
|
|
3219
|
+
}
|
|
3220
|
+
setIsOpen(false);
|
|
3221
|
+
};
|
|
3222
|
+
const displayLabel = type === "date" ? selectedDate ? formatDisplay(selectedDate) : value || "\u2014" : selectedOption?.label || value;
|
|
3223
|
+
const displayBg = type === "date" ? void 0 : selectedOption?.backgroundColor;
|
|
2949
3224
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: `rh-relative ${className}`, children: [
|
|
2950
3225
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2951
3226
|
"button",
|
|
2952
3227
|
{
|
|
2953
3228
|
type: "button",
|
|
2954
|
-
onClick:
|
|
3229
|
+
onClick: openDropdown,
|
|
2955
3230
|
className: "rh-w-full rh-h-full rh-flex rh-items-center rh-justify-between rh-py-1 rh-bg-transparent hover:rh-bg-background/50 rh-cursor-pointer rh-text-left",
|
|
2956
3231
|
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-truncate", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2957
3232
|
"span",
|
|
2958
3233
|
{
|
|
2959
3234
|
className: "rh-truncate rh-text-[14px] rh-px-2 rh-py-1 rh-rounded-xl",
|
|
2960
3235
|
style: {
|
|
2961
|
-
backgroundColor:
|
|
3236
|
+
backgroundColor: displayBg || "transparent",
|
|
2962
3237
|
fontFamily: "Inter, sans-serif",
|
|
2963
|
-
color:
|
|
3238
|
+
color: displayBg ? "white" : "inherit"
|
|
2964
3239
|
},
|
|
2965
|
-
children:
|
|
3240
|
+
children: displayLabel
|
|
2966
3241
|
}
|
|
2967
3242
|
) })
|
|
2968
3243
|
}
|
|
2969
3244
|
),
|
|
2970
|
-
isOpen && reactDom.createPortal(
|
|
3245
|
+
type === "select" && isOpen && reactDom.createPortal(
|
|
2971
3246
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2972
3247
|
"div",
|
|
2973
3248
|
{
|
|
@@ -2987,13 +3262,23 @@ var CustomSelect = ({ options, value, onChange, className = "" }) => {
|
|
|
2987
3262
|
},
|
|
2988
3263
|
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",
|
|
2989
3264
|
children: [
|
|
2990
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-4 rh-h-4", children: option.value === value && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2991
|
-
"
|
|
3265
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-4 rh-h-4", children: option.value === value && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3266
|
+
"svg",
|
|
2992
3267
|
{
|
|
2993
|
-
|
|
2994
|
-
|
|
3268
|
+
width: "13",
|
|
3269
|
+
height: "10",
|
|
3270
|
+
viewBox: "0 0 13 10",
|
|
3271
|
+
fill: "none",
|
|
3272
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3273
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3274
|
+
"path",
|
|
3275
|
+
{
|
|
3276
|
+
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",
|
|
3277
|
+
fill: "#374151"
|
|
3278
|
+
}
|
|
3279
|
+
)
|
|
2995
3280
|
}
|
|
2996
|
-
) })
|
|
3281
|
+
) }),
|
|
2997
3282
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2998
3283
|
"span",
|
|
2999
3284
|
{
|
|
@@ -3012,6 +3297,16 @@ var CustomSelect = ({ options, value, onChange, className = "" }) => {
|
|
|
3012
3297
|
}
|
|
3013
3298
|
),
|
|
3014
3299
|
document.body
|
|
3300
|
+
),
|
|
3301
|
+
type === "date" && isOpen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3302
|
+
DatePickerDropdown,
|
|
3303
|
+
{
|
|
3304
|
+
style: dropdownStyle,
|
|
3305
|
+
selectedDate,
|
|
3306
|
+
onSelect: handleDateSelect,
|
|
3307
|
+
onClose: () => setIsOpen(false),
|
|
3308
|
+
containerRef
|
|
3309
|
+
}
|
|
3015
3310
|
)
|
|
3016
3311
|
] });
|
|
3017
3312
|
};
|
|
@@ -3117,6 +3412,11 @@ function TableInner({
|
|
|
3117
3412
|
return {};
|
|
3118
3413
|
};
|
|
3119
3414
|
const rowPaddingStyle = getRowPaddingStyle();
|
|
3415
|
+
const isEditableCell = (column) => {
|
|
3416
|
+
if (!column.editable || !column.editableValue) return false;
|
|
3417
|
+
if (column.type === "date") return true;
|
|
3418
|
+
return !!column.choices;
|
|
3419
|
+
};
|
|
3120
3420
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-full rh-rounded rh-overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3121
3421
|
"table",
|
|
3122
3422
|
{
|
|
@@ -3214,9 +3514,10 @@ function TableInner({
|
|
|
3214
3514
|
"rh-text-text"
|
|
3215
3515
|
].filter(Boolean).join(" "),
|
|
3216
3516
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-between rh-gap-2", children: [
|
|
3217
|
-
column
|
|
3517
|
+
isEditableCell(column) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3218
3518
|
CustomSelect,
|
|
3219
3519
|
{
|
|
3520
|
+
type: column.type ?? "select",
|
|
3220
3521
|
options: column.choices,
|
|
3221
3522
|
value: column.editableValue(row),
|
|
3222
3523
|
onChange: (value) => column.onEditChange?.(row, index, value),
|