@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
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
4
|
+
import * as _sytechui_system from '@sytechui/system';
|
|
5
|
+
import { HTMLHeroUIProps, PropGetter } from '@sytechui/system';
|
|
6
|
+
import { SlotsToClasses, ModalSlots, ModalVariantProps } from '@sytechui/theme';
|
|
7
|
+
import { HTMLMotionProps } from 'framer-motion';
|
|
8
|
+
import { AriaModalOverlayProps } from '@react-aria/overlays';
|
|
9
|
+
import { ReactRef } from '@sytechui/react-utils';
|
|
10
|
+
import { OverlayTriggerProps } from '@react-stately/overlays';
|
|
11
|
+
|
|
12
|
+
interface Props extends HTMLHeroUIProps<"section"> {
|
|
13
|
+
/**
|
|
14
|
+
* Ref to the DOM node.
|
|
15
|
+
*/
|
|
16
|
+
ref?: ReactRef<HTMLElement | null>;
|
|
17
|
+
/**
|
|
18
|
+
* The props to modify the framer motion animation. Use the `variants` API to create your own animation.
|
|
19
|
+
*/
|
|
20
|
+
motionProps?: Omit<HTMLMotionProps<"section">, "ref">;
|
|
21
|
+
/**
|
|
22
|
+
* Determines whether to hide the modal close button.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
hideCloseButton?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Custom modal close button element.
|
|
28
|
+
*/
|
|
29
|
+
closeButton?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the animation should be disabled.
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
disableAnimation?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The container element in which the overlay portal will be placed.
|
|
37
|
+
* @default document.body
|
|
38
|
+
*/
|
|
39
|
+
portalContainer?: Element;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the scroll should be blocked when the modal is open.
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
shouldBlockScroll?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Callback fired when the modal is closed.
|
|
47
|
+
*/
|
|
48
|
+
onClose?: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Classname or List of classes to change the classNames of the element.
|
|
51
|
+
* if `className` is passed, it will be added to the base slot.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* <Modal classNames={{
|
|
56
|
+
* wrapper: "wrapper-classes", // main modal wrapper
|
|
57
|
+
* backdrop: "backdrop-classes",
|
|
58
|
+
* base:"base-classes", // modal content wrapper
|
|
59
|
+
* header: "header-classes", // modal header
|
|
60
|
+
* body: "body-classes", // modal body
|
|
61
|
+
* footer: "footer-classes", // modal footer
|
|
62
|
+
* closeButton: "close-button-classes", // modal close button
|
|
63
|
+
* }} />
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
classNames?: SlotsToClasses<ModalSlots>;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to close the overlay when the user interacts outside it.
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
isDismissable?: boolean;
|
|
72
|
+
}
|
|
73
|
+
type UseModalProps = Props & OverlayTriggerProps & Omit<AriaModalOverlayProps, "isDismissable"> & ModalVariantProps;
|
|
74
|
+
declare function useModal(originalProps: UseModalProps): {
|
|
75
|
+
Component: _sytechui_system.As<any>;
|
|
76
|
+
slots: {
|
|
77
|
+
wrapper: (slotProps?: ({
|
|
78
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
79
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
80
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
81
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
82
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
83
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
84
|
+
disableAnimation?: boolean | undefined;
|
|
85
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
86
|
+
base: (slotProps?: ({
|
|
87
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
88
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
89
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
90
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
91
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
92
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
93
|
+
disableAnimation?: boolean | undefined;
|
|
94
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
95
|
+
backdrop: (slotProps?: ({
|
|
96
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
97
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
98
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
99
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
100
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
101
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
102
|
+
disableAnimation?: boolean | undefined;
|
|
103
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
104
|
+
header: (slotProps?: ({
|
|
105
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
106
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
107
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
108
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
109
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
110
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
111
|
+
disableAnimation?: boolean | undefined;
|
|
112
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
113
|
+
body: (slotProps?: ({
|
|
114
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
115
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
116
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
117
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
118
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
119
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
120
|
+
disableAnimation?: boolean | undefined;
|
|
121
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
122
|
+
footer: (slotProps?: ({
|
|
123
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
124
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
125
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
126
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
127
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
128
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
129
|
+
disableAnimation?: boolean | undefined;
|
|
130
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
131
|
+
closeButton: (slotProps?: ({
|
|
132
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
133
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
134
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
135
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
136
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
137
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
138
|
+
disableAnimation?: boolean | undefined;
|
|
139
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
140
|
+
} & {
|
|
141
|
+
wrapper: (slotProps?: ({
|
|
142
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
143
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
144
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
145
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
146
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
147
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
148
|
+
disableAnimation?: boolean | undefined;
|
|
149
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
150
|
+
base: (slotProps?: ({
|
|
151
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
152
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
153
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
154
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
155
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
156
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
157
|
+
disableAnimation?: boolean | undefined;
|
|
158
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
159
|
+
backdrop: (slotProps?: ({
|
|
160
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
161
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
162
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
163
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
164
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
165
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
166
|
+
disableAnimation?: boolean | undefined;
|
|
167
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
168
|
+
header: (slotProps?: ({
|
|
169
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
170
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
171
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
172
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
173
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
174
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
175
|
+
disableAnimation?: boolean | undefined;
|
|
176
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
177
|
+
body: (slotProps?: ({
|
|
178
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
179
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
180
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
181
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
182
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
183
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
184
|
+
disableAnimation?: boolean | undefined;
|
|
185
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
186
|
+
footer: (slotProps?: ({
|
|
187
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
188
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
189
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
190
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
191
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
192
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
193
|
+
disableAnimation?: boolean | undefined;
|
|
194
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
195
|
+
closeButton: (slotProps?: ({
|
|
196
|
+
size?: "md" | "lg" | "sm" | "xs" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "full" | undefined;
|
|
197
|
+
backdrop?: "opaque" | "blur" | "transparent" | undefined;
|
|
198
|
+
radius?: "md" | "lg" | "sm" | "none" | undefined;
|
|
199
|
+
shadow?: "md" | "lg" | "sm" | "none" | undefined;
|
|
200
|
+
placement?: "center" | "auto" | "top" | "top-center" | "bottom" | "bottom-center" | undefined;
|
|
201
|
+
scrollBehavior?: "normal" | "inside" | "outside" | undefined;
|
|
202
|
+
disableAnimation?: boolean | undefined;
|
|
203
|
+
} & tailwind_variants.ClassProp<tailwind_variants.ClassValue>) | undefined) => string;
|
|
204
|
+
} & {};
|
|
205
|
+
domRef: react.RefObject<HTMLElement>;
|
|
206
|
+
headerId: string;
|
|
207
|
+
bodyId: string;
|
|
208
|
+
motionProps: Omit<HTMLMotionProps<"section">, "ref"> | undefined;
|
|
209
|
+
classNames: SlotsToClasses<"base" | "body" | "footer" | "header" | "backdrop" | "wrapper" | "closeButton"> | undefined;
|
|
210
|
+
isDismissable: boolean;
|
|
211
|
+
closeButton: ReactNode;
|
|
212
|
+
hideCloseButton: boolean;
|
|
213
|
+
portalContainer: Element | undefined;
|
|
214
|
+
shouldBlockScroll: boolean;
|
|
215
|
+
backdrop: "opaque" | "blur" | "transparent";
|
|
216
|
+
isOpen: boolean;
|
|
217
|
+
onClose: () => void;
|
|
218
|
+
disableAnimation: boolean;
|
|
219
|
+
setBodyMounted: react.Dispatch<react.SetStateAction<boolean>>;
|
|
220
|
+
setHeaderMounted: react.Dispatch<react.SetStateAction<boolean>>;
|
|
221
|
+
getDialogProps: PropGetter;
|
|
222
|
+
getBackdropProps: PropGetter;
|
|
223
|
+
getCloseButtonProps: PropGetter;
|
|
224
|
+
};
|
|
225
|
+
type UseModalReturn = ReturnType<typeof useModal>;
|
|
226
|
+
|
|
227
|
+
export { type UseModalProps, type UseModalReturn, useModal };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/use-modal.ts
|
|
22
|
+
var use_modal_exports = {};
|
|
23
|
+
__export(use_modal_exports, {
|
|
24
|
+
useModal: () => useModal
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(use_modal_exports);
|
|
27
|
+
var import_use_aria_modal_overlay = require("@sytechui/use-aria-modal-overlay");
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_theme = require("@sytechui/theme");
|
|
30
|
+
var import_system = require("@sytechui/system");
|
|
31
|
+
var import_use_aria_button = require("@sytechui/use-aria-button");
|
|
32
|
+
var import_focus = require("@react-aria/focus");
|
|
33
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
34
|
+
var import_react_utils = require("@sytechui/react-utils");
|
|
35
|
+
var import_overlays = require("@react-stately/overlays");
|
|
36
|
+
function useModal(originalProps) {
|
|
37
|
+
var _a, _b, _c;
|
|
38
|
+
const globalContext = (0, import_system.useProviderContext)();
|
|
39
|
+
const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.modal.variantKeys);
|
|
40
|
+
const {
|
|
41
|
+
ref,
|
|
42
|
+
as,
|
|
43
|
+
className,
|
|
44
|
+
classNames,
|
|
45
|
+
isOpen,
|
|
46
|
+
defaultOpen,
|
|
47
|
+
onOpenChange,
|
|
48
|
+
motionProps,
|
|
49
|
+
closeButton,
|
|
50
|
+
isDismissable = true,
|
|
51
|
+
hideCloseButton = false,
|
|
52
|
+
shouldBlockScroll = true,
|
|
53
|
+
portalContainer,
|
|
54
|
+
isKeyboardDismissDisabled = false,
|
|
55
|
+
onClose,
|
|
56
|
+
...otherProps
|
|
57
|
+
} = props;
|
|
58
|
+
const Component = as || "section";
|
|
59
|
+
const domRef = (0, import_react_utils.useDOMRef)(ref);
|
|
60
|
+
const closeButtonRef = (0, import_react.useRef)(null);
|
|
61
|
+
const [headerMounted, setHeaderMounted] = (0, import_react.useState)(false);
|
|
62
|
+
const [bodyMounted, setBodyMounted] = (0, import_react.useState)(false);
|
|
63
|
+
const disableAnimation = (_b = (_a = originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
|
|
64
|
+
const dialogId = (0, import_react.useId)();
|
|
65
|
+
const headerId = (0, import_react.useId)();
|
|
66
|
+
const bodyId = (0, import_react.useId)();
|
|
67
|
+
const state = (0, import_overlays.useOverlayTriggerState)({
|
|
68
|
+
isOpen,
|
|
69
|
+
defaultOpen,
|
|
70
|
+
onOpenChange: (isOpen2) => {
|
|
71
|
+
onOpenChange == null ? void 0 : onOpenChange(isOpen2);
|
|
72
|
+
if (!isOpen2) {
|
|
73
|
+
onClose == null ? void 0 : onClose();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const { modalProps, underlayProps } = (0, import_use_aria_modal_overlay.useAriaModalOverlay)(
|
|
78
|
+
{
|
|
79
|
+
isDismissable,
|
|
80
|
+
shouldBlockScroll,
|
|
81
|
+
isKeyboardDismissDisabled
|
|
82
|
+
},
|
|
83
|
+
state,
|
|
84
|
+
domRef
|
|
85
|
+
);
|
|
86
|
+
const { buttonProps: closeButtonProps } = (0, import_use_aria_button.useAriaButton)({ onPress: state.close }, closeButtonRef);
|
|
87
|
+
const { isFocusVisible: isCloseButtonFocusVisible, focusProps: closeButtonFocusProps } = (0, import_focus.useFocusRing)();
|
|
88
|
+
const baseStyles = (0, import_theme.cn)(classNames == null ? void 0 : classNames.base, className);
|
|
89
|
+
const slots = (0, import_react.useMemo)(
|
|
90
|
+
() => (0, import_theme.modal)({
|
|
91
|
+
...variantProps,
|
|
92
|
+
disableAnimation
|
|
93
|
+
}),
|
|
94
|
+
[(0, import_shared_utils.objectToDeps)(variantProps), disableAnimation]
|
|
95
|
+
);
|
|
96
|
+
const getDialogProps = (props2 = {}, ref2 = null) => {
|
|
97
|
+
var _a2;
|
|
98
|
+
return {
|
|
99
|
+
ref: (0, import_shared_utils.mergeRefs)(ref2, domRef),
|
|
100
|
+
...(0, import_shared_utils.mergeProps)(modalProps, otherProps, props2),
|
|
101
|
+
className: slots.base({ class: (0, import_theme.cn)(baseStyles, props2.className) }),
|
|
102
|
+
id: dialogId,
|
|
103
|
+
"data-open": (0, import_shared_utils.dataAttr)(state.isOpen),
|
|
104
|
+
"data-dismissable": (0, import_shared_utils.dataAttr)(isDismissable),
|
|
105
|
+
"aria-modal": (0, import_shared_utils.dataAttr)(true),
|
|
106
|
+
"data-placement": (_a2 = originalProps == null ? void 0 : originalProps.placement) != null ? _a2 : "right",
|
|
107
|
+
"aria-labelledby": headerMounted ? headerId : void 0,
|
|
108
|
+
"aria-describedby": bodyMounted ? bodyId : void 0
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
const getBackdropProps = (0, import_react.useCallback)(
|
|
112
|
+
(props2 = {}) => ({
|
|
113
|
+
className: slots.backdrop({ class: classNames == null ? void 0 : classNames.backdrop }),
|
|
114
|
+
...underlayProps,
|
|
115
|
+
...props2
|
|
116
|
+
}),
|
|
117
|
+
[slots, classNames, underlayProps]
|
|
118
|
+
);
|
|
119
|
+
const getCloseButtonProps = () => {
|
|
120
|
+
return {
|
|
121
|
+
role: "button",
|
|
122
|
+
tabIndex: 0,
|
|
123
|
+
"aria-label": "Close",
|
|
124
|
+
"data-focus-visible": (0, import_shared_utils.dataAttr)(isCloseButtonFocusVisible),
|
|
125
|
+
className: slots.closeButton({ class: classNames == null ? void 0 : classNames.closeButton }),
|
|
126
|
+
...(0, import_shared_utils.mergeProps)(closeButtonProps, closeButtonFocusProps)
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
Component,
|
|
131
|
+
slots,
|
|
132
|
+
domRef,
|
|
133
|
+
headerId,
|
|
134
|
+
bodyId,
|
|
135
|
+
motionProps,
|
|
136
|
+
classNames,
|
|
137
|
+
isDismissable,
|
|
138
|
+
closeButton,
|
|
139
|
+
hideCloseButton,
|
|
140
|
+
portalContainer,
|
|
141
|
+
shouldBlockScroll,
|
|
142
|
+
backdrop: (_c = originalProps.backdrop) != null ? _c : "opaque",
|
|
143
|
+
isOpen: state.isOpen,
|
|
144
|
+
onClose: state.close,
|
|
145
|
+
disableAnimation,
|
|
146
|
+
setBodyMounted,
|
|
147
|
+
setHeaderMounted,
|
|
148
|
+
getDialogProps,
|
|
149
|
+
getBackdropProps,
|
|
150
|
+
getCloseButtonProps
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
154
|
+
0 && (module.exports = {
|
|
155
|
+
useModal
|
|
156
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sytechui/modal",
|
|
3
|
+
"version": "2.2.29",
|
|
4
|
+
"description": "Displays a dialog with a custom content that requires attention or provides additional information.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"modal"
|
|
7
|
+
],
|
|
8
|
+
"author": "HeroUI <support@heroui.com>",
|
|
9
|
+
"homepage": "https://heroui.com",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/heroui-inc/heroui.git",
|
|
22
|
+
"directory": "packages/components/modal"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/heroui-inc/heroui/issues"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": ">=18 || >=19.0.0-rc.0",
|
|
29
|
+
"react-dom": ">=18 || >=19.0.0-rc.0",
|
|
30
|
+
"framer-motion": ">=11.5.6 || >=12.0.0-alpha.1",
|
|
31
|
+
"@sytechui/theme": ">=2.4.24",
|
|
32
|
+
"@sytechui/system": ">=2.4.18"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@react-aria/dialog": "3.5.34",
|
|
36
|
+
"@react-aria/focus": "3.21.5",
|
|
37
|
+
"@react-aria/overlays": "3.31.2",
|
|
38
|
+
"@react-stately/overlays": "3.6.23",
|
|
39
|
+
"@sytechui/use-disclosure": "2.2.19",
|
|
40
|
+
"@sytechui/use-draggable": "2.1.20",
|
|
41
|
+
"@sytechui/use-aria-button": "2.2.22",
|
|
42
|
+
"@sytechui/use-viewport-size": "2.0.1",
|
|
43
|
+
"@sytechui/framer-utils": "2.1.28",
|
|
44
|
+
"@sytechui/shared-utils": "2.1.12",
|
|
45
|
+
"@sytechui/react-utils": "2.1.14",
|
|
46
|
+
"@sytechui/shared-icons": "2.1.10",
|
|
47
|
+
"@sytechui/use-aria-modal-overlay": "2.2.21",
|
|
48
|
+
"@sytechui/dom-animation": "2.1.10"
|
|
49
|
+
},
|
|
50
|
+
"clean-package": "../../../clean-package.config.json",
|
|
51
|
+
"module": "dist/index.mjs",
|
|
52
|
+
"types": "dist/index.d.ts",
|
|
53
|
+
"exports": {
|
|
54
|
+
".": {
|
|
55
|
+
"types": "./dist/index.d.ts",
|
|
56
|
+
"import": "./dist/index.mjs",
|
|
57
|
+
"require": "./dist/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./package.json": "./package.json"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsup src --dts",
|
|
63
|
+
"build:fast": "tsup src",
|
|
64
|
+
"dev": "pnpm build:fast --watch",
|
|
65
|
+
"clean": "rimraf dist .turbo",
|
|
66
|
+
"typecheck": "tsc --noEmit"
|
|
67
|
+
}
|
|
68
|
+
}
|