visits-style 1.4.3 → 1.4.5

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.
@@ -22,6 +22,11 @@ export interface Props extends HTMLAttributes<HTMLDivElement> {
22
22
  * @default '0.85rem'
23
23
  */
24
24
  padding?: string;
25
+ /**
26
+ * モーダルの縦並びを設定します。
27
+ * @default 'center'
28
+ */
29
+ verticalAlign?: 'start' | 'center' | 'end';
25
30
  }
26
- export default function Modal({ show, children, timeout, padding, closeModal, closeOnOverlay, closeOnEsc, onExited, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
31
+ export default function Modal({ show, children, timeout, padding, verticalAlign, closeModal, closeOnOverlay, closeOnEsc, onExited, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
27
32
  export declare const ModalContent: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, import("../../elements/Box").Props>>;
@@ -64,7 +64,7 @@ declare const _default: import("styled-components").IStyledComponent<"web", {
64
64
  'aria-colindextext'?: string | undefined;
65
65
  'aria-colspan'?: number | undefined;
66
66
  'aria-controls'?: string | undefined;
67
- 'aria-current'?: boolean | "page" | "time" | "true" | "false" | "step" | "location" | "date" | undefined;
67
+ 'aria-current'?: boolean | "page" | "time" | "step" | "true" | "false" | "location" | "date" | undefined;
68
68
  'aria-describedby'?: string | undefined;
69
69
  'aria-description'?: string | undefined;
70
70
  'aria-details'?: string | undefined;
@@ -64,7 +64,7 @@ declare const _default: import("styled-components").IStyledComponent<"web", {
64
64
  'aria-colindextext'?: string | undefined;
65
65
  'aria-colspan'?: number | undefined;
66
66
  'aria-controls'?: string | undefined;
67
- 'aria-current'?: boolean | "page" | "time" | "true" | "false" | "step" | "location" | "date" | undefined;
67
+ 'aria-current'?: boolean | "page" | "time" | "step" | "true" | "false" | "location" | "date" | undefined;
68
68
  'aria-describedby'?: string | undefined;
69
69
  'aria-description'?: string | undefined;
70
70
  'aria-details'?: string | undefined;
@@ -64,7 +64,7 @@ declare const _default: import("styled-components").IStyledComponent<"web", {
64
64
  'aria-colindextext'?: string | undefined;
65
65
  'aria-colspan'?: number | undefined;
66
66
  'aria-controls'?: string | undefined;
67
- 'aria-current'?: boolean | "page" | "time" | "true" | "false" | "step" | "location" | "date" | undefined;
67
+ 'aria-current'?: boolean | "page" | "time" | "step" | "true" | "false" | "location" | "date" | undefined;
68
68
  'aria-describedby'?: string | undefined;
69
69
  'aria-description'?: string | undefined;
70
70
  'aria-details'?: string | undefined;
@@ -64,7 +64,7 @@ declare const _default: import("styled-components").IStyledComponent<"web", {
64
64
  'aria-colindextext'?: string | undefined;
65
65
  'aria-colspan'?: number | undefined;
66
66
  'aria-controls'?: string | undefined;
67
- 'aria-current'?: boolean | "page" | "time" | "true" | "false" | "step" | "location" | "date" | undefined;
67
+ 'aria-current'?: boolean | "page" | "time" | "step" | "true" | "false" | "location" | "date" | undefined;
68
68
  'aria-describedby'?: string | undefined;
69
69
  'aria-description'?: string | undefined;
70
70
  'aria-details'?: string | undefined;
package/dist/index.cjs.js CHANGED
@@ -774,6 +774,8 @@ const Popover = React.forwardRef(({
774
774
  }, ref) => {
775
775
  const [open, setOpen] = React.useState(false);
776
776
  const nodeId = react.useId();
777
+ const openRef = React.useRef(onOpen);
778
+ const closeRef = React.useRef(onClose);
777
779
  const {
778
780
  refs,
779
781
  floatingStyles,
@@ -791,33 +793,37 @@ const Popover = React.forwardRef(({
791
793
  onOpenChange: setOpen,
792
794
  whileElementsMounted: react.autoUpdate
793
795
  });
794
- const handleFocus = (e) => {
796
+ const handleFocus = React.useCallback((e) => {
795
797
  stopPropagation$1(e);
796
798
  setOpen(true);
797
- if (onOpen)
798
- onOpen();
799
- };
800
- const handleBlur = (e) => {
799
+ }, []);
800
+ const handleBlur = React.useCallback((e) => {
801
801
  stopPropagation$1(e);
802
802
  setOpen(false);
803
- if (onClose)
804
- onClose();
805
- };
803
+ }, []);
806
804
  React.useEffect(() => {
807
805
  if (disabled && open) {
808
806
  setOpen(false);
809
807
  }
810
808
  }, [disabled, open]);
809
+ React.useEffect(() => {
810
+ if (!open)
811
+ return;
812
+ openRef.current?.();
813
+ return () => closeRef.current?.();
814
+ }, [open]);
811
815
  React.useImperativeHandle(ref, () => ({
812
816
  open: handleFocus,
813
817
  close: handleBlur
814
- }));
818
+ }), [handleFocus, handleBlur]);
815
819
  const {
816
820
  getFloatingProps,
817
821
  getReferenceProps
818
822
  } = react.useInteractions([react.useClick(context, {
819
823
  enabled: !disabled
820
824
  })]);
825
+ openRef.current = onOpen;
826
+ closeRef.current = onClose;
821
827
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
822
828
  React.cloneElement(React.Children.only(label), {
823
829
  ref: refs.setReference,
@@ -853,6 +859,7 @@ function Modal({
853
859
  children,
854
860
  timeout = 200,
855
861
  padding = "0.85rem",
862
+ verticalAlign = "center",
856
863
  closeModal,
857
864
  closeOnOverlay,
858
865
  closeOnEsc,
@@ -903,7 +910,7 @@ function Modal({
903
910
  exitRef.current = onExited;
904
911
  return /* @__PURE__ */ jsxRuntime.jsx(Portal$1, { children: isMounted ? /* @__PURE__ */ jsxRuntime.jsx(Overlay, { lockScroll: true, "data-testid": "vs-modal-overlay", onClick: handleOverlayClose, style: {
905
912
  padding
906
- }, children: /* @__PURE__ */ jsxRuntime.jsx(Wrapper$2, { ref: refs.setFloating, role: "dialog", ...getFloatingProps({
913
+ }, $verticalAlign: verticalAlign, children: /* @__PURE__ */ jsxRuntime.jsx(Wrapper$2, { ref: refs.setFloating, role: "dialog", ...getFloatingProps({
907
914
  ...rest,
908
915
  style: styles,
909
916
  onClick: stopPropagation
@@ -912,7 +919,23 @@ function Modal({
912
919
  const Overlay = /* @__PURE__ */ styledComponents.styled(react.FloatingOverlay).withConfig({
913
920
  displayName: "Modal__Overlay",
914
921
  componentId: "sc-pb7lhx-0"
915
- })([" display:flex;display:grid;place-items:center;align-items:center;justify-content:center;background:", ";z-index:9997;"], ({
922
+ })([" display:flex;display:grid;place-items:", ";align-items:", ";justify-content:center;background:", ";z-index:9997;"], ({
923
+ $verticalAlign
924
+ }) => {
925
+ if ($verticalAlign === "start")
926
+ return "flex-start";
927
+ if ($verticalAlign === "end")
928
+ return "flex-end";
929
+ return "center";
930
+ }, ({
931
+ $verticalAlign
932
+ }) => {
933
+ if ($verticalAlign === "start")
934
+ return "flex-start";
935
+ if ($verticalAlign === "end")
936
+ return "flex-end";
937
+ return "center";
938
+ }, ({
916
939
  theme
917
940
  }) => theme.backdrop);
918
941
  const Wrapper$2 = /* @__PURE__ */ styledComponents.styled.div.withConfig({
@@ -1014,7 +1037,7 @@ function Toast({
1014
1037
  const ToastList = /* @__PURE__ */ styledComponents.styled.ul.withConfig({
1015
1038
  displayName: "Toast__ToastList",
1016
1039
  componentId: "sc-8192b2-0"
1017
- })(["display:flex;flex-direction:column;z-index:9999;pointer-events:none;overflow:hidden;li + li{margin-top:", ";}"], ({
1040
+ })(["display:flex;flex-direction:column;z-index:9999;overflow:hidden;li + li{margin-top:", ";}"], ({
1018
1041
  $space
1019
1042
  }) => $space);
1020
1043
 
package/dist/index.es.js CHANGED
@@ -766,6 +766,8 @@ const Popover = forwardRef(({
766
766
  }, ref) => {
767
767
  const [open, setOpen] = useState(false);
768
768
  const nodeId = useId();
769
+ const openRef = useRef(onOpen);
770
+ const closeRef = useRef(onClose);
769
771
  const {
770
772
  refs,
771
773
  floatingStyles,
@@ -783,33 +785,37 @@ const Popover = forwardRef(({
783
785
  onOpenChange: setOpen,
784
786
  whileElementsMounted: autoUpdate
785
787
  });
786
- const handleFocus = (e) => {
788
+ const handleFocus = useCallback((e) => {
787
789
  stopPropagation$1(e);
788
790
  setOpen(true);
789
- if (onOpen)
790
- onOpen();
791
- };
792
- const handleBlur = (e) => {
791
+ }, []);
792
+ const handleBlur = useCallback((e) => {
793
793
  stopPropagation$1(e);
794
794
  setOpen(false);
795
- if (onClose)
796
- onClose();
797
- };
795
+ }, []);
798
796
  useEffect(() => {
799
797
  if (disabled && open) {
800
798
  setOpen(false);
801
799
  }
802
800
  }, [disabled, open]);
801
+ useEffect(() => {
802
+ if (!open)
803
+ return;
804
+ openRef.current?.();
805
+ return () => closeRef.current?.();
806
+ }, [open]);
803
807
  useImperativeHandle(ref, () => ({
804
808
  open: handleFocus,
805
809
  close: handleBlur
806
- }));
810
+ }), [handleFocus, handleBlur]);
807
811
  const {
808
812
  getFloatingProps,
809
813
  getReferenceProps
810
814
  } = useInteractions([useClick(context, {
811
815
  enabled: !disabled
812
816
  })]);
817
+ openRef.current = onOpen;
818
+ closeRef.current = onClose;
813
819
  return /* @__PURE__ */ jsxs(Fragment, { children: [
814
820
  cloneElement(Children.only(label), {
815
821
  ref: refs.setReference,
@@ -845,6 +851,7 @@ function Modal({
845
851
  children,
846
852
  timeout = 200,
847
853
  padding = "0.85rem",
854
+ verticalAlign = "center",
848
855
  closeModal,
849
856
  closeOnOverlay,
850
857
  closeOnEsc,
@@ -895,7 +902,7 @@ function Modal({
895
902
  exitRef.current = onExited;
896
903
  return /* @__PURE__ */ jsx(Portal$1, { children: isMounted ? /* @__PURE__ */ jsx(Overlay, { lockScroll: true, "data-testid": "vs-modal-overlay", onClick: handleOverlayClose, style: {
897
904
  padding
898
- }, children: /* @__PURE__ */ jsx(Wrapper$2, { ref: refs.setFloating, role: "dialog", ...getFloatingProps({
905
+ }, $verticalAlign: verticalAlign, children: /* @__PURE__ */ jsx(Wrapper$2, { ref: refs.setFloating, role: "dialog", ...getFloatingProps({
899
906
  ...rest,
900
907
  style: styles,
901
908
  onClick: stopPropagation
@@ -904,7 +911,23 @@ function Modal({
904
911
  const Overlay = /* @__PURE__ */ styled(FloatingOverlay).withConfig({
905
912
  displayName: "Modal__Overlay",
906
913
  componentId: "sc-pb7lhx-0"
907
- })([" display:flex;display:grid;place-items:center;align-items:center;justify-content:center;background:", ";z-index:9997;"], ({
914
+ })([" display:flex;display:grid;place-items:", ";align-items:", ";justify-content:center;background:", ";z-index:9997;"], ({
915
+ $verticalAlign
916
+ }) => {
917
+ if ($verticalAlign === "start")
918
+ return "flex-start";
919
+ if ($verticalAlign === "end")
920
+ return "flex-end";
921
+ return "center";
922
+ }, ({
923
+ $verticalAlign
924
+ }) => {
925
+ if ($verticalAlign === "start")
926
+ return "flex-start";
927
+ if ($verticalAlign === "end")
928
+ return "flex-end";
929
+ return "center";
930
+ }, ({
908
931
  theme
909
932
  }) => theme.backdrop);
910
933
  const Wrapper$2 = /* @__PURE__ */ styled.div.withConfig({
@@ -1006,7 +1029,7 @@ function Toast({
1006
1029
  const ToastList = /* @__PURE__ */ styled.ul.withConfig({
1007
1030
  displayName: "Toast__ToastList",
1008
1031
  componentId: "sc-8192b2-0"
1009
- })(["display:flex;flex-direction:column;z-index:9999;pointer-events:none;overflow:hidden;li + li{margin-top:", ";}"], ({
1032
+ })(["display:flex;flex-direction:column;z-index:9999;overflow:hidden;li + li{margin-top:", ";}"], ({
1010
1033
  $space
1011
1034
  }) => $space);
1012
1035
 
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.3",
5
+ "version": "1.4.5",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs.js",
8
8
  "module": "./dist/index.es.js",
@@ -24,10 +24,11 @@
24
24
  "peerDependencies": {
25
25
  "react": ">=18.2.0",
26
26
  "react-dom": ">=18.2.0",
27
- "styled-components": ">=6.0.2"
27
+ "styled-components": ">=6.0.5"
28
28
  },
29
29
  "dependencies": {
30
- "@floating-ui/react": "^0.24.5",
30
+ "@floating-ui/react": "^0.25.0",
31
+ "eslint-config-react-app": "^7.0.1",
31
32
  "polished": "^4.2.2"
32
33
  }
33
34
  }