@rehagro/ui 1.0.55 → 1.0.56

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
@@ -911,6 +911,10 @@ type TableProps<T> = Omit<React__default.HTMLAttributes<HTMLTableElement>, "chil
911
911
  };
912
912
  /** Callback when add row is clicked */
913
913
  onAddRow?: () => void;
914
+ /** If true, rows become clickable and will call `onRowClick` when clicked */
915
+ rowClickable?: boolean;
916
+ /** Callback invoked when a row is clicked: `(row, index, event)` */
917
+ onRowClick?: (row: T, index: number, event?: React__default.MouseEvent<HTMLTableRowElement>) => void;
914
918
  };
915
919
  declare const Table: <T>(props: TableProps<T> & {
916
920
  ref?: React__default.ForwardedRef<HTMLTableElement>;
package/dist/index.d.ts CHANGED
@@ -911,6 +911,10 @@ type TableProps<T> = Omit<React__default.HTMLAttributes<HTMLTableElement>, "chil
911
911
  };
912
912
  /** Callback when add row is clicked */
913
913
  onAddRow?: () => void;
914
+ /** If true, rows become clickable and will call `onRowClick` when clicked */
915
+ rowClickable?: boolean;
916
+ /** Callback invoked when a row is clicked: `(row, index, event)` */
917
+ onRowClick?: (row: T, index: number, event?: React__default.MouseEvent<HTMLTableRowElement>) => void;
914
918
  };
915
919
  declare const Table: <T>(props: TableProps<T> & {
916
920
  ref?: React__default.ForwardedRef<HTMLTableElement>;
package/dist/index.js CHANGED
@@ -4089,6 +4089,7 @@ var CustomSelect = ({
4089
4089
  value,
4090
4090
  placeholder,
4091
4091
  rows: 1,
4092
+ onClick: (e) => e.stopPropagation(),
4092
4093
  onInput: (e) => {
4093
4094
  onChange(e.currentTarget.value);
4094
4095
  resizeTextArea();
@@ -4097,7 +4098,7 @@ var CustomSelect = ({
4097
4098
  color: inputTextColor,
4098
4099
  backgroundColor: backgroundColor || "transparent"
4099
4100
  },
4100
- 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"
4101
+ 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 hover:rh-ring-2 hover:rh-ring-gray-200"
4101
4102
  }
4102
4103
  ),
4103
4104
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: `.rh-table-textarea::placeholder { color: ${inputPlaceholderColor}; }` })
@@ -4108,13 +4109,16 @@ var CustomSelect = ({
4108
4109
  "button",
4109
4110
  {
4110
4111
  type: "button",
4111
- onClick: openDropdown,
4112
+ onClick: (e) => {
4113
+ e.stopPropagation();
4114
+ openDropdown();
4115
+ },
4112
4116
  style: { backgroundColor: backgroundColor || void 0 },
4113
4117
  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",
4114
4118
  children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-px-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(
4115
4119
  "span",
4116
4120
  {
4117
- className: "rh-text-[14px] rh-px-2 rh-py-0.5 rh-rounded-xl rh-whitespace-normal rh-break-words",
4121
+ className: "rh-text-[14px] rh-px-3.5 rh-py-0.5 rh-rounded-xl rh-whitespace-normal rh-break-words",
4118
4122
  style: { backgroundColor: displayBg || "transparent", fontFamily: "Inter, sans-serif", color: displayTextColor },
4119
4123
  children: displayLabel
4120
4124
  }
@@ -4133,6 +4137,7 @@ var CustomSelect = ({
4133
4137
  type: "button",
4134
4138
  onMouseDown: (e) => {
4135
4139
  e.preventDefault();
4140
+ e.stopPropagation();
4136
4141
  onChange(option.value);
4137
4142
  setIsOpen(false);
4138
4143
  },
@@ -4193,6 +4198,8 @@ function TableInner({
4193
4198
  columns,
4194
4199
  data,
4195
4200
  rowKey,
4201
+ rowClickable = false,
4202
+ onRowClick,
4196
4203
  size = "md",
4197
4204
  variant = "default",
4198
4205
  sort,
@@ -4396,9 +4403,18 @@ function TableInner({
4396
4403
  style: bodyStyleInline,
4397
4404
  className: [
4398
4405
  "rh-border-b rh-border-border rh-transition-colors",
4406
+ rowClickable ? "rh-cursor-pointer" : "",
4399
4407
  "hover:rh-bg-background/50",
4400
4408
  variant === "striped" && index % 2 === 1 ? "rh-bg-background/50" : ""
4401
4409
  ].filter(Boolean).join(" "),
4410
+ onClick: (e) => {
4411
+ if (!rowClickable || !onRowClick) return;
4412
+ const target = e.target;
4413
+ if (!target) return;
4414
+ const interactiveSelector = 'button, a, input, select, textarea, label, [role="button"], [data-no-row-click]';
4415
+ if (target.closest(interactiveSelector)) return;
4416
+ onRowClick(row, index, e);
4417
+ },
4402
4418
  children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
4403
4419
  "td",
4404
4420
  {
@@ -4408,7 +4424,7 @@ function TableInner({
4408
4424
  alignClasses[column.align || "left"],
4409
4425
  "rh-text-text"
4410
4426
  ].filter(Boolean).join(" "),
4411
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-between rh-gap-2", children: [
4427
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-stretch rh-justify-between rh-gap-2 rh-h-full", children: [
4412
4428
  isEditableCell(column) ? /* @__PURE__ */ jsxRuntime.jsx(
4413
4429
  CustomSelect,
4414
4430
  {