@sytechui/modal 2.2.29
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/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/chunk-6UNMARUO.mjs +112 -0
- package/dist/chunk-IYHOL6KG.mjs +37 -0
- package/dist/chunk-MZ2TEFDD.mjs +37 -0
- package/dist/chunk-NQ34YL6U.mjs +31 -0
- package/dist/chunk-NQV4LXOC.mjs +25 -0
- package/dist/chunk-PN5RGUFB.mjs +133 -0
- package/dist/chunk-S6FNYUYS.mjs +41 -0
- package/dist/chunk-ULX4JIBE.mjs +13 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +433 -0
- package/dist/index.mjs +40 -0
- package/dist/modal-body.d.mts +8 -0
- package/dist/modal-body.d.ts +8 -0
- package/dist/modal-body.js +62 -0
- package/dist/modal-body.mjs +8 -0
- package/dist/modal-content.d.mts +15 -0
- package/dist/modal-content.d.ts +15 -0
- package/dist/modal-content.js +180 -0
- package/dist/modal-content.mjs +9 -0
- package/dist/modal-context.d.mts +310 -0
- package/dist/modal-context.d.ts +310 -0
- package/dist/modal-context.js +37 -0
- package/dist/modal-context.mjs +9 -0
- package/dist/modal-footer.d.mts +8 -0
- package/dist/modal-footer.d.ts +8 -0
- package/dist/modal-footer.js +56 -0
- package/dist/modal-footer.mjs +8 -0
- package/dist/modal-header.d.mts +13 -0
- package/dist/modal-header.d.ts +13 -0
- package/dist/modal-header.js +62 -0
- package/dist/modal-header.mjs +8 -0
- package/dist/modal-transition.d.mts +35 -0
- package/dist/modal-transition.d.ts +35 -0
- package/dist/modal-transition.js +64 -0
- package/dist/modal-transition.mjs +7 -0
- package/dist/modal.d.mts +19 -0
- package/dist/modal.d.ts +19 -0
- package/dist/modal.js +175 -0
- package/dist/modal.mjs +9 -0
- package/dist/use-modal.d.mts +227 -0
- package/dist/use-modal.d.ts +227 -0
- package/dist/use-modal.js +156 -0
- package/dist/use-modal.mjs +7 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Next UI Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @sytechui/modal
|
|
2
|
+
|
|
3
|
+
Displays a dialog with a custom content that requires attention or provides additional information.
|
|
4
|
+
|
|
5
|
+
Please refer to the [documentation](https://heroui.com/docs/components/modal) for more information.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
yarn add @sytechui/modal
|
|
11
|
+
# or
|
|
12
|
+
npm i @sytechui/modal
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Contribution
|
|
16
|
+
|
|
17
|
+
Yes please! See the
|
|
18
|
+
[contributing guidelines](https://github.com/heroui-inc/heroui/blob/master/CONTRIBUTING.md)
|
|
19
|
+
for details.
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
This project is licensed under the terms of the
|
|
24
|
+
[MIT license](https://github.com/heroui-inc/heroui/blob/master/LICENSE).
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
scaleInOut
|
|
4
|
+
} from "./chunk-S6FNYUYS.mjs";
|
|
5
|
+
import {
|
|
6
|
+
useModalContext
|
|
7
|
+
} from "./chunk-ULX4JIBE.mjs";
|
|
8
|
+
|
|
9
|
+
// src/modal-content.tsx
|
|
10
|
+
import { cloneElement, isValidElement, useMemo, useCallback } from "react";
|
|
11
|
+
import { DismissButton } from "@react-aria/overlays";
|
|
12
|
+
import { TRANSITION_VARIANTS } from "@sytechui/framer-utils";
|
|
13
|
+
import { CloseIcon } from "@sytechui/shared-icons";
|
|
14
|
+
import { LazyMotion, m } from "framer-motion";
|
|
15
|
+
import { useDialog } from "@react-aria/dialog";
|
|
16
|
+
import { chain, mergeProps } from "@sytechui/shared-utils";
|
|
17
|
+
import { useViewportSize } from "@sytechui/use-viewport-size";
|
|
18
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
var domAnimation = () => import("@sytechui/dom-animation").then((res) => res.default);
|
|
20
|
+
var ModalContent = (props) => {
|
|
21
|
+
const { as, children, role = "dialog", ...otherProps } = props;
|
|
22
|
+
const {
|
|
23
|
+
Component: DialogComponent,
|
|
24
|
+
domRef,
|
|
25
|
+
slots,
|
|
26
|
+
classNames,
|
|
27
|
+
motionProps,
|
|
28
|
+
backdrop,
|
|
29
|
+
closeButton,
|
|
30
|
+
hideCloseButton,
|
|
31
|
+
disableAnimation,
|
|
32
|
+
getDialogProps,
|
|
33
|
+
getBackdropProps,
|
|
34
|
+
getCloseButtonProps,
|
|
35
|
+
onClose
|
|
36
|
+
} = useModalContext();
|
|
37
|
+
const Component = as || DialogComponent || "div";
|
|
38
|
+
const viewport = useViewportSize();
|
|
39
|
+
const { dialogProps } = useDialog(
|
|
40
|
+
{
|
|
41
|
+
role
|
|
42
|
+
},
|
|
43
|
+
domRef
|
|
44
|
+
);
|
|
45
|
+
const closeButtonContent = isValidElement(closeButton) ? cloneElement(closeButton, getCloseButtonProps()) : /* @__PURE__ */ jsx("button", { ...getCloseButtonProps(), children: /* @__PURE__ */ jsx(CloseIcon, {}) });
|
|
46
|
+
const onKeyDown = useCallback((e) => {
|
|
47
|
+
if (e.key === "Tab" && e.nativeEvent.isComposing) {
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
const contentProps = getDialogProps(mergeProps(dialogProps, otherProps));
|
|
53
|
+
const content = /* @__PURE__ */ jsxs(Component, { ...contentProps, onKeyDown: chain(contentProps.onKeyDown, onKeyDown), children: [
|
|
54
|
+
/* @__PURE__ */ jsx(DismissButton, { onDismiss: onClose }),
|
|
55
|
+
!hideCloseButton && closeButtonContent,
|
|
56
|
+
typeof children === "function" ? children(onClose) : children,
|
|
57
|
+
/* @__PURE__ */ jsx(DismissButton, { onDismiss: onClose })
|
|
58
|
+
] });
|
|
59
|
+
const backdropContent = useMemo(() => {
|
|
60
|
+
if (backdrop === "transparent") {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
if (disableAnimation) {
|
|
64
|
+
return /* @__PURE__ */ jsx("div", { ...getBackdropProps() });
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(
|
|
67
|
+
m.div,
|
|
68
|
+
{
|
|
69
|
+
animate: "enter",
|
|
70
|
+
exit: "exit",
|
|
71
|
+
initial: "exit",
|
|
72
|
+
variants: TRANSITION_VARIANTS.fade,
|
|
73
|
+
...getBackdropProps()
|
|
74
|
+
}
|
|
75
|
+
) });
|
|
76
|
+
}, [backdrop, disableAnimation, getBackdropProps]);
|
|
77
|
+
const viewportStyle = {
|
|
78
|
+
"--visual-viewport-height": viewport.height + "px"
|
|
79
|
+
};
|
|
80
|
+
const contents = disableAnimation ? /* @__PURE__ */ jsx(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
|
|
84
|
+
"data-slot": "wrapper",
|
|
85
|
+
style: viewportStyle,
|
|
86
|
+
children: content
|
|
87
|
+
}
|
|
88
|
+
) : /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(
|
|
89
|
+
m.div,
|
|
90
|
+
{
|
|
91
|
+
animate: "enter",
|
|
92
|
+
className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }),
|
|
93
|
+
"data-slot": "wrapper",
|
|
94
|
+
exit: "exit",
|
|
95
|
+
initial: "exit",
|
|
96
|
+
variants: scaleInOut,
|
|
97
|
+
...motionProps,
|
|
98
|
+
style: viewportStyle,
|
|
99
|
+
children: content
|
|
100
|
+
}
|
|
101
|
+
) });
|
|
102
|
+
return /* @__PURE__ */ jsxs("div", { tabIndex: -1, children: [
|
|
103
|
+
backdropContent,
|
|
104
|
+
contents
|
|
105
|
+
] });
|
|
106
|
+
};
|
|
107
|
+
ModalContent.displayName = "HeroUI.ModalContent";
|
|
108
|
+
var modal_content_default = ModalContent;
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
modal_content_default
|
|
112
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useModalContext
|
|
4
|
+
} from "./chunk-ULX4JIBE.mjs";
|
|
5
|
+
|
|
6
|
+
// src/modal-body.tsx
|
|
7
|
+
import { useEffect } from "react";
|
|
8
|
+
import { forwardRef } from "@sytechui/system";
|
|
9
|
+
import { useDOMRef } from "@sytechui/react-utils";
|
|
10
|
+
import { cn } from "@sytechui/theme";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
var ModalBody = forwardRef((props, ref) => {
|
|
13
|
+
const { as, children, className, ...otherProps } = props;
|
|
14
|
+
const { slots, classNames, bodyId, setBodyMounted } = useModalContext();
|
|
15
|
+
const domRef = useDOMRef(ref);
|
|
16
|
+
const Component = as || "div";
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setBodyMounted(true);
|
|
19
|
+
return () => setBodyMounted(false);
|
|
20
|
+
}, [setBodyMounted]);
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
Component,
|
|
23
|
+
{
|
|
24
|
+
ref: domRef,
|
|
25
|
+
className: slots.body({ class: cn(classNames == null ? void 0 : classNames.body, className) }),
|
|
26
|
+
id: bodyId,
|
|
27
|
+
...otherProps,
|
|
28
|
+
children
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
ModalBody.displayName = "HeroUI.ModalBody";
|
|
33
|
+
var modal_body_default = ModalBody;
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
modal_body_default
|
|
37
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useModalContext
|
|
4
|
+
} from "./chunk-ULX4JIBE.mjs";
|
|
5
|
+
|
|
6
|
+
// src/modal-header.tsx
|
|
7
|
+
import { useEffect } from "react";
|
|
8
|
+
import { forwardRef } from "@sytechui/system";
|
|
9
|
+
import { useDOMRef } from "@sytechui/react-utils";
|
|
10
|
+
import { cn } from "@sytechui/theme";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
var ModalHeader = forwardRef((props, ref) => {
|
|
13
|
+
const { as, children, className, ...otherProps } = props;
|
|
14
|
+
const { slots, classNames, headerId, setHeaderMounted } = useModalContext();
|
|
15
|
+
const domRef = useDOMRef(ref);
|
|
16
|
+
const Component = as || "header";
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setHeaderMounted(true);
|
|
19
|
+
return () => setHeaderMounted(false);
|
|
20
|
+
}, [setHeaderMounted]);
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
Component,
|
|
23
|
+
{
|
|
24
|
+
ref: domRef,
|
|
25
|
+
className: slots.header({ class: cn(classNames == null ? void 0 : classNames.header, className) }),
|
|
26
|
+
id: headerId,
|
|
27
|
+
...otherProps,
|
|
28
|
+
children
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
ModalHeader.displayName = "HeroUI.ModalHeader";
|
|
33
|
+
var modal_header_default = ModalHeader;
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
modal_header_default
|
|
37
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useModalContext
|
|
4
|
+
} from "./chunk-ULX4JIBE.mjs";
|
|
5
|
+
|
|
6
|
+
// src/modal-footer.tsx
|
|
7
|
+
import { forwardRef } from "@sytechui/system";
|
|
8
|
+
import { useDOMRef } from "@sytechui/react-utils";
|
|
9
|
+
import { cn } from "@sytechui/theme";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
var ModalFooter = forwardRef((props, ref) => {
|
|
12
|
+
const { as, children, className, ...otherProps } = props;
|
|
13
|
+
const { slots, classNames } = useModalContext();
|
|
14
|
+
const domRef = useDOMRef(ref);
|
|
15
|
+
const Component = as || "footer";
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
Component,
|
|
18
|
+
{
|
|
19
|
+
ref: domRef,
|
|
20
|
+
className: slots.footer({ class: cn(classNames == null ? void 0 : classNames.footer, className) }),
|
|
21
|
+
...otherProps,
|
|
22
|
+
children
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
ModalFooter.displayName = "HeroUI.ModalFooter";
|
|
27
|
+
var modal_footer_default = ModalFooter;
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
modal_footer_default
|
|
31
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useModal
|
|
4
|
+
} from "./chunk-PN5RGUFB.mjs";
|
|
5
|
+
import {
|
|
6
|
+
ModalProvider
|
|
7
|
+
} from "./chunk-ULX4JIBE.mjs";
|
|
8
|
+
|
|
9
|
+
// src/modal.tsx
|
|
10
|
+
import { AnimatePresence } from "framer-motion";
|
|
11
|
+
import { Overlay } from "@react-aria/overlays";
|
|
12
|
+
import { forwardRef } from "@sytechui/system";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
var Modal = forwardRef((props, ref) => {
|
|
15
|
+
const { children, ...otherProps } = props;
|
|
16
|
+
const context = useModal({ ...otherProps, ref });
|
|
17
|
+
const overlay = /* @__PURE__ */ jsx(Overlay, { portalContainer: context.portalContainer, children });
|
|
18
|
+
return /* @__PURE__ */ jsx(ModalProvider, { value: context, children: context.disableAnimation && context.isOpen ? overlay : /* @__PURE__ */ jsx(AnimatePresence, { children: context.isOpen ? overlay : null }) });
|
|
19
|
+
});
|
|
20
|
+
Modal.displayName = "HeroUI.Modal";
|
|
21
|
+
var modal_default = Modal;
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
modal_default
|
|
25
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/use-modal.ts
|
|
4
|
+
import { useAriaModalOverlay } from "@sytechui/use-aria-modal-overlay";
|
|
5
|
+
import { useCallback, useId, useRef, useState, useMemo } from "react";
|
|
6
|
+
import { modal, cn } from "@sytechui/theme";
|
|
7
|
+
import { mapPropsVariants, useProviderContext } from "@sytechui/system";
|
|
8
|
+
import { useAriaButton } from "@sytechui/use-aria-button";
|
|
9
|
+
import { useFocusRing } from "@react-aria/focus";
|
|
10
|
+
import { dataAttr, objectToDeps, mergeRefs, mergeProps } from "@sytechui/shared-utils";
|
|
11
|
+
import { useDOMRef } from "@sytechui/react-utils";
|
|
12
|
+
import { useOverlayTriggerState } from "@react-stately/overlays";
|
|
13
|
+
function useModal(originalProps) {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
const globalContext = useProviderContext();
|
|
16
|
+
const [props, variantProps] = mapPropsVariants(originalProps, modal.variantKeys);
|
|
17
|
+
const {
|
|
18
|
+
ref,
|
|
19
|
+
as,
|
|
20
|
+
className,
|
|
21
|
+
classNames,
|
|
22
|
+
isOpen,
|
|
23
|
+
defaultOpen,
|
|
24
|
+
onOpenChange,
|
|
25
|
+
motionProps,
|
|
26
|
+
closeButton,
|
|
27
|
+
isDismissable = true,
|
|
28
|
+
hideCloseButton = false,
|
|
29
|
+
shouldBlockScroll = true,
|
|
30
|
+
portalContainer,
|
|
31
|
+
isKeyboardDismissDisabled = false,
|
|
32
|
+
onClose,
|
|
33
|
+
...otherProps
|
|
34
|
+
} = props;
|
|
35
|
+
const Component = as || "section";
|
|
36
|
+
const domRef = useDOMRef(ref);
|
|
37
|
+
const closeButtonRef = useRef(null);
|
|
38
|
+
const [headerMounted, setHeaderMounted] = useState(false);
|
|
39
|
+
const [bodyMounted, setBodyMounted] = useState(false);
|
|
40
|
+
const disableAnimation = (_b = (_a = originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
|
|
41
|
+
const dialogId = useId();
|
|
42
|
+
const headerId = useId();
|
|
43
|
+
const bodyId = useId();
|
|
44
|
+
const state = useOverlayTriggerState({
|
|
45
|
+
isOpen,
|
|
46
|
+
defaultOpen,
|
|
47
|
+
onOpenChange: (isOpen2) => {
|
|
48
|
+
onOpenChange == null ? void 0 : onOpenChange(isOpen2);
|
|
49
|
+
if (!isOpen2) {
|
|
50
|
+
onClose == null ? void 0 : onClose();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const { modalProps, underlayProps } = useAriaModalOverlay(
|
|
55
|
+
{
|
|
56
|
+
isDismissable,
|
|
57
|
+
shouldBlockScroll,
|
|
58
|
+
isKeyboardDismissDisabled
|
|
59
|
+
},
|
|
60
|
+
state,
|
|
61
|
+
domRef
|
|
62
|
+
);
|
|
63
|
+
const { buttonProps: closeButtonProps } = useAriaButton({ onPress: state.close }, closeButtonRef);
|
|
64
|
+
const { isFocusVisible: isCloseButtonFocusVisible, focusProps: closeButtonFocusProps } = useFocusRing();
|
|
65
|
+
const baseStyles = cn(classNames == null ? void 0 : classNames.base, className);
|
|
66
|
+
const slots = useMemo(
|
|
67
|
+
() => modal({
|
|
68
|
+
...variantProps,
|
|
69
|
+
disableAnimation
|
|
70
|
+
}),
|
|
71
|
+
[objectToDeps(variantProps), disableAnimation]
|
|
72
|
+
);
|
|
73
|
+
const getDialogProps = (props2 = {}, ref2 = null) => {
|
|
74
|
+
var _a2;
|
|
75
|
+
return {
|
|
76
|
+
ref: mergeRefs(ref2, domRef),
|
|
77
|
+
...mergeProps(modalProps, otherProps, props2),
|
|
78
|
+
className: slots.base({ class: cn(baseStyles, props2.className) }),
|
|
79
|
+
id: dialogId,
|
|
80
|
+
"data-open": dataAttr(state.isOpen),
|
|
81
|
+
"data-dismissable": dataAttr(isDismissable),
|
|
82
|
+
"aria-modal": dataAttr(true),
|
|
83
|
+
"data-placement": (_a2 = originalProps == null ? void 0 : originalProps.placement) != null ? _a2 : "right",
|
|
84
|
+
"aria-labelledby": headerMounted ? headerId : void 0,
|
|
85
|
+
"aria-describedby": bodyMounted ? bodyId : void 0
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const getBackdropProps = useCallback(
|
|
89
|
+
(props2 = {}) => ({
|
|
90
|
+
className: slots.backdrop({ class: classNames == null ? void 0 : classNames.backdrop }),
|
|
91
|
+
...underlayProps,
|
|
92
|
+
...props2
|
|
93
|
+
}),
|
|
94
|
+
[slots, classNames, underlayProps]
|
|
95
|
+
);
|
|
96
|
+
const getCloseButtonProps = () => {
|
|
97
|
+
return {
|
|
98
|
+
role: "button",
|
|
99
|
+
tabIndex: 0,
|
|
100
|
+
"aria-label": "Close",
|
|
101
|
+
"data-focus-visible": dataAttr(isCloseButtonFocusVisible),
|
|
102
|
+
className: slots.closeButton({ class: classNames == null ? void 0 : classNames.closeButton }),
|
|
103
|
+
...mergeProps(closeButtonProps, closeButtonFocusProps)
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
Component,
|
|
108
|
+
slots,
|
|
109
|
+
domRef,
|
|
110
|
+
headerId,
|
|
111
|
+
bodyId,
|
|
112
|
+
motionProps,
|
|
113
|
+
classNames,
|
|
114
|
+
isDismissable,
|
|
115
|
+
closeButton,
|
|
116
|
+
hideCloseButton,
|
|
117
|
+
portalContainer,
|
|
118
|
+
shouldBlockScroll,
|
|
119
|
+
backdrop: (_c = originalProps.backdrop) != null ? _c : "opaque",
|
|
120
|
+
isOpen: state.isOpen,
|
|
121
|
+
onClose: state.close,
|
|
122
|
+
disableAnimation,
|
|
123
|
+
setBodyMounted,
|
|
124
|
+
setHeaderMounted,
|
|
125
|
+
getDialogProps,
|
|
126
|
+
getBackdropProps,
|
|
127
|
+
getCloseButtonProps
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
useModal
|
|
133
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/modal-transition.ts
|
|
4
|
+
import { TRANSITION_EASINGS } from "@sytechui/framer-utils";
|
|
5
|
+
var scaleInOut = {
|
|
6
|
+
enter: {
|
|
7
|
+
scale: "var(--scale-enter)",
|
|
8
|
+
y: "var(--slide-enter)",
|
|
9
|
+
opacity: 1,
|
|
10
|
+
willChange: "auto",
|
|
11
|
+
transition: {
|
|
12
|
+
scale: {
|
|
13
|
+
duration: 0.4,
|
|
14
|
+
ease: TRANSITION_EASINGS.ease
|
|
15
|
+
},
|
|
16
|
+
opacity: {
|
|
17
|
+
duration: 0.4,
|
|
18
|
+
ease: TRANSITION_EASINGS.ease
|
|
19
|
+
},
|
|
20
|
+
y: {
|
|
21
|
+
type: "spring",
|
|
22
|
+
bounce: 0,
|
|
23
|
+
duration: 0.6
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
exit: {
|
|
28
|
+
scale: "var(--scale-exit)",
|
|
29
|
+
y: "var(--slide-exit)",
|
|
30
|
+
opacity: 0,
|
|
31
|
+
willChange: "transform",
|
|
32
|
+
transition: {
|
|
33
|
+
duration: 0.3,
|
|
34
|
+
ease: TRANSITION_EASINGS.ease
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
scaleInOut
|
|
41
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/modal-context.ts
|
|
4
|
+
import { createContext } from "@sytechui/react-utils";
|
|
5
|
+
var [ModalProvider, useModalContext] = createContext({
|
|
6
|
+
name: "ModalContext",
|
|
7
|
+
errorMessage: "useModalContext: `context` is undefined. Seems you forgot to wrap all popover components within `<Modal />`"
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
ModalProvider,
|
|
12
|
+
useModalContext
|
|
13
|
+
};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { default as Modal, ModalProps } from './modal.mjs';
|
|
2
|
+
export { default as ModalContent, ModalContentProps } from './modal-content.mjs';
|
|
3
|
+
export { default as ModalHeader, ModalHeaderProps } from './modal-header.mjs';
|
|
4
|
+
export { default as ModalBody, ModalBodyProps } from './modal-body.mjs';
|
|
5
|
+
export { default as ModalFooter, ModalFooterProps } from './modal-footer.mjs';
|
|
6
|
+
export { UseDisclosureProps, useDisclosure } from '@sytechui/use-disclosure';
|
|
7
|
+
export { useModal } from './use-modal.mjs';
|
|
8
|
+
export { useDraggable } from '@sytechui/use-draggable';
|
|
9
|
+
export { ModalProvider, useModalContext } from './modal-context.mjs';
|
|
10
|
+
import '@sytechui/system';
|
|
11
|
+
import 'react';
|
|
12
|
+
import 'react/jsx-runtime';
|
|
13
|
+
import '@react-aria/dialog';
|
|
14
|
+
import '@sytechui/react-utils';
|
|
15
|
+
import 'tailwind-variants';
|
|
16
|
+
import '@sytechui/theme';
|
|
17
|
+
import 'framer-motion';
|
|
18
|
+
import '@react-aria/overlays';
|
|
19
|
+
import '@react-stately/overlays';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { default as Modal, ModalProps } from './modal.js';
|
|
2
|
+
export { default as ModalContent, ModalContentProps } from './modal-content.js';
|
|
3
|
+
export { default as ModalHeader, ModalHeaderProps } from './modal-header.js';
|
|
4
|
+
export { default as ModalBody, ModalBodyProps } from './modal-body.js';
|
|
5
|
+
export { default as ModalFooter, ModalFooterProps } from './modal-footer.js';
|
|
6
|
+
export { UseDisclosureProps, useDisclosure } from '@sytechui/use-disclosure';
|
|
7
|
+
export { useModal } from './use-modal.js';
|
|
8
|
+
export { useDraggable } from '@sytechui/use-draggable';
|
|
9
|
+
export { ModalProvider, useModalContext } from './modal-context.js';
|
|
10
|
+
import '@sytechui/system';
|
|
11
|
+
import 'react';
|
|
12
|
+
import 'react/jsx-runtime';
|
|
13
|
+
import '@react-aria/dialog';
|
|
14
|
+
import '@sytechui/react-utils';
|
|
15
|
+
import 'tailwind-variants';
|
|
16
|
+
import '@sytechui/theme';
|
|
17
|
+
import 'framer-motion';
|
|
18
|
+
import '@react-aria/overlays';
|
|
19
|
+
import '@react-stately/overlays';
|