cr-ui-lib 1.1.113 → 1.1.115

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
@@ -530,6 +530,17 @@ declare type PopupWrapperProps = {
530
530
  } & React.HTMLAttributes<HTMLElement>;
531
531
  declare const PopupWrapper: ({ children, className, isOpen, stayMounted, closePopup, hasClosePopup, ...rest }: PopupWrapperProps) => JSX.Element | null;
532
532
 
533
+ declare type PopupWrapperV2Props = {
534
+ children?: React.ReactNode;
535
+ className?: string;
536
+ isOpen: boolean;
537
+ stayMounted?: boolean;
538
+ closePopup?: () => void;
539
+ hasClosePopup?: boolean;
540
+ isPortal?: boolean;
541
+ } & React.HTMLAttributes<HTMLElement>;
542
+ declare const PopupWrapperV2: ({ children, className, isOpen, stayMounted, closePopup, hasClosePopup, isPortal, ...rest }: PopupWrapperV2Props) => JSX.Element | null;
543
+
533
544
  declare type LayoutProps = {
534
545
  children: React.ReactNode;
535
546
  wrapperClassName?: string;
@@ -568,4 +579,4 @@ declare function toEndOfDay(date: Date): Date;
568
579
  declare function toMidnight(date: Date): Date;
569
580
  declare function isSameDateMDY(date1: Date, date2: Date): boolean;
570
581
 
571
- export { Box, BoxBody, BoxHeader, Button, CollapseButton, type Column, CommonInput, CommonInputSingle, DateRangePicker, DynamicTable, DynamicTableV2, ErrorToast, GraphedCard, GroupedCheckboxDropdown, Label, Modal, MultiBarGraph, MultiLineGraph, MultipleAutoSuggestionInput, NavBar, type NavBarProps, Pagination, PlainButton, PopupWrapper, SelectionButton, SideNav, type LayoutProps as SideNavProps, SimpleCard, SingleDateInput, SingleLineGraph, SingleListInput, SingleSelectDropdown, SuccessToast, TableHeader, TimeInput, isSameDateMDY, toEndOfDay, toMidnight, validateAndFormatInput, validateDate, validateDateRange };
582
+ export { Box, BoxBody, BoxHeader, Button, CollapseButton, type Column, CommonInput, CommonInputSingle, DateRangePicker, DynamicTable, DynamicTableV2, ErrorToast, GraphedCard, GroupedCheckboxDropdown, Label, Modal, MultiBarGraph, MultiLineGraph, MultipleAutoSuggestionInput, NavBar, type NavBarProps, Pagination, PlainButton, PopupWrapper, PopupWrapperV2, SelectionButton, SideNav, type LayoutProps as SideNavProps, SimpleCard, SingleDateInput, SingleLineGraph, SingleListInput, SingleSelectDropdown, SuccessToast, TableHeader, TimeInput, isSameDateMDY, toEndOfDay, toMidnight, validateAndFormatInput, validateDate, validateDateRange };
package/dist/index.d.ts CHANGED
@@ -530,6 +530,17 @@ declare type PopupWrapperProps = {
530
530
  } & React.HTMLAttributes<HTMLElement>;
531
531
  declare const PopupWrapper: ({ children, className, isOpen, stayMounted, closePopup, hasClosePopup, ...rest }: PopupWrapperProps) => JSX.Element | null;
532
532
 
533
+ declare type PopupWrapperV2Props = {
534
+ children?: React.ReactNode;
535
+ className?: string;
536
+ isOpen: boolean;
537
+ stayMounted?: boolean;
538
+ closePopup?: () => void;
539
+ hasClosePopup?: boolean;
540
+ isPortal?: boolean;
541
+ } & React.HTMLAttributes<HTMLElement>;
542
+ declare const PopupWrapperV2: ({ children, className, isOpen, stayMounted, closePopup, hasClosePopup, isPortal, ...rest }: PopupWrapperV2Props) => JSX.Element | null;
543
+
533
544
  declare type LayoutProps = {
534
545
  children: React.ReactNode;
535
546
  wrapperClassName?: string;
@@ -568,4 +579,4 @@ declare function toEndOfDay(date: Date): Date;
568
579
  declare function toMidnight(date: Date): Date;
569
580
  declare function isSameDateMDY(date1: Date, date2: Date): boolean;
570
581
 
571
- export { Box, BoxBody, BoxHeader, Button, CollapseButton, type Column, CommonInput, CommonInputSingle, DateRangePicker, DynamicTable, DynamicTableV2, ErrorToast, GraphedCard, GroupedCheckboxDropdown, Label, Modal, MultiBarGraph, MultiLineGraph, MultipleAutoSuggestionInput, NavBar, type NavBarProps, Pagination, PlainButton, PopupWrapper, SelectionButton, SideNav, type LayoutProps as SideNavProps, SimpleCard, SingleDateInput, SingleLineGraph, SingleListInput, SingleSelectDropdown, SuccessToast, TableHeader, TimeInput, isSameDateMDY, toEndOfDay, toMidnight, validateAndFormatInput, validateDate, validateDateRange };
582
+ export { Box, BoxBody, BoxHeader, Button, CollapseButton, type Column, CommonInput, CommonInputSingle, DateRangePicker, DynamicTable, DynamicTableV2, ErrorToast, GraphedCard, GroupedCheckboxDropdown, Label, Modal, MultiBarGraph, MultiLineGraph, MultipleAutoSuggestionInput, NavBar, type NavBarProps, Pagination, PlainButton, PopupWrapper, PopupWrapperV2, SelectionButton, SideNav, type LayoutProps as SideNavProps, SimpleCard, SingleDateInput, SingleLineGraph, SingleListInput, SingleSelectDropdown, SuccessToast, TableHeader, TimeInput, isSameDateMDY, toEndOfDay, toMidnight, validateAndFormatInput, validateDate, validateDateRange };
package/dist/index.js CHANGED
@@ -3628,8 +3628,12 @@ function SingleSelectDropdown({
3628
3628
  setIsOpen(!isOpen);
3629
3629
  }
3630
3630
  };
3631
+ const hasMounted = React.useRef(false);
3632
+ React.useEffect(() => {
3633
+ hasMounted.current = true;
3634
+ }, []);
3631
3635
  const openList = () => {
3632
- if (!disabled) {
3636
+ if (!disabled && !isOpen && hasMounted.current) {
3633
3637
  setIsOpen(true);
3634
3638
  }
3635
3639
  };
@@ -3837,7 +3841,6 @@ function SingleSelectDropdown({
3837
3841
  "input",
3838
3842
  {
3839
3843
  type: "text",
3840
- autoFocus: true,
3841
3844
  onClick: openList,
3842
3845
  onFocus: openList,
3843
3846
  className: tailwindMerge.twMerge(
@@ -5601,6 +5604,84 @@ var PopupWrapper = ({
5601
5604
  );
5602
5605
  };
5603
5606
  var PopupWrapper_default = PopupWrapper;
5607
+ var PopupWrapperV2 = ({
5608
+ children,
5609
+ className,
5610
+ isOpen = false,
5611
+ stayMounted = false,
5612
+ closePopup,
5613
+ hasClosePopup = false,
5614
+ isPortal = false,
5615
+ ...rest
5616
+ }) => {
5617
+ const anchorRef = React.useRef(null);
5618
+ const [portalStyle, setPortalStyle] = React.useState({});
5619
+ React.useEffect(() => {
5620
+ if (!isPortal || !isOpen) return;
5621
+ const updatePosition = () => {
5622
+ const anchor = anchorRef.current;
5623
+ if (!anchor) return;
5624
+ const parent = anchor.parentElement;
5625
+ if (!parent) return;
5626
+ const rect = parent.getBoundingClientRect();
5627
+ setPortalStyle({
5628
+ position: "fixed",
5629
+ top: rect.bottom + 4,
5630
+ right: window.innerWidth - rect.right,
5631
+ width: "20rem",
5632
+ zIndex: 9999
5633
+ });
5634
+ };
5635
+ updatePosition();
5636
+ window.addEventListener("scroll", updatePosition, true);
5637
+ window.addEventListener("resize", updatePosition);
5638
+ return () => {
5639
+ window.removeEventListener("scroll", updatePosition, true);
5640
+ window.removeEventListener("resize", updatePosition);
5641
+ };
5642
+ }, [isPortal, isOpen]);
5643
+ if (!stayMounted && !isOpen) return null;
5644
+ const content = /* @__PURE__ */ jsxRuntime.jsxs(
5645
+ "div",
5646
+ {
5647
+ ...rest,
5648
+ style: isPortal ? portalStyle : void 0,
5649
+ className: tailwindMerge.twMerge(
5650
+ isPortal ? "shadow-lg bg-white rounded-lg p-4 w-80 border border-opacity-10" : "absolute right-0 top-1 mt-10 shadow-lg bg-white rounded-lg p-4 w-80 z-10 border border-opacity-10",
5651
+ isOpen ? "block" : "hidden",
5652
+ className
5653
+ ),
5654
+ children: [
5655
+ hasClosePopup && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: closePopup, className: "cursor-pointer", children: /* @__PURE__ */ jsxRuntime.jsx(
5656
+ "svg",
5657
+ {
5658
+ xmlns: "http://www.w3.org/2000/svg",
5659
+ width: "17.5",
5660
+ height: "17.5",
5661
+ viewBox: "0 0 14 14",
5662
+ fill: "none",
5663
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5664
+ "path",
5665
+ {
5666
+ d: "M11.0837 3.739L10.2612 2.9165L7.00033 6.17734L3.73949 2.9165L2.91699 3.739L6.17783 6.99984L2.91699 10.2607L3.73949 11.0832L7.00033 7.82234L10.2612 11.0832L11.0837 10.2607L7.82283 6.99984L11.0837 3.739Z",
5667
+ fill: "#4B5563"
5668
+ }
5669
+ )
5670
+ }
5671
+ ) }) }),
5672
+ children
5673
+ ]
5674
+ }
5675
+ );
5676
+ if (isPortal) {
5677
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5678
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: anchorRef, style: { display: "none" } }),
5679
+ reactDom.createPortal(content, document.body)
5680
+ ] });
5681
+ }
5682
+ return content;
5683
+ };
5684
+ var PopupWrapperV2_default = PopupWrapperV2;
5604
5685
  var SideNav = ({
5605
5686
  children,
5606
5687
  wrapperClassName,
@@ -5705,6 +5786,7 @@ exports.NavBar = NavBar_default;
5705
5786
  exports.Pagination = Pagination;
5706
5787
  exports.PlainButton = PlainButton_default;
5707
5788
  exports.PopupWrapper = PopupWrapper_default;
5789
+ exports.PopupWrapperV2 = PopupWrapperV2_default;
5708
5790
  exports.SelectionButton = SelectionButton_default;
5709
5791
  exports.SideNav = SideNav_default;
5710
5792
  exports.SimpleCard = SimpleCard_default;