@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.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import React9, { forwardRef, createContext, useState, useRef, useCallback, useEffect, useMemo, useContext } from 'react';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { createPortal } from 'react-dom';
4
5
 
5
6
  // src/provider/RehagroProvider.tsx
6
7
 
@@ -1111,6 +1112,7 @@ var TextInput = forwardRef(function TextInput2({
1111
1112
  className = "",
1112
1113
  wrapperClassName = "",
1113
1114
  borderColor,
1115
+ backgroundColor,
1114
1116
  borderWidth = "sm",
1115
1117
  id,
1116
1118
  ...rest
@@ -1120,6 +1122,10 @@ var TextInput = forwardRef(function TextInput2({
1120
1122
  const [isHelperDismissed, setIsHelperDismissed] = React9.useState(false);
1121
1123
  const { onChange, ...inputProps } = rest;
1122
1124
  const visualStatus = helperText && isHelperDismissed ? "default" : status;
1125
+ const containerStyle = {
1126
+ ...borderColor ? { borderColor } : {},
1127
+ ...!disabled && backgroundColor ? { backgroundColor } : {}
1128
+ };
1123
1129
  return /* @__PURE__ */ jsxs(
1124
1130
  "div",
1125
1131
  {
@@ -1139,7 +1145,7 @@ var TextInput = forwardRef(function TextInput2({
1139
1145
  /* @__PURE__ */ jsxs(
1140
1146
  "div",
1141
1147
  {
1142
- style: borderColor ? { borderColor } : void 0,
1148
+ style: containerStyle,
1143
1149
  className: [
1144
1150
  "rh-flex rh-items-center rh-gap-2",
1145
1151
  "rh-bg-surface rh-font-body",
@@ -1587,7 +1593,8 @@ var Select = forwardRef(function Select2(props, ref) {
1587
1593
  disabled = false,
1588
1594
  className = "",
1589
1595
  wrapperClassName = "",
1590
- multiple = false
1596
+ multiple = false,
1597
+ backgroundColor
1591
1598
  } = props;
1592
1599
  const triggerId = React9.useId();
1593
1600
  const listboxId = React9.useId();
@@ -1766,9 +1773,11 @@ var Select = forwardRef(function Select2(props, ref) {
1766
1773
  disabled,
1767
1774
  onClick: () => !disabled && setIsOpen((o) => !o),
1768
1775
  onKeyDown: handleKeyDown,
1776
+ style: backgroundColor ? { backgroundColor } : void 0,
1769
1777
  className: [
1770
1778
  "rh-group rh-flex rh-items-center rh-justify-between rh-gap-2",
1771
- "rh-border rh-bg-surface rh-font-body",
1779
+ "rh-border rh-font-body",
1780
+ !backgroundColor && "rh-bg-surface",
1772
1781
  "rh-transition-colors rh-duration-150",
1773
1782
  "rh-text-left rh-w-full",
1774
1783
  statusClasses2[visualStatus],
@@ -1792,7 +1801,7 @@ var Select = forwardRef(function Select2(props, ref) {
1792
1801
  ChevronIcon,
1793
1802
  {
1794
1803
  className: [
1795
- "rh-w-5 rh-h-5 rh-shrink-0 rh-text-text-muted rh-transition-transform rh-duration-150",
1804
+ "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",
1796
1805
  isOpen ? "rh-rotate-180" : ""
1797
1806
  ].filter(Boolean).join(" ")
1798
1807
  }
@@ -2911,6 +2920,390 @@ var Spinner = forwardRef(function Spinner2({ size = "md", color = "primary", lab
2911
2920
  }
2912
2921
  );
2913
2922
  });
2923
+ var DAYS_SHORT = ["D", "S", "T", "Q", "Q", "S", "S"];
2924
+ var MONTHS_PT = [
2925
+ "Janeiro",
2926
+ "Fevereiro",
2927
+ "Mar\xE7o",
2928
+ "Abril",
2929
+ "Maio",
2930
+ "Junho",
2931
+ "Julho",
2932
+ "Agosto",
2933
+ "Setembro",
2934
+ "Outubro",
2935
+ "Novembro",
2936
+ "Dezembro"
2937
+ ];
2938
+ function parseDate(value) {
2939
+ if (!value) return null;
2940
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
2941
+ const [y, m, d] = value.split("-").map(Number);
2942
+ return new Date(y, m - 1, d);
2943
+ }
2944
+ if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
2945
+ const [d, m, y] = value.split("/").map(Number);
2946
+ return new Date(y, m - 1, d);
2947
+ }
2948
+ return null;
2949
+ }
2950
+ function formatISO(date) {
2951
+ const y = date.getFullYear();
2952
+ const m = String(date.getMonth() + 1).padStart(2, "0");
2953
+ const d = String(date.getDate()).padStart(2, "0");
2954
+ return `${y}-${m}-${d}`;
2955
+ }
2956
+ function formatDisplay(date) {
2957
+ const d = String(date.getDate()).padStart(2, "0");
2958
+ const m = String(date.getMonth() + 1).padStart(2, "0");
2959
+ const y = date.getFullYear();
2960
+ return `${d}/${m}/${y}`;
2961
+ }
2962
+ function getDaysInMonth(year, month) {
2963
+ return new Date(year, month + 1, 0).getDate();
2964
+ }
2965
+ function getFirstDayOfMonth(year, month) {
2966
+ return new Date(year, month, 1).getDay();
2967
+ }
2968
+ var ChevronLeftIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", className: "rh-w-5 rh-h-5", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
2969
+ "path",
2970
+ {
2971
+ fillRule: "evenodd",
2972
+ 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",
2973
+ clipRule: "evenodd"
2974
+ }
2975
+ ) });
2976
+ var ChevronRightIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", className: "rh-w-5 rh-h-5", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
2977
+ "path",
2978
+ {
2979
+ fillRule: "evenodd",
2980
+ 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",
2981
+ clipRule: "evenodd"
2982
+ }
2983
+ ) });
2984
+ var DatePickerDropdown = ({
2985
+ style,
2986
+ selectedDate,
2987
+ onSelect,
2988
+ onClose,
2989
+ containerRef
2990
+ }) => {
2991
+ const today = /* @__PURE__ */ new Date();
2992
+ const [viewYear, setViewYear] = useState(
2993
+ selectedDate ? selectedDate.getFullYear() : today.getFullYear()
2994
+ );
2995
+ const [viewMonth, setViewMonth] = useState(
2996
+ selectedDate ? selectedDate.getMonth() : today.getMonth()
2997
+ );
2998
+ const [tempDate, setTempDate] = useState(selectedDate);
2999
+ const dropdownRef = useRef(null);
3000
+ useEffect(() => {
3001
+ const handleClickOutside = (e) => {
3002
+ const target = e.target;
3003
+ if (dropdownRef.current && !dropdownRef.current.contains(target) && containerRef.current && !containerRef.current.contains(target)) {
3004
+ onClose();
3005
+ }
3006
+ };
3007
+ document.addEventListener("mousedown", handleClickOutside);
3008
+ return () => document.removeEventListener("mousedown", handleClickOutside);
3009
+ }, [onClose, containerRef]);
3010
+ const prevMonth = () => {
3011
+ if (viewMonth === 0) {
3012
+ setViewMonth(11);
3013
+ setViewYear((y) => y - 1);
3014
+ } else {
3015
+ setViewMonth((m) => m - 1);
3016
+ }
3017
+ };
3018
+ const nextMonth = () => {
3019
+ if (viewMonth === 11) {
3020
+ setViewMonth(0);
3021
+ setViewYear((y) => y + 1);
3022
+ } else {
3023
+ setViewMonth((m) => m + 1);
3024
+ }
3025
+ };
3026
+ const daysInMonth = getDaysInMonth(viewYear, viewMonth);
3027
+ const firstDay = getFirstDayOfMonth(viewYear, viewMonth);
3028
+ const prevMonthDays = getDaysInMonth(
3029
+ viewMonth === 0 ? viewYear - 1 : viewYear,
3030
+ viewMonth === 0 ? 11 : viewMonth - 1
3031
+ );
3032
+ const totalCells = firstDay + daysInMonth;
3033
+ const trailingCount = totalCells % 7 === 0 ? 0 : 7 - totalCells % 7;
3034
+ const isSelected = (day) => !!tempDate && tempDate.getFullYear() === viewYear && tempDate.getMonth() === viewMonth && tempDate.getDate() === day;
3035
+ return createPortal(
3036
+ /* @__PURE__ */ jsxs(
3037
+ "div",
3038
+ {
3039
+ ref: dropdownRef,
3040
+ style: {
3041
+ ...style,
3042
+ boxShadow: "0 0 9.6px 0 rgba(8, 11, 18, 0.08)",
3043
+ width: 260
3044
+ },
3045
+ className: "rh-bg-surface rh-rounded-xs rh-p-5 rh-select-none rh-font-body",
3046
+ children: [
3047
+ /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-items-center rh-justify-between", children: [
3048
+ /* @__PURE__ */ jsx(
3049
+ "button",
3050
+ {
3051
+ type: "button",
3052
+ onMouseDown: (e) => {
3053
+ e.preventDefault();
3054
+ prevMonth();
3055
+ },
3056
+ className: "rh-p-1 hover:rh-bg-background rh-rounded rh-cursor-pointer rh-text-text",
3057
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
3058
+ }
3059
+ ),
3060
+ /* @__PURE__ */ jsxs("span", { className: "rh-text-sm rh-font-medium rh-text-text", children: [
3061
+ MONTHS_PT[viewMonth],
3062
+ " - ",
3063
+ viewYear
3064
+ ] }),
3065
+ /* @__PURE__ */ jsx(
3066
+ "button",
3067
+ {
3068
+ type: "button",
3069
+ onMouseDown: (e) => {
3070
+ e.preventDefault();
3071
+ nextMonth();
3072
+ },
3073
+ className: "rh-p-1 hover:rh-bg-background rh-rounded rh-cursor-pointer rh-text-text",
3074
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
3075
+ }
3076
+ )
3077
+ ] }),
3078
+ /* @__PURE__ */ jsx("div", { className: "rh-grid rh-grid-cols-7", children: DAYS_SHORT.map((d, i) => /* @__PURE__ */ jsx(
3079
+ "div",
3080
+ {
3081
+ className: "rh-text-center rh-text-xs rh-text-text-muted rh-font-medium rh-py-1",
3082
+ children: d
3083
+ },
3084
+ i
3085
+ )) }),
3086
+ /* @__PURE__ */ jsx(
3087
+ "svg",
3088
+ {
3089
+ xmlns: "http://www.w3.org/2000/svg",
3090
+ width: "100%",
3091
+ height: "1",
3092
+ viewBox: "0 0 350 1",
3093
+ fill: "none",
3094
+ className: "rh-mb-3",
3095
+ children: /* @__PURE__ */ jsx("path", { d: "M0 0.5H350", stroke: "#F5F5F5" })
3096
+ }
3097
+ ),
3098
+ /* @__PURE__ */ jsxs("div", { className: "rh-grid rh-grid-cols-7 rh-gap-0", children: [
3099
+ Array.from({ length: firstDay }).map((_, i) => /* @__PURE__ */ jsx(
3100
+ "div",
3101
+ {
3102
+ 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",
3103
+ children: prevMonthDays - firstDay + i + 1
3104
+ },
3105
+ `prev-${i}`
3106
+ )),
3107
+ Array.from({ length: daysInMonth }).map((_, i) => {
3108
+ const day = i + 1;
3109
+ const selected = isSelected(day);
3110
+ return /* @__PURE__ */ jsx(
3111
+ "button",
3112
+ {
3113
+ type: "button",
3114
+ style: { backgroundColor: selected ? "#15607A" : "transparent" },
3115
+ onMouseDown: (e) => {
3116
+ e.preventDefault();
3117
+ setTempDate(new Date(viewYear, viewMonth, day));
3118
+ },
3119
+ className: [
3120
+ "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",
3121
+ selected ? "rh-text-surface" : "rh-text-text hover:rh-ring-1 hover:rh-ring-[#15607A] hover:rh-bg-transparent"
3122
+ ].join(" "),
3123
+ children: day
3124
+ },
3125
+ day
3126
+ );
3127
+ }),
3128
+ Array.from({ length: trailingCount }).map((_, i) => /* @__PURE__ */ jsx(
3129
+ "div",
3130
+ {
3131
+ 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",
3132
+ children: i + 1
3133
+ },
3134
+ `next-${i}`
3135
+ ))
3136
+ ] }),
3137
+ /* @__PURE__ */ jsx("div", { className: "rh-flex rh-justify-end rh-gap-2 rh-mt-4", children: /* @__PURE__ */ jsx(
3138
+ "button",
3139
+ {
3140
+ type: "button",
3141
+ style: { backgroundColor: "#87A851" },
3142
+ onClick: () => {
3143
+ if (tempDate) {
3144
+ onSelect(tempDate);
3145
+ }
3146
+ onClose();
3147
+ },
3148
+ 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",
3149
+ children: "Aplicar"
3150
+ }
3151
+ ) })
3152
+ ]
3153
+ }
3154
+ ),
3155
+ document.body
3156
+ );
3157
+ };
3158
+ var CustomSelect = ({
3159
+ options = [],
3160
+ value,
3161
+ onChange,
3162
+ className = "",
3163
+ type = "select"
3164
+ }) => {
3165
+ const [isOpen, setIsOpen] = useState(false);
3166
+ const [dropdownStyle, setDropdownStyle] = useState({});
3167
+ const containerRef = useRef(null);
3168
+ const calcPosition = () => {
3169
+ if (!containerRef.current) return {};
3170
+ const rect = containerRef.current.getBoundingClientRect();
3171
+ const spaceBelow = window.innerHeight - rect.bottom;
3172
+ const spaceAbove = rect.top;
3173
+ const DROPDOWN_HEIGHT = 320;
3174
+ const openUpward = spaceBelow < DROPDOWN_HEIGHT && spaceAbove > spaceBelow;
3175
+ return {
3176
+ position: "fixed",
3177
+ ...openUpward ? { bottom: window.innerHeight - rect.top + 4 } : { top: rect.bottom + 4 },
3178
+ left: rect.left,
3179
+ zIndex: 2
3180
+ };
3181
+ };
3182
+ const openDropdown = () => {
3183
+ if (!isOpen) setDropdownStyle(calcPosition());
3184
+ setIsOpen((prev) => !prev);
3185
+ };
3186
+ useEffect(() => {
3187
+ if (!isOpen) return;
3188
+ const close = () => setIsOpen(false);
3189
+ window.addEventListener("scroll", close, { capture: true, passive: true });
3190
+ window.addEventListener("resize", close, { passive: true });
3191
+ return () => {
3192
+ window.removeEventListener("scroll", close, { capture: true });
3193
+ window.removeEventListener("resize", close);
3194
+ };
3195
+ }, [isOpen]);
3196
+ const selectedOption = options.find((opt) => opt.value === value);
3197
+ useEffect(() => {
3198
+ if (type !== "select") return;
3199
+ const handleClickOutside = (e) => {
3200
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
3201
+ setIsOpen(false);
3202
+ }
3203
+ };
3204
+ if (isOpen) {
3205
+ document.addEventListener("mousedown", handleClickOutside);
3206
+ return () => document.removeEventListener("mousedown", handleClickOutside);
3207
+ }
3208
+ }, [isOpen, type]);
3209
+ const selectedDate = type === "date" ? parseDate(value) : null;
3210
+ const handleDateSelect = (date) => {
3211
+ if (date) {
3212
+ onChange(formatISO(date));
3213
+ }
3214
+ setIsOpen(false);
3215
+ };
3216
+ const displayLabel = type === "date" ? selectedDate ? formatDisplay(selectedDate) : value || "\u2014" : selectedOption?.label || value;
3217
+ const displayBg = type === "date" ? void 0 : selectedOption?.backgroundColor;
3218
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `rh-relative ${className}`, children: [
3219
+ /* @__PURE__ */ jsx(
3220
+ "button",
3221
+ {
3222
+ type: "button",
3223
+ onClick: openDropdown,
3224
+ 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",
3225
+ children: /* @__PURE__ */ jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-truncate", children: /* @__PURE__ */ jsx(
3226
+ "span",
3227
+ {
3228
+ className: "rh-truncate rh-text-[14px] rh-px-2 rh-py-1 rh-rounded-xl",
3229
+ style: {
3230
+ backgroundColor: displayBg || "transparent",
3231
+ fontFamily: "Inter, sans-serif",
3232
+ color: displayBg ? "white" : "inherit"
3233
+ },
3234
+ children: displayLabel
3235
+ }
3236
+ ) })
3237
+ }
3238
+ ),
3239
+ type === "select" && isOpen && createPortal(
3240
+ /* @__PURE__ */ jsx(
3241
+ "div",
3242
+ {
3243
+ style: {
3244
+ ...dropdownStyle,
3245
+ boxShadow: "0 10px 20px 0 rgba(0, 0, 0, 0.05)"
3246
+ },
3247
+ className: "rh-bg-surface rh-border rh-border-border rh-rounded-xs rh-max-h-60 rh-overflow-auto rh-pr-3",
3248
+ children: options.map((option) => /* @__PURE__ */ jsxs(
3249
+ "button",
3250
+ {
3251
+ type: "button",
3252
+ onMouseDown: (e) => {
3253
+ e.preventDefault();
3254
+ onChange(option.value);
3255
+ setIsOpen(false);
3256
+ },
3257
+ 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",
3258
+ children: [
3259
+ /* @__PURE__ */ jsx("div", { className: "rh-w-4 rh-h-4", children: option.value === value && /* @__PURE__ */ jsx(
3260
+ "svg",
3261
+ {
3262
+ width: "13",
3263
+ height: "10",
3264
+ viewBox: "0 0 13 10",
3265
+ fill: "none",
3266
+ xmlns: "http://www.w3.org/2000/svg",
3267
+ children: /* @__PURE__ */ jsx(
3268
+ "path",
3269
+ {
3270
+ 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",
3271
+ fill: "#374151"
3272
+ }
3273
+ )
3274
+ }
3275
+ ) }),
3276
+ /* @__PURE__ */ jsx(
3277
+ "span",
3278
+ {
3279
+ className: "rh-truncate rh-p-1 rh-px-2 rh-rounded-xl rh-text-white rh-text-[14px]",
3280
+ style: {
3281
+ backgroundColor: option.backgroundColor || "transparent",
3282
+ fontFamily: "Inter, sans-serif"
3283
+ },
3284
+ children: option.label
3285
+ }
3286
+ )
3287
+ ]
3288
+ },
3289
+ option.value
3290
+ ))
3291
+ }
3292
+ ),
3293
+ document.body
3294
+ ),
3295
+ type === "date" && isOpen && /* @__PURE__ */ jsx(
3296
+ DatePickerDropdown,
3297
+ {
3298
+ style: dropdownStyle,
3299
+ selectedDate,
3300
+ onSelect: handleDateSelect,
3301
+ onClose: () => setIsOpen(false),
3302
+ containerRef
3303
+ }
3304
+ )
3305
+ ] });
3306
+ };
2914
3307
  var sizeClasses12 = {
2915
3308
  sm: { cell: "rh-px-2 rh-py-2 rh-text-xs", header: "rh-px-2 rh-py-2 rh-text-xs" },
2916
3309
  md: { cell: "rh-px-3 rh-py-3 rh-text-sm", header: "rh-px-3 rh-py-3 rh-text-xs" },
@@ -2935,6 +3328,12 @@ function TableInner({
2935
3328
  stickyHeader = false,
2936
3329
  headerStyle,
2937
3330
  headerTextClassName,
3331
+ headerTextStyle,
3332
+ bodyBackground,
3333
+ bodyTextStyle,
3334
+ rowPadding,
3335
+ addRowButton,
3336
+ onAddRow,
2938
3337
  className = "",
2939
3338
  ...rest
2940
3339
  }, ref) {
@@ -2976,34 +3375,86 @@ function TableInner({
2976
3375
  };
2977
3376
  const isEmpty = !loading && data.length === 0;
2978
3377
  const colSpan = columns.length;
2979
- return /* @__PURE__ */ jsx("div", { className: "rh-w-full rh-overflow-x-auto", children: /* @__PURE__ */ jsxs(
3378
+ const headerTextStyleInline = {
3379
+ color: headerTextStyle?.color,
3380
+ fontFamily: headerTextStyle?.fontFamily,
3381
+ fontSize: headerTextStyle?.fontSize,
3382
+ fontWeight: headerTextStyle?.fontWeight
3383
+ };
3384
+ const bodyStyleInline = {
3385
+ color: bodyTextStyle?.color,
3386
+ fontFamily: bodyTextStyle?.fontFamily,
3387
+ fontSize: bodyTextStyle?.fontSize,
3388
+ fontWeight: bodyTextStyle?.fontWeight
3389
+ };
3390
+ const getRowPaddingStyle = () => {
3391
+ if (typeof rowPadding === "string") {
3392
+ return { padding: rowPadding };
3393
+ }
3394
+ if (typeof rowPadding === "object") {
3395
+ const style = {};
3396
+ if (rowPadding.x) {
3397
+ style.paddingLeft = rowPadding.x;
3398
+ style.paddingRight = rowPadding.x;
3399
+ }
3400
+ if (rowPadding.y) {
3401
+ style.paddingTop = rowPadding.y;
3402
+ style.paddingBottom = rowPadding.y;
3403
+ }
3404
+ return style;
3405
+ }
3406
+ return {};
3407
+ };
3408
+ const rowPaddingStyle = getRowPaddingStyle();
3409
+ const isEditableCell = (column) => {
3410
+ if (!column.editable || !column.editableValue) return false;
3411
+ if (column.type === "date") return true;
3412
+ return !!column.choices;
3413
+ };
3414
+ return /* @__PURE__ */ jsx("div", { className: "rh-w-full rh-rounded rh-overflow-hidden", children: /* @__PURE__ */ jsxs(
2980
3415
  "table",
2981
3416
  {
2982
3417
  ref,
3418
+ style: { backgroundColor: bodyBackground },
2983
3419
  className: ["rh-w-full rh-border-collapse rh-font-body", className].filter(Boolean).join(" "),
2984
3420
  ...rest,
2985
3421
  children: [
2986
- /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: "rh-border-b rh-border-border", style: headerStyle, children: columns.map((column) => /* @__PURE__ */ jsx(
2987
- "th",
3422
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx(
3423
+ "tr",
2988
3424
  {
2989
- scope: "col",
2990
- style: { width: column.width },
2991
- className: [
2992
- sizeClasses12[size].header,
2993
- alignClasses[column.align || "left"],
2994
- `rh-font-semibold rh-whitespace-nowrap ${headerTextClassName || "rh-text-text-muted"}`,
2995
- stickyHeader ? "rh-sticky rh-top-0 rh-bg-surface rh-z-10" : "",
2996
- column.sortable ? "rh-cursor-pointer rh-select-none hover:rh-text-text" : ""
2997
- ].filter(Boolean).join(" "),
2998
- onClick: () => handleSort(column),
2999
- children: /* @__PURE__ */ jsxs("span", { className: "rh-inline-flex rh-items-center", children: [
3000
- column.header,
3001
- renderSortIcon(column)
3002
- ] })
3003
- },
3004
- column.key
3005
- )) }) }),
3006
- /* @__PURE__ */ jsxs("tbody", { children: [
3425
+ className: "rh-border-b rh-border-border",
3426
+ style: {
3427
+ backgroundColor: headerStyle?.backgroundColor,
3428
+ height: headerStyle?.height,
3429
+ border: headerStyle?.border
3430
+ },
3431
+ children: columns.map((column) => /* @__PURE__ */ jsx(
3432
+ "th",
3433
+ {
3434
+ scope: "col",
3435
+ style: {
3436
+ width: column.width,
3437
+ maxWidth: column.maxWidth,
3438
+ ...rowPaddingStyle
3439
+ },
3440
+ className: [
3441
+ rowPadding ? "" : sizeClasses12[size].header,
3442
+ alignClasses[column.align || "left"],
3443
+ `rh-font-semibold rh-whitespace-nowrap ${headerTextClassName || "rh-text-text-muted"}`,
3444
+ stickyHeader ? "rh-sticky rh-top-0 rh-bg-surface rh-z-10" : "",
3445
+ column.sortable ? "rh-cursor-pointer rh-select-none hover:rh-text-text" : ""
3446
+ ].filter(Boolean).join(" "),
3447
+ onClick: () => handleSort(column),
3448
+ children: /* @__PURE__ */ jsxs("span", { className: "rh-inline-flex rh-items-center", style: headerTextStyleInline, children: [
3449
+ column.header,
3450
+ renderSortIcon(column)
3451
+ ] })
3452
+ },
3453
+ column.key
3454
+ ))
3455
+ }
3456
+ ) }),
3457
+ /* @__PURE__ */ jsxs("tbody", { style: { backgroundColor: bodyBackground }, children: [
3007
3458
  loading && /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, className: "rh-text-center rh-py-8", children: loadingContent || /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-items-center rh-justify-center rh-gap-2 rh-text-text-muted", children: [
3008
3459
  /* @__PURE__ */ jsxs(
3009
3460
  "svg",
@@ -3041,6 +3492,7 @@ function TableInner({
3041
3492
  !loading && data.map((row, index) => /* @__PURE__ */ jsx(
3042
3493
  "tr",
3043
3494
  {
3495
+ style: bodyStyleInline,
3044
3496
  className: [
3045
3497
  "rh-border-b rh-border-border rh-transition-colors",
3046
3498
  "hover:rh-bg-background",
@@ -3049,18 +3501,57 @@ function TableInner({
3049
3501
  children: columns.map((column) => /* @__PURE__ */ jsx(
3050
3502
  "td",
3051
3503
  {
3504
+ style: { width: column.width, maxWidth: column.maxWidth, ...rowPaddingStyle },
3052
3505
  className: [
3053
- sizeClasses12[size].cell,
3506
+ rowPadding ? "" : sizeClasses12[size].cell,
3054
3507
  alignClasses[column.align || "left"],
3055
3508
  "rh-text-text"
3056
3509
  ].filter(Boolean).join(" "),
3057
- children: column.render(row, index)
3510
+ children: /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-items-center rh-justify-between rh-gap-2", children: [
3511
+ isEditableCell(column) ? /* @__PURE__ */ jsx(
3512
+ CustomSelect,
3513
+ {
3514
+ type: column.type ?? "select",
3515
+ options: column.choices,
3516
+ value: column.editableValue(row),
3517
+ onChange: (value) => column.onEditChange?.(row, index, value),
3518
+ className: "rh-w-full rh-h-full"
3519
+ }
3520
+ ) : /* @__PURE__ */ jsx("span", { children: column.render(row, index) }),
3521
+ column.actionIcon && /* @__PURE__ */ jsx(
3522
+ "span",
3523
+ {
3524
+ className: "rh-cursor-pointer hover:rh-bg-background/50 rh-p-1 rh-rounded",
3525
+ onClick: (e) => {
3526
+ e.stopPropagation();
3527
+ column.actionIcon?.onClick(row, index);
3528
+ },
3529
+ children: column.actionIcon.icon
3530
+ }
3531
+ )
3532
+ ] })
3058
3533
  },
3059
3534
  column.key
3060
3535
  ))
3061
3536
  },
3062
3537
  rowKey(row, index)
3063
- ))
3538
+ )),
3539
+ addRowButton && !loading && /* @__PURE__ */ jsx("tr", { className: "rh-border-border hover:rh-bg-background/100 rh-rounde-lg", children: /* @__PURE__ */ jsx(
3540
+ "td",
3541
+ {
3542
+ colSpan,
3543
+ style: rowPaddingStyle,
3544
+ className: [
3545
+ rowPadding ? "" : sizeClasses12[size].cell,
3546
+ "rh-text-center rh-cursor-pointer rh-text-[#9CA3AF] rh-font-medium"
3547
+ ].filter(Boolean).join(" "),
3548
+ onClick: onAddRow,
3549
+ children: /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-items-center rh-justify-center rh-gap-2 rh-h-6 rh-font-bold rh-text-sm", children: [
3550
+ addRowButton.icon,
3551
+ addRowButton.text
3552
+ ] })
3553
+ }
3554
+ ) })
3064
3555
  ] })
3065
3556
  ]
3066
3557
  }