@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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import React9, { forwardRef, createContext, useState, useRef, useMemo, useEffect, useCallback, useContext } from 'react';
2
+ import React9, { forwardRef, createContext, useState, useMemo, useRef, useEffect, useCallback, useContext } from 'react';
3
3
  import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { createPortal } from 'react-dom';
5
5
 
@@ -2049,7 +2049,8 @@ var DateSelect = forwardRef(
2049
2049
  wrapperClassName = "",
2050
2050
  startYear,
2051
2051
  endYear,
2052
- backgroundColor
2052
+ backgroundColor,
2053
+ modes
2053
2054
  } = props;
2054
2055
  const triggerId = React9.useId();
2055
2056
  const helperId = React9.useId();
@@ -2061,7 +2062,14 @@ var DateSelect = forwardRef(
2061
2062
  );
2062
2063
  const isControlled = props.value !== void 0;
2063
2064
  const value = isControlled ? props.value ?? internalValue : internalValue;
2064
- const [activeMode, setActiveMode] = useState(value.mode ?? "day");
2065
+ const availableModes = useMemo(
2066
+ () => modes && modes.length > 0 ? MODE_OPTIONS.filter((o) => modes.includes(o.value)) : MODE_OPTIONS,
2067
+ [modes]
2068
+ );
2069
+ const defaultMode = availableModes[0]?.value ?? "day";
2070
+ const [activeMode, setActiveMode] = useState(
2071
+ availableModes.some((o) => o.value === (value.mode ?? "day")) ? value.mode ?? "day" : defaultMode
2072
+ );
2065
2073
  const [selectedYear, setSelectedYear] = useState((/* @__PURE__ */ new Date()).getFullYear());
2066
2074
  const [selectedMonth, setSelectedMonth] = useState((/* @__PURE__ */ new Date()).getMonth());
2067
2075
  const rightMonth = selectedMonth === 11 ? 0 : selectedMonth + 1;
@@ -2177,19 +2185,22 @@ var DateSelect = forwardRef(
2177
2185
  const [lo, hi] = start <= ref2 ? [start, ref2] : [ref2, start];
2178
2186
  return date > lo && date < hi;
2179
2187
  };
2180
- const renderModeTabs = () => /* @__PURE__ */ jsx("div", { className: "rh-flex rh-border-b rh-border-border rh-bg-transparent", children: MODE_OPTIONS.map((option) => /* @__PURE__ */ jsx(
2181
- "button",
2182
- {
2183
- onClick: () => setActiveMode(option.value),
2184
- className: [
2185
- "rh-flex-1 rh-py-2 rh-px-4 rh-text-sm rh-transition-colors rh-duration-150 rh-text-text rh-font-bold",
2186
- "rh-border-b-2 -rh-mb-px",
2187
- activeMode === option.value ? "rh-border-primary" : "rh-border-transparent hover:rh-border-border"
2188
- ].join(" "),
2189
- children: option.label
2190
- },
2191
- option.value
2192
- )) });
2188
+ const renderModeTabs = () => {
2189
+ if (availableModes.length <= 1) return null;
2190
+ return /* @__PURE__ */ jsx("div", { className: "rh-flex rh-border-b rh-border-border rh-bg-transparent", children: availableModes.map((option) => /* @__PURE__ */ jsx(
2191
+ "button",
2192
+ {
2193
+ onClick: () => setActiveMode(option.value),
2194
+ className: [
2195
+ "rh-flex-1 rh-py-2 rh-px-4 rh-text-sm rh-transition-colors rh-duration-150 rh-text-text rh-font-bold",
2196
+ "rh-border-b-2 -rh-mb-px",
2197
+ activeMode === option.value ? "rh-border-primary" : "rh-border-transparent hover:rh-border-border"
2198
+ ].join(" "),
2199
+ children: option.label
2200
+ },
2201
+ option.value
2202
+ )) });
2203
+ };
2193
2204
  const renderYearGrid = () => /* @__PURE__ */ jsxs("div", { className: "rh-p-1", children: [
2194
2205
  /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-items-center rh-justify-between", children: [
2195
2206
  /* @__PURE__ */ jsx(
@@ -2716,7 +2727,7 @@ var DateSelect = forwardRef(
2716
2727
  },
2717
2728
  children: [
2718
2729
  renderModeTabs(),
2719
- /* @__PURE__ */ jsx("div", { className: "rh-mt-2", children: renderContent() })
2730
+ /* @__PURE__ */ jsx("div", { className: availableModes.length > 1 ? "rh-mt-2" : "", children: renderContent() })
2720
2731
  ]
2721
2732
  }
2722
2733
  ),
@@ -4083,6 +4094,7 @@ var CustomSelect = ({
4083
4094
  value,
4084
4095
  placeholder,
4085
4096
  rows: 1,
4097
+ onClick: (e) => e.stopPropagation(),
4086
4098
  onInput: (e) => {
4087
4099
  onChange(e.currentTarget.value);
4088
4100
  resizeTextArea();
@@ -4091,7 +4103,7 @@ var CustomSelect = ({
4091
4103
  color: inputTextColor,
4092
4104
  backgroundColor: backgroundColor || "transparent"
4093
4105
  },
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"
4106
+ 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"
4095
4107
  }
4096
4108
  ),
4097
4109
  /* @__PURE__ */ jsx("style", { children: `.rh-table-textarea::placeholder { color: ${inputPlaceholderColor}; }` })
@@ -4102,13 +4114,16 @@ var CustomSelect = ({
4102
4114
  "button",
4103
4115
  {
4104
4116
  type: "button",
4105
- onClick: openDropdown,
4117
+ onClick: (e) => {
4118
+ e.stopPropagation();
4119
+ openDropdown();
4120
+ },
4106
4121
  style: { backgroundColor: backgroundColor || void 0 },
4107
4122
  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
4123
  children: /* @__PURE__ */ jsx("div", { className: "rh-flex rh-items-center rh-gap-2 rh-flex-1 rh-px-0.5", children: /* @__PURE__ */ jsx(
4109
4124
  "span",
4110
4125
  {
4111
- className: "rh-text-[14px] rh-px-2 rh-py-0.5 rh-rounded-xl rh-whitespace-normal rh-break-words",
4126
+ className: "rh-text-[14px] rh-px-3.5 rh-py-0.5 rh-rounded-xl rh-whitespace-normal rh-break-words",
4112
4127
  style: { backgroundColor: displayBg || "transparent", fontFamily: "Inter, sans-serif", color: displayTextColor },
4113
4128
  children: displayLabel
4114
4129
  }
@@ -4127,6 +4142,7 @@ var CustomSelect = ({
4127
4142
  type: "button",
4128
4143
  onMouseDown: (e) => {
4129
4144
  e.preventDefault();
4145
+ e.stopPropagation();
4130
4146
  onChange(option.value);
4131
4147
  setIsOpen(false);
4132
4148
  },
@@ -4187,6 +4203,8 @@ function TableInner({
4187
4203
  columns,
4188
4204
  data,
4189
4205
  rowKey,
4206
+ rowClickable = false,
4207
+ onRowClick,
4190
4208
  size = "md",
4191
4209
  variant = "default",
4192
4210
  sort,
@@ -4390,9 +4408,18 @@ function TableInner({
4390
4408
  style: bodyStyleInline,
4391
4409
  className: [
4392
4410
  "rh-border-b rh-border-border rh-transition-colors",
4411
+ rowClickable ? "rh-cursor-pointer" : "",
4393
4412
  "hover:rh-bg-background/50",
4394
4413
  variant === "striped" && index % 2 === 1 ? "rh-bg-background/50" : ""
4395
4414
  ].filter(Boolean).join(" "),
4415
+ onClick: (e) => {
4416
+ if (!rowClickable || !onRowClick) return;
4417
+ const target = e.target;
4418
+ if (!target) return;
4419
+ const interactiveSelector = 'button, a, input, select, textarea, label, [role="button"], [data-no-row-click]';
4420
+ if (target.closest(interactiveSelector)) return;
4421
+ onRowClick(row, index, e);
4422
+ },
4396
4423
  children: columns.map((column) => /* @__PURE__ */ jsx(
4397
4424
  "td",
4398
4425
  {
@@ -4402,7 +4429,7 @@ function TableInner({
4402
4429
  alignClasses[column.align || "left"],
4403
4430
  "rh-text-text"
4404
4431
  ].filter(Boolean).join(" "),
4405
- children: /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-items-center rh-justify-between rh-gap-2", children: [
4432
+ children: /* @__PURE__ */ jsxs("div", { className: "rh-flex rh-items-stretch rh-justify-between rh-gap-2 rh-h-full", children: [
4406
4433
  isEditableCell(column) ? /* @__PURE__ */ jsx(
4407
4434
  CustomSelect,
4408
4435
  {