fui-material 2.7.11 → 2.7.12

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.
@@ -1009,20 +1009,22 @@ const FTableFooter = ({
1009
1009
  }
1010
1010
  );
1011
1011
  };
1012
- const active$4 = "_active_16jkc_16";
1013
- const hide = "_hide_16jkc_37";
1012
+ const entering = "_entering_dwagt_17";
1013
+ const exiting = "_exiting_dwagt_23";
1014
+ const hide = "_hide_dwagt_45";
1014
1015
  const styles$r = {
1015
- "f-dialog": "_f-dialog_16jkc_1",
1016
- "active-dialog": "_active-dialog_16jkc_16",
1017
- "f-dialog__content": "_f-dialog__content_16jkc_20",
1018
- active: active$4,
1016
+ "f-dialog": "_f-dialog_dwagt_1",
1017
+ entering,
1018
+ "f-dialog__content": "_f-dialog__content_dwagt_20",
1019
+ exiting,
1019
1020
  hide,
1020
- "f-dialog__header": "_f-dialog__header_16jkc_41",
1021
- "f-dialog__header_title": "_f-dialog__header_title_16jkc_53",
1022
- "f-dialog__header_close": "_f-dialog__header_close_16jkc_64",
1023
- "f-dialog__body": "_f-dialog__body_16jkc_79",
1024
- "f-dialog__footer": "_f-dialog__footer_16jkc_84"
1021
+ "f-dialog__header": "_f-dialog__header_dwagt_49",
1022
+ "f-dialog__header_title": "_f-dialog__header_title_dwagt_61",
1023
+ "f-dialog__header_close": "_f-dialog__header_close_dwagt_72",
1024
+ "f-dialog__body": "_f-dialog__body_dwagt_87",
1025
+ "f-dialog__footer": "_f-dialog__footer_dwagt_92"
1025
1026
  };
1027
+ let openDialogsCount = 0;
1026
1028
  const FDialog = ({
1027
1029
  openAndClose,
1028
1030
  closeButtonBackPage,
@@ -1033,22 +1035,55 @@ const FDialog = ({
1033
1035
  st,
1034
1036
  width = "lg"
1035
1037
  }) => {
1038
+ const [isMounted, setIsMounted] = useState(openAndClose);
1039
+ const [isClosing, setIsClosing] = useState(false);
1036
1040
  useEffect(() => {
1037
- if (!openAndClose) return;
1038
- const dialogCount = document.querySelectorAll(".active-dialog").length;
1039
- if (dialogCount > 0) {
1040
- document.body.classList.add("open-dialog");
1041
- } else {
1042
- document.body.classList.remove("open-dialog");
1041
+ if (openAndClose) {
1042
+ setIsMounted(true);
1043
+ setIsClosing(false);
1044
+ } else if (isMounted) {
1045
+ setIsClosing(true);
1043
1046
  }
1044
- return () => {
1045
- const updatedCount = document.querySelectorAll(".active-dialog").length;
1046
- if (updatedCount === 0) {
1047
- document.body.classList.remove("open-dialog");
1048
- }
1049
- };
1050
1047
  }, [openAndClose]);
1051
- if (!openAndClose) return null;
1048
+ const handleAnimationEnd = (e) => {
1049
+ if (isClosing && e.target === e.currentTarget) {
1050
+ setIsMounted(false);
1051
+ setIsClosing(false);
1052
+ }
1053
+ };
1054
+ useEffect(() => {
1055
+ if (isClosing) {
1056
+ const timer = setTimeout(() => {
1057
+ setIsMounted(false);
1058
+ setIsClosing(false);
1059
+ }, 300);
1060
+ return () => clearTimeout(timer);
1061
+ }
1062
+ }, [isClosing]);
1063
+ useEffect(() => {
1064
+ if (isMounted && !isClosing) {
1065
+ openDialogsCount += 1;
1066
+ document.body.classList.add("open-dialog");
1067
+ return () => {
1068
+ openDialogsCount = Math.max(0, openDialogsCount - 1);
1069
+ if (openDialogsCount === 0) {
1070
+ document.body.classList.remove("open-dialog");
1071
+ }
1072
+ };
1073
+ }
1074
+ }, [isMounted, isClosing]);
1075
+ const handleKeyDown = useCallback((e) => {
1076
+ if (e.key === "Escape" && openAndClose && !isClosing) {
1077
+ closeButtonBackPage == null ? void 0 : closeButtonBackPage(false);
1078
+ }
1079
+ }, [openAndClose, isClosing, closeButtonBackPage]);
1080
+ useEffect(() => {
1081
+ if (isMounted && !isClosing) {
1082
+ window.addEventListener("keydown", handleKeyDown);
1083
+ return () => window.removeEventListener("keydown", handleKeyDown);
1084
+ }
1085
+ }, [isMounted, isClosing, handleKeyDown]);
1086
+ if (!isMounted) return null;
1052
1087
  const widthStyles = {
1053
1088
  xs: "50vw",
1054
1089
  md: "65vw",
@@ -1057,22 +1092,28 @@ const FDialog = ({
1057
1092
  adaptive: "fit-content"
1058
1093
  };
1059
1094
  const contentWidth = widthStyles[width];
1095
+ const animationClass = isClosing ? styles$r["exiting"] : styles$r["entering"];
1060
1096
  return ReactDOM.createPortal(
1061
1097
  /* @__PURE__ */ jsx(
1062
1098
  "div",
1063
1099
  {
1064
1100
  id,
1065
1101
  style: st,
1066
- className: `${styles$r["f-dialog"]} ${openAndClose ? styles$r["active-dialog"] : ""} ${className || ""}`,
1067
- onClick: () => closeButtonBackPage == null ? void 0 : closeButtonBackPage(false),
1102
+ className: `${styles$r["f-dialog"]} ${animationClass} ${className || ""}`,
1103
+ onMouseDown: (e) => {
1104
+ if (e.target === e.currentTarget) {
1105
+ closeButtonBackPage == null ? void 0 : closeButtonBackPage(false);
1106
+ }
1107
+ },
1108
+ onAnimationEnd: handleAnimationEnd,
1068
1109
  children: /* @__PURE__ */ jsx(
1069
1110
  "div",
1070
1111
  {
1071
- className: `${styles$r["f-dialog__content"]} ${openAndClose ? styles$r["active"] : ""} ${hide2 ? styles$r["hide"] : ""}`,
1112
+ className: `${styles$r["f-dialog__content"]} ${hide2 ? styles$r["hide"] : ""}`,
1072
1113
  style: {
1073
1114
  width: contentWidth
1074
1115
  },
1075
- onClick: (e) => e.stopPropagation(),
1116
+ onMouseDown: (e) => e.stopPropagation(),
1076
1117
  children
1077
1118
  }
1078
1119
  )