@rehagro/ui 1.0.46 → 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.js CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  var React9 = require('react');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var reactDom = require('react-dom');
6
7
 
7
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
9
 
@@ -1117,6 +1118,7 @@ var TextInput = React9.forwardRef(function TextInput2({
1117
1118
  className = "",
1118
1119
  wrapperClassName = "",
1119
1120
  borderColor,
1121
+ backgroundColor,
1120
1122
  borderWidth = "sm",
1121
1123
  id,
1122
1124
  ...rest
@@ -1126,6 +1128,10 @@ var TextInput = React9.forwardRef(function TextInput2({
1126
1128
  const [isHelperDismissed, setIsHelperDismissed] = React9__default.default.useState(false);
1127
1129
  const { onChange, ...inputProps } = rest;
1128
1130
  const visualStatus = helperText && isHelperDismissed ? "default" : status;
1131
+ const containerStyle = {
1132
+ ...borderColor ? { borderColor } : {},
1133
+ ...!disabled && backgroundColor ? { backgroundColor } : {}
1134
+ };
1129
1135
  return /* @__PURE__ */ jsxRuntime.jsxs(
1130
1136
  "div",
1131
1137
  {
@@ -1145,7 +1151,7 @@ var TextInput = React9.forwardRef(function TextInput2({
1145
1151
  /* @__PURE__ */ jsxRuntime.jsxs(
1146
1152
  "div",
1147
1153
  {
1148
- style: borderColor ? { borderColor } : void 0,
1154
+ style: containerStyle,
1149
1155
  className: [
1150
1156
  "rh-flex rh-items-center rh-gap-2",
1151
1157
  "rh-bg-surface rh-font-body",
@@ -1593,7 +1599,8 @@ var Select = React9.forwardRef(function Select2(props, ref) {
1593
1599
  disabled = false,
1594
1600
  className = "",
1595
1601
  wrapperClassName = "",
1596
- multiple = false
1602
+ multiple = false,
1603
+ backgroundColor
1597
1604
  } = props;
1598
1605
  const triggerId = React9__default.default.useId();
1599
1606
  const listboxId = React9__default.default.useId();
@@ -1772,9 +1779,11 @@ var Select = React9.forwardRef(function Select2(props, ref) {
1772
1779
  disabled,
1773
1780
  onClick: () => !disabled && setIsOpen((o) => !o),
1774
1781
  onKeyDown: handleKeyDown,
1782
+ style: backgroundColor ? { backgroundColor } : void 0,
1775
1783
  className: [
1776
1784
  "rh-group rh-flex rh-items-center rh-justify-between rh-gap-2",
1777
- "rh-border rh-bg-surface rh-font-body",
1785
+ "rh-border rh-font-body",
1786
+ !backgroundColor && "rh-bg-surface",
1778
1787
  "rh-transition-colors rh-duration-150",
1779
1788
  "rh-text-left rh-w-full",
1780
1789
  statusClasses2[visualStatus],
@@ -1798,7 +1807,7 @@ var Select = React9.forwardRef(function Select2(props, ref) {
1798
1807
  ChevronIcon,
1799
1808
  {
1800
1809
  className: [
1801
- "rh-w-5 rh-h-5 rh-shrink-0 rh-text-text-muted rh-transition-transform rh-duration-150",
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",
1802
1811
  isOpen ? "rh-rotate-180" : ""
1803
1812
  ].filter(Boolean).join(" ")
1804
1813
  }
@@ -2917,6 +2926,390 @@ var Spinner = React9.forwardRef(function Spinner2({ size = "md", color = "primar
2917
2926
  }
2918
2927
  );
2919
2928
  });
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
+ }) => {
3171
+ const [isOpen, setIsOpen] = React9.useState(false);
3172
+ const [dropdownStyle, setDropdownStyle] = React9.useState({});
3173
+ const containerRef = React9.useRef(null);
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());
3190
+ setIsOpen((prev) => !prev);
3191
+ };
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;
3205
+ const handleClickOutside = (e) => {
3206
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
3207
+ setIsOpen(false);
3208
+ }
3209
+ };
3210
+ if (isOpen) {
3211
+ document.addEventListener("mousedown", handleClickOutside);
3212
+ return () => document.removeEventListener("mousedown", handleClickOutside);
3213
+ }
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;
3224
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: `rh-relative ${className}`, children: [
3225
+ /* @__PURE__ */ jsxRuntime.jsx(
3226
+ "button",
3227
+ {
3228
+ type: "button",
3229
+ onClick: openDropdown,
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",
3231
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-truncate", children: /* @__PURE__ */ jsxRuntime.jsx(
3232
+ "span",
3233
+ {
3234
+ className: "rh-truncate rh-text-[14px] rh-px-2 rh-py-1 rh-rounded-xl",
3235
+ style: {
3236
+ backgroundColor: displayBg || "transparent",
3237
+ fontFamily: "Inter, sans-serif",
3238
+ color: displayBg ? "white" : "inherit"
3239
+ },
3240
+ children: displayLabel
3241
+ }
3242
+ ) })
3243
+ }
3244
+ ),
3245
+ type === "select" && isOpen && reactDom.createPortal(
3246
+ /* @__PURE__ */ jsxRuntime.jsx(
3247
+ "div",
3248
+ {
3249
+ style: {
3250
+ ...dropdownStyle,
3251
+ boxShadow: "0 10px 20px 0 rgba(0, 0, 0, 0.05)"
3252
+ },
3253
+ className: "rh-bg-surface rh-border rh-border-border rh-rounded-xs rh-max-h-60 rh-overflow-auto rh-pr-3",
3254
+ children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
3255
+ "button",
3256
+ {
3257
+ type: "button",
3258
+ onMouseDown: (e) => {
3259
+ e.preventDefault();
3260
+ onChange(option.value);
3261
+ setIsOpen(false);
3262
+ },
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",
3264
+ children: [
3265
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-4 rh-h-4", children: option.value === value && /* @__PURE__ */ jsxRuntime.jsx(
3266
+ "svg",
3267
+ {
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
+ )
3280
+ }
3281
+ ) }),
3282
+ /* @__PURE__ */ jsxRuntime.jsx(
3283
+ "span",
3284
+ {
3285
+ className: "rh-truncate rh-p-1 rh-px-2 rh-rounded-xl rh-text-white rh-text-[14px]",
3286
+ style: {
3287
+ backgroundColor: option.backgroundColor || "transparent",
3288
+ fontFamily: "Inter, sans-serif"
3289
+ },
3290
+ children: option.label
3291
+ }
3292
+ )
3293
+ ]
3294
+ },
3295
+ option.value
3296
+ ))
3297
+ }
3298
+ ),
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
+ }
3310
+ )
3311
+ ] });
3312
+ };
2920
3313
  var sizeClasses12 = {
2921
3314
  sm: { cell: "rh-px-2 rh-py-2 rh-text-xs", header: "rh-px-2 rh-py-2 rh-text-xs" },
2922
3315
  md: { cell: "rh-px-3 rh-py-3 rh-text-sm", header: "rh-px-3 rh-py-3 rh-text-xs" },
@@ -2941,6 +3334,12 @@ function TableInner({
2941
3334
  stickyHeader = false,
2942
3335
  headerStyle,
2943
3336
  headerTextClassName,
3337
+ headerTextStyle,
3338
+ bodyBackground,
3339
+ bodyTextStyle,
3340
+ rowPadding,
3341
+ addRowButton,
3342
+ onAddRow,
2944
3343
  className = "",
2945
3344
  ...rest
2946
3345
  }, ref) {
@@ -2982,34 +3381,86 @@ function TableInner({
2982
3381
  };
2983
3382
  const isEmpty = !loading && data.length === 0;
2984
3383
  const colSpan = columns.length;
2985
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-full rh-overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs(
3384
+ const headerTextStyleInline = {
3385
+ color: headerTextStyle?.color,
3386
+ fontFamily: headerTextStyle?.fontFamily,
3387
+ fontSize: headerTextStyle?.fontSize,
3388
+ fontWeight: headerTextStyle?.fontWeight
3389
+ };
3390
+ const bodyStyleInline = {
3391
+ color: bodyTextStyle?.color,
3392
+ fontFamily: bodyTextStyle?.fontFamily,
3393
+ fontSize: bodyTextStyle?.fontSize,
3394
+ fontWeight: bodyTextStyle?.fontWeight
3395
+ };
3396
+ const getRowPaddingStyle = () => {
3397
+ if (typeof rowPadding === "string") {
3398
+ return { padding: rowPadding };
3399
+ }
3400
+ if (typeof rowPadding === "object") {
3401
+ const style = {};
3402
+ if (rowPadding.x) {
3403
+ style.paddingLeft = rowPadding.x;
3404
+ style.paddingRight = rowPadding.x;
3405
+ }
3406
+ if (rowPadding.y) {
3407
+ style.paddingTop = rowPadding.y;
3408
+ style.paddingBottom = rowPadding.y;
3409
+ }
3410
+ return style;
3411
+ }
3412
+ return {};
3413
+ };
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
+ };
3420
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-full rh-rounded rh-overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(
2986
3421
  "table",
2987
3422
  {
2988
3423
  ref,
3424
+ style: { backgroundColor: bodyBackground },
2989
3425
  className: ["rh-w-full rh-border-collapse rh-font-body", className].filter(Boolean).join(" "),
2990
3426
  ...rest,
2991
3427
  children: [
2992
- /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-b rh-border-border", style: headerStyle, children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
2993
- "th",
3428
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx(
3429
+ "tr",
2994
3430
  {
2995
- scope: "col",
2996
- style: { width: column.width },
2997
- className: [
2998
- sizeClasses12[size].header,
2999
- alignClasses[column.align || "left"],
3000
- `rh-font-semibold rh-whitespace-nowrap ${headerTextClassName || "rh-text-text-muted"}`,
3001
- stickyHeader ? "rh-sticky rh-top-0 rh-bg-surface rh-z-10" : "",
3002
- column.sortable ? "rh-cursor-pointer rh-select-none hover:rh-text-text" : ""
3003
- ].filter(Boolean).join(" "),
3004
- onClick: () => handleSort(column),
3005
- children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rh-inline-flex rh-items-center", children: [
3006
- column.header,
3007
- renderSortIcon(column)
3008
- ] })
3009
- },
3010
- column.key
3011
- )) }) }),
3012
- /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
3431
+ className: "rh-border-b rh-border-border",
3432
+ style: {
3433
+ backgroundColor: headerStyle?.backgroundColor,
3434
+ height: headerStyle?.height,
3435
+ border: headerStyle?.border
3436
+ },
3437
+ children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
3438
+ "th",
3439
+ {
3440
+ scope: "col",
3441
+ style: {
3442
+ width: column.width,
3443
+ maxWidth: column.maxWidth,
3444
+ ...rowPaddingStyle
3445
+ },
3446
+ className: [
3447
+ rowPadding ? "" : sizeClasses12[size].header,
3448
+ alignClasses[column.align || "left"],
3449
+ `rh-font-semibold rh-whitespace-nowrap ${headerTextClassName || "rh-text-text-muted"}`,
3450
+ stickyHeader ? "rh-sticky rh-top-0 rh-bg-surface rh-z-10" : "",
3451
+ column.sortable ? "rh-cursor-pointer rh-select-none hover:rh-text-text" : ""
3452
+ ].filter(Boolean).join(" "),
3453
+ onClick: () => handleSort(column),
3454
+ children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rh-inline-flex rh-items-center", style: headerTextStyleInline, children: [
3455
+ column.header,
3456
+ renderSortIcon(column)
3457
+ ] })
3458
+ },
3459
+ column.key
3460
+ ))
3461
+ }
3462
+ ) }),
3463
+ /* @__PURE__ */ jsxRuntime.jsxs("tbody", { style: { backgroundColor: bodyBackground }, children: [
3013
3464
  loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan, className: "rh-text-center rh-py-8", children: loadingContent || /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-center rh-gap-2 rh-text-text-muted", children: [
3014
3465
  /* @__PURE__ */ jsxRuntime.jsxs(
3015
3466
  "svg",
@@ -3047,6 +3498,7 @@ function TableInner({
3047
3498
  !loading && data.map((row, index) => /* @__PURE__ */ jsxRuntime.jsx(
3048
3499
  "tr",
3049
3500
  {
3501
+ style: bodyStyleInline,
3050
3502
  className: [
3051
3503
  "rh-border-b rh-border-border rh-transition-colors",
3052
3504
  "hover:rh-bg-background",
@@ -3055,18 +3507,57 @@ function TableInner({
3055
3507
  children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
3056
3508
  "td",
3057
3509
  {
3510
+ style: { width: column.width, maxWidth: column.maxWidth, ...rowPaddingStyle },
3058
3511
  className: [
3059
- sizeClasses12[size].cell,
3512
+ rowPadding ? "" : sizeClasses12[size].cell,
3060
3513
  alignClasses[column.align || "left"],
3061
3514
  "rh-text-text"
3062
3515
  ].filter(Boolean).join(" "),
3063
- children: column.render(row, index)
3516
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-between rh-gap-2", children: [
3517
+ isEditableCell(column) ? /* @__PURE__ */ jsxRuntime.jsx(
3518
+ CustomSelect,
3519
+ {
3520
+ type: column.type ?? "select",
3521
+ options: column.choices,
3522
+ value: column.editableValue(row),
3523
+ onChange: (value) => column.onEditChange?.(row, index, value),
3524
+ className: "rh-w-full rh-h-full"
3525
+ }
3526
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: column.render(row, index) }),
3527
+ column.actionIcon && /* @__PURE__ */ jsxRuntime.jsx(
3528
+ "span",
3529
+ {
3530
+ className: "rh-cursor-pointer hover:rh-bg-background/50 rh-p-1 rh-rounded",
3531
+ onClick: (e) => {
3532
+ e.stopPropagation();
3533
+ column.actionIcon?.onClick(row, index);
3534
+ },
3535
+ children: column.actionIcon.icon
3536
+ }
3537
+ )
3538
+ ] })
3064
3539
  },
3065
3540
  column.key
3066
3541
  ))
3067
3542
  },
3068
3543
  rowKey(row, index)
3069
- ))
3544
+ )),
3545
+ addRowButton && !loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-border hover:rh-bg-background/100 rh-rounde-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
3546
+ "td",
3547
+ {
3548
+ colSpan,
3549
+ style: rowPaddingStyle,
3550
+ className: [
3551
+ rowPadding ? "" : sizeClasses12[size].cell,
3552
+ "rh-text-center rh-cursor-pointer rh-text-[#9CA3AF] rh-font-medium"
3553
+ ].filter(Boolean).join(" "),
3554
+ onClick: onAddRow,
3555
+ 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: [
3556
+ addRowButton.icon,
3557
+ addRowButton.text
3558
+ ] })
3559
+ }
3560
+ ) })
3070
3561
  ] })
3071
3562
  ]
3072
3563
  }