visits-style 1.4.13 → 1.4.15

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.es.js CHANGED
@@ -2,7 +2,7 @@ import { styled, css, keyframes } from 'styled-components';
2
2
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
3
  import React, { forwardRef, useLayoutEffect, useEffect, useRef, useMemo, useImperativeHandle, useState, cloneElement, Children, useCallback, createElement } from 'react';
4
4
  import { getLuminance, transparentize, darken } from 'polished';
5
- import { useId, useFloating, shift, flip, offset, useInteractions, useHover, useClientPoint, autoUpdate, useClick, FloatingOverlay, useDismiss, useTransitionStyles } from '@floating-ui/react';
5
+ import { useId, useFloating, shift, flip, offset, autoUpdate, useInteractions, useHover, useClientPoint, useClick, FloatingOverlay, useDismiss, useTransitionStyles } from '@floating-ui/react';
6
6
  import { createPortal } from 'react-dom';
7
7
 
8
8
  const Wrapper$6 = /* @__PURE__ */ styled.div.withConfig({
@@ -694,6 +694,7 @@ const Tooltip$1 = forwardRef(({
694
694
  mainAxis: offset$1.y,
695
695
  crossAxis: offset$1.x
696
696
  })],
697
+ whileElementsMounted: disabled ? void 0 : autoUpdate,
697
698
  onOpenChange: setOpen
698
699
  });
699
700
  const {
@@ -793,7 +794,14 @@ const Popover = forwardRef(({
793
794
  crossAxis: offset$1.x
794
795
  })],
795
796
  open,
796
- onOpenChange: setOpen,
797
+ onOpenChange: (value) => {
798
+ if (value) {
799
+ openRef.current?.(refs.reference.current, refs.floating.current);
800
+ } else {
801
+ closeRef.current?.(refs.reference.current, refs.floating.current);
802
+ }
803
+ setOpen(value);
804
+ },
797
805
  whileElementsMounted: autoUpdate
798
806
  });
799
807
  const handleBlur = useCallback((e) => {
@@ -801,21 +809,23 @@ const Popover = forwardRef(({
801
809
  if (onManualClose)
802
810
  return onManualClose();
803
811
  setOpen(false);
812
+ closeRef.current?.(refs.reference.current, refs.floating.current);
804
813
  }, [onManualClose]);
805
814
  useEffect(() => {
806
815
  if (disabled && open) {
807
816
  setOpen(false);
808
817
  }
809
818
  }, [disabled, open]);
810
- useEffect(() => {
811
- if (!open)
812
- return;
813
- openRef.current?.();
814
- return () => closeRef.current?.();
815
- }, [open]);
816
819
  useImperativeHandle(ref, () => ({
817
- open: () => setOpen(true),
818
- close: () => setOpen(false)
820
+ open: () => {
821
+ setOpen(true);
822
+ openRef.current?.(refs.reference.current, refs.floating.current);
823
+ },
824
+ close: () => {
825
+ setOpen(false);
826
+ closeRef.current?.(refs.reference.current, refs.floating.current);
827
+ }
828
+ // eslint-disable-next-line react-hooks/exhaustive-deps
819
829
  }), []);
820
830
  const {
821
831
  getFloatingProps,
@@ -826,15 +836,13 @@ const Popover = forwardRef(({
826
836
  openRef.current = onOpen;
827
837
  closeRef.current = onClose;
828
838
  return /* @__PURE__ */ jsxs(Fragment, { children: [
829
- cloneElement(Children.only(label), {
839
+ cloneElement(Children.only(label), getReferenceProps({
830
840
  ref: refs.setReference,
831
- ...getReferenceProps({
832
- tabIndex: 0,
833
- role: "button",
834
- disabled,
835
- onClick: stopPropagation$1
836
- })
837
- }),
841
+ tabIndex: 0,
842
+ role: "button",
843
+ disabled,
844
+ onClick: stopPropagation$1
845
+ })),
838
846
  /* @__PURE__ */ jsx(Portal$1, { children: open && !disabled ? /* @__PURE__ */ jsx(FloatingOverlay, { "data-testid": "visits-style-shadow", onClick: handleBlur, style: {
839
847
  zIndex
840
848
  }, children: /* @__PURE__ */ jsx(Tooltip, { role: "tooltip", ref: refs.setFloating, color, style: floatingStyles, ...getFloatingProps({
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "visits-style",
3
3
  "repository": "https://github.com/visits-works/visits-style",
4
4
  "homepage": "https://github.com/visits-works/visits-style",
5
- "version": "1.4.13",
5
+ "version": "1.4.15",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs.js",
8
8
  "module": "./dist/index.es.js",
@@ -19,7 +19,7 @@
19
19
  "dist"
20
20
  ],
21
21
  "engines": {
22
- "node": ">=16"
22
+ "node": ">=18"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": ">=18.2.0",
@@ -27,8 +27,8 @@
27
27
  "styled-components": ">=6.0.5"
28
28
  },
29
29
  "dependencies": {
30
- "@floating-ui/react": "^0.26.6",
30
+ "@floating-ui/react": "^0.26.13",
31
31
  "eslint-config-react-app": "^7.0.1",
32
- "polished": "^4.2.2"
32
+ "polished": "^4.3.1"
33
33
  }
34
34
  }