@edu-tosel/design 1.0.87 → 1.0.88

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.
@@ -1,2 +1,2 @@
1
1
  import { ModalProps } from "../../interface/Modal";
2
- export default function ModalDesign({ titles, showAction, children, option, debug, }: ModalProps): import("react").ReactPortal | null;
2
+ export default function ModalProvider(props: ModalProps): JSX.Element | null;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import ReactDOM from "react-dom";
2
+ import { createPortal } from "react-dom";
3
3
  import { useTransition, animated } from "react-spring";
4
4
  import { useActionStore } from "../../store";
5
5
  import { cn } from "../../util";
@@ -25,22 +25,40 @@ const heightSize = {
25
25
  "2xl": "max-w-176",
26
26
  full: "h-full",
27
27
  };
28
- export default function ModalDesign({ titles, showAction, children, option, debug, }) {
29
- const { isVisible, event } = showAction ?? {};
30
- const { position, width, height, noClose, noBackground, isShadow } = option ?? {};
28
+ export default function ModalProvider(props) {
29
+ const { isVisible } = props.showAction ?? {};
30
+ const { position, noBackground } = props.option ?? {};
31
31
  const [detection, setDetection] = useState(null);
32
- const { setIsOwn, removeModal } = useActionStore();
32
+ const { setIsOwn } = useActionStore();
33
33
  useEffect(() => {
34
34
  setDetection(document.getElementById("portal"));
35
35
  }, []);
36
+ const transitions = useTransition(isVisible, {
37
+ from: { opacity: 0 },
38
+ enter: { opacity: 1 },
39
+ leave: { opacity: 0 },
40
+ config: { duration: 200 },
41
+ });
36
42
  const background = {
37
43
  positions: "z-50 fixed top-0 left-0",
38
44
  displays: !position && "flex items-center justify-center ",
39
45
  sizes: "min-h-screen w-full ",
40
46
  styles: !noBackground && "bg-black/10 backdrop-blur-sm ",
41
47
  };
48
+ const positionContainer = {
49
+ positions: "absolute z-45",
50
+ position,
51
+ };
52
+ return (detection &&
53
+ (!position
54
+ ? createPortal(transitions((styles, item) => item && (_jsx(animated.div, { style: styles, className: cn(background), onClick: () => setIsOwn(true), children: _jsx(ModalDesign, { ...props }) }))), document.body)
55
+ : transitions((styles, item) => item && (_jsx(animated.div, { style: styles, className: cn(positionContainer), onClick: () => setIsOwn(true), children: _jsx(ModalDesign, { ...props }) })))));
56
+ }
57
+ function ModalDesign({ titles, showAction, children, option, debug, }) {
58
+ const { removeModal } = useActionStore();
59
+ const { width, height, noClose, isShadow } = option ?? {};
60
+ const { event } = showAction ?? {};
42
61
  const container = {
43
- positions: position,
44
62
  paddings: "p-5",
45
63
  sizes: `${heightSize[height ?? "lg"]} ${widthSize[width ?? "md"]}`,
46
64
  styles: "rounded-xl bg-white relative overflow-hidden",
@@ -51,12 +69,5 @@ export default function ModalDesign({ titles, showAction, children, option, debu
51
69
  displays: "flex flex-col items-end",
52
70
  sizes: "w-full min-h-[83px]",
53
71
  };
54
- const transitions = useTransition(isVisible, {
55
- from: { opacity: 0 },
56
- enter: { opacity: 1 },
57
- leave: { opacity: 0 },
58
- config: { duration: 200 },
59
- });
60
- return (detection &&
61
- ReactDOM.createPortal(transitions((styles, item) => item && (_jsx(animated.div, { style: styles, className: cn(background), onClick: () => setIsOwn(true), children: _jsxs("div", { className: cn(container), children: [_jsxs("div", { className: cn(titleBox), children: [_jsx("div", { className: "text-xl leading-none font-pretendard-bold", children: titles.title }), _jsx("div", { className: "bg-gray-light w-13.75 h-2 mt-3" }), _jsx(LineBreaks, { texts: titles.subtitle, className: "mt-5 text-base leading-none text-end font-pretendard-bold" })] }), children, !noClose && event && (_jsx(SVG.Close, { onClick: () => removeModal(event), className: "absolute top-5 left-5" }))] }) }))), document.body));
72
+ return (_jsxs("div", { className: cn(container), children: [_jsxs("div", { className: cn(titleBox), children: [_jsx("div", { className: "text-xl leading-none font-pretendard-bold", children: titles.title }), _jsx("div", { className: "bg-gray-light w-13.75 h-2 mt-3" }), _jsx(LineBreaks, { texts: titles.subtitle, className: "mt-5 text-base leading-none text-end font-pretendard-bold" })] }), children, !noClose && event && (_jsx(SVG.Close, { onClick: () => removeModal(event), className: "absolute top-5 left-5" }))] }));
62
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edu-tosel/design",
3
- "version": "1.0.87",
3
+ "version": "1.0.88",
4
4
  "description": "UI components for International TOSEL Committee",
5
5
  "keywords": [
6
6
  "jsx",
package/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.87
1
+ 1.0.88