cr-ui-lib 1.1.115 → 1.1.117

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
@@ -538,8 +538,10 @@ declare type PopupWrapperV2Props = {
538
538
  closePopup?: () => void;
539
539
  hasClosePopup?: boolean;
540
540
  isPortal?: boolean;
541
+ portalTop?: number;
542
+ portalRight?: number;
541
543
  } & React.HTMLAttributes<HTMLElement>;
542
- declare const PopupWrapperV2: ({ children, className, isOpen, stayMounted, closePopup, hasClosePopup, isPortal, ...rest }: PopupWrapperV2Props) => JSX.Element | null;
544
+ declare const PopupWrapperV2: ({ children, className, isOpen, stayMounted, closePopup, hasClosePopup, isPortal, portalTop, portalRight, ...rest }: PopupWrapperV2Props) => JSX.Element | null;
543
545
 
544
546
  declare type LayoutProps = {
545
547
  children: React.ReactNode;
package/dist/index.d.ts CHANGED
@@ -538,8 +538,10 @@ declare type PopupWrapperV2Props = {
538
538
  closePopup?: () => void;
539
539
  hasClosePopup?: boolean;
540
540
  isPortal?: boolean;
541
+ portalTop?: number;
542
+ portalRight?: number;
541
543
  } & React.HTMLAttributes<HTMLElement>;
542
- declare const PopupWrapperV2: ({ children, className, isOpen, stayMounted, closePopup, hasClosePopup, isPortal, ...rest }: PopupWrapperV2Props) => JSX.Element | null;
544
+ declare const PopupWrapperV2: ({ children, className, isOpen, stayMounted, closePopup, hasClosePopup, isPortal, portalTop, portalRight, ...rest }: PopupWrapperV2Props) => JSX.Element | null;
543
545
 
544
546
  declare type LayoutProps = {
545
547
  children: React.ReactNode;
package/dist/index.js CHANGED
@@ -2025,9 +2025,8 @@ var DateRangePicker = ({
2025
2025
  );
2026
2026
  const [endDate, setEndDate] = React.useState(getInitialEndDate());
2027
2027
  const [leftMonth, setLeftMonth] = React.useState(() => {
2028
- const prevMonth = /* @__PURE__ */ new Date();
2029
- prevMonth.setMonth(prevMonth.getMonth() - 1);
2030
- return prevMonth;
2028
+ const now = /* @__PURE__ */ new Date();
2029
+ return new Date(now.getFullYear(), now.getMonth() - 1, 1);
2031
2030
  });
2032
2031
  const [rightMonth, setRightMonth] = React.useState(/* @__PURE__ */ new Date());
2033
2032
  const [hoveredDate, setHoveredDate] = React.useState(null);
@@ -2140,11 +2139,17 @@ var DateRangePicker = ({
2140
2139
  ];
2141
2140
  React.useEffect(() => {
2142
2141
  if (previousLabelRef.current === "" && end_date !== "" && start_date !== "") {
2143
- setLeftMonth(new Date(start_date));
2144
- setRightMonth(new Date(end_date));
2145
- setStartDate(new Date(start_date));
2146
- setEndDate(new Date(end_date));
2147
- if (new Date(end_date) < /* @__PURE__ */ new Date() && previousLabelRef.current !== "") {
2142
+ const parsedStart = new Date(start_date);
2143
+ const parsedEnd = new Date(end_date);
2144
+ if (parsedStart.getMonth() === parsedEnd.getMonth() && parsedStart.getFullYear() === parsedEnd.getFullYear()) {
2145
+ setLeftMonth(new Date(parsedEnd.getFullYear(), parsedEnd.getMonth() - 1, 1));
2146
+ } else {
2147
+ setLeftMonth(parsedStart);
2148
+ }
2149
+ setRightMonth(parsedEnd);
2150
+ setStartDate(parsedStart);
2151
+ setEndDate(parsedEnd);
2152
+ if (parsedEnd < /* @__PURE__ */ new Date() && previousLabelRef.current !== "") {
2148
2153
  setLabel("Custom Range");
2149
2154
  }
2150
2155
  }
@@ -2686,7 +2691,7 @@ var DateRangePicker = ({
2686
2691
  setLeftCalendarView("day");
2687
2692
  setRightCalendarView("day");
2688
2693
  setLeftMonth(
2689
- originalStart ? new Date(originalStart.getFullYear(), originalStart.getMonth(), 1) : new Date((/* @__PURE__ */ new Date()).setMonth((/* @__PURE__ */ new Date()).getMonth() - 1))
2694
+ originalStart ? new Date(originalStart.getFullYear(), originalStart.getMonth(), 1) : new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1)
2690
2695
  );
2691
2696
  setRightMonth(
2692
2697
  originalEnd ? new Date(originalEnd.getFullYear(), originalEnd.getMonth(), 1) : /* @__PURE__ */ new Date()
@@ -2800,9 +2805,9 @@ var DateRangePicker = ({
2800
2805
  setStartDate(null);
2801
2806
  setEndDate(null);
2802
2807
  setRightMonth(/* @__PURE__ */ new Date());
2803
- const prev = /* @__PURE__ */ new Date();
2804
- prev.setMonth(prev.getMonth() - 1);
2805
- setLeftMonth(prev);
2808
+ const now = /* @__PURE__ */ new Date();
2809
+ setRightMonth(now);
2810
+ setLeftMonth(new Date(now.getFullYear(), now.getMonth() - 1, 1));
2806
2811
  setLeftCalendarView("day");
2807
2812
  setRightCalendarView("day");
2808
2813
  },
@@ -5612,6 +5617,8 @@ var PopupWrapperV2 = ({
5612
5617
  closePopup,
5613
5618
  hasClosePopup = false,
5614
5619
  isPortal = false,
5620
+ portalTop = 0,
5621
+ portalRight = 0,
5615
5622
  ...rest
5616
5623
  }) => {
5617
5624
  const anchorRef = React.useRef(null);
@@ -5626,8 +5633,8 @@ var PopupWrapperV2 = ({
5626
5633
  const rect = parent.getBoundingClientRect();
5627
5634
  setPortalStyle({
5628
5635
  position: "fixed",
5629
- top: rect.bottom + 4,
5630
- right: window.innerWidth - rect.right,
5636
+ top: rect.bottom + 4 + portalTop,
5637
+ right: window.innerWidth - rect.right + portalRight,
5631
5638
  width: "20rem",
5632
5639
  zIndex: 9999
5633
5640
  });