@rehagro/ui 1.0.49 → 1.0.50

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
@@ -470,6 +470,8 @@ type SelectBaseProps = {
470
470
  radius?: SelectRadius;
471
471
  /** Helper/error message displayed below the select */
472
472
  helperText?: React__default.ReactNode;
473
+ /** Whether to use radio buttons instead of checkboxes */
474
+ radio?: boolean;
473
475
  /** Whether the select is disabled */
474
476
  disabled?: boolean;
475
477
  /** Custom class for the trigger container */
@@ -513,20 +515,35 @@ type DateSelectValue = {
513
515
  };
514
516
  type DateSelectProps = DateSelectBaseProps;
515
517
  type DateSelectBaseProps = {
518
+ /** Text displayed above the field */
516
519
  label?: string;
520
+ /** Secondary text next to the label; use "*" to render a red asterisk */
517
521
  subtitle?: string;
522
+ /** Text displayed when no date is selected */
518
523
  placeholder?: string;
524
+ /** Visual state of the field: "default" (default) or "error" */
519
525
  status?: SelectStatus;
526
+ /** Field size: "sm" | "md" | "lg" */
520
527
  size?: SelectSize;
528
+ /** Border radius of the field */
521
529
  radius?: SelectRadius;
530
+ /** Helper or error message displayed below the field */
522
531
  helperText?: React__default.ReactNode;
532
+ /** Disables the field, preventing any interaction */
523
533
  disabled?: boolean;
534
+ /** CSS class applied to the inner trigger element */
524
535
  className?: string;
536
+ /** CSS class applied to the outer wrapper element */
525
537
  wrapperClassName?: string;
538
+ /** Controlled value of the selected date */
526
539
  value?: DateSelectValue;
540
+ /** Uncontrolled initial value of the selected date */
527
541
  defaultValue?: DateSelectValue;
542
+ /** Callback fired when the selected date changes */
528
543
  onChange?: (value: DateSelectValue) => void;
544
+ /** Start year of the range shown in the picker */
529
545
  startYear?: number;
546
+ /** End year of the range shown in the picker */
530
547
  endYear?: number;
531
548
  /** Custom background color for the trigger button */
532
549
  backgroundColor?: string;
package/dist/index.d.ts CHANGED
@@ -470,6 +470,8 @@ type SelectBaseProps = {
470
470
  radius?: SelectRadius;
471
471
  /** Helper/error message displayed below the select */
472
472
  helperText?: React__default.ReactNode;
473
+ /** Whether to use radio buttons instead of checkboxes */
474
+ radio?: boolean;
473
475
  /** Whether the select is disabled */
474
476
  disabled?: boolean;
475
477
  /** Custom class for the trigger container */
@@ -513,20 +515,35 @@ type DateSelectValue = {
513
515
  };
514
516
  type DateSelectProps = DateSelectBaseProps;
515
517
  type DateSelectBaseProps = {
518
+ /** Text displayed above the field */
516
519
  label?: string;
520
+ /** Secondary text next to the label; use "*" to render a red asterisk */
517
521
  subtitle?: string;
522
+ /** Text displayed when no date is selected */
518
523
  placeholder?: string;
524
+ /** Visual state of the field: "default" (default) or "error" */
519
525
  status?: SelectStatus;
526
+ /** Field size: "sm" | "md" | "lg" */
520
527
  size?: SelectSize;
528
+ /** Border radius of the field */
521
529
  radius?: SelectRadius;
530
+ /** Helper or error message displayed below the field */
522
531
  helperText?: React__default.ReactNode;
532
+ /** Disables the field, preventing any interaction */
523
533
  disabled?: boolean;
534
+ /** CSS class applied to the inner trigger element */
524
535
  className?: string;
536
+ /** CSS class applied to the outer wrapper element */
525
537
  wrapperClassName?: string;
538
+ /** Controlled value of the selected date */
526
539
  value?: DateSelectValue;
540
+ /** Uncontrolled initial value of the selected date */
527
541
  defaultValue?: DateSelectValue;
542
+ /** Callback fired when the selected date changes */
528
543
  onChange?: (value: DateSelectValue) => void;
544
+ /** Start year of the range shown in the picker */
529
545
  startYear?: number;
546
+ /** End year of the range shown in the picker */
530
547
  endYear?: number;
531
548
  /** Custom background color for the trigger button */
532
549
  backgroundColor?: string;
package/dist/index.js CHANGED
@@ -1586,6 +1586,19 @@ var CheckIcon2 = ({ className }) => /* @__PURE__ */ jsxRuntime.jsx(
1586
1586
  )
1587
1587
  }
1588
1588
  );
1589
+ var RadioIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsx(
1590
+ "span",
1591
+ {
1592
+ className: [
1593
+ "rh-inline-flex rh-items-center rh-justify-center",
1594
+ "rh-w-4 rh-h-4 rh-shrink-0",
1595
+ "rh-border rh-rounded-full rh-transition-colors rh-duration-150",
1596
+ isSelected ? "rh-border-primary" : "rh-border-border rh-bg-surface"
1597
+ ].filter(Boolean).join(" "),
1598
+ "aria-hidden": "true",
1599
+ children: isSelected && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rh-w-2.5 rh-h-2.5 rh-rounded-full rh-bg-primary" })
1600
+ }
1601
+ );
1589
1602
  var Select = React9.forwardRef(function Select2(props, ref) {
1590
1603
  const {
1591
1604
  options,
@@ -1596,6 +1609,7 @@ var Select = React9.forwardRef(function Select2(props, ref) {
1596
1609
  size = "md",
1597
1610
  radius = "xs",
1598
1611
  helperText,
1612
+ radio = false,
1599
1613
  disabled = false,
1600
1614
  className = "",
1601
1615
  wrapperClassName = "",
@@ -1859,7 +1873,7 @@ var Select = React9.forwardRef(function Select2(props, ref) {
1859
1873
  ].filter(Boolean).join(" "),
1860
1874
  children: [
1861
1875
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rh-flex-1 rh-truncate rh-text-text", children: option.label }),
1862
- multiple ? /* @__PURE__ */ jsxRuntime.jsx(
1876
+ radio ? /* @__PURE__ */ jsxRuntime.jsx(RadioIcon, { isSelected }) : multiple ? /* @__PURE__ */ jsxRuntime.jsx(
1863
1877
  "span",
1864
1878
  {
1865
1879
  className: [
@@ -2047,6 +2061,7 @@ var DateSelect = React9.forwardRef(
2047
2061
  const helperId = React9__default.default.useId();
2048
2062
  const [isOpen, setIsOpen] = React9.useState(false);
2049
2063
  const [isHelperDismissed, setIsHelperDismissed] = React9.useState(false);
2064
+ const [dropdownAlign, setDropdownAlign] = React9.useState("left");
2050
2065
  const [internalValue, setInternalValue] = React9.useState(
2051
2066
  props.defaultValue ?? { mode: "day" }
2052
2067
  );
@@ -2063,8 +2078,9 @@ var DateSelect = React9.forwardRef(
2063
2078
  const [yearGridStart, setYearGridStart] = React9.useState(
2064
2079
  Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 12) * 12
2065
2080
  );
2066
- const wrapperRef = React9__default.default.useRef(null);
2067
- const innerRef = React9__default.default.useRef(null);
2081
+ const wrapperRef = React9.useRef(null);
2082
+ const innerRef = React9.useRef(null);
2083
+ const dropdownRef = React9.useRef(null);
2068
2084
  React9__default.default.useImperativeHandle(ref, () => innerRef.current);
2069
2085
  const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
2070
2086
  const yearStart = startYear ?? currentYear - 10;
@@ -2098,7 +2114,7 @@ var DateSelect = React9.forwardRef(
2098
2114
  if (!isControlled) setInternalValue(newValue);
2099
2115
  props.onChange?.(newValue);
2100
2116
  };
2101
- const displayText = React9__default.default.useMemo(() => {
2117
+ const displayText = React9.useMemo(() => {
2102
2118
  if (value.mode === "year" && value.year) return value.year.toString();
2103
2119
  if (value.mode === "month" && value.year != null)
2104
2120
  return `${MONTHS_SHORT[value.month || 0]} ${value.year}`;
@@ -2109,7 +2125,7 @@ var DateSelect = React9.forwardRef(
2109
2125
  }
2110
2126
  return null;
2111
2127
  }, [value]);
2112
- React9__default.default.useEffect(() => {
2128
+ React9.useEffect(() => {
2113
2129
  if (!isOpen) return;
2114
2130
  const handleClickOutside = (e) => {
2115
2131
  if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
@@ -2119,7 +2135,7 @@ var DateSelect = React9.forwardRef(
2119
2135
  document.addEventListener("mousedown", handleClickOutside);
2120
2136
  return () => document.removeEventListener("mousedown", handleClickOutside);
2121
2137
  }, [isOpen]);
2122
- React9__default.default.useEffect(() => {
2138
+ React9.useEffect(() => {
2123
2139
  if (!isOpen) return;
2124
2140
  const handleEscape = (e) => {
2125
2141
  if (e.key === "Escape") {
@@ -2130,6 +2146,18 @@ var DateSelect = React9.forwardRef(
2130
2146
  document.addEventListener("keydown", handleEscape);
2131
2147
  return () => document.removeEventListener("keydown", handleEscape);
2132
2148
  }, [isOpen]);
2149
+ React9.useEffect(() => {
2150
+ if (!isOpen || !innerRef.current || !dropdownRef.current) return;
2151
+ const triggerRect = innerRef.current.getBoundingClientRect();
2152
+ const dropdownWidth = activeMode === "interval" ? 720 : 385;
2153
+ const spaceLeft = triggerRect.left;
2154
+ const spaceRight = window.innerWidth - triggerRect.right;
2155
+ if (spaceLeft < dropdownWidth && spaceRight >= dropdownWidth) {
2156
+ setDropdownAlign("right");
2157
+ } else {
2158
+ setDropdownAlign("left");
2159
+ }
2160
+ }, [isOpen, activeMode]);
2133
2161
  const getDaysInMonth2 = (year, month) => new Date(year, month + 1, 0).getDate();
2134
2162
  const getFirstDayOfMonth2 = (year, month) => new Date(year, month, 1).getDay();
2135
2163
  const isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
@@ -2632,11 +2660,13 @@ var DateSelect = React9.forwardRef(
2632
2660
  isOpen && /* @__PURE__ */ jsxRuntime.jsxs(
2633
2661
  "div",
2634
2662
  {
2663
+ ref: dropdownRef,
2635
2664
  className: [
2636
2665
  "rh-absolute rh-z-50 rh-mt-1 rh-p-5",
2637
2666
  "rh-bg-surface rh-rounded-md",
2638
2667
  dropdownRadiusClasses2[radius],
2639
- activeMode === "interval" ? "rh-w-[720px]" : "rh-w-[385px]"
2668
+ activeMode === "interval" ? "rh-w-[720px]" : "rh-w-[385px]",
2669
+ dropdownAlign === "left" ? "rh-right-0" : "rh-left-0"
2640
2670
  ].filter(Boolean).join(" "),
2641
2671
  style: {
2642
2672
  top: "100%",
@@ -4312,7 +4342,7 @@ function TableInner({
4312
4342
  },
4313
4343
  rowKey(row, index)
4314
4344
  )),
4315
- addRowButton && !loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-border hover:rh-bg-background/100 rh-rounde-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
4345
+ addRowButton && !loading && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "rh-border-border hover:rh-bg-background/50 rh-rounde-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
4316
4346
  "td",
4317
4347
  {
4318
4348
  colSpan,