visits-style 1.4.14 → 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/components/Popover/index.d.ts +3 -2
- package/dist/index.cjs.js +24 -17
- package/dist/index.es.js +24 -17
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
import { type ReferenceType } from '@floating-ui/react';
|
|
2
3
|
import type { Placement } from '@floating-ui/core';
|
|
3
4
|
export interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
4
5
|
/** ボタンの内容 */
|
|
@@ -24,9 +25,9 @@ export interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
|
24
25
|
y: number;
|
|
25
26
|
};
|
|
26
27
|
/** 閉じた場合のコールバック */
|
|
27
|
-
onClose?: () => void;
|
|
28
|
+
onClose?: (ref?: ReferenceType | null, float?: HTMLElement | null) => void;
|
|
28
29
|
/** 開けた場合のコールバック */
|
|
29
|
-
onOpen?: () => void;
|
|
30
|
+
onOpen?: (ref?: ReferenceType | null, float?: HTMLElement | null) => void;
|
|
30
31
|
/** popoverを閉じる処理を手動に設定します */
|
|
31
32
|
onManualClose?: () => void;
|
|
32
33
|
/** コンテンツを出さない */
|
package/dist/index.cjs.js
CHANGED
|
@@ -802,7 +802,14 @@ const Popover = React.forwardRef(({
|
|
|
802
802
|
crossAxis: offset.x
|
|
803
803
|
})],
|
|
804
804
|
open,
|
|
805
|
-
onOpenChange:
|
|
805
|
+
onOpenChange: (value) => {
|
|
806
|
+
if (value) {
|
|
807
|
+
openRef.current?.(refs.reference.current, refs.floating.current);
|
|
808
|
+
} else {
|
|
809
|
+
closeRef.current?.(refs.reference.current, refs.floating.current);
|
|
810
|
+
}
|
|
811
|
+
setOpen(value);
|
|
812
|
+
},
|
|
806
813
|
whileElementsMounted: react.autoUpdate
|
|
807
814
|
});
|
|
808
815
|
const handleBlur = React.useCallback((e) => {
|
|
@@ -810,21 +817,23 @@ const Popover = React.forwardRef(({
|
|
|
810
817
|
if (onManualClose)
|
|
811
818
|
return onManualClose();
|
|
812
819
|
setOpen(false);
|
|
820
|
+
closeRef.current?.(refs.reference.current, refs.floating.current);
|
|
813
821
|
}, [onManualClose]);
|
|
814
822
|
React.useEffect(() => {
|
|
815
823
|
if (disabled && open) {
|
|
816
824
|
setOpen(false);
|
|
817
825
|
}
|
|
818
826
|
}, [disabled, open]);
|
|
819
|
-
React.useEffect(() => {
|
|
820
|
-
if (!open)
|
|
821
|
-
return;
|
|
822
|
-
openRef.current?.();
|
|
823
|
-
return () => closeRef.current?.();
|
|
824
|
-
}, [open]);
|
|
825
827
|
React.useImperativeHandle(ref, () => ({
|
|
826
|
-
open: () =>
|
|
827
|
-
|
|
828
|
+
open: () => {
|
|
829
|
+
setOpen(true);
|
|
830
|
+
openRef.current?.(refs.reference.current, refs.floating.current);
|
|
831
|
+
},
|
|
832
|
+
close: () => {
|
|
833
|
+
setOpen(false);
|
|
834
|
+
closeRef.current?.(refs.reference.current, refs.floating.current);
|
|
835
|
+
}
|
|
836
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
828
837
|
}), []);
|
|
829
838
|
const {
|
|
830
839
|
getFloatingProps,
|
|
@@ -835,15 +844,13 @@ const Popover = React.forwardRef(({
|
|
|
835
844
|
openRef.current = onOpen;
|
|
836
845
|
closeRef.current = onClose;
|
|
837
846
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
838
|
-
React.cloneElement(React.Children.only(label), {
|
|
847
|
+
React.cloneElement(React.Children.only(label), getReferenceProps({
|
|
839
848
|
ref: refs.setReference,
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
})
|
|
846
|
-
}),
|
|
849
|
+
tabIndex: 0,
|
|
850
|
+
role: "button",
|
|
851
|
+
disabled,
|
|
852
|
+
onClick: stopPropagation$1
|
|
853
|
+
})),
|
|
847
854
|
/* @__PURE__ */ jsxRuntime.jsx(Portal$1, { children: open && !disabled ? /* @__PURE__ */ jsxRuntime.jsx(react.FloatingOverlay, { "data-testid": "visits-style-shadow", onClick: handleBlur, style: {
|
|
848
855
|
zIndex
|
|
849
856
|
}, children: /* @__PURE__ */ jsxRuntime.jsx(Tooltip, { role: "tooltip", ref: refs.setFloating, color, style: floatingStyles, ...getFloatingProps({
|
package/dist/index.es.js
CHANGED
|
@@ -794,7 +794,14 @@ const Popover = forwardRef(({
|
|
|
794
794
|
crossAxis: offset$1.x
|
|
795
795
|
})],
|
|
796
796
|
open,
|
|
797
|
-
onOpenChange:
|
|
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
|
+
},
|
|
798
805
|
whileElementsMounted: autoUpdate
|
|
799
806
|
});
|
|
800
807
|
const handleBlur = useCallback((e) => {
|
|
@@ -802,21 +809,23 @@ const Popover = forwardRef(({
|
|
|
802
809
|
if (onManualClose)
|
|
803
810
|
return onManualClose();
|
|
804
811
|
setOpen(false);
|
|
812
|
+
closeRef.current?.(refs.reference.current, refs.floating.current);
|
|
805
813
|
}, [onManualClose]);
|
|
806
814
|
useEffect(() => {
|
|
807
815
|
if (disabled && open) {
|
|
808
816
|
setOpen(false);
|
|
809
817
|
}
|
|
810
818
|
}, [disabled, open]);
|
|
811
|
-
useEffect(() => {
|
|
812
|
-
if (!open)
|
|
813
|
-
return;
|
|
814
|
-
openRef.current?.();
|
|
815
|
-
return () => closeRef.current?.();
|
|
816
|
-
}, [open]);
|
|
817
819
|
useImperativeHandle(ref, () => ({
|
|
818
|
-
open: () =>
|
|
819
|
-
|
|
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
|
|
820
829
|
}), []);
|
|
821
830
|
const {
|
|
822
831
|
getFloatingProps,
|
|
@@ -827,15 +836,13 @@ const Popover = forwardRef(({
|
|
|
827
836
|
openRef.current = onOpen;
|
|
828
837
|
closeRef.current = onClose;
|
|
829
838
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
830
|
-
cloneElement(Children.only(label), {
|
|
839
|
+
cloneElement(Children.only(label), getReferenceProps({
|
|
831
840
|
ref: refs.setReference,
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
})
|
|
838
|
-
}),
|
|
841
|
+
tabIndex: 0,
|
|
842
|
+
role: "button",
|
|
843
|
+
disabled,
|
|
844
|
+
onClick: stopPropagation$1
|
|
845
|
+
})),
|
|
839
846
|
/* @__PURE__ */ jsx(Portal$1, { children: open && !disabled ? /* @__PURE__ */ jsx(FloatingOverlay, { "data-testid": "visits-style-shadow", onClick: handleBlur, style: {
|
|
840
847
|
zIndex
|
|
841
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.
|
|
5
|
+
"version": "1.4.15",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs.js",
|
|
8
8
|
"module": "./dist/index.es.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"styled-components": ">=6.0.5"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@floating-ui/react": "^0.26.
|
|
30
|
+
"@floating-ui/react": "^0.26.13",
|
|
31
31
|
"eslint-config-react-app": "^7.0.1",
|
|
32
32
|
"polished": "^4.3.1"
|
|
33
33
|
}
|