@rehagro/ui 1.0.53 → 1.0.55

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
@@ -3772,7 +3772,7 @@ var DAYS_SHORT = ["D", "S", "T", "Q", "Q", "S", "S"];
3772
3772
  var MONTHS_PT = [
3773
3773
  "Janeiro",
3774
3774
  "Fevereiro",
3775
- "Mar\xE7o",
3775
+ "Marco",
3776
3776
  "Abril",
3777
3777
  "Maio",
3778
3778
  "Junho",
@@ -3847,18 +3847,15 @@ var DatePickerDropdown = ({
3847
3847
  onClose,
3848
3848
  containerRef,
3849
3849
  backgroundColor,
3850
- textColor,
3851
- calendarTextColor
3850
+ textColor
3852
3851
  }) => {
3853
3852
  const today = /* @__PURE__ */ new Date();
3854
3853
  const opaqueBackgroundColor = removeHexAlpha(backgroundColor);
3855
- const calendarTextStyle = calendarTextColor ? { color: calendarTextColor } : void 0;
3854
+ const calendarTextStyle = textColor ? { color: textColor } : void 0;
3856
3855
  const [viewYear, setViewYear] = useState(
3857
3856
  selectedDate ? selectedDate.getFullYear() : today.getFullYear()
3858
3857
  );
3859
- const [viewMonth, setViewMonth] = useState(
3860
- selectedDate ? selectedDate.getMonth() : today.getMonth()
3861
- );
3858
+ const [viewMonth, setViewMonth] = useState(selectedDate ? selectedDate.getMonth() : today.getMonth());
3862
3859
  const [tempDate, setTempDate] = useState(selectedDate);
3863
3860
  const dropdownRef = useRef(null);
3864
3861
  useEffect(() => {
@@ -3889,12 +3886,8 @@ var DatePickerDropdown = ({
3889
3886
  };
3890
3887
  const daysInMonth = getDaysInMonth(viewYear, viewMonth);
3891
3888
  const firstDay = getFirstDayOfMonth(viewYear, viewMonth);
3892
- const prevMonthDays = getDaysInMonth(
3893
- viewMonth === 0 ? viewYear - 1 : viewYear,
3894
- viewMonth === 0 ? 11 : viewMonth - 1
3895
- );
3896
- const totalCells = firstDay + daysInMonth;
3897
- const trailingCount = totalCells % 7 === 0 ? 0 : 7 - totalCells % 7;
3889
+ const prevMonthDays = getDaysInMonth(viewMonth === 0 ? viewYear - 1 : viewYear, viewMonth === 0 ? 11 : viewMonth - 1);
3890
+ const trailingCount = (firstDay + daysInMonth) % 7 === 0 ? 0 : 7 - (firstDay + daysInMonth) % 7;
3898
3891
  const isSelected = (day) => !!tempDate && tempDate.getFullYear() === viewYear && tempDate.getMonth() === viewMonth && tempDate.getDate() === day;
3899
3892
  return createPortal(
3900
3893
  /* @__PURE__ */ jsxs(
@@ -3952,28 +3945,9 @@ var DatePickerDropdown = ({
3952
3945
  },
3953
3946
  i
3954
3947
  )) }),
3955
- /* @__PURE__ */ jsx(
3956
- "svg",
3957
- {
3958
- xmlns: "http://www.w3.org/2000/svg",
3959
- width: "100%",
3960
- height: "1",
3961
- viewBox: "0 0 350 1",
3962
- fill: "none",
3963
- className: "rh-mb-3",
3964
- children: /* @__PURE__ */ jsx("path", { d: "M0 0.5H350", stroke: "#F5F5F5" })
3965
- }
3966
- ),
3948
+ /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "100%", height: "1", viewBox: "0 0 350 1", fill: "none", className: "rh-mb-3", children: /* @__PURE__ */ jsx("path", { d: "M0 0.5H350", stroke: "#F5F5F5" }) }),
3967
3949
  /* @__PURE__ */ jsxs("div", { className: "rh-grid rh-grid-cols-7 rh-gap-0", children: [
3968
- Array.from({ length: firstDay }).map((_, i) => /* @__PURE__ */ jsx(
3969
- "div",
3970
- {
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,
3973
- children: prevMonthDays - firstDay + i + 1
3974
- },
3975
- `prev-${i}`
3976
- )),
3950
+ Array.from({ length: firstDay }).map((_, i) => /* @__PURE__ */ jsx("div", { 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", style: calendarTextStyle, children: prevMonthDays - firstDay + i + 1 }, `prev-${i}`)),
3977
3951
  Array.from({ length: daysInMonth }).map((_, i) => {
3978
3952
  const day = i + 1;
3979
3953
  const selected = isSelected(day);
@@ -3981,10 +3955,7 @@ var DatePickerDropdown = ({
3981
3955
  "button",
3982
3956
  {
3983
3957
  type: "button",
3984
- style: {
3985
- backgroundColor: selected ? "#15607A" : "transparent",
3986
- ...calendarTextStyle
3987
- },
3958
+ style: { backgroundColor: selected ? "#15607A" : "transparent", ...calendarTextStyle },
3988
3959
  onMouseDown: (e) => {
3989
3960
  e.preventDefault();
3990
3961
  setTempDate(new Date(viewYear, viewMonth, day));
@@ -3998,15 +3969,7 @@ var DatePickerDropdown = ({
3998
3969
  day
3999
3970
  );
4000
3971
  }),
4001
- Array.from({ length: trailingCount }).map((_, i) => /* @__PURE__ */ jsx(
4002
- "div",
4003
- {
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,
4006
- children: i + 1
4007
- },
4008
- `next-${i}`
4009
- ))
3972
+ Array.from({ length: trailingCount }).map((_, i) => /* @__PURE__ */ jsx("div", { 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", style: calendarTextStyle, children: i + 1 }, `next-${i}`))
4010
3973
  ] }),
4011
3974
  /* @__PURE__ */ jsx("div", { className: "rh-flex rh-justify-end rh-gap-2 rh-mt-4", children: /* @__PURE__ */ jsx(
4012
3975
  "button",
@@ -4014,9 +3977,7 @@ var DatePickerDropdown = ({
4014
3977
  type: "button",
4015
3978
  style: { backgroundColor: "#87A851" },
4016
3979
  onClick: () => {
4017
- if (tempDate) {
4018
- onSelect(tempDate);
4019
- }
3980
+ if (tempDate) onSelect(tempDate);
4020
3981
  onClose();
4021
3982
  },
4022
3983
  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",
@@ -4034,16 +3995,29 @@ var CustomSelect = ({
4034
3995
  value,
4035
3996
  onChange,
4036
3997
  className = "",
3998
+ placeholder,
4037
3999
  textColor,
4000
+ placeholderColor,
4038
4001
  backgroundColor,
4039
- selectBackgroundColor,
4040
- calendarBackgroundColor,
4041
- calendarTextColor,
4042
4002
  type = "select"
4043
4003
  }) => {
4044
4004
  const [isOpen, setIsOpen] = useState(false);
4045
4005
  const [dropdownStyle, setDropdownStyle] = useState({});
4046
4006
  const containerRef = useRef(null);
4007
+ const textAreaRef = useRef(null);
4008
+ const resizeTextArea = React9.useCallback(() => {
4009
+ if (type !== "textInput" || !textAreaRef.current) return;
4010
+ const textarea = textAreaRef.current;
4011
+ textarea.style.height = "auto";
4012
+ if (textarea.value) {
4013
+ textarea.style.height = `${textarea.scrollHeight}px`;
4014
+ return;
4015
+ }
4016
+ const previousValue = textarea.value;
4017
+ textarea.value = placeholder || "";
4018
+ textarea.style.height = `${textarea.scrollHeight}px`;
4019
+ textarea.value = previousValue;
4020
+ }, [type, placeholder]);
4047
4021
  const calcPosition = () => {
4048
4022
  if (!containerRef.current) return {};
4049
4023
  const rect = containerRef.current.getBoundingClientRect();
@@ -4072,6 +4046,9 @@ var CustomSelect = ({
4072
4046
  window.removeEventListener("resize", close);
4073
4047
  };
4074
4048
  }, [isOpen]);
4049
+ useEffect(() => {
4050
+ resizeTextArea();
4051
+ }, [resizeTextArea, value]);
4075
4052
  const selectedOption = options.find((opt) => opt.value === value);
4076
4053
  useEffect(() => {
4077
4054
  if (type !== "select") return;
@@ -4087,31 +4064,52 @@ var CustomSelect = ({
4087
4064
  }, [isOpen, type]);
4088
4065
  const selectedDate = type === "date" ? parseDate(value) : null;
4089
4066
  const handleDateSelect = (date) => {
4090
- if (date) {
4091
- onChange(formatISO(date));
4092
- }
4067
+ if (date) onChange(formatISO(date));
4093
4068
  setIsOpen(false);
4094
4069
  };
4095
- const displayLabel = type === "date" ? selectedDate ? formatDisplay(selectedDate) : value || "\u2014" : selectedOption?.label || value;
4070
+ const hasValue = value != null && value !== "";
4071
+ const displayLabel = type === "date" ? selectedDate ? formatDisplay(selectedDate) : hasValue ? value : placeholder || "-" : selectedOption?.label || (hasValue ? value : placeholder || "");
4096
4072
  const displayBg = type === "date" ? backgroundColor : selectedOption?.backgroundColor || backgroundColor;
4097
- const displayTextColor = type === "date" ? textColor : selectedOption?.textColor || textColor || (displayBg ? "white" : "inherit");
4073
+ const displayTextColor = type === "date" ? textColor : selectedOption?.textColor || (hasValue ? textColor : placeholderColor) || (displayBg ? "white" : "inherit");
4074
+ if (type === "textInput") {
4075
+ const inputTextColor = textColor || "#111827";
4076
+ const inputPlaceholderColor = placeholderColor || "#9CA3AF";
4077
+ const textInputWrapperClassName = className.replace(/\brh-h-full\b/g, "").trim();
4078
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `rh-relative rh-h-full rh-flex rh-items-center ${textInputWrapperClassName}`, children: [
4079
+ /* @__PURE__ */ jsx(
4080
+ "textarea",
4081
+ {
4082
+ ref: textAreaRef,
4083
+ value,
4084
+ placeholder,
4085
+ rows: 1,
4086
+ onInput: (e) => {
4087
+ onChange(e.currentTarget.value);
4088
+ resizeTextArea();
4089
+ },
4090
+ style: {
4091
+ color: inputTextColor,
4092
+ backgroundColor: backgroundColor || "transparent"
4093
+ },
4094
+ className: "rh-table-textarea rh-flex rh-items-center rh-leading-[20px] rh-py-[7px] rh-w-full rh-min-h-[40px] rh-text-sm rh-px-1 rh-border rh-bg-surface rh-rounded-xs rh-border-transparent rh-line-height-[20px] rh-outline-none rh-resize-none rh-overflow-hidden hover:rh-border-primary focus:rh-border-primary focus:rh-ring-2 focus:rh-ring-gray-200"
4095
+ }
4096
+ ),
4097
+ /* @__PURE__ */ jsx("style", { children: `.rh-table-textarea::placeholder { color: ${inputPlaceholderColor}; }` })
4098
+ ] });
4099
+ }
4098
4100
  return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `rh-relative ${className}`, children: [
4099
4101
  /* @__PURE__ */ jsx(
4100
4102
  "button",
4101
4103
  {
4102
4104
  type: "button",
4103
4105
  onClick: openDropdown,
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",
4106
- children: /* @__PURE__ */ jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-truncate", children: /* @__PURE__ */ jsx(
4106
+ style: { backgroundColor: backgroundColor || void 0 },
4107
+ className: "rh-w-full rh-min-h-[40px] rh-flex rh-items-center rh-border rh-bg-surface rh-rounded-sm rh-border-transparent rh-justify-between rh-py-2 hover:rh-border-primary hover:rh-ring-2 hover:rh-ring-gray-200 rh-cursor-pointer rh-text-left",
4108
+ children: /* @__PURE__ */ jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-px-0.5", children: /* @__PURE__ */ jsx(
4107
4109
  "span",
4108
4110
  {
4109
- className: "rh-truncate rh-text-[14px] rh-px-2 rh-py-1 rh-rounded-xl",
4110
- style: {
4111
- backgroundColor: displayBg || "transparent",
4112
- fontFamily: "Inter, sans-serif",
4113
- color: displayTextColor
4114
- },
4111
+ className: "rh-text-[14px] rh-px-2 rh-py-0.5 rh-rounded-xl rh-whitespace-normal rh-break-words",
4112
+ style: { backgroundColor: displayBg || "transparent", fontFamily: "Inter, sans-serif", color: displayTextColor },
4115
4113
  children: displayLabel
4116
4114
  }
4117
4115
  ) })
@@ -4121,11 +4119,7 @@ var CustomSelect = ({
4121
4119
  /* @__PURE__ */ jsx(
4122
4120
  "div",
4123
4121
  {
4124
- style: {
4125
- ...dropdownStyle,
4126
- backgroundColor: selectBackgroundColor || void 0,
4127
- boxShadow: "0 10px 20px 0 rgba(0, 0, 0, 0.05)"
4128
- },
4122
+ style: { ...dropdownStyle, backgroundColor: backgroundColor || void 0, boxShadow: "0 10px 20px 0 rgba(0, 0, 0, 0.05)" },
4129
4123
  className: "rh-border rh-border-border rh-rounded-xs rh-max-h-60 rh-overflow-auto",
4130
4124
  children: options.map((option) => /* @__PURE__ */ jsxs(
4131
4125
  "button",
@@ -4138,27 +4132,17 @@ var CustomSelect = ({
4138
4132
  },
4139
4133
  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",
4140
4134
  children: [
4141
- /* @__PURE__ */ jsx("div", { className: "rh-w-4", children: option.value === value && /* @__PURE__ */ jsx(
4142
- "svg",
4135
+ /* @__PURE__ */ jsx("div", { className: "rh-w-4", children: option.value === value && /* @__PURE__ */ jsx("svg", { width: "13", height: "10", viewBox: "0 0 13 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx(
4136
+ "path",
4143
4137
  {
4144
- width: "13",
4145
- height: "10",
4146
- viewBox: "0 0 13 10",
4147
- fill: "none",
4148
- xmlns: "http://www.w3.org/2000/svg",
4149
- children: /* @__PURE__ */ jsx(
4150
- "path",
4151
- {
4152
- 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",
4153
- fill: "#374151"
4154
- }
4155
- )
4138
+ 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",
4139
+ fill: "#374151"
4156
4140
  }
4157
- ) }),
4141
+ ) }) }),
4158
4142
  /* @__PURE__ */ jsx(
4159
4143
  "span",
4160
4144
  {
4161
- className: "rh-truncate rh-p-1 rh-px-2 rh-rounded-xl rh-text-white rh-text-[14px]",
4145
+ className: "rh-p-0.5 rh-px-2 rh-rounded-xl rh-text-white rh-text-[14px] rh-whitespace-normal rh-break-words",
4162
4146
  style: {
4163
4147
  backgroundColor: option.backgroundColor || backgroundColor || "transparent",
4164
4148
  fontFamily: "Inter, sans-serif",
@@ -4183,9 +4167,8 @@ var CustomSelect = ({
4183
4167
  onSelect: handleDateSelect,
4184
4168
  onClose: () => setIsOpen(false),
4185
4169
  containerRef,
4186
- backgroundColor: calendarBackgroundColor,
4187
- textColor,
4188
- calendarTextColor
4170
+ backgroundColor,
4171
+ textColor
4189
4172
  }
4190
4173
  )
4191
4174
  ] });
@@ -4294,7 +4277,7 @@ function TableInner({
4294
4277
  const rowPaddingStyle = getRowPaddingStyle();
4295
4278
  const isEditableCell = (column) => {
4296
4279
  if (!column.editable || !column.editableValue) return false;
4297
- if (column.type === "date") return true;
4280
+ if (column.type === "date" || column.type === "textInput") return true;
4298
4281
  return !!column.choices;
4299
4282
  };
4300
4283
  const getEditableTextColor = (column, row, index) => {
@@ -4309,23 +4292,11 @@ function TableInner({
4309
4292
  }
4310
4293
  return column.editableBackgroundColor;
4311
4294
  };
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);
4295
+ const getEditablePlaceholderColor = (column, row, index) => {
4296
+ if (typeof column.editablePlaceholderColor === "function") {
4297
+ return column.editablePlaceholderColor(row, index);
4327
4298
  }
4328
- return column.editableCalendarTextColor;
4299
+ return column.editablePlaceholderColor;
4329
4300
  };
4330
4301
  return /* @__PURE__ */ jsx("div", { className: "rh-w-full rh-rounded rh-overflow-hidden", children: /* @__PURE__ */ jsxs(
4331
4302
  "table",
@@ -4351,6 +4322,7 @@ function TableInner({
4351
4322
  style: {
4352
4323
  width: column.width,
4353
4324
  maxWidth: column.maxWidth,
4325
+ backgroundColor: column.headerBgColor ?? headerStyle?.backgroundColor,
4354
4326
  ...rowPaddingStyle
4355
4327
  },
4356
4328
  className: [
@@ -4361,10 +4333,17 @@ function TableInner({
4361
4333
  column.sortable ? "rh-cursor-pointer rh-select-none hover:rh-text-text" : ""
4362
4334
  ].filter(Boolean).join(" "),
4363
4335
  onClick: () => handleSort(column),
4364
- children: /* @__PURE__ */ jsxs("span", { className: "rh-inline-flex rh-items-center", style: headerTextStyleInline, children: [
4365
- column.header,
4366
- renderSortIcon(column)
4367
- ] })
4336
+ children: /* @__PURE__ */ jsxs(
4337
+ "span",
4338
+ {
4339
+ className: "rh-inline-flex rh-items-center",
4340
+ style: column.headerTextColor ? { ...headerTextStyleInline, color: column.headerTextColor } : headerTextStyleInline,
4341
+ children: [
4342
+ column.header,
4343
+ renderSortIcon(column)
4344
+ ]
4345
+ }
4346
+ )
4368
4347
  },
4369
4348
  column.key
4370
4349
  ))
@@ -4430,23 +4409,10 @@ function TableInner({
4430
4409
  type: column.type ?? "select",
4431
4410
  options: column.choices,
4432
4411
  value: column.editableValue(row),
4412
+ placeholder: column.editablePlaceholder,
4433
4413
  textColor: getEditableTextColor(column, row, index),
4414
+ placeholderColor: getEditablePlaceholderColor(column, row, index),
4434
4415
  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
- ),
4450
4416
  onChange: (value) => column.onEditChange?.(row, index, value),
4451
4417
  className: "rh-w-full rh-h-full"
4452
4418
  }