@saas-ui/modals 3.0.0-next.2 → 3.0.0-next.3
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/CHANGELOG.md +9 -0
- package/dist/_tsup-dts-rollup.d.cts +212 -0
- package/dist/_tsup-dts-rollup.d.ts +212 -0
- package/dist/index.cjs +10 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -182
- package/dist/index.d.ts +8 -182
- package/dist/index.js +10 -11
- package/dist/index.js.map +1 -1
- package/package.json +4 -16
package/CHANGELOG.md
CHANGED
@@ -0,0 +1,212 @@
|
|
1
|
+
import { AlertDialogProps as AlertDialogProps_2 } from './alert-dialog';
|
2
|
+
import { AlertDialogProps as AlertDialogProps_3 } from './alert-dialog.tsx';
|
3
|
+
import { ButtonProps } from '@chakra-ui/react';
|
4
|
+
import { Dialog } from '@saas-ui/react/dialog';
|
5
|
+
import { Drawer as Drawer_2 } from '@saas-ui/react/drawer';
|
6
|
+
import { DrawerProps as DrawerProps_2 } from './drawer';
|
7
|
+
import { FC } from 'react';
|
8
|
+
import { HTMLChakraProps } from '@chakra-ui/react';
|
9
|
+
import { JSX } from 'react/jsx-runtime';
|
10
|
+
import { MaybeRenderProp } from '@saas-ui/core/utils';
|
11
|
+
import { ModalProps as ModalProps_2 } from './modal';
|
12
|
+
import { ModalsContextValue } from '@saas-ui/modals-provider';
|
13
|
+
import { ModalsProviderProps } from '@saas-ui/modals-provider';
|
14
|
+
import * as React_2 from 'react';
|
15
|
+
|
16
|
+
declare const AlertDialog: React_2.FC<AlertDialogProps>;
|
17
|
+
export { AlertDialog }
|
18
|
+
export { AlertDialog as AlertDialog_alias_1 }
|
19
|
+
|
20
|
+
declare interface AlertDialogProps extends Omit<Dialog.RootProps, 'leastDestructiveRef' | 'onOpenChange' | 'open'> {
|
21
|
+
/**
|
22
|
+
* Whether the dialog is open
|
23
|
+
*/
|
24
|
+
open: boolean;
|
25
|
+
/**
|
26
|
+
* Callback when the dialog is opened or closed
|
27
|
+
*/
|
28
|
+
onOpenChange: (details: {
|
29
|
+
open: boolean;
|
30
|
+
}) => void;
|
31
|
+
/**
|
32
|
+
* The dialog title
|
33
|
+
*/
|
34
|
+
title?: React_2.ReactNode;
|
35
|
+
translations?: {
|
36
|
+
cancel?: React_2.ReactNode;
|
37
|
+
confirm?: React_2.ReactNode;
|
38
|
+
close?: React_2.ReactNode;
|
39
|
+
};
|
40
|
+
slotProps?: {
|
41
|
+
cancel?: ButtonProps;
|
42
|
+
confirm?: ButtonProps;
|
43
|
+
footer?: HTMLChakraProps<'div'>;
|
44
|
+
};
|
45
|
+
/**
|
46
|
+
* Close the dialog on cancel
|
47
|
+
* @default true
|
48
|
+
*/
|
49
|
+
closeOnCancel?: boolean;
|
50
|
+
/**
|
51
|
+
* Close the dialog on confirm
|
52
|
+
* @default true
|
53
|
+
*/
|
54
|
+
closeOnConfirm?: boolean;
|
55
|
+
/**
|
56
|
+
* Hide the backdrop
|
57
|
+
*/
|
58
|
+
backdrop?: boolean;
|
59
|
+
/**
|
60
|
+
* Hide the close button
|
61
|
+
*/
|
62
|
+
hideCloseButton?: boolean;
|
63
|
+
/**
|
64
|
+
* Defines which button gets initial focus
|
65
|
+
* https://www.w3.org/TR/wai-aria-practices/#alertdialog
|
66
|
+
*/
|
67
|
+
leastDestructiveFocus?: 'cancel' | 'confirm';
|
68
|
+
/**
|
69
|
+
* Function that's called when cancel is clicked
|
70
|
+
*/
|
71
|
+
onCancel?: () => void;
|
72
|
+
/**
|
73
|
+
* Function that's called when confirm is clicked.
|
74
|
+
*/
|
75
|
+
onConfirm?: () => Promise<void> | void;
|
76
|
+
}
|
77
|
+
export { AlertDialogProps }
|
78
|
+
export { AlertDialogProps as AlertDialogProps_alias_1 }
|
79
|
+
|
80
|
+
export declare const defaultModals: {
|
81
|
+
alert: FC<AlertDialogProps_2>;
|
82
|
+
confirm: FC<AlertDialogProps_2>;
|
83
|
+
drawer: FC<DrawerProps_2>;
|
84
|
+
modal: FC<ModalProps_2>;
|
85
|
+
};
|
86
|
+
|
87
|
+
declare const Drawer: React_2.FC<DrawerProps>;
|
88
|
+
export { Drawer }
|
89
|
+
export { Drawer as Drawer_alias_1 }
|
90
|
+
|
91
|
+
declare interface DrawerProps extends Omit<Drawer_2.RootProps, 'children'> {
|
92
|
+
/**
|
93
|
+
* The drawer title
|
94
|
+
*/
|
95
|
+
title: React_2.ReactNode;
|
96
|
+
/**
|
97
|
+
* Whether the modal is open
|
98
|
+
*/
|
99
|
+
open: boolean;
|
100
|
+
/**
|
101
|
+
* Callback when the drawer is opened or closed
|
102
|
+
*/
|
103
|
+
onOpenChange: (details: {
|
104
|
+
open: boolean;
|
105
|
+
}) => void;
|
106
|
+
/**
|
107
|
+
* The drawer children
|
108
|
+
*/
|
109
|
+
children: MaybeRenderProp<{
|
110
|
+
open: boolean;
|
111
|
+
setOpen: (open: boolean) => void;
|
112
|
+
}>;
|
113
|
+
/**
|
114
|
+
* The modal footer
|
115
|
+
*/
|
116
|
+
footer?: React_2.ReactNode;
|
117
|
+
/**
|
118
|
+
* Hide the close button
|
119
|
+
*/
|
120
|
+
hideCloseButton?: boolean;
|
121
|
+
/**
|
122
|
+
* Hide the backdrop
|
123
|
+
*/
|
124
|
+
hideBackdrop?: boolean;
|
125
|
+
/**
|
126
|
+
* Props for the modal header
|
127
|
+
*/
|
128
|
+
headerProps?: HTMLChakraProps<'div'>;
|
129
|
+
/**
|
130
|
+
* Props for the modal content
|
131
|
+
*/
|
132
|
+
contentProps?: Drawer_2.ContentProps;
|
133
|
+
/**
|
134
|
+
* Props for the modal footer
|
135
|
+
*/
|
136
|
+
footerProps?: HTMLChakraProps<'div'>;
|
137
|
+
/**
|
138
|
+
* Props for the modal body
|
139
|
+
*/
|
140
|
+
bodyProps?: HTMLChakraProps<'div'>;
|
141
|
+
}
|
142
|
+
export { DrawerProps }
|
143
|
+
export { DrawerProps as DrawerProps_alias_1 }
|
144
|
+
|
145
|
+
declare const Modal: React_2.FC<ModalProps>;
|
146
|
+
export { Modal }
|
147
|
+
export { Modal as Modal_alias_1 }
|
148
|
+
|
149
|
+
declare interface ModalProps extends Omit<Dialog.RootProps, 'children'> {
|
150
|
+
/**
|
151
|
+
* The modal title
|
152
|
+
*/
|
153
|
+
title?: React_2.ReactNode;
|
154
|
+
/**
|
155
|
+
* Whether the modal is open
|
156
|
+
*/
|
157
|
+
open: boolean;
|
158
|
+
/**
|
159
|
+
* Callback when the modal is opened or closed
|
160
|
+
*/
|
161
|
+
onOpenChange: (details: {
|
162
|
+
open: boolean;
|
163
|
+
}) => void;
|
164
|
+
/**
|
165
|
+
* The modal children
|
166
|
+
*/
|
167
|
+
children: MaybeRenderProp<{
|
168
|
+
open: boolean;
|
169
|
+
setOpen: (open: boolean) => void;
|
170
|
+
}>;
|
171
|
+
/**
|
172
|
+
* The modal footer
|
173
|
+
*/
|
174
|
+
footer?: React_2.ReactNode;
|
175
|
+
/**
|
176
|
+
* Hide the close button
|
177
|
+
*/
|
178
|
+
hideCloseButton?: boolean;
|
179
|
+
/**
|
180
|
+
* Hide the overlay
|
181
|
+
*/
|
182
|
+
hideBackdrop?: boolean;
|
183
|
+
/**
|
184
|
+
* Props for the modal header
|
185
|
+
*/
|
186
|
+
headerProps?: HTMLChakraProps<'div'>;
|
187
|
+
/**
|
188
|
+
* Props for the modal content
|
189
|
+
*/
|
190
|
+
contentProps?: HTMLChakraProps<'div'>;
|
191
|
+
/**
|
192
|
+
* Props for the modal body
|
193
|
+
*/
|
194
|
+
bodyProps?: HTMLChakraProps<'div'>;
|
195
|
+
/**
|
196
|
+
* Props for the modal footer
|
197
|
+
*/
|
198
|
+
footerProps?: HTMLChakraProps<'div'>;
|
199
|
+
}
|
200
|
+
export { ModalProps }
|
201
|
+
export { ModalProps as ModalProps_alias_1 }
|
202
|
+
|
203
|
+
export declare const ModalsProvider: (props: Omit<ModalsProviderProps, "modals">) => JSX.Element;
|
204
|
+
|
205
|
+
export declare const useModals: () => ModalsContextValue< {
|
206
|
+
alert: FC<AlertDialogProps_3>;
|
207
|
+
confirm: FC<AlertDialogProps_3>;
|
208
|
+
drawer: FC<DrawerProps_2>;
|
209
|
+
modal: FC<ModalProps_2>;
|
210
|
+
}, "modal" | "alert" | "drawer" | "confirm">;
|
211
|
+
|
212
|
+
export { }
|
@@ -0,0 +1,212 @@
|
|
1
|
+
import { AlertDialogProps as AlertDialogProps_2 } from './alert-dialog';
|
2
|
+
import { AlertDialogProps as AlertDialogProps_3 } from './alert-dialog.tsx';
|
3
|
+
import { ButtonProps } from '@chakra-ui/react';
|
4
|
+
import { Dialog } from '@saas-ui/react/dialog';
|
5
|
+
import { Drawer as Drawer_2 } from '@saas-ui/react/drawer';
|
6
|
+
import { DrawerProps as DrawerProps_2 } from './drawer';
|
7
|
+
import { FC } from 'react';
|
8
|
+
import { HTMLChakraProps } from '@chakra-ui/react';
|
9
|
+
import { JSX } from 'react/jsx-runtime';
|
10
|
+
import { MaybeRenderProp } from '@saas-ui/core/utils';
|
11
|
+
import { ModalProps as ModalProps_2 } from './modal';
|
12
|
+
import { ModalsContextValue } from '@saas-ui/modals-provider';
|
13
|
+
import { ModalsProviderProps } from '@saas-ui/modals-provider';
|
14
|
+
import * as React_2 from 'react';
|
15
|
+
|
16
|
+
declare const AlertDialog: React_2.FC<AlertDialogProps>;
|
17
|
+
export { AlertDialog }
|
18
|
+
export { AlertDialog as AlertDialog_alias_1 }
|
19
|
+
|
20
|
+
declare interface AlertDialogProps extends Omit<Dialog.RootProps, 'leastDestructiveRef' | 'onOpenChange' | 'open'> {
|
21
|
+
/**
|
22
|
+
* Whether the dialog is open
|
23
|
+
*/
|
24
|
+
open: boolean;
|
25
|
+
/**
|
26
|
+
* Callback when the dialog is opened or closed
|
27
|
+
*/
|
28
|
+
onOpenChange: (details: {
|
29
|
+
open: boolean;
|
30
|
+
}) => void;
|
31
|
+
/**
|
32
|
+
* The dialog title
|
33
|
+
*/
|
34
|
+
title?: React_2.ReactNode;
|
35
|
+
translations?: {
|
36
|
+
cancel?: React_2.ReactNode;
|
37
|
+
confirm?: React_2.ReactNode;
|
38
|
+
close?: React_2.ReactNode;
|
39
|
+
};
|
40
|
+
slotProps?: {
|
41
|
+
cancel?: ButtonProps;
|
42
|
+
confirm?: ButtonProps;
|
43
|
+
footer?: HTMLChakraProps<'div'>;
|
44
|
+
};
|
45
|
+
/**
|
46
|
+
* Close the dialog on cancel
|
47
|
+
* @default true
|
48
|
+
*/
|
49
|
+
closeOnCancel?: boolean;
|
50
|
+
/**
|
51
|
+
* Close the dialog on confirm
|
52
|
+
* @default true
|
53
|
+
*/
|
54
|
+
closeOnConfirm?: boolean;
|
55
|
+
/**
|
56
|
+
* Hide the backdrop
|
57
|
+
*/
|
58
|
+
backdrop?: boolean;
|
59
|
+
/**
|
60
|
+
* Hide the close button
|
61
|
+
*/
|
62
|
+
hideCloseButton?: boolean;
|
63
|
+
/**
|
64
|
+
* Defines which button gets initial focus
|
65
|
+
* https://www.w3.org/TR/wai-aria-practices/#alertdialog
|
66
|
+
*/
|
67
|
+
leastDestructiveFocus?: 'cancel' | 'confirm';
|
68
|
+
/**
|
69
|
+
* Function that's called when cancel is clicked
|
70
|
+
*/
|
71
|
+
onCancel?: () => void;
|
72
|
+
/**
|
73
|
+
* Function that's called when confirm is clicked.
|
74
|
+
*/
|
75
|
+
onConfirm?: () => Promise<void> | void;
|
76
|
+
}
|
77
|
+
export { AlertDialogProps }
|
78
|
+
export { AlertDialogProps as AlertDialogProps_alias_1 }
|
79
|
+
|
80
|
+
export declare const defaultModals: {
|
81
|
+
alert: FC<AlertDialogProps_2>;
|
82
|
+
confirm: FC<AlertDialogProps_2>;
|
83
|
+
drawer: FC<DrawerProps_2>;
|
84
|
+
modal: FC<ModalProps_2>;
|
85
|
+
};
|
86
|
+
|
87
|
+
declare const Drawer: React_2.FC<DrawerProps>;
|
88
|
+
export { Drawer }
|
89
|
+
export { Drawer as Drawer_alias_1 }
|
90
|
+
|
91
|
+
declare interface DrawerProps extends Omit<Drawer_2.RootProps, 'children'> {
|
92
|
+
/**
|
93
|
+
* The drawer title
|
94
|
+
*/
|
95
|
+
title: React_2.ReactNode;
|
96
|
+
/**
|
97
|
+
* Whether the modal is open
|
98
|
+
*/
|
99
|
+
open: boolean;
|
100
|
+
/**
|
101
|
+
* Callback when the drawer is opened or closed
|
102
|
+
*/
|
103
|
+
onOpenChange: (details: {
|
104
|
+
open: boolean;
|
105
|
+
}) => void;
|
106
|
+
/**
|
107
|
+
* The drawer children
|
108
|
+
*/
|
109
|
+
children: MaybeRenderProp<{
|
110
|
+
open: boolean;
|
111
|
+
setOpen: (open: boolean) => void;
|
112
|
+
}>;
|
113
|
+
/**
|
114
|
+
* The modal footer
|
115
|
+
*/
|
116
|
+
footer?: React_2.ReactNode;
|
117
|
+
/**
|
118
|
+
* Hide the close button
|
119
|
+
*/
|
120
|
+
hideCloseButton?: boolean;
|
121
|
+
/**
|
122
|
+
* Hide the backdrop
|
123
|
+
*/
|
124
|
+
hideBackdrop?: boolean;
|
125
|
+
/**
|
126
|
+
* Props for the modal header
|
127
|
+
*/
|
128
|
+
headerProps?: HTMLChakraProps<'div'>;
|
129
|
+
/**
|
130
|
+
* Props for the modal content
|
131
|
+
*/
|
132
|
+
contentProps?: Drawer_2.ContentProps;
|
133
|
+
/**
|
134
|
+
* Props for the modal footer
|
135
|
+
*/
|
136
|
+
footerProps?: HTMLChakraProps<'div'>;
|
137
|
+
/**
|
138
|
+
* Props for the modal body
|
139
|
+
*/
|
140
|
+
bodyProps?: HTMLChakraProps<'div'>;
|
141
|
+
}
|
142
|
+
export { DrawerProps }
|
143
|
+
export { DrawerProps as DrawerProps_alias_1 }
|
144
|
+
|
145
|
+
declare const Modal: React_2.FC<ModalProps>;
|
146
|
+
export { Modal }
|
147
|
+
export { Modal as Modal_alias_1 }
|
148
|
+
|
149
|
+
declare interface ModalProps extends Omit<Dialog.RootProps, 'children'> {
|
150
|
+
/**
|
151
|
+
* The modal title
|
152
|
+
*/
|
153
|
+
title?: React_2.ReactNode;
|
154
|
+
/**
|
155
|
+
* Whether the modal is open
|
156
|
+
*/
|
157
|
+
open: boolean;
|
158
|
+
/**
|
159
|
+
* Callback when the modal is opened or closed
|
160
|
+
*/
|
161
|
+
onOpenChange: (details: {
|
162
|
+
open: boolean;
|
163
|
+
}) => void;
|
164
|
+
/**
|
165
|
+
* The modal children
|
166
|
+
*/
|
167
|
+
children: MaybeRenderProp<{
|
168
|
+
open: boolean;
|
169
|
+
setOpen: (open: boolean) => void;
|
170
|
+
}>;
|
171
|
+
/**
|
172
|
+
* The modal footer
|
173
|
+
*/
|
174
|
+
footer?: React_2.ReactNode;
|
175
|
+
/**
|
176
|
+
* Hide the close button
|
177
|
+
*/
|
178
|
+
hideCloseButton?: boolean;
|
179
|
+
/**
|
180
|
+
* Hide the overlay
|
181
|
+
*/
|
182
|
+
hideBackdrop?: boolean;
|
183
|
+
/**
|
184
|
+
* Props for the modal header
|
185
|
+
*/
|
186
|
+
headerProps?: HTMLChakraProps<'div'>;
|
187
|
+
/**
|
188
|
+
* Props for the modal content
|
189
|
+
*/
|
190
|
+
contentProps?: HTMLChakraProps<'div'>;
|
191
|
+
/**
|
192
|
+
* Props for the modal body
|
193
|
+
*/
|
194
|
+
bodyProps?: HTMLChakraProps<'div'>;
|
195
|
+
/**
|
196
|
+
* Props for the modal footer
|
197
|
+
*/
|
198
|
+
footerProps?: HTMLChakraProps<'div'>;
|
199
|
+
}
|
200
|
+
export { ModalProps }
|
201
|
+
export { ModalProps as ModalProps_alias_1 }
|
202
|
+
|
203
|
+
export declare const ModalsProvider: (props: Omit<ModalsProviderProps, "modals">) => JSX.Element;
|
204
|
+
|
205
|
+
export declare const useModals: () => ModalsContextValue< {
|
206
|
+
alert: FC<AlertDialogProps_3>;
|
207
|
+
confirm: FC<AlertDialogProps_3>;
|
208
|
+
drawer: FC<DrawerProps_2>;
|
209
|
+
modal: FC<ModalProps_2>;
|
210
|
+
}, "modal" | "alert" | "drawer" | "confirm">;
|
211
|
+
|
212
|
+
export { }
|
package/dist/index.cjs
CHANGED
@@ -47,7 +47,6 @@ var import_utils = require("@saas-ui/core/utils");
|
|
47
47
|
var import_dialog = require("@saas-ui/react/dialog");
|
48
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
49
49
|
var AlertDialog = (props) => {
|
50
|
-
var _a, _b, _c, _d;
|
51
50
|
const {
|
52
51
|
title,
|
53
52
|
translations,
|
@@ -67,8 +66,8 @@ var AlertDialog = (props) => {
|
|
67
66
|
const [isLoading, setIsLoading] = React.useState(false);
|
68
67
|
const handleConfirm = async () => {
|
69
68
|
try {
|
70
|
-
const result = onConfirm
|
71
|
-
if (typeof
|
69
|
+
const result = onConfirm?.();
|
70
|
+
if (typeof result?.then === "function") {
|
72
71
|
setIsLoading(true);
|
73
72
|
await result;
|
74
73
|
}
|
@@ -94,19 +93,19 @@ var AlertDialog = (props) => {
|
|
94
93
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog.Content, { children: [
|
95
94
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Title, { id: titleId, children: title }) }),
|
96
95
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog.Body, { id: contentId, children }),
|
97
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog.Footer, { ...slotProps
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.Dialog.Footer, { ...slotProps?.footer, children: [
|
98
97
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
99
98
|
import_react.Button,
|
100
99
|
{
|
101
100
|
ref: cancelRef,
|
102
101
|
variant: "ghost",
|
103
102
|
colorPalette: "gray",
|
104
|
-
...slotProps
|
105
|
-
onClick: (0, import_utils.callAll)(
|
106
|
-
onCancel
|
103
|
+
...slotProps?.cancel,
|
104
|
+
onClick: (0, import_utils.callAll)(slotProps?.cancel?.onClick, () => {
|
105
|
+
onCancel?.();
|
107
106
|
closeOnCancel && onOpenChange({ open: false });
|
108
107
|
}),
|
109
|
-
children:
|
108
|
+
children: slotProps?.cancel?.children || translations?.cancel || "Cancel"
|
110
109
|
}
|
111
110
|
),
|
112
111
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
@@ -115,9 +114,9 @@ var AlertDialog = (props) => {
|
|
115
114
|
ref: confirmRef,
|
116
115
|
variant: "solid",
|
117
116
|
disabled: isLoading,
|
118
|
-
...slotProps
|
119
|
-
onClick: (0, import_utils.callAll)(handleConfirm,
|
120
|
-
children:
|
117
|
+
...slotProps?.confirm,
|
118
|
+
onClick: (0, import_utils.callAll)(handleConfirm, slotProps?.confirm?.onClick),
|
119
|
+
children: slotProps?.confirm?.children || translations?.confirm || "OK"
|
121
120
|
}
|
122
121
|
)
|
123
122
|
] })
|
package/dist/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/alert-dialog.tsx","../src/drawer.tsx","../src/modal.tsx","../src/default-modals.ts"],"sourcesContent":["import { createModals } from '@saas-ui/modals-provider'\n\nimport { defaultModals } from './default-modals.ts'\n\n// Exporting from './dialog'\nexport { AlertDialog } from './alert-dialog.tsx'\nexport type { AlertDialogProps } from './alert-dialog.tsx'\n\n// Exporting from './drawer'\nexport { Drawer } from './drawer'\nexport type { DrawerProps } from './drawer'\n\n// Exporting from './modal'\nexport { Modal } from './modal'\nexport type { ModalProps } from './modal'\n\n// Exporting from './form'\n// export { FormDialog, createFormDialog } from './form'\n// export type {\n// DefaultFormType,\n// FormDialogFieldOverrides,\n// FormDialogProps,\n// } from './form'\n\n// Exporting from './provider'\n\nconst { useModals, ModalsProvider } = createModals({\n modals: defaultModals,\n})\n\nexport { ModalsProvider, useModals }\n","import * as React from 'react'\n\nimport { Button, ButtonProps, type HTMLChakraProps } from '@chakra-ui/react'\nimport { callAll } from '@saas-ui/core/utils'\nimport { Dialog } from '@saas-ui/react/dialog'\n\nexport interface AlertDialogProps\n extends Omit<\n Dialog.RootProps,\n 'leastDestructiveRef' | 'onOpenChange' | 'open'\n > {\n /**\n * Whether the dialog is open\n */\n open: boolean\n /**\n * Callback when the dialog is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The dialog title\n */\n title?: React.ReactNode\n translations?: {\n cancel?: React.ReactNode\n confirm?: React.ReactNode\n close?: React.ReactNode\n }\n slotProps?: {\n cancel?: ButtonProps\n confirm?: ButtonProps\n footer?: HTMLChakraProps<'div'>\n }\n /**\n * Close the dialog on cancel\n * @default true\n */\n closeOnCancel?: boolean\n /**\n * Close the dialog on confirm\n * @default true\n */\n closeOnConfirm?: boolean\n /**\n * Hide the backdrop\n */\n backdrop?: boolean\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Defines which button gets initial focus\n * https://www.w3.org/TR/wai-aria-practices/#alertdialog\n */\n leastDestructiveFocus?: 'cancel' | 'confirm'\n /**\n * Function that's called when cancel is clicked\n */\n onCancel?: () => void\n /**\n * Function that's called when confirm is clicked.\n */\n onConfirm?: () => Promise<void> | void\n}\n\nexport const AlertDialog: React.FC<AlertDialogProps> = (props) => {\n const {\n title,\n translations,\n slotProps,\n open,\n closeOnCancel = true,\n closeOnConfirm = true,\n leastDestructiveFocus = 'cancel',\n onOpenChange,\n onCancel,\n onConfirm,\n children,\n ...rest\n } = props\n\n const cancelRef = React.useRef(null)\n const confirmRef = React.useRef(null)\n const [isLoading, setIsLoading] = React.useState(false)\n\n const handleConfirm = async () => {\n try {\n const result = onConfirm?.()\n if (typeof result?.then === 'function') {\n setIsLoading(true)\n await result\n }\n\n closeOnConfirm && onOpenChange({ open: false })\n /* eslint-disable no-useless-catch */\n } catch (e: any) {\n throw e\n } finally {\n setIsLoading(false)\n }\n /* eslint-enable */\n }\n\n const titleId = React.useId()\n const contentId = React.useId()\n\n return (\n <Dialog.Root\n open={open}\n onOpenChange={onOpenChange}\n size=\"sm\"\n aria-labelledby={titleId}\n aria-describedby={contentId}\n {...rest}\n initialFocusEl={() =>\n leastDestructiveFocus === 'cancel'\n ? cancelRef.current\n : confirmRef.current\n }\n >\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title id={titleId}>{title}</Dialog.Title>\n </Dialog.Header>\n\n <Dialog.Body id={contentId}>{children}</Dialog.Body>\n\n <Dialog.Footer {...slotProps?.footer}>\n <Button\n ref={cancelRef}\n variant=\"ghost\"\n colorPalette=\"gray\"\n {...slotProps?.cancel}\n onClick={callAll(slotProps?.cancel?.onClick, () => {\n onCancel?.()\n\n closeOnCancel && onOpenChange({ open: false })\n })}\n >\n {slotProps?.cancel?.children || translations?.cancel || 'Cancel'}\n </Button>\n <Button\n ref={confirmRef}\n variant=\"solid\"\n disabled={isLoading}\n {...slotProps?.confirm}\n onClick={callAll(handleConfirm, slotProps?.confirm?.onClick)}\n >\n {slotProps?.confirm?.children || translations?.confirm || 'OK'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog.Root>\n )\n}\n","import * as React from 'react'\n\nimport { type HTMLChakraProps } from '@chakra-ui/react'\nimport { MaybeRenderProp, runIfFn } from '@saas-ui/core/utils'\nimport { Drawer as BaseDrawer } from '@saas-ui/react/drawer'\n\nexport interface DrawerProps extends Omit<BaseDrawer.RootProps, 'children'> {\n /**\n * The drawer title\n */\n title: React.ReactNode\n /**\n * Whether the modal is open\n */\n open: boolean\n /**\n * Callback when the drawer is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The drawer children\n */\n children: MaybeRenderProp<{\n open: boolean\n setOpen: (open: boolean) => void\n }>\n /**\n * The modal footer\n */\n footer?: React.ReactNode\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Hide the backdrop\n */\n hideBackdrop?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal content\n */\n contentProps?: BaseDrawer.ContentProps\n /**\n * Props for the modal footer\n */\n footerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal body\n */\n bodyProps?: HTMLChakraProps<'div'>\n}\n\nexport const Drawer: React.FC<DrawerProps> = (props) => {\n const {\n title,\n children,\n footer,\n open,\n onOpenChange,\n hideCloseButton,\n hideBackdrop,\n headerProps,\n contentProps,\n bodyProps,\n footerProps,\n ...rest\n } = props\n return (\n <BaseDrawer.Root open={open} onOpenChange={onOpenChange} {...rest}>\n {!hideBackdrop && <BaseDrawer.Backdrop />}\n <BaseDrawer.Content {...contentProps}>\n {title && (\n <BaseDrawer.Header {...headerProps}>{title}</BaseDrawer.Header>\n )}\n {!hideCloseButton && <BaseDrawer.CloseButton />}\n <BaseDrawer.Body {...bodyProps}>\n <BaseDrawer.Context>\n {({ open, setOpen }) => runIfFn(children, { open, setOpen })}\n </BaseDrawer.Context>\n </BaseDrawer.Body>\n {footer && (\n <BaseDrawer.Footer {...footerProps}>{footer}</BaseDrawer.Footer>\n )}\n </BaseDrawer.Content>\n </BaseDrawer.Root>\n )\n}\n","import * as React from 'react'\n\nimport type { HTMLChakraProps } from '@chakra-ui/react'\nimport { MaybeRenderProp, runIfFn } from '@saas-ui/core/utils'\nimport { Dialog as BaseDialog } from '@saas-ui/react/dialog'\n\nexport interface ModalProps extends Omit<BaseDialog.RootProps, 'children'> {\n /**\n * The modal title\n */\n title?: React.ReactNode\n /**\n * Whether the modal is open\n */\n open: boolean\n /**\n * Callback when the modal is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The modal children\n */\n children: MaybeRenderProp<{\n open: boolean\n setOpen: (open: boolean) => void\n }>\n /**\n * The modal footer\n */\n footer?: React.ReactNode\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Hide the overlay\n */\n hideBackdrop?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal content\n */\n contentProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal body\n */\n bodyProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal footer\n */\n footerProps?: HTMLChakraProps<'div'>\n}\n\nexport const Modal: React.FC<ModalProps> = (props) => {\n const {\n title,\n footer,\n children,\n open,\n onOpenChange,\n hideCloseButton,\n hideBackdrop,\n headerProps,\n contentProps,\n bodyProps,\n footerProps,\n ...rest\n } = props\n return (\n <BaseDialog.Root open={open} onOpenChange={onOpenChange} {...rest}>\n <BaseDialog.Content {...contentProps}>\n {title && (\n <BaseDialog.Header {...headerProps}>{title}</BaseDialog.Header>\n )}\n {!hideCloseButton && <BaseDialog.CloseButton />}\n <BaseDialog.Body>\n <BaseDialog.Context>\n {({ open, setOpen }) => runIfFn(children, { open, setOpen })}\n </BaseDialog.Context>\n </BaseDialog.Body>\n {footer && (\n <BaseDialog.Footer {...footerProps}>{footer}</BaseDialog.Footer>\n )}\n </BaseDialog.Content>\n </BaseDialog.Root>\n )\n}\n","import { AlertDialog } from './alert-dialog'\nimport { Drawer } from './drawer'\nimport { Modal } from './modal'\n\nexport const defaultModals = {\n alert: AlertDialog,\n confirm: AlertDialog,\n drawer: Drawer,\n modal: Modal,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA6B;;;ACA7B,YAAuB;AAEvB,mBAA0D;AAC1D,mBAAwB;AACxB,oBAAuB;AAuHb;AAzDH,IAAM,cAA0C,CAAC,UAAU;AAlElE;AAmEE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,wBAAwB;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,YAAkB,aAAO,IAAI;AACnC,QAAM,aAAmB,aAAO,IAAI;AACpC,Q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,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,SACE,6CAAC,eAAAC,OAAW,MAAX,EAAgB,MAAY,cAA6B,GAAG,MAC3D,wDAAC,eAAAA,OAAW,SAAX,EAAoB,GAAG,cACrB;AAAA,aACC,6CAAC,eAAAA,OAAW,QAAX,EAAmB,GAAG,aAAc,iBAAM;AAAA,IAE5C,CAAC,mBAAmB,6CAAC,eAAAA,OAAW,aAAX,EAAuB;AAAA,IAC7C,6CAAC,eAAAA,OAAW,MAAX,EACC,uDAAC,eAAAA,OAAW,SAAX,EACE,WAAC,EAAE,MAAAC,OAAM,QAAQ,UAAM,uBAAQ,UAAU,EAAE,MAAAA,OAAM,QAAQ,CAAC,GAC7D,GACF;AAAA,IACC,UACC,6CAAC,eAAAD,OAAW,QAAX,EAAmB,GAAG,aAAc,kBAAO;AAAA,KAEhD,GACF;AAEJ;;;ACrFO,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AACT;;;AJiBA,IAAM,EAAE,WAAW,eAAe,QAAI,qCAAa;AAAA,EACjD,QAAQ;AACV,CAAC;","names":["import_utils","import_jsx_runtime","BaseDrawer","open","import_utils","import_dialog","import_jsx_runtime","BaseDialog","open"]}
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/alert-dialog.tsx","../src/drawer.tsx","../src/modal.tsx","../src/default-modals.ts"],"sourcesContent":["import { createModals } from '@saas-ui/modals-provider'\n\nimport { defaultModals } from './default-modals.ts'\n\n// Exporting from './dialog'\nexport { AlertDialog } from './alert-dialog.tsx'\nexport type { AlertDialogProps } from './alert-dialog.tsx'\n\n// Exporting from './drawer'\nexport { Drawer } from './drawer'\nexport type { DrawerProps } from './drawer'\n\n// Exporting from './modal'\nexport { Modal } from './modal'\nexport type { ModalProps } from './modal'\n\nconst { useModals, ModalsProvider } = createModals({\n modals: defaultModals,\n})\n\nexport { ModalsProvider, useModals }\n","import * as React from 'react'\n\nimport { Button, ButtonProps, type HTMLChakraProps } from '@chakra-ui/react'\nimport { callAll } from '@saas-ui/core/utils'\nimport { Dialog } from '@saas-ui/react/dialog'\n\nexport interface AlertDialogProps\n extends Omit<\n Dialog.RootProps,\n 'leastDestructiveRef' | 'onOpenChange' | 'open'\n > {\n /**\n * Whether the dialog is open\n */\n open: boolean\n /**\n * Callback when the dialog is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The dialog title\n */\n title?: React.ReactNode\n translations?: {\n cancel?: React.ReactNode\n confirm?: React.ReactNode\n close?: React.ReactNode\n }\n slotProps?: {\n cancel?: ButtonProps\n confirm?: ButtonProps\n footer?: HTMLChakraProps<'div'>\n }\n /**\n * Close the dialog on cancel\n * @default true\n */\n closeOnCancel?: boolean\n /**\n * Close the dialog on confirm\n * @default true\n */\n closeOnConfirm?: boolean\n /**\n * Hide the backdrop\n */\n backdrop?: boolean\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Defines which button gets initial focus\n * https://www.w3.org/TR/wai-aria-practices/#alertdialog\n */\n leastDestructiveFocus?: 'cancel' | 'confirm'\n /**\n * Function that's called when cancel is clicked\n */\n onCancel?: () => void\n /**\n * Function that's called when confirm is clicked.\n */\n onConfirm?: () => Promise<void> | void\n}\n\nexport const AlertDialog: React.FC<AlertDialogProps> = (props) => {\n const {\n title,\n translations,\n slotProps,\n open,\n closeOnCancel = true,\n closeOnConfirm = true,\n leastDestructiveFocus = 'cancel',\n onOpenChange,\n onCancel,\n onConfirm,\n children,\n ...rest\n } = props\n\n const cancelRef = React.useRef(null)\n const confirmRef = React.useRef(null)\n const [isLoading, setIsLoading] = React.useState(false)\n\n const handleConfirm = async () => {\n try {\n const result = onConfirm?.()\n if (typeof result?.then === 'function') {\n setIsLoading(true)\n await result\n }\n\n closeOnConfirm && onOpenChange({ open: false })\n /* eslint-disable no-useless-catch */\n } catch (e: any) {\n throw e\n } finally {\n setIsLoading(false)\n }\n /* eslint-enable */\n }\n\n const titleId = React.useId()\n const contentId = React.useId()\n\n return (\n <Dialog.Root\n open={open}\n onOpenChange={onOpenChange}\n size=\"sm\"\n aria-labelledby={titleId}\n aria-describedby={contentId}\n {...rest}\n initialFocusEl={() =>\n leastDestructiveFocus === 'cancel'\n ? cancelRef.current\n : confirmRef.current\n }\n >\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title id={titleId}>{title}</Dialog.Title>\n </Dialog.Header>\n\n <Dialog.Body id={contentId}>{children}</Dialog.Body>\n\n <Dialog.Footer {...slotProps?.footer}>\n <Button\n ref={cancelRef}\n variant=\"ghost\"\n colorPalette=\"gray\"\n {...slotProps?.cancel}\n onClick={callAll(slotProps?.cancel?.onClick, () => {\n onCancel?.()\n\n closeOnCancel && onOpenChange({ open: false })\n })}\n >\n {slotProps?.cancel?.children || translations?.cancel || 'Cancel'}\n </Button>\n <Button\n ref={confirmRef}\n variant=\"solid\"\n disabled={isLoading}\n {...slotProps?.confirm}\n onClick={callAll(handleConfirm, slotProps?.confirm?.onClick)}\n >\n {slotProps?.confirm?.children || translations?.confirm || 'OK'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog.Root>\n )\n}\n","import * as React from 'react'\n\nimport { type HTMLChakraProps } from '@chakra-ui/react'\nimport { MaybeRenderProp, runIfFn } from '@saas-ui/core/utils'\nimport { Drawer as BaseDrawer } from '@saas-ui/react/drawer'\n\nexport interface DrawerProps extends Omit<BaseDrawer.RootProps, 'children'> {\n /**\n * The drawer title\n */\n title: React.ReactNode\n /**\n * Whether the modal is open\n */\n open: boolean\n /**\n * Callback when the drawer is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The drawer children\n */\n children: MaybeRenderProp<{\n open: boolean\n setOpen: (open: boolean) => void\n }>\n /**\n * The modal footer\n */\n footer?: React.ReactNode\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Hide the backdrop\n */\n hideBackdrop?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal content\n */\n contentProps?: BaseDrawer.ContentProps\n /**\n * Props for the modal footer\n */\n footerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal body\n */\n bodyProps?: HTMLChakraProps<'div'>\n}\n\nexport const Drawer: React.FC<DrawerProps> = (props) => {\n const {\n title,\n children,\n footer,\n open,\n onOpenChange,\n hideCloseButton,\n hideBackdrop,\n headerProps,\n contentProps,\n bodyProps,\n footerProps,\n ...rest\n } = props\n return (\n <BaseDrawer.Root open={open} onOpenChange={onOpenChange} {...rest}>\n {!hideBackdrop && <BaseDrawer.Backdrop />}\n <BaseDrawer.Content {...contentProps}>\n {title && (\n <BaseDrawer.Header {...headerProps}>{title}</BaseDrawer.Header>\n )}\n {!hideCloseButton && <BaseDrawer.CloseButton />}\n <BaseDrawer.Body {...bodyProps}>\n <BaseDrawer.Context>\n {({ open, setOpen }) => runIfFn(children, { open, setOpen })}\n </BaseDrawer.Context>\n </BaseDrawer.Body>\n {footer && (\n <BaseDrawer.Footer {...footerProps}>{footer}</BaseDrawer.Footer>\n )}\n </BaseDrawer.Content>\n </BaseDrawer.Root>\n )\n}\n","import * as React from 'react'\n\nimport type { HTMLChakraProps } from '@chakra-ui/react'\nimport { MaybeRenderProp, runIfFn } from '@saas-ui/core/utils'\nimport { Dialog as BaseDialog } from '@saas-ui/react/dialog'\n\nexport interface ModalProps extends Omit<BaseDialog.RootProps, 'children'> {\n /**\n * The modal title\n */\n title?: React.ReactNode\n /**\n * Whether the modal is open\n */\n open: boolean\n /**\n * Callback when the modal is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The modal children\n */\n children: MaybeRenderProp<{\n open: boolean\n setOpen: (open: boolean) => void\n }>\n /**\n * The modal footer\n */\n footer?: React.ReactNode\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Hide the overlay\n */\n hideBackdrop?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal content\n */\n contentProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal body\n */\n bodyProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal footer\n */\n footerProps?: HTMLChakraProps<'div'>\n}\n\nexport const Modal: React.FC<ModalProps> = (props) => {\n const {\n title,\n footer,\n children,\n open,\n onOpenChange,\n hideCloseButton,\n hideBackdrop,\n headerProps,\n contentProps,\n bodyProps,\n footerProps,\n ...rest\n } = props\n return (\n <BaseDialog.Root open={open} onOpenChange={onOpenChange} {...rest}>\n <BaseDialog.Content {...contentProps}>\n {title && (\n <BaseDialog.Header {...headerProps}>{title}</BaseDialog.Header>\n )}\n {!hideCloseButton && <BaseDialog.CloseButton />}\n <BaseDialog.Body>\n <BaseDialog.Context>\n {({ open, setOpen }) => runIfFn(children, { open, setOpen })}\n </BaseDialog.Context>\n </BaseDialog.Body>\n {footer && (\n <BaseDialog.Footer {...footerProps}>{footer}</BaseDialog.Footer>\n )}\n </BaseDialog.Content>\n </BaseDialog.Root>\n )\n}\n","import { AlertDialog } from './alert-dialog'\nimport { Drawer } from './drawer'\nimport { Modal } from './modal'\n\nexport const defaultModals = {\n alert: AlertDialog,\n confirm: AlertDialog,\n drawer: Drawer,\n modal: Modal,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA6B;;;ACA7B,YAAuB;AAEvB,mBAA0D;AAC1D,mBAAwB;AACxB,oBAAuB;AAuHb;AAzDH,IAAM,cAA0C,CAAC,UAAU;AAChE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,wBAAwB;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,YAAkB,aA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,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,SACE,6CAAC,eAAAC,OAAW,MAAX,EAAgB,MAAY,cAA6B,GAAG,MAC3D,wDAAC,eAAAA,OAAW,SAAX,EAAoB,GAAG,cACrB;AAAA,aACC,6CAAC,eAAAA,OAAW,QAAX,EAAmB,GAAG,aAAc,iBAAM;AAAA,IAE5C,CAAC,mBAAmB,6CAAC,eAAAA,OAAW,aAAX,EAAuB;AAAA,IAC7C,6CAAC,eAAAA,OAAW,MAAX,EACC,uDAAC,eAAAA,OAAW,SAAX,EACE,WAAC,EAAE,MAAAC,OAAM,QAAQ,UAAM,uBAAQ,UAAU,EAAE,MAAAA,OAAM,QAAQ,CAAC,GAC7D,GACF;AAAA,IACC,UACC,6CAAC,eAAAD,OAAW,QAAX,EAAmB,GAAG,aAAc,kBAAO;AAAA,KAEhD,GACF;AAEJ;;;ACrFO,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AACT;;;AJOA,IAAM,EAAE,WAAW,eAAe,QAAI,qCAAa;AAAA,EACjD,QAAQ;AACV,CAAC;","names":["import_utils","import_jsx_runtime","BaseDrawer","open","import_utils","import_dialog","import_jsx_runtime","BaseDialog","open"]}
|
package/dist/index.d.cts
CHANGED
@@ -1,182 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
interface ModalProps extends Omit<Dialog.RootProps, 'children'> {
|
10
|
-
/**
|
11
|
-
* The modal title
|
12
|
-
*/
|
13
|
-
title?: React.ReactNode;
|
14
|
-
/**
|
15
|
-
* Whether the modal is open
|
16
|
-
*/
|
17
|
-
open: boolean;
|
18
|
-
/**
|
19
|
-
* Callback when the modal is opened or closed
|
20
|
-
*/
|
21
|
-
onOpenChange: (details: {
|
22
|
-
open: boolean;
|
23
|
-
}) => void;
|
24
|
-
/**
|
25
|
-
* The modal children
|
26
|
-
*/
|
27
|
-
children: MaybeRenderProp<{
|
28
|
-
open: boolean;
|
29
|
-
setOpen: (open: boolean) => void;
|
30
|
-
}>;
|
31
|
-
/**
|
32
|
-
* The modal footer
|
33
|
-
*/
|
34
|
-
footer?: React.ReactNode;
|
35
|
-
/**
|
36
|
-
* Hide the close button
|
37
|
-
*/
|
38
|
-
hideCloseButton?: boolean;
|
39
|
-
/**
|
40
|
-
* Hide the overlay
|
41
|
-
*/
|
42
|
-
hideBackdrop?: boolean;
|
43
|
-
/**
|
44
|
-
* Props for the modal header
|
45
|
-
*/
|
46
|
-
headerProps?: HTMLChakraProps<'div'>;
|
47
|
-
/**
|
48
|
-
* Props for the modal content
|
49
|
-
*/
|
50
|
-
contentProps?: HTMLChakraProps<'div'>;
|
51
|
-
/**
|
52
|
-
* Props for the modal body
|
53
|
-
*/
|
54
|
-
bodyProps?: HTMLChakraProps<'div'>;
|
55
|
-
/**
|
56
|
-
* Props for the modal footer
|
57
|
-
*/
|
58
|
-
footerProps?: HTMLChakraProps<'div'>;
|
59
|
-
}
|
60
|
-
declare const Modal: React.FC<ModalProps>;
|
61
|
-
|
62
|
-
interface DrawerProps extends Omit<Drawer$1.RootProps, 'children'> {
|
63
|
-
/**
|
64
|
-
* The drawer title
|
65
|
-
*/
|
66
|
-
title: React.ReactNode;
|
67
|
-
/**
|
68
|
-
* Whether the modal is open
|
69
|
-
*/
|
70
|
-
open: boolean;
|
71
|
-
/**
|
72
|
-
* Callback when the drawer is opened or closed
|
73
|
-
*/
|
74
|
-
onOpenChange: (details: {
|
75
|
-
open: boolean;
|
76
|
-
}) => void;
|
77
|
-
/**
|
78
|
-
* The drawer children
|
79
|
-
*/
|
80
|
-
children: MaybeRenderProp<{
|
81
|
-
open: boolean;
|
82
|
-
setOpen: (open: boolean) => void;
|
83
|
-
}>;
|
84
|
-
/**
|
85
|
-
* The modal footer
|
86
|
-
*/
|
87
|
-
footer?: React.ReactNode;
|
88
|
-
/**
|
89
|
-
* Hide the close button
|
90
|
-
*/
|
91
|
-
hideCloseButton?: boolean;
|
92
|
-
/**
|
93
|
-
* Hide the backdrop
|
94
|
-
*/
|
95
|
-
hideBackdrop?: boolean;
|
96
|
-
/**
|
97
|
-
* Props for the modal header
|
98
|
-
*/
|
99
|
-
headerProps?: HTMLChakraProps<'div'>;
|
100
|
-
/**
|
101
|
-
* Props for the modal content
|
102
|
-
*/
|
103
|
-
contentProps?: Drawer$1.ContentProps;
|
104
|
-
/**
|
105
|
-
* Props for the modal footer
|
106
|
-
*/
|
107
|
-
footerProps?: HTMLChakraProps<'div'>;
|
108
|
-
/**
|
109
|
-
* Props for the modal body
|
110
|
-
*/
|
111
|
-
bodyProps?: HTMLChakraProps<'div'>;
|
112
|
-
}
|
113
|
-
declare const Drawer: React.FC<DrawerProps>;
|
114
|
-
|
115
|
-
interface AlertDialogProps extends Omit<Dialog.RootProps, 'leastDestructiveRef' | 'onOpenChange' | 'open'> {
|
116
|
-
/**
|
117
|
-
* Whether the dialog is open
|
118
|
-
*/
|
119
|
-
open: boolean;
|
120
|
-
/**
|
121
|
-
* Callback when the dialog is opened or closed
|
122
|
-
*/
|
123
|
-
onOpenChange: (details: {
|
124
|
-
open: boolean;
|
125
|
-
}) => void;
|
126
|
-
/**
|
127
|
-
* The dialog title
|
128
|
-
*/
|
129
|
-
title?: React.ReactNode;
|
130
|
-
translations?: {
|
131
|
-
cancel?: React.ReactNode;
|
132
|
-
confirm?: React.ReactNode;
|
133
|
-
close?: React.ReactNode;
|
134
|
-
};
|
135
|
-
slotProps?: {
|
136
|
-
cancel?: ButtonProps;
|
137
|
-
confirm?: ButtonProps;
|
138
|
-
footer?: HTMLChakraProps<'div'>;
|
139
|
-
};
|
140
|
-
/**
|
141
|
-
* Close the dialog on cancel
|
142
|
-
* @default true
|
143
|
-
*/
|
144
|
-
closeOnCancel?: boolean;
|
145
|
-
/**
|
146
|
-
* Close the dialog on confirm
|
147
|
-
* @default true
|
148
|
-
*/
|
149
|
-
closeOnConfirm?: boolean;
|
150
|
-
/**
|
151
|
-
* Hide the backdrop
|
152
|
-
*/
|
153
|
-
backdrop?: boolean;
|
154
|
-
/**
|
155
|
-
* Hide the close button
|
156
|
-
*/
|
157
|
-
hideCloseButton?: boolean;
|
158
|
-
/**
|
159
|
-
* Defines which button gets initial focus
|
160
|
-
* https://www.w3.org/TR/wai-aria-practices/#alertdialog
|
161
|
-
*/
|
162
|
-
leastDestructiveFocus?: 'cancel' | 'confirm';
|
163
|
-
/**
|
164
|
-
* Function that's called when cancel is clicked
|
165
|
-
*/
|
166
|
-
onCancel?: () => void;
|
167
|
-
/**
|
168
|
-
* Function that's called when confirm is clicked.
|
169
|
-
*/
|
170
|
-
onConfirm?: () => Promise<void> | void;
|
171
|
-
}
|
172
|
-
declare const AlertDialog: React.FC<AlertDialogProps>;
|
173
|
-
|
174
|
-
declare const useModals: () => _saas_ui_modals_provider.ModalsContextValue<{
|
175
|
-
alert: React.FC<AlertDialogProps>;
|
176
|
-
confirm: React.FC<AlertDialogProps>;
|
177
|
-
drawer: React.FC<DrawerProps>;
|
178
|
-
modal: React.FC<ModalProps>;
|
179
|
-
}, "alert" | "drawer" | "modal" | "confirm">;
|
180
|
-
declare const ModalsProvider: (props: Omit<_saas_ui_modals_provider.ModalsProviderProps, "modals">) => react_jsx_runtime.JSX.Element;
|
181
|
-
|
182
|
-
export { AlertDialog, type AlertDialogProps, Drawer, type DrawerProps, Modal, type ModalProps, ModalsProvider, useModals };
|
1
|
+
export { AlertDialog_alias_1 as AlertDialog } from './_tsup-dts-rollup.cjs';
|
2
|
+
export { AlertDialogProps_alias_1 as AlertDialogProps } from './_tsup-dts-rollup.cjs';
|
3
|
+
export { Drawer_alias_1 as Drawer } from './_tsup-dts-rollup.cjs';
|
4
|
+
export { DrawerProps_alias_1 as DrawerProps } from './_tsup-dts-rollup.cjs';
|
5
|
+
export { Modal } from './_tsup-dts-rollup.cjs';
|
6
|
+
export { ModalProps } from './_tsup-dts-rollup.cjs';
|
7
|
+
export { ModalsProvider } from './_tsup-dts-rollup.cjs';
|
8
|
+
export { useModals } from './_tsup-dts-rollup.cjs';
|
package/dist/index.d.ts
CHANGED
@@ -1,182 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
interface ModalProps extends Omit<Dialog.RootProps, 'children'> {
|
10
|
-
/**
|
11
|
-
* The modal title
|
12
|
-
*/
|
13
|
-
title?: React.ReactNode;
|
14
|
-
/**
|
15
|
-
* Whether the modal is open
|
16
|
-
*/
|
17
|
-
open: boolean;
|
18
|
-
/**
|
19
|
-
* Callback when the modal is opened or closed
|
20
|
-
*/
|
21
|
-
onOpenChange: (details: {
|
22
|
-
open: boolean;
|
23
|
-
}) => void;
|
24
|
-
/**
|
25
|
-
* The modal children
|
26
|
-
*/
|
27
|
-
children: MaybeRenderProp<{
|
28
|
-
open: boolean;
|
29
|
-
setOpen: (open: boolean) => void;
|
30
|
-
}>;
|
31
|
-
/**
|
32
|
-
* The modal footer
|
33
|
-
*/
|
34
|
-
footer?: React.ReactNode;
|
35
|
-
/**
|
36
|
-
* Hide the close button
|
37
|
-
*/
|
38
|
-
hideCloseButton?: boolean;
|
39
|
-
/**
|
40
|
-
* Hide the overlay
|
41
|
-
*/
|
42
|
-
hideBackdrop?: boolean;
|
43
|
-
/**
|
44
|
-
* Props for the modal header
|
45
|
-
*/
|
46
|
-
headerProps?: HTMLChakraProps<'div'>;
|
47
|
-
/**
|
48
|
-
* Props for the modal content
|
49
|
-
*/
|
50
|
-
contentProps?: HTMLChakraProps<'div'>;
|
51
|
-
/**
|
52
|
-
* Props for the modal body
|
53
|
-
*/
|
54
|
-
bodyProps?: HTMLChakraProps<'div'>;
|
55
|
-
/**
|
56
|
-
* Props for the modal footer
|
57
|
-
*/
|
58
|
-
footerProps?: HTMLChakraProps<'div'>;
|
59
|
-
}
|
60
|
-
declare const Modal: React.FC<ModalProps>;
|
61
|
-
|
62
|
-
interface DrawerProps extends Omit<Drawer$1.RootProps, 'children'> {
|
63
|
-
/**
|
64
|
-
* The drawer title
|
65
|
-
*/
|
66
|
-
title: React.ReactNode;
|
67
|
-
/**
|
68
|
-
* Whether the modal is open
|
69
|
-
*/
|
70
|
-
open: boolean;
|
71
|
-
/**
|
72
|
-
* Callback when the drawer is opened or closed
|
73
|
-
*/
|
74
|
-
onOpenChange: (details: {
|
75
|
-
open: boolean;
|
76
|
-
}) => void;
|
77
|
-
/**
|
78
|
-
* The drawer children
|
79
|
-
*/
|
80
|
-
children: MaybeRenderProp<{
|
81
|
-
open: boolean;
|
82
|
-
setOpen: (open: boolean) => void;
|
83
|
-
}>;
|
84
|
-
/**
|
85
|
-
* The modal footer
|
86
|
-
*/
|
87
|
-
footer?: React.ReactNode;
|
88
|
-
/**
|
89
|
-
* Hide the close button
|
90
|
-
*/
|
91
|
-
hideCloseButton?: boolean;
|
92
|
-
/**
|
93
|
-
* Hide the backdrop
|
94
|
-
*/
|
95
|
-
hideBackdrop?: boolean;
|
96
|
-
/**
|
97
|
-
* Props for the modal header
|
98
|
-
*/
|
99
|
-
headerProps?: HTMLChakraProps<'div'>;
|
100
|
-
/**
|
101
|
-
* Props for the modal content
|
102
|
-
*/
|
103
|
-
contentProps?: Drawer$1.ContentProps;
|
104
|
-
/**
|
105
|
-
* Props for the modal footer
|
106
|
-
*/
|
107
|
-
footerProps?: HTMLChakraProps<'div'>;
|
108
|
-
/**
|
109
|
-
* Props for the modal body
|
110
|
-
*/
|
111
|
-
bodyProps?: HTMLChakraProps<'div'>;
|
112
|
-
}
|
113
|
-
declare const Drawer: React.FC<DrawerProps>;
|
114
|
-
|
115
|
-
interface AlertDialogProps extends Omit<Dialog.RootProps, 'leastDestructiveRef' | 'onOpenChange' | 'open'> {
|
116
|
-
/**
|
117
|
-
* Whether the dialog is open
|
118
|
-
*/
|
119
|
-
open: boolean;
|
120
|
-
/**
|
121
|
-
* Callback when the dialog is opened or closed
|
122
|
-
*/
|
123
|
-
onOpenChange: (details: {
|
124
|
-
open: boolean;
|
125
|
-
}) => void;
|
126
|
-
/**
|
127
|
-
* The dialog title
|
128
|
-
*/
|
129
|
-
title?: React.ReactNode;
|
130
|
-
translations?: {
|
131
|
-
cancel?: React.ReactNode;
|
132
|
-
confirm?: React.ReactNode;
|
133
|
-
close?: React.ReactNode;
|
134
|
-
};
|
135
|
-
slotProps?: {
|
136
|
-
cancel?: ButtonProps;
|
137
|
-
confirm?: ButtonProps;
|
138
|
-
footer?: HTMLChakraProps<'div'>;
|
139
|
-
};
|
140
|
-
/**
|
141
|
-
* Close the dialog on cancel
|
142
|
-
* @default true
|
143
|
-
*/
|
144
|
-
closeOnCancel?: boolean;
|
145
|
-
/**
|
146
|
-
* Close the dialog on confirm
|
147
|
-
* @default true
|
148
|
-
*/
|
149
|
-
closeOnConfirm?: boolean;
|
150
|
-
/**
|
151
|
-
* Hide the backdrop
|
152
|
-
*/
|
153
|
-
backdrop?: boolean;
|
154
|
-
/**
|
155
|
-
* Hide the close button
|
156
|
-
*/
|
157
|
-
hideCloseButton?: boolean;
|
158
|
-
/**
|
159
|
-
* Defines which button gets initial focus
|
160
|
-
* https://www.w3.org/TR/wai-aria-practices/#alertdialog
|
161
|
-
*/
|
162
|
-
leastDestructiveFocus?: 'cancel' | 'confirm';
|
163
|
-
/**
|
164
|
-
* Function that's called when cancel is clicked
|
165
|
-
*/
|
166
|
-
onCancel?: () => void;
|
167
|
-
/**
|
168
|
-
* Function that's called when confirm is clicked.
|
169
|
-
*/
|
170
|
-
onConfirm?: () => Promise<void> | void;
|
171
|
-
}
|
172
|
-
declare const AlertDialog: React.FC<AlertDialogProps>;
|
173
|
-
|
174
|
-
declare const useModals: () => _saas_ui_modals_provider.ModalsContextValue<{
|
175
|
-
alert: React.FC<AlertDialogProps>;
|
176
|
-
confirm: React.FC<AlertDialogProps>;
|
177
|
-
drawer: React.FC<DrawerProps>;
|
178
|
-
modal: React.FC<ModalProps>;
|
179
|
-
}, "alert" | "drawer" | "modal" | "confirm">;
|
180
|
-
declare const ModalsProvider: (props: Omit<_saas_ui_modals_provider.ModalsProviderProps, "modals">) => react_jsx_runtime.JSX.Element;
|
181
|
-
|
182
|
-
export { AlertDialog, type AlertDialogProps, Drawer, type DrawerProps, Modal, type ModalProps, ModalsProvider, useModals };
|
1
|
+
export { AlertDialog_alias_1 as AlertDialog } from './_tsup-dts-rollup.js';
|
2
|
+
export { AlertDialogProps_alias_1 as AlertDialogProps } from './_tsup-dts-rollup.js';
|
3
|
+
export { Drawer_alias_1 as Drawer } from './_tsup-dts-rollup.js';
|
4
|
+
export { DrawerProps_alias_1 as DrawerProps } from './_tsup-dts-rollup.js';
|
5
|
+
export { Modal } from './_tsup-dts-rollup.js';
|
6
|
+
export { ModalProps } from './_tsup-dts-rollup.js';
|
7
|
+
export { ModalsProvider } from './_tsup-dts-rollup.js';
|
8
|
+
export { useModals } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
@@ -10,7 +10,6 @@ import { callAll } from "@saas-ui/core/utils";
|
|
10
10
|
import { Dialog } from "@saas-ui/react/dialog";
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
12
12
|
var AlertDialog = (props) => {
|
13
|
-
var _a, _b, _c, _d;
|
14
13
|
const {
|
15
14
|
title,
|
16
15
|
translations,
|
@@ -30,8 +29,8 @@ var AlertDialog = (props) => {
|
|
30
29
|
const [isLoading, setIsLoading] = React.useState(false);
|
31
30
|
const handleConfirm = async () => {
|
32
31
|
try {
|
33
|
-
const result = onConfirm
|
34
|
-
if (typeof
|
32
|
+
const result = onConfirm?.();
|
33
|
+
if (typeof result?.then === "function") {
|
35
34
|
setIsLoading(true);
|
36
35
|
await result;
|
37
36
|
}
|
@@ -57,19 +56,19 @@ var AlertDialog = (props) => {
|
|
57
56
|
children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
|
58
57
|
/* @__PURE__ */ jsx(Dialog.Header, { children: /* @__PURE__ */ jsx(Dialog.Title, { id: titleId, children: title }) }),
|
59
58
|
/* @__PURE__ */ jsx(Dialog.Body, { id: contentId, children }),
|
60
|
-
/* @__PURE__ */ jsxs(Dialog.Footer, { ...slotProps
|
59
|
+
/* @__PURE__ */ jsxs(Dialog.Footer, { ...slotProps?.footer, children: [
|
61
60
|
/* @__PURE__ */ jsx(
|
62
61
|
Button,
|
63
62
|
{
|
64
63
|
ref: cancelRef,
|
65
64
|
variant: "ghost",
|
66
65
|
colorPalette: "gray",
|
67
|
-
...slotProps
|
68
|
-
onClick: callAll(
|
69
|
-
onCancel
|
66
|
+
...slotProps?.cancel,
|
67
|
+
onClick: callAll(slotProps?.cancel?.onClick, () => {
|
68
|
+
onCancel?.();
|
70
69
|
closeOnCancel && onOpenChange({ open: false });
|
71
70
|
}),
|
72
|
-
children:
|
71
|
+
children: slotProps?.cancel?.children || translations?.cancel || "Cancel"
|
73
72
|
}
|
74
73
|
),
|
75
74
|
/* @__PURE__ */ jsx(
|
@@ -78,9 +77,9 @@ var AlertDialog = (props) => {
|
|
78
77
|
ref: confirmRef,
|
79
78
|
variant: "solid",
|
80
79
|
disabled: isLoading,
|
81
|
-
...slotProps
|
82
|
-
onClick: callAll(handleConfirm,
|
83
|
-
children:
|
80
|
+
...slotProps?.confirm,
|
81
|
+
onClick: callAll(handleConfirm, slotProps?.confirm?.onClick),
|
82
|
+
children: slotProps?.confirm?.children || translations?.confirm || "OK"
|
84
83
|
}
|
85
84
|
)
|
86
85
|
] })
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/alert-dialog.tsx","../src/drawer.tsx","../src/modal.tsx","../src/default-modals.ts"],"sourcesContent":["import { createModals } from '@saas-ui/modals-provider'\n\nimport { defaultModals } from './default-modals.ts'\n\n// Exporting from './dialog'\nexport { AlertDialog } from './alert-dialog.tsx'\nexport type { AlertDialogProps } from './alert-dialog.tsx'\n\n// Exporting from './drawer'\nexport { Drawer } from './drawer'\nexport type { DrawerProps } from './drawer'\n\n// Exporting from './modal'\nexport { Modal } from './modal'\nexport type { ModalProps } from './modal'\n\n// Exporting from './form'\n// export { FormDialog, createFormDialog } from './form'\n// export type {\n// DefaultFormType,\n// FormDialogFieldOverrides,\n// FormDialogProps,\n// } from './form'\n\n// Exporting from './provider'\n\nconst { useModals, ModalsProvider } = createModals({\n modals: defaultModals,\n})\n\nexport { ModalsProvider, useModals }\n","import * as React from 'react'\n\nimport { Button, ButtonProps, type HTMLChakraProps } from '@chakra-ui/react'\nimport { callAll } from '@saas-ui/core/utils'\nimport { Dialog } from '@saas-ui/react/dialog'\n\nexport interface AlertDialogProps\n extends Omit<\n Dialog.RootProps,\n 'leastDestructiveRef' | 'onOpenChange' | 'open'\n > {\n /**\n * Whether the dialog is open\n */\n open: boolean\n /**\n * Callback when the dialog is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The dialog title\n */\n title?: React.ReactNode\n translations?: {\n cancel?: React.ReactNode\n confirm?: React.ReactNode\n close?: React.ReactNode\n }\n slotProps?: {\n cancel?: ButtonProps\n confirm?: ButtonProps\n footer?: HTMLChakraProps<'div'>\n }\n /**\n * Close the dialog on cancel\n * @default true\n */\n closeOnCancel?: boolean\n /**\n * Close the dialog on confirm\n * @default true\n */\n closeOnConfirm?: boolean\n /**\n * Hide the backdrop\n */\n backdrop?: boolean\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Defines which button gets initial focus\n * https://www.w3.org/TR/wai-aria-practices/#alertdialog\n */\n leastDestructiveFocus?: 'cancel' | 'confirm'\n /**\n * Function that's called when cancel is clicked\n */\n onCancel?: () => void\n /**\n * Function that's called when confirm is clicked.\n */\n onConfirm?: () => Promise<void> | void\n}\n\nexport const AlertDialog: React.FC<AlertDialogProps> = (props) => {\n const {\n title,\n translations,\n slotProps,\n open,\n closeOnCancel = true,\n closeOnConfirm = true,\n leastDestructiveFocus = 'cancel',\n onOpenChange,\n onCancel,\n onConfirm,\n children,\n ...rest\n } = props\n\n const cancelRef = React.useRef(null)\n const confirmRef = React.useRef(null)\n const [isLoading, setIsLoading] = React.useState(false)\n\n const handleConfirm = async () => {\n try {\n const result = onConfirm?.()\n if (typeof result?.then === 'function') {\n setIsLoading(true)\n await result\n }\n\n closeOnConfirm && onOpenChange({ open: false })\n /* eslint-disable no-useless-catch */\n } catch (e: any) {\n throw e\n } finally {\n setIsLoading(false)\n }\n /* eslint-enable */\n }\n\n const titleId = React.useId()\n const contentId = React.useId()\n\n return (\n <Dialog.Root\n open={open}\n onOpenChange={onOpenChange}\n size=\"sm\"\n aria-labelledby={titleId}\n aria-describedby={contentId}\n {...rest}\n initialFocusEl={() =>\n leastDestructiveFocus === 'cancel'\n ? cancelRef.current\n : confirmRef.current\n }\n >\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title id={titleId}>{title}</Dialog.Title>\n </Dialog.Header>\n\n <Dialog.Body id={contentId}>{children}</Dialog.Body>\n\n <Dialog.Footer {...slotProps?.footer}>\n <Button\n ref={cancelRef}\n variant=\"ghost\"\n colorPalette=\"gray\"\n {...slotProps?.cancel}\n onClick={callAll(slotProps?.cancel?.onClick, () => {\n onCancel?.()\n\n closeOnCancel && onOpenChange({ open: false })\n })}\n >\n {slotProps?.cancel?.children || translations?.cancel || 'Cancel'}\n </Button>\n <Button\n ref={confirmRef}\n variant=\"solid\"\n disabled={isLoading}\n {...slotProps?.confirm}\n onClick={callAll(handleConfirm, slotProps?.confirm?.onClick)}\n >\n {slotProps?.confirm?.children || translations?.confirm || 'OK'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog.Root>\n )\n}\n","import * as React from 'react'\n\nimport { type HTMLChakraProps } from '@chakra-ui/react'\nimport { MaybeRenderProp, runIfFn } from '@saas-ui/core/utils'\nimport { Drawer as BaseDrawer } from '@saas-ui/react/drawer'\n\nexport interface DrawerProps extends Omit<BaseDrawer.RootProps, 'children'> {\n /**\n * The drawer title\n */\n title: React.ReactNode\n /**\n * Whether the modal is open\n */\n open: boolean\n /**\n * Callback when the drawer is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The drawer children\n */\n children: MaybeRenderProp<{\n open: boolean\n setOpen: (open: boolean) => void\n }>\n /**\n * The modal footer\n */\n footer?: React.ReactNode\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Hide the backdrop\n */\n hideBackdrop?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal content\n */\n contentProps?: BaseDrawer.ContentProps\n /**\n * Props for the modal footer\n */\n footerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal body\n */\n bodyProps?: HTMLChakraProps<'div'>\n}\n\nexport const Drawer: React.FC<DrawerProps> = (props) => {\n const {\n title,\n children,\n footer,\n open,\n onOpenChange,\n hideCloseButton,\n hideBackdrop,\n headerProps,\n contentProps,\n bodyProps,\n footerProps,\n ...rest\n } = props\n return (\n <BaseDrawer.Root open={open} onOpenChange={onOpenChange} {...rest}>\n {!hideBackdrop && <BaseDrawer.Backdrop />}\n <BaseDrawer.Content {...contentProps}>\n {title && (\n <BaseDrawer.Header {...headerProps}>{title}</BaseDrawer.Header>\n )}\n {!hideCloseButton && <BaseDrawer.CloseButton />}\n <BaseDrawer.Body {...bodyProps}>\n <BaseDrawer.Context>\n {({ open, setOpen }) => runIfFn(children, { open, setOpen })}\n </BaseDrawer.Context>\n </BaseDrawer.Body>\n {footer && (\n <BaseDrawer.Footer {...footerProps}>{footer}</BaseDrawer.Footer>\n )}\n </BaseDrawer.Content>\n </BaseDrawer.Root>\n )\n}\n","import * as React from 'react'\n\nimport type { HTMLChakraProps } from '@chakra-ui/react'\nimport { MaybeRenderProp, runIfFn } from '@saas-ui/core/utils'\nimport { Dialog as BaseDialog } from '@saas-ui/react/dialog'\n\nexport interface ModalProps extends Omit<BaseDialog.RootProps, 'children'> {\n /**\n * The modal title\n */\n title?: React.ReactNode\n /**\n * Whether the modal is open\n */\n open: boolean\n /**\n * Callback when the modal is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The modal children\n */\n children: MaybeRenderProp<{\n open: boolean\n setOpen: (open: boolean) => void\n }>\n /**\n * The modal footer\n */\n footer?: React.ReactNode\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Hide the overlay\n */\n hideBackdrop?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal content\n */\n contentProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal body\n */\n bodyProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal footer\n */\n footerProps?: HTMLChakraProps<'div'>\n}\n\nexport const Modal: React.FC<ModalProps> = (props) => {\n const {\n title,\n footer,\n children,\n open,\n onOpenChange,\n hideCloseButton,\n hideBackdrop,\n headerProps,\n contentProps,\n bodyProps,\n footerProps,\n ...rest\n } = props\n return (\n <BaseDialog.Root open={open} onOpenChange={onOpenChange} {...rest}>\n <BaseDialog.Content {...contentProps}>\n {title && (\n <BaseDialog.Header {...headerProps}>{title}</BaseDialog.Header>\n )}\n {!hideCloseButton && <BaseDialog.CloseButton />}\n <BaseDialog.Body>\n <BaseDialog.Context>\n {({ open, setOpen }) => runIfFn(children, { open, setOpen })}\n </BaseDialog.Context>\n </BaseDialog.Body>\n {footer && (\n <BaseDialog.Footer {...footerProps}>{footer}</BaseDialog.Footer>\n )}\n </BaseDialog.Content>\n </BaseDialog.Root>\n )\n}\n","import { AlertDialog } from './alert-dialog'\nimport { Drawer } from './drawer'\nimport { Modal } from './modal'\n\nexport const defaultModals = {\n alert: AlertDialog,\n confirm: AlertDialog,\n drawer: Drawer,\n modal: Modal,\n}\n"],"mappings":";;;AAAA,SAAS,oBAAoB;;;ACA7B,YAAY,WAAW;AAEvB,SAAS,cAAiD;AAC1D,SAAS,eAAe;AACxB,SAAS,cAAc;AAuHb,cAKF,YAL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ACF;AAAA,MACC,UACC,gBAAAF,KAAC,WAAW,QAAX,EAAmB,GAAG,aAAc,kBAAO;AAAA,OAEhD;AAAA,KACF;AAEJ;;;ACvFA,SAA0B,WAAAG,gBAAe;AACzC,SAAS,UAAU,kBAAkB;AAqE/B,SAEI,OAAAC,MAFJ,QAAAC,aAAA;AAjBC,IAAM,QAA8B,CAAC,UAAU;AACpD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,SACE,gBAAAD,KAAC,WAAW,MAAX,EAAgB,MAAY,cAA6B,GAAG,MAC3D,0BAAAC,MAAC,WAAW,SAAX,EAAoB,GAAG,cACrB;AAAA,aACC,gBAAAD,KAAC,WAAW,QAAX,EAAmB,GAAG,aAAc,iBAAM;AAAA,IAE5C,CAAC,mBAAmB,gBAAAA,KAAC,WAAW,aAAX,EAAuB;AAAA,IAC7C,gBAAAA,KAAC,WAAW,MAAX,EACC,0BAAAA,KAAC,WAAW,SAAX,EACE,WAAC,EAAE,MAAAE,OAAM,QAAQ,MAAMH,SAAQ,UAAU,EAAE,MAAAG,OAAM,QAAQ,CAAC,GAC7D,GACF;AAAA,IACC,UACC,gBAAAF,KAAC,WAAW,QAAX,EAAmB,GAAG,aAAc,kBAAO;AAAA,KAEhD,GACF;AAEJ;;;ACrFO,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AACT;;;AJiBA,IAAM,EAAE,WAAW,eAAe,IAAI,aAAa;AAAA,EACjD,QAAQ;AACV,CAAC;","names":["jsx","jsxs","open","runIfFn","jsx","jsxs","open"]}
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/alert-dialog.tsx","../src/drawer.tsx","../src/modal.tsx","../src/default-modals.ts"],"sourcesContent":["import { createModals } from '@saas-ui/modals-provider'\n\nimport { defaultModals } from './default-modals.ts'\n\n// Exporting from './dialog'\nexport { AlertDialog } from './alert-dialog.tsx'\nexport type { AlertDialogProps } from './alert-dialog.tsx'\n\n// Exporting from './drawer'\nexport { Drawer } from './drawer'\nexport type { DrawerProps } from './drawer'\n\n// Exporting from './modal'\nexport { Modal } from './modal'\nexport type { ModalProps } from './modal'\n\nconst { useModals, ModalsProvider } = createModals({\n modals: defaultModals,\n})\n\nexport { ModalsProvider, useModals }\n","import * as React from 'react'\n\nimport { Button, ButtonProps, type HTMLChakraProps } from '@chakra-ui/react'\nimport { callAll } from '@saas-ui/core/utils'\nimport { Dialog } from '@saas-ui/react/dialog'\n\nexport interface AlertDialogProps\n extends Omit<\n Dialog.RootProps,\n 'leastDestructiveRef' | 'onOpenChange' | 'open'\n > {\n /**\n * Whether the dialog is open\n */\n open: boolean\n /**\n * Callback when the dialog is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The dialog title\n */\n title?: React.ReactNode\n translations?: {\n cancel?: React.ReactNode\n confirm?: React.ReactNode\n close?: React.ReactNode\n }\n slotProps?: {\n cancel?: ButtonProps\n confirm?: ButtonProps\n footer?: HTMLChakraProps<'div'>\n }\n /**\n * Close the dialog on cancel\n * @default true\n */\n closeOnCancel?: boolean\n /**\n * Close the dialog on confirm\n * @default true\n */\n closeOnConfirm?: boolean\n /**\n * Hide the backdrop\n */\n backdrop?: boolean\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Defines which button gets initial focus\n * https://www.w3.org/TR/wai-aria-practices/#alertdialog\n */\n leastDestructiveFocus?: 'cancel' | 'confirm'\n /**\n * Function that's called when cancel is clicked\n */\n onCancel?: () => void\n /**\n * Function that's called when confirm is clicked.\n */\n onConfirm?: () => Promise<void> | void\n}\n\nexport const AlertDialog: React.FC<AlertDialogProps> = (props) => {\n const {\n title,\n translations,\n slotProps,\n open,\n closeOnCancel = true,\n closeOnConfirm = true,\n leastDestructiveFocus = 'cancel',\n onOpenChange,\n onCancel,\n onConfirm,\n children,\n ...rest\n } = props\n\n const cancelRef = React.useRef(null)\n const confirmRef = React.useRef(null)\n const [isLoading, setIsLoading] = React.useState(false)\n\n const handleConfirm = async () => {\n try {\n const result = onConfirm?.()\n if (typeof result?.then === 'function') {\n setIsLoading(true)\n await result\n }\n\n closeOnConfirm && onOpenChange({ open: false })\n /* eslint-disable no-useless-catch */\n } catch (e: any) {\n throw e\n } finally {\n setIsLoading(false)\n }\n /* eslint-enable */\n }\n\n const titleId = React.useId()\n const contentId = React.useId()\n\n return (\n <Dialog.Root\n open={open}\n onOpenChange={onOpenChange}\n size=\"sm\"\n aria-labelledby={titleId}\n aria-describedby={contentId}\n {...rest}\n initialFocusEl={() =>\n leastDestructiveFocus === 'cancel'\n ? cancelRef.current\n : confirmRef.current\n }\n >\n <Dialog.Content>\n <Dialog.Header>\n <Dialog.Title id={titleId}>{title}</Dialog.Title>\n </Dialog.Header>\n\n <Dialog.Body id={contentId}>{children}</Dialog.Body>\n\n <Dialog.Footer {...slotProps?.footer}>\n <Button\n ref={cancelRef}\n variant=\"ghost\"\n colorPalette=\"gray\"\n {...slotProps?.cancel}\n onClick={callAll(slotProps?.cancel?.onClick, () => {\n onCancel?.()\n\n closeOnCancel && onOpenChange({ open: false })\n })}\n >\n {slotProps?.cancel?.children || translations?.cancel || 'Cancel'}\n </Button>\n <Button\n ref={confirmRef}\n variant=\"solid\"\n disabled={isLoading}\n {...slotProps?.confirm}\n onClick={callAll(handleConfirm, slotProps?.confirm?.onClick)}\n >\n {slotProps?.confirm?.children || translations?.confirm || 'OK'}\n </Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog.Root>\n )\n}\n","import * as React from 'react'\n\nimport { type HTMLChakraProps } from '@chakra-ui/react'\nimport { MaybeRenderProp, runIfFn } from '@saas-ui/core/utils'\nimport { Drawer as BaseDrawer } from '@saas-ui/react/drawer'\n\nexport interface DrawerProps extends Omit<BaseDrawer.RootProps, 'children'> {\n /**\n * The drawer title\n */\n title: React.ReactNode\n /**\n * Whether the modal is open\n */\n open: boolean\n /**\n * Callback when the drawer is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The drawer children\n */\n children: MaybeRenderProp<{\n open: boolean\n setOpen: (open: boolean) => void\n }>\n /**\n * The modal footer\n */\n footer?: React.ReactNode\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Hide the backdrop\n */\n hideBackdrop?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal content\n */\n contentProps?: BaseDrawer.ContentProps\n /**\n * Props for the modal footer\n */\n footerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal body\n */\n bodyProps?: HTMLChakraProps<'div'>\n}\n\nexport const Drawer: React.FC<DrawerProps> = (props) => {\n const {\n title,\n children,\n footer,\n open,\n onOpenChange,\n hideCloseButton,\n hideBackdrop,\n headerProps,\n contentProps,\n bodyProps,\n footerProps,\n ...rest\n } = props\n return (\n <BaseDrawer.Root open={open} onOpenChange={onOpenChange} {...rest}>\n {!hideBackdrop && <BaseDrawer.Backdrop />}\n <BaseDrawer.Content {...contentProps}>\n {title && (\n <BaseDrawer.Header {...headerProps}>{title}</BaseDrawer.Header>\n )}\n {!hideCloseButton && <BaseDrawer.CloseButton />}\n <BaseDrawer.Body {...bodyProps}>\n <BaseDrawer.Context>\n {({ open, setOpen }) => runIfFn(children, { open, setOpen })}\n </BaseDrawer.Context>\n </BaseDrawer.Body>\n {footer && (\n <BaseDrawer.Footer {...footerProps}>{footer}</BaseDrawer.Footer>\n )}\n </BaseDrawer.Content>\n </BaseDrawer.Root>\n )\n}\n","import * as React from 'react'\n\nimport type { HTMLChakraProps } from '@chakra-ui/react'\nimport { MaybeRenderProp, runIfFn } from '@saas-ui/core/utils'\nimport { Dialog as BaseDialog } from '@saas-ui/react/dialog'\n\nexport interface ModalProps extends Omit<BaseDialog.RootProps, 'children'> {\n /**\n * The modal title\n */\n title?: React.ReactNode\n /**\n * Whether the modal is open\n */\n open: boolean\n /**\n * Callback when the modal is opened or closed\n */\n onOpenChange: (details: { open: boolean }) => void\n /**\n * The modal children\n */\n children: MaybeRenderProp<{\n open: boolean\n setOpen: (open: boolean) => void\n }>\n /**\n * The modal footer\n */\n footer?: React.ReactNode\n /**\n * Hide the close button\n */\n hideCloseButton?: boolean\n /**\n * Hide the overlay\n */\n hideBackdrop?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal content\n */\n contentProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal body\n */\n bodyProps?: HTMLChakraProps<'div'>\n /**\n * Props for the modal footer\n */\n footerProps?: HTMLChakraProps<'div'>\n}\n\nexport const Modal: React.FC<ModalProps> = (props) => {\n const {\n title,\n footer,\n children,\n open,\n onOpenChange,\n hideCloseButton,\n hideBackdrop,\n headerProps,\n contentProps,\n bodyProps,\n footerProps,\n ...rest\n } = props\n return (\n <BaseDialog.Root open={open} onOpenChange={onOpenChange} {...rest}>\n <BaseDialog.Content {...contentProps}>\n {title && (\n <BaseDialog.Header {...headerProps}>{title}</BaseDialog.Header>\n )}\n {!hideCloseButton && <BaseDialog.CloseButton />}\n <BaseDialog.Body>\n <BaseDialog.Context>\n {({ open, setOpen }) => runIfFn(children, { open, setOpen })}\n </BaseDialog.Context>\n </BaseDialog.Body>\n {footer && (\n <BaseDialog.Footer {...footerProps}>{footer}</BaseDialog.Footer>\n )}\n </BaseDialog.Content>\n </BaseDialog.Root>\n )\n}\n","import { AlertDialog } from './alert-dialog'\nimport { Drawer } from './drawer'\nimport { Modal } from './modal'\n\nexport const defaultModals = {\n alert: AlertDialog,\n confirm: AlertDialog,\n drawer: Drawer,\n modal: Modal,\n}\n"],"mappings":";;;AAAA,SAAS,oBAAoB;;;ACA7B,YAAY,WAAW;AAEvB,SAAS,cAAiD;AAC1D,SAAS,eAAe;AACxB,SAAS,cAAc;AAuH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",
|
4
4
|
"description": "A modal manager for Chakra UI",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -11,18 +11,6 @@
|
|
11
11
|
"import": "./dist/index.js"
|
12
12
|
}
|
13
13
|
},
|
14
|
-
"typesVersions": {
|
15
|
-
"zod": {
|
16
|
-
"*": [
|
17
|
-
"dist/zod/*"
|
18
|
-
]
|
19
|
-
},
|
20
|
-
"yup": {
|
21
|
-
"*": [
|
22
|
-
"dist/yup/*"
|
23
|
-
]
|
24
|
-
}
|
25
|
-
},
|
26
14
|
"main": "./dist/index.cjs",
|
27
15
|
"module": "./dist/index.js",
|
28
16
|
"types": "./dist/index.d.ts",
|
@@ -66,15 +54,15 @@
|
|
66
54
|
"url": "https://storybook.saas-ui.dev"
|
67
55
|
},
|
68
56
|
"dependencies": {
|
69
|
-
"@saas-ui/core": "3.0.0-next.
|
70
|
-
"@saas-ui/forms": "3.0.0-next.
|
57
|
+
"@saas-ui/core": "3.0.0-next.1",
|
58
|
+
"@saas-ui/forms": "3.0.0-next.3",
|
71
59
|
"@saas-ui/hooks": "3.0.0-next.0",
|
72
60
|
"@saas-ui/modals-provider": "1.0.0-next.0"
|
73
61
|
},
|
74
62
|
"peerDependencies": {
|
75
63
|
"@chakra-ui/react": "^3.2.1",
|
76
64
|
"@emotion/react": ">=11.0.0",
|
77
|
-
"@saas-ui/react": "3.0.0-next.
|
65
|
+
"@saas-ui/react": "3.0.0-next.3",
|
78
66
|
"react": ">=18.0.0",
|
79
67
|
"react-dom": ">=18.0.0"
|
80
68
|
},
|