@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.mjs CHANGED
@@ -2108,6 +2108,21 @@ var DateSelect = forwardRef(
2108
2108
  if (!isControlled) setInternalValue(newValue);
2109
2109
  props.onChange?.(newValue);
2110
2110
  };
2111
+ const handleMonthClear = () => {
2112
+ const newValue = { mode: "month" };
2113
+ if (!isControlled) setInternalValue(newValue);
2114
+ props.onChange?.(newValue);
2115
+ };
2116
+ const handleDayClear = () => {
2117
+ const newValue = { mode: "day" };
2118
+ if (!isControlled) setInternalValue(newValue);
2119
+ props.onChange?.(newValue);
2120
+ };
2121
+ const handleYearClear = () => {
2122
+ const newValue = { mode: "year" };
2123
+ if (!isControlled) setInternalValue(newValue);
2124
+ props.onChange?.(newValue);
2125
+ };
2111
2126
  const displayText = useMemo(() => {
2112
2127
  if (value.mode === "year" && value.year) return value.year.toString();
2113
2128
  if (value.mode === "month" && value.year != null)
@@ -2228,7 +2243,18 @@ var DateSelect = forwardRef(
2228
2243
  },
2229
2244
  year
2230
2245
  );
2231
- }) })
2246
+ }) }),
2247
+ /* @__PURE__ */ 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__ */ jsxs(
2248
+ "button",
2249
+ {
2250
+ onClick: handleYearClear,
2251
+ 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",
2252
+ children: [
2253
+ /* @__PURE__ */ jsx(EraserIcon, { className: "rh-w-4 rh-h-4" }),
2254
+ "Limpar"
2255
+ ]
2256
+ }
2257
+ ) })
2232
2258
  ] });
2233
2259
  const renderMonthGrid = () => /* @__PURE__ */ jsxs("div", { className: "rh-p-1", children: [
2234
2260
  /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-items-center rh-justify-between", children: [
@@ -2276,7 +2302,18 @@ var DateSelect = forwardRef(
2276
2302
  },
2277
2303
  month
2278
2304
  );
2279
- }) })
2305
+ }) }),
2306
+ /* @__PURE__ */ 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__ */ jsxs(
2307
+ "button",
2308
+ {
2309
+ onClick: handleMonthClear,
2310
+ 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",
2311
+ children: [
2312
+ /* @__PURE__ */ jsx(EraserIcon, { className: "rh-w-4 rh-h-4" }),
2313
+ "Limpar"
2314
+ ]
2315
+ }
2316
+ ) })
2280
2317
  ] });
2281
2318
  const renderIntervalNav = () => /* @__PURE__ */ jsxs("div", { children: [
2282
2319
  /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-gap-4 rh-p-1", children: [
@@ -2534,7 +2571,18 @@ var DateSelect = forwardRef(
2534
2571
  },
2535
2572
  i
2536
2573
  )) }),
2537
- renderDayGrid(selectedYear, selectedMonth)
2574
+ renderDayGrid(selectedYear, selectedMonth),
2575
+ /* @__PURE__ */ 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__ */ jsxs(
2576
+ "button",
2577
+ {
2578
+ onClick: handleDayClear,
2579
+ 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",
2580
+ children: [
2581
+ /* @__PURE__ */ jsx(EraserIcon, { className: "rh-w-4 rh-h-4" }),
2582
+ "Limpar"
2583
+ ]
2584
+ }
2585
+ ) })
2538
2586
  ] });
2539
2587
  case "month":
2540
2588
  return renderMonthGrid();
@@ -3765,6 +3813,17 @@ function getDaysInMonth(year, month) {
3765
3813
  function getFirstDayOfMonth(year, month) {
3766
3814
  return new Date(year, month, 1).getDay();
3767
3815
  }
3816
+ function removeHexAlpha(color) {
3817
+ if (!color) return color;
3818
+ if (/^#[0-9a-fA-F]{4}$/.test(color)) {
3819
+ const [, r, g, b] = color;
3820
+ return `#${r}${r}${g}${g}${b}${b}`;
3821
+ }
3822
+ if (/^#[0-9a-fA-F]{8}$/.test(color)) {
3823
+ return color.slice(0, 7);
3824
+ }
3825
+ return color;
3826
+ }
3768
3827
  var ChevronLeftIcon2 = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", className: "rh-w-5 rh-h-5", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
3769
3828
  "path",
3770
3829
  {
@@ -3786,9 +3845,14 @@ var DatePickerDropdown = ({
3786
3845
  selectedDate,
3787
3846
  onSelect,
3788
3847
  onClose,
3789
- containerRef
3848
+ containerRef,
3849
+ backgroundColor,
3850
+ textColor,
3851
+ calendarTextColor
3790
3852
  }) => {
3791
3853
  const today = /* @__PURE__ */ new Date();
3854
+ const opaqueBackgroundColor = removeHexAlpha(backgroundColor);
3855
+ const calendarTextStyle = calendarTextColor ? { color: calendarTextColor } : void 0;
3792
3856
  const [viewYear, setViewYear] = useState(
3793
3857
  selectedDate ? selectedDate.getFullYear() : today.getFullYear()
3794
3858
  );
@@ -3839,6 +3903,8 @@ var DatePickerDropdown = ({
3839
3903
  ref: dropdownRef,
3840
3904
  style: {
3841
3905
  ...style,
3906
+ backgroundColor: opaqueBackgroundColor,
3907
+ color: textColor,
3842
3908
  boxShadow: "0 0 9.6px 0 rgba(8, 11, 18, 0.08)",
3843
3909
  width: 260
3844
3910
  },
@@ -3849,6 +3915,7 @@ var DatePickerDropdown = ({
3849
3915
  "button",
3850
3916
  {
3851
3917
  type: "button",
3918
+ style: calendarTextStyle,
3852
3919
  onMouseDown: (e) => {
3853
3920
  e.preventDefault();
3854
3921
  prevMonth();
@@ -3857,7 +3924,7 @@ var DatePickerDropdown = ({
3857
3924
  children: /* @__PURE__ */ jsx(ChevronLeftIcon2, {})
3858
3925
  }
3859
3926
  ),
3860
- /* @__PURE__ */ jsxs("span", { className: "rh-text-sm rh-font-medium rh-text-text", children: [
3927
+ /* @__PURE__ */ jsxs("span", { className: "rh-text-sm rh-font-medium rh-text-text", style: calendarTextStyle, children: [
3861
3928
  MONTHS_PT[viewMonth],
3862
3929
  " - ",
3863
3930
  viewYear
@@ -3866,6 +3933,7 @@ var DatePickerDropdown = ({
3866
3933
  "button",
3867
3934
  {
3868
3935
  type: "button",
3936
+ style: calendarTextStyle,
3869
3937
  onMouseDown: (e) => {
3870
3938
  e.preventDefault();
3871
3939
  nextMonth();
@@ -3879,6 +3947,7 @@ var DatePickerDropdown = ({
3879
3947
  "div",
3880
3948
  {
3881
3949
  className: "rh-text-center rh-text-xs rh-text-text-muted rh-font-medium rh-py-1",
3950
+ style: calendarTextStyle,
3882
3951
  children: d
3883
3952
  },
3884
3953
  i
@@ -3900,6 +3969,7 @@ var DatePickerDropdown = ({
3900
3969
  "div",
3901
3970
  {
3902
3971
  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",
3972
+ style: calendarTextStyle,
3903
3973
  children: prevMonthDays - firstDay + i + 1
3904
3974
  },
3905
3975
  `prev-${i}`
@@ -3911,7 +3981,10 @@ var DatePickerDropdown = ({
3911
3981
  "button",
3912
3982
  {
3913
3983
  type: "button",
3914
- style: { backgroundColor: selected ? "#15607A" : "transparent" },
3984
+ style: {
3985
+ backgroundColor: selected ? "#15607A" : "transparent",
3986
+ ...calendarTextStyle
3987
+ },
3915
3988
  onMouseDown: (e) => {
3916
3989
  e.preventDefault();
3917
3990
  setTempDate(new Date(viewYear, viewMonth, day));
@@ -3929,6 +4002,7 @@ var DatePickerDropdown = ({
3929
4002
  "div",
3930
4003
  {
3931
4004
  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",
4005
+ style: calendarTextStyle,
3932
4006
  children: i + 1
3933
4007
  },
3934
4008
  `next-${i}`
@@ -3960,6 +4034,11 @@ var CustomSelect = ({
3960
4034
  value,
3961
4035
  onChange,
3962
4036
  className = "",
4037
+ textColor,
4038
+ backgroundColor,
4039
+ selectBackgroundColor,
4040
+ calendarBackgroundColor,
4041
+ calendarTextColor,
3963
4042
  type = "select"
3964
4043
  }) => {
3965
4044
  const [isOpen, setIsOpen] = useState(false);
@@ -4014,14 +4093,16 @@ var CustomSelect = ({
4014
4093
  setIsOpen(false);
4015
4094
  };
4016
4095
  const displayLabel = type === "date" ? selectedDate ? formatDisplay(selectedDate) : value || "\u2014" : selectedOption?.label || value;
4017
- const displayBg = type === "date" ? void 0 : selectedOption?.backgroundColor;
4096
+ const displayBg = type === "date" ? backgroundColor : selectedOption?.backgroundColor || backgroundColor;
4097
+ const displayTextColor = type === "date" ? textColor : selectedOption?.textColor || textColor || (displayBg ? "white" : "inherit");
4018
4098
  return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `rh-relative ${className}`, children: [
4019
4099
  /* @__PURE__ */ jsx(
4020
4100
  "button",
4021
4101
  {
4022
4102
  type: "button",
4023
4103
  onClick: openDropdown,
4024
- 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",
4104
+ style: { backgroundColor: selectBackgroundColor || void 0 },
4105
+ 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",
4025
4106
  children: /* @__PURE__ */ jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-truncate", children: /* @__PURE__ */ jsx(
4026
4107
  "span",
4027
4108
  {
@@ -4029,7 +4110,7 @@ var CustomSelect = ({
4029
4110
  style: {
4030
4111
  backgroundColor: displayBg || "transparent",
4031
4112
  fontFamily: "Inter, sans-serif",
4032
- color: displayBg ? "white" : "inherit"
4113
+ color: displayTextColor
4033
4114
  },
4034
4115
  children: displayLabel
4035
4116
  }
@@ -4042,9 +4123,10 @@ var CustomSelect = ({
4042
4123
  {
4043
4124
  style: {
4044
4125
  ...dropdownStyle,
4126
+ backgroundColor: selectBackgroundColor || void 0,
4045
4127
  boxShadow: "0 10px 20px 0 rgba(0, 0, 0, 0.05)"
4046
4128
  },
4047
- className: "rh-bg-surface rh-border rh-border-border rh-rounded-xs rh-max-h-60 rh-overflow-auto rh-pr-3",
4129
+ className: "rh-border rh-border-border rh-rounded-xs rh-max-h-60 rh-overflow-auto",
4048
4130
  children: options.map((option) => /* @__PURE__ */ jsxs(
4049
4131
  "button",
4050
4132
  {
@@ -4054,9 +4136,9 @@ var CustomSelect = ({
4054
4136
  onChange(option.value);
4055
4137
  setIsOpen(false);
4056
4138
  },
4057
- className: "rh-flex rh-items-center rh-gap-2 rh-px-3 rh-py-2 rh-text-left hover:rh-bg-background/50 rh-cursor-pointer",
4139
+ className: "rh-flex rh-items-center rh-gap-2 rh-px-3 rh-py-2 rh-text-left hover:rh-bg-background/50 rh-w-full rh-cursor-pointer",
4058
4140
  children: [
4059
- /* @__PURE__ */ jsx("div", { className: "rh-w-4 rh-h-4", children: option.value === value && /* @__PURE__ */ jsx(
4141
+ /* @__PURE__ */ jsx("div", { className: "rh-w-4", children: option.value === value && /* @__PURE__ */ jsx(
4060
4142
  "svg",
4061
4143
  {
4062
4144
  width: "13",
@@ -4078,8 +4160,9 @@ var CustomSelect = ({
4078
4160
  {
4079
4161
  className: "rh-truncate rh-p-1 rh-px-2 rh-rounded-xl rh-text-white rh-text-[14px]",
4080
4162
  style: {
4081
- backgroundColor: option.backgroundColor || "transparent",
4082
- fontFamily: "Inter, sans-serif"
4163
+ backgroundColor: option.backgroundColor || backgroundColor || "transparent",
4164
+ fontFamily: "Inter, sans-serif",
4165
+ color: option.textColor || textColor || (option.backgroundColor || backgroundColor ? "white" : "inherit")
4083
4166
  },
4084
4167
  children: option.label
4085
4168
  }
@@ -4099,7 +4182,10 @@ var CustomSelect = ({
4099
4182
  selectedDate,
4100
4183
  onSelect: handleDateSelect,
4101
4184
  onClose: () => setIsOpen(false),
4102
- containerRef
4185
+ containerRef,
4186
+ backgroundColor: calendarBackgroundColor,
4187
+ textColor,
4188
+ calendarTextColor
4103
4189
  }
4104
4190
  )
4105
4191
  ] });
@@ -4211,6 +4297,36 @@ function TableInner({
4211
4297
  if (column.type === "date") return true;
4212
4298
  return !!column.choices;
4213
4299
  };
4300
+ const getEditableTextColor = (column, row, index) => {
4301
+ if (typeof column.editableTextColor === "function") {
4302
+ return column.editableTextColor(row, index);
4303
+ }
4304
+ return column.editableTextColor;
4305
+ };
4306
+ const getEditableBackgroundColor = (column, row, index) => {
4307
+ if (typeof column.editableBackgroundColor === "function") {
4308
+ return column.editableBackgroundColor(row, index);
4309
+ }
4310
+ return column.editableBackgroundColor;
4311
+ };
4312
+ const getEditableSelectBackgroundColor = (column, row, index) => {
4313
+ if (typeof column.editableSelectBackgroundColor === "function") {
4314
+ return column.editableSelectBackgroundColor(row, index);
4315
+ }
4316
+ return column.editableSelectBackgroundColor;
4317
+ };
4318
+ const getEditableCalendarBackgroundColor = (column, row, index) => {
4319
+ if (typeof column.editableCalendarBackgroundColor === "function") {
4320
+ return column.editableCalendarBackgroundColor(row, index);
4321
+ }
4322
+ return column.editableCalendarBackgroundColor;
4323
+ };
4324
+ const getEditableCalendarTextColor = (column, row, index) => {
4325
+ if (typeof column.editableCalendarTextColor === "function") {
4326
+ return column.editableCalendarTextColor(row, index);
4327
+ }
4328
+ return column.editableCalendarTextColor;
4329
+ };
4214
4330
  return /* @__PURE__ */ jsx("div", { className: "rh-w-full rh-rounded rh-overflow-hidden", children: /* @__PURE__ */ jsxs(
4215
4331
  "table",
4216
4332
  {
@@ -4295,7 +4411,7 @@ function TableInner({
4295
4411
  style: bodyStyleInline,
4296
4412
  className: [
4297
4413
  "rh-border-b rh-border-border rh-transition-colors",
4298
- "hover:rh-bg-background",
4414
+ "hover:rh-bg-background/50",
4299
4415
  variant === "striped" && index % 2 === 1 ? "rh-bg-background/50" : ""
4300
4416
  ].filter(Boolean).join(" "),
4301
4417
  children: columns.map((column) => /* @__PURE__ */ jsx(
@@ -4314,10 +4430,27 @@ function TableInner({
4314
4430
  type: column.type ?? "select",
4315
4431
  options: column.choices,
4316
4432
  value: column.editableValue(row),
4433
+ textColor: getEditableTextColor(column, row, index),
4434
+ backgroundColor: getEditableBackgroundColor(column, row, index),
4435
+ selectBackgroundColor: getEditableSelectBackgroundColor(
4436
+ column,
4437
+ row,
4438
+ index
4439
+ ),
4440
+ calendarBackgroundColor: getEditableCalendarBackgroundColor(
4441
+ column,
4442
+ row,
4443
+ index
4444
+ ),
4445
+ calendarTextColor: getEditableCalendarTextColor(
4446
+ column,
4447
+ row,
4448
+ index
4449
+ ),
4317
4450
  onChange: (value) => column.onEditChange?.(row, index, value),
4318
4451
  className: "rh-w-full rh-h-full"
4319
4452
  }
4320
- ) : /* @__PURE__ */ jsx("span", { children: column.render(row, index) }),
4453
+ ) : /* @__PURE__ */ jsx("span", { style: { width: "100%" }, children: column.render(row, index) }),
4321
4454
  column.actionIcon && /* @__PURE__ */ jsx(
4322
4455
  "span",
4323
4456
  {
@@ -4336,14 +4469,12 @@ function TableInner({
4336
4469
  },
4337
4470
  rowKey(row, index)
4338
4471
  )),
4339
- addRowButton && !loading && /* @__PURE__ */ jsx("tr", { className: "rh-border-border hover:rh-bg-background/50 rh-rounde-lg", children: /* @__PURE__ */ jsx(
4472
+ addRowButton && !loading && /* @__PURE__ */ jsx("tr", { className: "rh-border-border hover:rh-bg-background/50 rh-cursor-pointer rh-py-3", children: /* @__PURE__ */ jsx(
4340
4473
  "td",
4341
4474
  {
4342
4475
  colSpan,
4343
- style: rowPaddingStyle,
4344
4476
  className: [
4345
- rowPadding ? "" : sizeClasses13[size].cell,
4346
- "rh-text-center rh-cursor-pointer rh-text-[#9CA3AF] rh-font-medium"
4477
+ "rh-text-center rh-cursor-pointer rh-text-[#9CA3AF] rh-font-medium rh-px-4 rh-py-3 rh-rounded-b"
4347
4478
  ].filter(Boolean).join(" "),
4348
4479
  onClick: onAddRow,
4349
4480
  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: [