@rehagro/ui 1.0.52 → 1.0.53

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 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";
@@ -836,6 +837,16 @@ type TableColumn<T> = {
836
837
  editableValue?: (row: T) => string;
837
838
  /** Callback when the editable value changes */
838
839
  onEditChange?: (row: T, index: number, value: string) => void;
840
+ /** Text color for the editable select/date value. Can be fixed or derived from the row. */
841
+ editableTextColor?: string | ((row: T, index: number) => string | undefined);
842
+ /** Background color for the editable select/date value. Can be fixed or derived from the row. */
843
+ editableBackgroundColor?: string | ((row: T, index: number) => string | undefined);
844
+ /** Background color for the editable select/date control itself. Can be fixed or derived from the row. */
845
+ editableSelectBackgroundColor?: string | ((row: T, index: number) => string | undefined);
846
+ /** Background color for the editable date calendar panel. Can be fixed or derived from the row. */
847
+ editableCalendarBackgroundColor?: string | ((row: T, index: number) => string | undefined);
848
+ /** Text color for the editable date calendar panel, excluding the apply button. */
849
+ editableCalendarTextColor?: string | ((row: T, index: number) => string | undefined);
839
850
  };
840
851
  type SortDirection = "asc" | "desc" | null;
841
852
  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";
@@ -836,6 +837,16 @@ type TableColumn<T> = {
836
837
  editableValue?: (row: T) => string;
837
838
  /** Callback when the editable value changes */
838
839
  onEditChange?: (row: T, index: number, value: string) => void;
840
+ /** Text color for the editable select/date value. Can be fixed or derived from the row. */
841
+ editableTextColor?: string | ((row: T, index: number) => string | undefined);
842
+ /** Background color for the editable select/date value. Can be fixed or derived from the row. */
843
+ editableBackgroundColor?: string | ((row: T, index: number) => string | undefined);
844
+ /** Background color for the editable select/date control itself. Can be fixed or derived from the row. */
845
+ editableSelectBackgroundColor?: string | ((row: T, index: number) => string | undefined);
846
+ /** Background color for the editable date calendar panel. Can be fixed or derived from the row. */
847
+ editableCalendarBackgroundColor?: string | ((row: T, index: number) => string | undefined);
848
+ /** Text color for the editable date calendar panel, excluding the apply button. */
849
+ editableCalendarTextColor?: string | ((row: T, index: number) => string | undefined);
839
850
  };
840
851
  type SortDirection = "asc" | "desc" | null;
841
852
  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();
@@ -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,9 +3851,14 @@ var DatePickerDropdown = ({
3792
3851
  selectedDate,
3793
3852
  onSelect,
3794
3853
  onClose,
3795
- containerRef
3854
+ containerRef,
3855
+ backgroundColor,
3856
+ textColor,
3857
+ calendarTextColor
3796
3858
  }) => {
3797
3859
  const today = /* @__PURE__ */ new Date();
3860
+ const opaqueBackgroundColor = removeHexAlpha(backgroundColor);
3861
+ const calendarTextStyle = calendarTextColor ? { color: calendarTextColor } : void 0;
3798
3862
  const [viewYear, setViewYear] = React9.useState(
3799
3863
  selectedDate ? selectedDate.getFullYear() : today.getFullYear()
3800
3864
  );
@@ -3845,6 +3909,8 @@ var DatePickerDropdown = ({
3845
3909
  ref: dropdownRef,
3846
3910
  style: {
3847
3911
  ...style,
3912
+ backgroundColor: opaqueBackgroundColor,
3913
+ color: textColor,
3848
3914
  boxShadow: "0 0 9.6px 0 rgba(8, 11, 18, 0.08)",
3849
3915
  width: 260
3850
3916
  },
@@ -3855,6 +3921,7 @@ var DatePickerDropdown = ({
3855
3921
  "button",
3856
3922
  {
3857
3923
  type: "button",
3924
+ style: calendarTextStyle,
3858
3925
  onMouseDown: (e) => {
3859
3926
  e.preventDefault();
3860
3927
  prevMonth();
@@ -3863,7 +3930,7 @@ var DatePickerDropdown = ({
3863
3930
  children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon2, {})
3864
3931
  }
3865
3932
  ),
3866
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rh-text-sm rh-font-medium rh-text-text", children: [
3933
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "rh-text-sm rh-font-medium rh-text-text", style: calendarTextStyle, children: [
3867
3934
  MONTHS_PT[viewMonth],
3868
3935
  " - ",
3869
3936
  viewYear
@@ -3872,6 +3939,7 @@ var DatePickerDropdown = ({
3872
3939
  "button",
3873
3940
  {
3874
3941
  type: "button",
3942
+ style: calendarTextStyle,
3875
3943
  onMouseDown: (e) => {
3876
3944
  e.preventDefault();
3877
3945
  nextMonth();
@@ -3885,6 +3953,7 @@ var DatePickerDropdown = ({
3885
3953
  "div",
3886
3954
  {
3887
3955
  className: "rh-text-center rh-text-xs rh-text-text-muted rh-font-medium rh-py-1",
3956
+ style: calendarTextStyle,
3888
3957
  children: d
3889
3958
  },
3890
3959
  i
@@ -3906,6 +3975,7 @@ var DatePickerDropdown = ({
3906
3975
  "div",
3907
3976
  {
3908
3977
  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",
3978
+ style: calendarTextStyle,
3909
3979
  children: prevMonthDays - firstDay + i + 1
3910
3980
  },
3911
3981
  `prev-${i}`
@@ -3917,7 +3987,10 @@ var DatePickerDropdown = ({
3917
3987
  "button",
3918
3988
  {
3919
3989
  type: "button",
3920
- style: { backgroundColor: selected ? "#15607A" : "transparent" },
3990
+ style: {
3991
+ backgroundColor: selected ? "#15607A" : "transparent",
3992
+ ...calendarTextStyle
3993
+ },
3921
3994
  onMouseDown: (e) => {
3922
3995
  e.preventDefault();
3923
3996
  setTempDate(new Date(viewYear, viewMonth, day));
@@ -3935,6 +4008,7 @@ var DatePickerDropdown = ({
3935
4008
  "div",
3936
4009
  {
3937
4010
  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",
4011
+ style: calendarTextStyle,
3938
4012
  children: i + 1
3939
4013
  },
3940
4014
  `next-${i}`
@@ -3966,6 +4040,11 @@ var CustomSelect = ({
3966
4040
  value,
3967
4041
  onChange,
3968
4042
  className = "",
4043
+ textColor,
4044
+ backgroundColor,
4045
+ selectBackgroundColor,
4046
+ calendarBackgroundColor,
4047
+ calendarTextColor,
3969
4048
  type = "select"
3970
4049
  }) => {
3971
4050
  const [isOpen, setIsOpen] = React9.useState(false);
@@ -4020,14 +4099,16 @@ var CustomSelect = ({
4020
4099
  setIsOpen(false);
4021
4100
  };
4022
4101
  const displayLabel = type === "date" ? selectedDate ? formatDisplay(selectedDate) : value || "\u2014" : selectedOption?.label || value;
4023
- const displayBg = type === "date" ? void 0 : selectedOption?.backgroundColor;
4102
+ const displayBg = type === "date" ? backgroundColor : selectedOption?.backgroundColor || backgroundColor;
4103
+ const displayTextColor = type === "date" ? textColor : selectedOption?.textColor || textColor || (displayBg ? "white" : "inherit");
4024
4104
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: `rh-relative ${className}`, children: [
4025
4105
  /* @__PURE__ */ jsxRuntime.jsx(
4026
4106
  "button",
4027
4107
  {
4028
4108
  type: "button",
4029
4109
  onClick: openDropdown,
4030
- 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",
4110
+ style: { backgroundColor: selectBackgroundColor || void 0 },
4111
+ className: "rh-w-full rh-h-full rh-flex rh-items-center rh-border rh-bg-surface rh-rounded-sm rh-border-transparent rh-justify-between rh-py-2\n hover:rh-border-primary hover:rh-ring-2 hover:rh-ring-gray-200 rh-cursor-pointer rh-text-left",
4031
4112
  children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-truncate", children: /* @__PURE__ */ jsxRuntime.jsx(
4032
4113
  "span",
4033
4114
  {
@@ -4035,7 +4116,7 @@ var CustomSelect = ({
4035
4116
  style: {
4036
4117
  backgroundColor: displayBg || "transparent",
4037
4118
  fontFamily: "Inter, sans-serif",
4038
- color: displayBg ? "white" : "inherit"
4119
+ color: displayTextColor
4039
4120
  },
4040
4121
  children: displayLabel
4041
4122
  }
@@ -4048,9 +4129,10 @@ var CustomSelect = ({
4048
4129
  {
4049
4130
  style: {
4050
4131
  ...dropdownStyle,
4132
+ backgroundColor: selectBackgroundColor || void 0,
4051
4133
  boxShadow: "0 10px 20px 0 rgba(0, 0, 0, 0.05)"
4052
4134
  },
4053
- className: "rh-bg-surface rh-border rh-border-border rh-rounded-xs rh-max-h-60 rh-overflow-auto rh-pr-3",
4135
+ className: "rh-border rh-border-border rh-rounded-xs rh-max-h-60 rh-overflow-auto",
4054
4136
  children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
4055
4137
  "button",
4056
4138
  {
@@ -4060,9 +4142,9 @@ var CustomSelect = ({
4060
4142
  onChange(option.value);
4061
4143
  setIsOpen(false);
4062
4144
  },
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",
4145
+ 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
4146
  children: [
4065
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-4 rh-h-4", children: option.value === value && /* @__PURE__ */ jsxRuntime.jsx(
4147
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-4", children: option.value === value && /* @__PURE__ */ jsxRuntime.jsx(
4066
4148
  "svg",
4067
4149
  {
4068
4150
  width: "13",
@@ -4084,8 +4166,9 @@ var CustomSelect = ({
4084
4166
  {
4085
4167
  className: "rh-truncate rh-p-1 rh-px-2 rh-rounded-xl rh-text-white rh-text-[14px]",
4086
4168
  style: {
4087
- backgroundColor: option.backgroundColor || "transparent",
4088
- fontFamily: "Inter, sans-serif"
4169
+ backgroundColor: option.backgroundColor || backgroundColor || "transparent",
4170
+ fontFamily: "Inter, sans-serif",
4171
+ color: option.textColor || textColor || (option.backgroundColor || backgroundColor ? "white" : "inherit")
4089
4172
  },
4090
4173
  children: option.label
4091
4174
  }
@@ -4105,7 +4188,10 @@ var CustomSelect = ({
4105
4188
  selectedDate,
4106
4189
  onSelect: handleDateSelect,
4107
4190
  onClose: () => setIsOpen(false),
4108
- containerRef
4191
+ containerRef,
4192
+ backgroundColor: calendarBackgroundColor,
4193
+ textColor,
4194
+ calendarTextColor
4109
4195
  }
4110
4196
  )
4111
4197
  ] });
@@ -4217,6 +4303,36 @@ function TableInner({
4217
4303
  if (column.type === "date") return true;
4218
4304
  return !!column.choices;
4219
4305
  };
4306
+ const getEditableTextColor = (column, row, index) => {
4307
+ if (typeof column.editableTextColor === "function") {
4308
+ return column.editableTextColor(row, index);
4309
+ }
4310
+ return column.editableTextColor;
4311
+ };
4312
+ const getEditableBackgroundColor = (column, row, index) => {
4313
+ if (typeof column.editableBackgroundColor === "function") {
4314
+ return column.editableBackgroundColor(row, index);
4315
+ }
4316
+ return column.editableBackgroundColor;
4317
+ };
4318
+ const getEditableSelectBackgroundColor = (column, row, index) => {
4319
+ if (typeof column.editableSelectBackgroundColor === "function") {
4320
+ return column.editableSelectBackgroundColor(row, index);
4321
+ }
4322
+ return column.editableSelectBackgroundColor;
4323
+ };
4324
+ const getEditableCalendarBackgroundColor = (column, row, index) => {
4325
+ if (typeof column.editableCalendarBackgroundColor === "function") {
4326
+ return column.editableCalendarBackgroundColor(row, index);
4327
+ }
4328
+ return column.editableCalendarBackgroundColor;
4329
+ };
4330
+ const getEditableCalendarTextColor = (column, row, index) => {
4331
+ if (typeof column.editableCalendarTextColor === "function") {
4332
+ return column.editableCalendarTextColor(row, index);
4333
+ }
4334
+ return column.editableCalendarTextColor;
4335
+ };
4220
4336
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-full rh-rounded rh-overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(
4221
4337
  "table",
4222
4338
  {
@@ -4301,7 +4417,7 @@ function TableInner({
4301
4417
  style: bodyStyleInline,
4302
4418
  className: [
4303
4419
  "rh-border-b rh-border-border rh-transition-colors",
4304
- "hover:rh-bg-background",
4420
+ "hover:rh-bg-background/50",
4305
4421
  variant === "striped" && index % 2 === 1 ? "rh-bg-background/50" : ""
4306
4422
  ].filter(Boolean).join(" "),
4307
4423
  children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -4320,10 +4436,27 @@ function TableInner({
4320
4436
  type: column.type ?? "select",
4321
4437
  options: column.choices,
4322
4438
  value: column.editableValue(row),
4439
+ textColor: getEditableTextColor(column, row, index),
4440
+ backgroundColor: getEditableBackgroundColor(column, row, index),
4441
+ selectBackgroundColor: getEditableSelectBackgroundColor(
4442
+ column,
4443
+ row,
4444
+ index
4445
+ ),
4446
+ calendarBackgroundColor: getEditableCalendarBackgroundColor(
4447
+ column,
4448
+ row,
4449
+ index
4450
+ ),
4451
+ calendarTextColor: getEditableCalendarTextColor(
4452
+ column,
4453
+ row,
4454
+ index
4455
+ ),
4323
4456
  onChange: (value) => column.onEditChange?.(row, index, value),
4324
4457
  className: "rh-w-full rh-h-full"
4325
4458
  }
4326
- ) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: column.render(row, index) }),
4459
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { style: { width: "100%" }, children: column.render(row, index) }),
4327
4460
  column.actionIcon && /* @__PURE__ */ jsxRuntime.jsx(
4328
4461
  "span",
4329
4462
  {
@@ -4342,14 +4475,12 @@ function TableInner({
4342
4475
  },
4343
4476
  rowKey(row, index)
4344
4477
  )),
4345
- addRowButton && !loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-border hover:rh-bg-background/50 rh-rounde-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
4478
+ 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
4479
  "td",
4347
4480
  {
4348
4481
  colSpan,
4349
- style: rowPaddingStyle,
4350
4482
  className: [
4351
- rowPadding ? "" : sizeClasses13[size].cell,
4352
- "rh-text-center rh-cursor-pointer rh-text-[#9CA3AF] rh-font-medium"
4483
+ "rh-text-center rh-cursor-pointer rh-text-[#9CA3AF] rh-font-medium rh-px-4 rh-py-3 rh-rounded-b"
4353
4484
  ].filter(Boolean).join(" "),
4354
4485
  onClick: onAddRow,
4355
4486
  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: [