@shoplflow/base 0.25.2 → 0.25.4

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.cjs CHANGED
@@ -796,10 +796,36 @@ var ModalFooter = ({ children }) => {
796
796
  };
797
797
  ModalFooter[exports.MODAL_FOOTER_KEY] = true;
798
798
  var ModalFooter_default = ModalFooter;
799
- var ScrollArea = (_a) => {
799
+ var ScrollArea = React2.forwardRef((_a, ref) => {
800
800
  var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
801
- return /* @__PURE__ */ jsxRuntime.jsx(Scrollbars__default.default, __spreadProps(__spreadValues({ autoHide: true, autoHideTimeout: 1e3, autoHideDuration: 200 }, rest), { "data-shoplflow": "ScrollArea", children }));
802
- };
801
+ const scrollRef = React2.useRef(null);
802
+ const mergeRef = utils.useMergeRefs(scrollRef, ref);
803
+ const [windowWidth, setWindowWidth] = React2.useState(window.innerWidth);
804
+ const [windowHeight, setWindowHeight] = React2.useState(window.innerHeight);
805
+ const onResize = React2.useCallback(() => {
806
+ setWindowWidth(window.innerWidth);
807
+ setWindowHeight(window.innerHeight);
808
+ }, []);
809
+ React2.useEffect(() => {
810
+ window.addEventListener("resize", onResize);
811
+ return () => {
812
+ window.removeEventListener("resize", onResize);
813
+ };
814
+ }, [onResize]);
815
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: Boolean(windowWidth) && Boolean(windowHeight) && /* @__PURE__ */ jsxRuntime.jsx(
816
+ Scrollbars__default.default,
817
+ __spreadProps(__spreadValues(__spreadProps(__spreadValues({
818
+ ref: mergeRef
819
+ }, rest), {
820
+ autoHide: true,
821
+ autoHideTimeout: 1e3,
822
+ autoHideDuration: 200
823
+ }), rest), {
824
+ "data-shoplflow": "ScrollArea",
825
+ children
826
+ })
827
+ ) });
828
+ });
803
829
  exports.ScrollArea = ScrollArea;
804
830
  var ModalBody = ({
805
831
  children,
@@ -1701,7 +1727,7 @@ function mergeRefs(...refs) {
1701
1727
  });
1702
1728
  };
1703
1729
  }
1704
- function useMergeRefs(...refs) {
1730
+ function useMergeRefs2(...refs) {
1705
1731
  return React2.useMemo(() => mergeRefs(...refs), refs);
1706
1732
  }
1707
1733
  var Popper = ({
@@ -1737,7 +1763,7 @@ exports.PopperTrigger = React2.forwardRef(
1737
1763
  (_a, ref) => {
1738
1764
  var _b = _a, { children, isOpen = false } = _b, rest = __objRest(_b, ["children", "isOpen"]);
1739
1765
  const { setReference, setIsOpen } = usePopper();
1740
- const refs = useMergeRefs(ref, setReference);
1766
+ const refs = useMergeRefs2(ref, setReference);
1741
1767
  React2.useEffect(() => {
1742
1768
  setIsOpen(isOpen);
1743
1769
  }, [isOpen, setIsOpen]);
@@ -1748,7 +1774,7 @@ exports.PopperPortal = React2.forwardRef(
1748
1774
  ({ children, animation: initialAnimation }, ref) => {
1749
1775
  const { floatingStyles, setFloating, isOpen } = usePopper();
1750
1776
  const animation = initialAnimation != null ? initialAnimation : fadeInOut;
1751
- const refs = useMergeRefs(ref, setFloating);
1777
+ const refs = useMergeRefs2(ref, setFloating);
1752
1778
  if (!isOpen) {
1753
1779
  return null;
1754
1780
  }
@@ -2764,7 +2790,7 @@ var Input = React2.forwardRef(
2764
2790
  const [isHovered, setIsHovered] = React2.useState(false);
2765
2791
  const uniqueId = React2.useId();
2766
2792
  const inputRef = React2__namespace.default.useRef(null);
2767
- const refs = useMergeRefs(ref, inputRef);
2793
+ const refs = useMergeRefs2(ref, inputRef);
2768
2794
  const convertToString = React2.useCallback((value2) => {
2769
2795
  if (typeof value2 !== "number") {
2770
2796
  return typeof value2 === "string" ? value2 : value2.join("");