@rehagro/ui 1.0.55 → 1.0.57

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
@@ -12,8 +12,8 @@ type ToastLink = {
12
12
  type ToastProps = React__default.HTMLAttributes<HTMLDivElement> & {
13
13
  /** Toast title */
14
14
  title: string;
15
- /** Optional description below the title */
16
- description?: string;
15
+ /** Optional description below the title. Accepts a string or any React node (e.g. a list of items). */
16
+ description?: React__default.ReactNode;
17
17
  /** Optional link below the content */
18
18
  link?: ToastLink;
19
19
  /** Visual variant */
@@ -26,8 +26,8 @@ type ToastProps = React__default.HTMLAttributes<HTMLDivElement> & {
26
26
  declare const Toast: React__default.ForwardRefExoticComponent<React__default.HTMLAttributes<HTMLDivElement> & {
27
27
  /** Toast title */
28
28
  title: string;
29
- /** Optional description below the title */
30
- description?: string;
29
+ /** Optional description below the title. Accepts a string or any React node (e.g. a list of items). */
30
+ description?: React__default.ReactNode;
31
31
  /** Optional link below the content */
32
32
  link?: ToastLink;
33
33
  /** Visual variant */
@@ -42,7 +42,7 @@ type ToastPosition = "top-right" | "top-left" | "top-center" | "bottom-right" |
42
42
  type ToastItem = {
43
43
  id: string;
44
44
  title: string;
45
- description?: string;
45
+ description?: React__default.ReactNode;
46
46
  link?: ToastLink;
47
47
  variant: ToastVariant;
48
48
  appearance: ToastAppearance;
@@ -50,7 +50,7 @@ type ToastItem = {
50
50
  duration: number;
51
51
  };
52
52
  type ToastOptions = {
53
- description?: string;
53
+ description?: React__default.ReactNode;
54
54
  link?: ToastLink;
55
55
  appearance?: ToastAppearance;
56
56
  /** Auto-dismiss duration in ms. 0 = permanent. Default: 5000 */
@@ -547,6 +547,12 @@ type DateSelectBaseProps = {
547
547
  endYear?: number;
548
548
  /** Custom background color for the trigger button */
549
549
  backgroundColor?: string;
550
+ /**
551
+ * Restricts which modes are available in the picker.
552
+ * When a single mode is provided the tab bar is hidden entirely.
553
+ * Defaults to all four modes: ["interval", "day", "month", "year"].
554
+ */
555
+ modes?: DateSelectMode[];
550
556
  };
551
557
  declare const DateSelect: React__default.ForwardRefExoticComponent<DateSelectBaseProps & React__default.RefAttributes<HTMLButtonElement>>;
552
558
 
@@ -911,6 +917,10 @@ type TableProps<T> = Omit<React__default.HTMLAttributes<HTMLTableElement>, "chil
911
917
  };
912
918
  /** Callback when add row is clicked */
913
919
  onAddRow?: () => void;
920
+ /** If true, rows become clickable and will call `onRowClick` when clicked */
921
+ rowClickable?: boolean;
922
+ /** Callback invoked when a row is clicked: `(row, index, event)` */
923
+ onRowClick?: (row: T, index: number, event?: React__default.MouseEvent<HTMLTableRowElement>) => void;
914
924
  };
915
925
  declare const Table: <T>(props: TableProps<T> & {
916
926
  ref?: React__default.ForwardedRef<HTMLTableElement>;
package/dist/index.d.ts CHANGED
@@ -12,8 +12,8 @@ type ToastLink = {
12
12
  type ToastProps = React__default.HTMLAttributes<HTMLDivElement> & {
13
13
  /** Toast title */
14
14
  title: string;
15
- /** Optional description below the title */
16
- description?: string;
15
+ /** Optional description below the title. Accepts a string or any React node (e.g. a list of items). */
16
+ description?: React__default.ReactNode;
17
17
  /** Optional link below the content */
18
18
  link?: ToastLink;
19
19
  /** Visual variant */
@@ -26,8 +26,8 @@ type ToastProps = React__default.HTMLAttributes<HTMLDivElement> & {
26
26
  declare const Toast: React__default.ForwardRefExoticComponent<React__default.HTMLAttributes<HTMLDivElement> & {
27
27
  /** Toast title */
28
28
  title: string;
29
- /** Optional description below the title */
30
- description?: string;
29
+ /** Optional description below the title. Accepts a string or any React node (e.g. a list of items). */
30
+ description?: React__default.ReactNode;
31
31
  /** Optional link below the content */
32
32
  link?: ToastLink;
33
33
  /** Visual variant */
@@ -42,7 +42,7 @@ type ToastPosition = "top-right" | "top-left" | "top-center" | "bottom-right" |
42
42
  type ToastItem = {
43
43
  id: string;
44
44
  title: string;
45
- description?: string;
45
+ description?: React__default.ReactNode;
46
46
  link?: ToastLink;
47
47
  variant: ToastVariant;
48
48
  appearance: ToastAppearance;
@@ -50,7 +50,7 @@ type ToastItem = {
50
50
  duration: number;
51
51
  };
52
52
  type ToastOptions = {
53
- description?: string;
53
+ description?: React__default.ReactNode;
54
54
  link?: ToastLink;
55
55
  appearance?: ToastAppearance;
56
56
  /** Auto-dismiss duration in ms. 0 = permanent. Default: 5000 */
@@ -547,6 +547,12 @@ type DateSelectBaseProps = {
547
547
  endYear?: number;
548
548
  /** Custom background color for the trigger button */
549
549
  backgroundColor?: string;
550
+ /**
551
+ * Restricts which modes are available in the picker.
552
+ * When a single mode is provided the tab bar is hidden entirely.
553
+ * Defaults to all four modes: ["interval", "day", "month", "year"].
554
+ */
555
+ modes?: DateSelectMode[];
550
556
  };
551
557
  declare const DateSelect: React__default.ForwardRefExoticComponent<DateSelectBaseProps & React__default.RefAttributes<HTMLButtonElement>>;
552
558
 
@@ -911,6 +917,10 @@ type TableProps<T> = Omit<React__default.HTMLAttributes<HTMLTableElement>, "chil
911
917
  };
912
918
  /** Callback when add row is clicked */
913
919
  onAddRow?: () => void;
920
+ /** If true, rows become clickable and will call `onRowClick` when clicked */
921
+ rowClickable?: boolean;
922
+ /** Callback invoked when a row is clicked: `(row, index, event)` */
923
+ onRowClick?: (row: T, index: number, event?: React__default.MouseEvent<HTMLTableRowElement>) => void;
914
924
  };
915
925
  declare const Table: <T>(props: TableProps<T> & {
916
926
  ref?: React__default.ForwardedRef<HTMLTableElement>;
package/dist/index.js CHANGED
@@ -2055,7 +2055,8 @@ var DateSelect = React9.forwardRef(
2055
2055
  wrapperClassName = "",
2056
2056
  startYear,
2057
2057
  endYear,
2058
- backgroundColor
2058
+ backgroundColor,
2059
+ modes
2059
2060
  } = props;
2060
2061
  const triggerId = React9__default.default.useId();
2061
2062
  const helperId = React9__default.default.useId();
@@ -2067,7 +2068,14 @@ var DateSelect = React9.forwardRef(
2067
2068
  );
2068
2069
  const isControlled = props.value !== void 0;
2069
2070
  const value = isControlled ? props.value ?? internalValue : internalValue;
2070
- const [activeMode, setActiveMode] = React9.useState(value.mode ?? "day");
2071
+ const availableModes = React9.useMemo(
2072
+ () => modes && modes.length > 0 ? MODE_OPTIONS.filter((o) => modes.includes(o.value)) : MODE_OPTIONS,
2073
+ [modes]
2074
+ );
2075
+ const defaultMode = availableModes[0]?.value ?? "day";
2076
+ const [activeMode, setActiveMode] = React9.useState(
2077
+ availableModes.some((o) => o.value === (value.mode ?? "day")) ? value.mode ?? "day" : defaultMode
2078
+ );
2071
2079
  const [selectedYear, setSelectedYear] = React9.useState((/* @__PURE__ */ new Date()).getFullYear());
2072
2080
  const [selectedMonth, setSelectedMonth] = React9.useState((/* @__PURE__ */ new Date()).getMonth());
2073
2081
  const rightMonth = selectedMonth === 11 ? 0 : selectedMonth + 1;
@@ -2183,19 +2191,22 @@ var DateSelect = React9.forwardRef(
2183
2191
  const [lo, hi] = start <= ref2 ? [start, ref2] : [ref2, start];
2184
2192
  return date > lo && date < hi;
2185
2193
  };
2186
- const renderModeTabs = () => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-border-b rh-border-border rh-bg-transparent", children: MODE_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
2187
- "button",
2188
- {
2189
- onClick: () => setActiveMode(option.value),
2190
- className: [
2191
- "rh-flex-1 rh-py-2 rh-px-4 rh-text-sm rh-transition-colors rh-duration-150 rh-text-text rh-font-bold",
2192
- "rh-border-b-2 -rh-mb-px",
2193
- activeMode === option.value ? "rh-border-primary" : "rh-border-transparent hover:rh-border-border"
2194
- ].join(" "),
2195
- children: option.label
2196
- },
2197
- option.value
2198
- )) });
2194
+ const renderModeTabs = () => {
2195
+ if (availableModes.length <= 1) return null;
2196
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-flex rh-border-b rh-border-border rh-bg-transparent", children: availableModes.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
2197
+ "button",
2198
+ {
2199
+ onClick: () => setActiveMode(option.value),
2200
+ className: [
2201
+ "rh-flex-1 rh-py-2 rh-px-4 rh-text-sm rh-transition-colors rh-duration-150 rh-text-text rh-font-bold",
2202
+ "rh-border-b-2 -rh-mb-px",
2203
+ activeMode === option.value ? "rh-border-primary" : "rh-border-transparent hover:rh-border-border"
2204
+ ].join(" "),
2205
+ children: option.label
2206
+ },
2207
+ option.value
2208
+ )) });
2209
+ };
2199
2210
  const renderYearGrid = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-p-1", children: [
2200
2211
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-between", children: [
2201
2212
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2722,7 +2733,7 @@ var DateSelect = React9.forwardRef(
2722
2733
  },
2723
2734
  children: [
2724
2735
  renderModeTabs(),
2725
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rh-mt-2", children: renderContent() })
2736
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: availableModes.length > 1 ? "rh-mt-2" : "", children: renderContent() })
2726
2737
  ]
2727
2738
  }
2728
2739
  ),
@@ -4089,6 +4100,7 @@ var CustomSelect = ({
4089
4100
  value,
4090
4101
  placeholder,
4091
4102
  rows: 1,
4103
+ onClick: (e) => e.stopPropagation(),
4092
4104
  onInput: (e) => {
4093
4105
  onChange(e.currentTarget.value);
4094
4106
  resizeTextArea();
@@ -4097,7 +4109,7 @@ var CustomSelect = ({
4097
4109
  color: inputTextColor,
4098
4110
  backgroundColor: backgroundColor || "transparent"
4099
4111
  },
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"
4112
+ 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
4113
  }
4102
4114
  ),
4103
4115
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: `.rh-table-textarea::placeholder { color: ${inputPlaceholderColor}; }` })
@@ -4108,13 +4120,16 @@ var CustomSelect = ({
4108
4120
  "button",
4109
4121
  {
4110
4122
  type: "button",
4111
- onClick: openDropdown,
4123
+ onClick: (e) => {
4124
+ e.stopPropagation();
4125
+ openDropdown();
4126
+ },
4112
4127
  style: { backgroundColor: backgroundColor || void 0 },
4113
4128
  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
4129
  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
4130
  "span",
4116
4131
  {
4117
- className: "rh-text-[14px] rh-px-2 rh-py-0.5 rh-rounded-xl rh-whitespace-normal rh-break-words",
4132
+ className: "rh-text-[14px] rh-px-3.5 rh-py-0.5 rh-rounded-xl rh-whitespace-normal rh-break-words",
4118
4133
  style: { backgroundColor: displayBg || "transparent", fontFamily: "Inter, sans-serif", color: displayTextColor },
4119
4134
  children: displayLabel
4120
4135
  }
@@ -4133,6 +4148,7 @@ var CustomSelect = ({
4133
4148
  type: "button",
4134
4149
  onMouseDown: (e) => {
4135
4150
  e.preventDefault();
4151
+ e.stopPropagation();
4136
4152
  onChange(option.value);
4137
4153
  setIsOpen(false);
4138
4154
  },
@@ -4193,6 +4209,8 @@ function TableInner({
4193
4209
  columns,
4194
4210
  data,
4195
4211
  rowKey,
4212
+ rowClickable = false,
4213
+ onRowClick,
4196
4214
  size = "md",
4197
4215
  variant = "default",
4198
4216
  sort,
@@ -4396,9 +4414,18 @@ function TableInner({
4396
4414
  style: bodyStyleInline,
4397
4415
  className: [
4398
4416
  "rh-border-b rh-border-border rh-transition-colors",
4417
+ rowClickable ? "rh-cursor-pointer" : "",
4399
4418
  "hover:rh-bg-background/50",
4400
4419
  variant === "striped" && index % 2 === 1 ? "rh-bg-background/50" : ""
4401
4420
  ].filter(Boolean).join(" "),
4421
+ onClick: (e) => {
4422
+ if (!rowClickable || !onRowClick) return;
4423
+ const target = e.target;
4424
+ if (!target) return;
4425
+ const interactiveSelector = 'button, a, input, select, textarea, label, [role="button"], [data-no-row-click]';
4426
+ if (target.closest(interactiveSelector)) return;
4427
+ onRowClick(row, index, e);
4428
+ },
4402
4429
  children: columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
4403
4430
  "td",
4404
4431
  {
@@ -4408,7 +4435,7 @@ function TableInner({
4408
4435
  alignClasses[column.align || "left"],
4409
4436
  "rh-text-text"
4410
4437
  ].filter(Boolean).join(" "),
4411
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-center rh-justify-between rh-gap-2", children: [
4438
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rh-flex rh-items-stretch rh-justify-between rh-gap-2 rh-h-full", children: [
4412
4439
  isEditableCell(column) ? /* @__PURE__ */ jsxRuntime.jsx(
4413
4440
  CustomSelect,
4414
4441
  {