@rehagro/ui 1.0.51 → 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
@@ -1841,7 +1841,7 @@ var Select = React9.forwardRef(function Select2(props, ref) {
1841
1841
  className: [
1842
1842
  "rh-absolute rh-z-50 rh-w-full rh-mt-1",
1843
1843
  "rh-border rh-border-border rh-bg-surface",
1844
- "rh-shadow-md rh-overflow-auto rh-max-h-60",
1844
+ "rh-shadow-md rh-overflow-y-auto rh-overscroll-contain rh-max-h-60",
1845
1845
  "rh-py-1",
1846
1846
  dropdownRadiusClasses[radius]
1847
1847
  ].filter(Boolean).join(" "),
@@ -3819,6 +3819,17 @@ function getDaysInMonth(year, month) {
3819
3819
  function getFirstDayOfMonth(year, month) {
3820
3820
  return new Date(year, month, 1).getDay();
3821
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
+ }
3822
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(
3823
3834
  "path",
3824
3835
  {
@@ -3840,9 +3851,14 @@ var DatePickerDropdown = ({
3840
3851
  selectedDate,
3841
3852
  onSelect,
3842
3853
  onClose,
3843
- containerRef
3854
+ containerRef,
3855
+ backgroundColor,
3856
+ textColor,
3857
+ calendarTextColor
3844
3858
  }) => {
3845
3859
  const today = /* @__PURE__ */ new Date();
3860
+ const opaqueBackgroundColor = removeHexAlpha(backgroundColor);
3861
+ const calendarTextStyle = calendarTextColor ? { color: calendarTextColor } : void 0;
3846
3862
  const [viewYear, setViewYear] = React9.useState(
3847
3863
  selectedDate ? selectedDate.getFullYear() : today.getFullYear()
3848
3864
  );
@@ -3893,6 +3909,8 @@ var DatePickerDropdown = ({
3893
3909
  ref: dropdownRef,
3894
3910
  style: {
3895
3911
  ...style,
3912
+ backgroundColor: opaqueBackgroundColor,
3913
+ color: textColor,
3896
3914
  boxShadow: "0 0 9.6px 0 rgba(8, 11, 18, 0.08)",
3897
3915
  width: 260
3898
3916
  },
@@ -3903,6 +3921,7 @@ var DatePickerDropdown = ({
3903
3921
  "button",
3904
3922
  {
3905
3923
  type: "button",
3924
+ style: calendarTextStyle,
3906
3925
  onMouseDown: (e) => {
3907
3926
  e.preventDefault();
3908
3927
  prevMonth();
@@ -3911,7 +3930,7 @@ var DatePickerDropdown = ({
3911
3930
  children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon2, {})
3912
3931
  }
3913
3932
  ),
3914
- /* @__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: [
3915
3934
  MONTHS_PT[viewMonth],
3916
3935
  " - ",
3917
3936
  viewYear
@@ -3920,6 +3939,7 @@ var DatePickerDropdown = ({
3920
3939
  "button",
3921
3940
  {
3922
3941
  type: "button",
3942
+ style: calendarTextStyle,
3923
3943
  onMouseDown: (e) => {
3924
3944
  e.preventDefault();
3925
3945
  nextMonth();
@@ -3933,6 +3953,7 @@ var DatePickerDropdown = ({
3933
3953
  "div",
3934
3954
  {
3935
3955
  className: "rh-text-center rh-text-xs rh-text-text-muted rh-font-medium rh-py-1",
3956
+ style: calendarTextStyle,
3936
3957
  children: d
3937
3958
  },
3938
3959
  i
@@ -3954,6 +3975,7 @@ var DatePickerDropdown = ({
3954
3975
  "div",
3955
3976
  {
3956
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,
3957
3979
  children: prevMonthDays - firstDay + i + 1
3958
3980
  },
3959
3981
  `prev-${i}`
@@ -3965,7 +3987,10 @@ var DatePickerDropdown = ({
3965
3987
  "button",
3966
3988
  {
3967
3989
  type: "button",
3968
- style: { backgroundColor: selected ? "#15607A" : "transparent" },
3990
+ style: {
3991
+ backgroundColor: selected ? "#15607A" : "transparent",
3992
+ ...calendarTextStyle
3993
+ },
3969
3994
  onMouseDown: (e) => {
3970
3995
  e.preventDefault();
3971
3996
  setTempDate(new Date(viewYear, viewMonth, day));
@@ -3983,6 +4008,7 @@ var DatePickerDropdown = ({
3983
4008
  "div",
3984
4009
  {
3985
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,
3986
4012
  children: i + 1
3987
4013
  },
3988
4014
  `next-${i}`
@@ -4014,6 +4040,11 @@ var CustomSelect = ({
4014
4040
  value,
4015
4041
  onChange,
4016
4042
  className = "",
4043
+ textColor,
4044
+ backgroundColor,
4045
+ selectBackgroundColor,
4046
+ calendarBackgroundColor,
4047
+ calendarTextColor,
4017
4048
  type = "select"
4018
4049
  }) => {
4019
4050
  const [isOpen, setIsOpen] = React9.useState(false);
@@ -4068,14 +4099,16 @@ var CustomSelect = ({
4068
4099
  setIsOpen(false);
4069
4100
  };
4070
4101
  const displayLabel = type === "date" ? selectedDate ? formatDisplay(selectedDate) : value || "\u2014" : selectedOption?.label || value;
4071
- 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");
4072
4104
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: `rh-relative ${className}`, children: [
4073
4105
  /* @__PURE__ */ jsxRuntime.jsx(
4074
4106
  "button",
4075
4107
  {
4076
4108
  type: "button",
4077
4109
  onClick: openDropdown,
4078
- 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",
4079
4112
  children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-truncate", children: /* @__PURE__ */ jsxRuntime.jsx(
4080
4113
  "span",
4081
4114
  {
@@ -4083,7 +4116,7 @@ var CustomSelect = ({
4083
4116
  style: {
4084
4117
  backgroundColor: displayBg || "transparent",
4085
4118
  fontFamily: "Inter, sans-serif",
4086
- color: displayBg ? "white" : "inherit"
4119
+ color: displayTextColor
4087
4120
  },
4088
4121
  children: displayLabel
4089
4122
  }
@@ -4096,9 +4129,10 @@ var CustomSelect = ({
4096
4129
  {
4097
4130
  style: {
4098
4131
  ...dropdownStyle,
4132
+ backgroundColor: selectBackgroundColor || void 0,
4099
4133
  boxShadow: "0 10px 20px 0 rgba(0, 0, 0, 0.05)"
4100
4134
  },
4101
- 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",
4102
4136
  children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
4103
4137
  "button",
4104
4138
  {
@@ -4108,9 +4142,9 @@ var CustomSelect = ({
4108
4142
  onChange(option.value);
4109
4143
  setIsOpen(false);
4110
4144
  },
4111
- 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",
4112
4146
  children: [
4113
- /* @__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(
4114
4148
  "svg",
4115
4149
  {
4116
4150
  width: "13",
@@ -4132,8 +4166,9 @@ var CustomSelect = ({
4132
4166
  {
4133
4167
  className: "rh-truncate rh-p-1 rh-px-2 rh-rounded-xl rh-text-white rh-text-[14px]",
4134
4168
  style: {
4135
- backgroundColor: option.backgroundColor || "transparent",
4136
- 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")
4137
4172
  },
4138
4173
  children: option.label
4139
4174
  }
@@ -4153,7 +4188,10 @@ var CustomSelect = ({
4153
4188
  selectedDate,
4154
4189
  onSelect: handleDateSelect,
4155
4190
  onClose: () => setIsOpen(false),
4156
- containerRef
4191
+ containerRef,
4192
+ backgroundColor: calendarBackgroundColor,
4193
+ textColor,
4194
+ calendarTextColor
4157
4195
  }
4158
4196
  )
4159
4197
  ] });
@@ -4265,6 +4303,36 @@ function TableInner({
4265
4303
  if (column.type === "date") return true;
4266
4304
  return !!column.choices;
4267
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
+ };
4268
4336
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-w-full rh-rounded rh-overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(
4269
4337
  "table",
4270
4338
  {
@@ -4368,6 +4436,23 @@ function TableInner({
4368
4436
  type: column.type ?? "select",
4369
4437
  options: column.choices,
4370
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
+ ),
4371
4456
  onChange: (value) => column.onEditChange?.(row, index, value),
4372
4457
  className: "rh-w-full rh-h-full"
4373
4458
  }
@@ -4390,14 +4475,12 @@ function TableInner({
4390
4475
  },
4391
4476
  rowKey(row, index)
4392
4477
  )),
4393
- 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(
4394
4479
  "td",
4395
4480
  {
4396
4481
  colSpan,
4397
- style: rowPaddingStyle,
4398
4482
  className: [
4399
- rowPadding ? "" : sizeClasses13[size].cell,
4400
- "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"
4401
4484
  ].filter(Boolean).join(" "),
4402
4485
  onClick: onAddRow,
4403
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: [