visits-style 1.4.6 → 1.4.8

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.
@@ -27,6 +27,8 @@ export interface Props extends HTMLAttributes<HTMLDivElement> {
27
27
  onClose?: () => void;
28
28
  /** 開けた場合のコールバック */
29
29
  onOpen?: () => void;
30
+ /** popoverを閉じる処理を手動に設定します */
31
+ onManualClose?: () => void;
30
32
  /** コンテンツを出さない */
31
33
  disabled?: boolean;
32
34
  }
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes } from 'react';
1
+ import { ButtonHTMLAttributes } from 'react';
2
2
  import { ColorType, SizeType } from '../../types';
3
- export interface Props extends HTMLAttributes<HTMLButtonElement> {
3
+ export interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
4
4
  /** ボタンの色 */
5
5
  color?: ColorType;
6
6
  /** ボタンのサイズ */
@@ -14,5 +14,5 @@ export interface Props extends HTMLAttributes<HTMLButtonElement> {
14
14
  /** アイコンボタンとしてpaddingを同じにする */
15
15
  icon?: boolean;
16
16
  }
17
- declare const _default: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, Props>>;
17
+ declare const _default: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, Props>>;
18
18
  export default _default;
@@ -1,6 +1,6 @@
1
- import { HTMLAttributes } from 'react';
1
+ import { ButtonHTMLAttributes } from 'react';
2
2
  import { ColorType, SizeType } from '../../types';
3
- export interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {
3
+ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
4
  /** ボタンの色 */
5
5
  color?: ColorType;
6
6
  /** ボタンのサイズ */
@@ -12,5 +12,5 @@ export interface ButtonProps extends HTMLAttributes<HTMLButtonElement> {
12
12
  /** アイコンボタンとしてpaddingを同じにする */
13
13
  icon?: boolean;
14
14
  }
15
- declare const _default: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, ButtonProps>>;
15
+ declare const _default: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, ButtonProps>>;
16
16
  export default _default;
package/dist/index.cjs.js CHANGED
@@ -771,6 +771,7 @@ const Popover = React.forwardRef(({
771
771
  x: 0,
772
772
  y: 6
773
773
  },
774
+ onManualClose,
774
775
  ...rest
775
776
  }, ref) => {
776
777
  const [open, setOpen] = React.useState(false);
@@ -794,14 +795,12 @@ const Popover = React.forwardRef(({
794
795
  onOpenChange: setOpen,
795
796
  whileElementsMounted: react.autoUpdate
796
797
  });
797
- const handleFocus = React.useCallback((e) => {
798
- stopPropagation$1(e);
799
- setOpen(true);
800
- }, []);
801
798
  const handleBlur = React.useCallback((e) => {
802
799
  stopPropagation$1(e);
800
+ if (onManualClose)
801
+ return onManualClose();
803
802
  setOpen(false);
804
- }, []);
803
+ }, [onManualClose]);
805
804
  React.useEffect(() => {
806
805
  if (disabled && open) {
807
806
  setOpen(false);
@@ -814,9 +813,9 @@ const Popover = React.forwardRef(({
814
813
  return () => closeRef.current?.();
815
814
  }, [open]);
816
815
  React.useImperativeHandle(ref, () => ({
817
- open: handleFocus,
818
- close: handleBlur
819
- }), [handleFocus, handleBlur]);
816
+ open: () => setOpen(true),
817
+ close: () => setOpen(false)
818
+ }), []);
820
819
  const {
821
820
  getFloatingProps,
822
821
  getReferenceProps
package/dist/index.es.js CHANGED
@@ -763,6 +763,7 @@ const Popover = forwardRef(({
763
763
  x: 0,
764
764
  y: 6
765
765
  },
766
+ onManualClose,
766
767
  ...rest
767
768
  }, ref) => {
768
769
  const [open, setOpen] = useState(false);
@@ -786,14 +787,12 @@ const Popover = forwardRef(({
786
787
  onOpenChange: setOpen,
787
788
  whileElementsMounted: autoUpdate
788
789
  });
789
- const handleFocus = useCallback((e) => {
790
- stopPropagation$1(e);
791
- setOpen(true);
792
- }, []);
793
790
  const handleBlur = useCallback((e) => {
794
791
  stopPropagation$1(e);
792
+ if (onManualClose)
793
+ return onManualClose();
795
794
  setOpen(false);
796
- }, []);
795
+ }, [onManualClose]);
797
796
  useEffect(() => {
798
797
  if (disabled && open) {
799
798
  setOpen(false);
@@ -806,9 +805,9 @@ const Popover = forwardRef(({
806
805
  return () => closeRef.current?.();
807
806
  }, [open]);
808
807
  useImperativeHandle(ref, () => ({
809
- open: handleFocus,
810
- close: handleBlur
811
- }), [handleFocus, handleBlur]);
808
+ open: () => setOpen(true),
809
+ close: () => setOpen(false)
810
+ }), []);
812
811
  const {
813
812
  getFloatingProps,
814
813
  getReferenceProps
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.6",
5
+ "version": "1.4.8",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs.js",
8
8
  "module": "./dist/index.es.js",