@saas-ui/modals 1.5.5 → 2.0.0-next.1
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 +23 -3
- package/dist/index.d.ts +218 -7
- package/dist/index.js +433 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +401 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +13 -11
- package/src/dialog.tsx +3 -6
- package/src/form.tsx +24 -14
- package/src/menu.tsx +1 -3
- package/dist/dialog.d.ts +0 -54
- package/dist/dialog.d.ts.map +0 -1
- package/dist/drawer.d.ts +0 -26
- package/dist/drawer.d.ts.map +0 -1
- package/dist/form.d.ts +0 -32
- package/dist/form.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.modern.mjs +0 -2
- package/dist/index.modern.mjs.map +0 -1
- package/dist/menu.d.ts +0 -14
- package/dist/menu.d.ts.map +0 -1
- package/dist/modal.d.ts +0 -23
- package/dist/modal.d.ts.map +0 -1
- package/dist/provider.d.ts +0 -83
- package/dist/provider.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -1,11 +1,31 @@
|
|
1
1
|
# @saas-ui/modals
|
2
2
|
|
3
|
-
##
|
3
|
+
## 2.0.0-next.1
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
-
-
|
8
|
-
|
7
|
+
- 166978bd: Fix esm bundle filename.
|
8
|
+
- Updated dependencies [166978bd]
|
9
|
+
- @saas-ui/forms@2.0.0-next.1
|
10
|
+
- @saas-ui/hooks@2.0.0-next.1
|
11
|
+
- @saas-ui/react-utils@2.0.0-next.1
|
12
|
+
|
13
|
+
## 2.0.0-next.0
|
14
|
+
|
15
|
+
### Major Changes
|
16
|
+
|
17
|
+
- f1e99198: Restructured packages.
|
18
|
+
|
19
|
+
### Patch Changes
|
20
|
+
|
21
|
+
- f1e99198: Migrated from microbundle to tsup for builds
|
22
|
+
- Updated dependencies [d7c87a31]
|
23
|
+
- Updated dependencies [f1e99198]
|
24
|
+
- Updated dependencies [8b82d945]
|
25
|
+
- Updated dependencies [f1e99198]
|
26
|
+
- @saas-ui/forms@2.0.0-next.0
|
27
|
+
- @saas-ui/hooks@2.0.0-next.0
|
28
|
+
- @saas-ui/react-utils@2.0.0-next.0
|
9
29
|
|
10
30
|
## 1.5.4
|
11
31
|
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,218 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
import * as React from 'react';
|
2
|
+
import { AlertDialogProps, ButtonProps, ButtonGroupProps, DrawerProps as DrawerProps$1, ModalProps, MenuListProps } from '@chakra-ui/react';
|
3
|
+
import * as _chakra_ui_system_dist_system_types from '@chakra-ui/system/dist/system.types';
|
4
|
+
import { FieldValues, FormProps, FieldResolver } from '@saas-ui/forms';
|
5
|
+
|
6
|
+
interface ConfirmDialogProps extends Omit<AlertDialogProps, 'leastDestructiveRef'> {
|
7
|
+
/**
|
8
|
+
* The dialog title
|
9
|
+
*/
|
10
|
+
title?: React.ReactNode;
|
11
|
+
/**
|
12
|
+
* The cancel button label
|
13
|
+
*/
|
14
|
+
cancelLabel?: React.ReactNode;
|
15
|
+
/**
|
16
|
+
* The confirm button label
|
17
|
+
*/
|
18
|
+
confirmLabel?: React.ReactNode;
|
19
|
+
/**
|
20
|
+
* The cancel button props
|
21
|
+
*/
|
22
|
+
cancelProps?: ButtonProps;
|
23
|
+
/**
|
24
|
+
* The confirm button props
|
25
|
+
*/
|
26
|
+
confirmProps?: ButtonProps;
|
27
|
+
/**
|
28
|
+
* The button group props
|
29
|
+
*/
|
30
|
+
buttonGroupProps?: ButtonGroupProps;
|
31
|
+
/**
|
32
|
+
* Close the dialog on cancel
|
33
|
+
* @default true
|
34
|
+
*/
|
35
|
+
closeOnCancel?: boolean;
|
36
|
+
/**
|
37
|
+
* Close the dialog on confirm
|
38
|
+
* @default true
|
39
|
+
*/
|
40
|
+
closeOnConfirm?: boolean;
|
41
|
+
/**
|
42
|
+
* Defines which button gets initial focus
|
43
|
+
* https://www.w3.org/TR/wai-aria-practices/#alertdialog
|
44
|
+
*/
|
45
|
+
leastDestructiveFocus?: 'cancel' | 'confirm';
|
46
|
+
/**
|
47
|
+
* Function that's called when cancel is clicked
|
48
|
+
*/
|
49
|
+
onCancel?: () => void;
|
50
|
+
/**
|
51
|
+
* Function that's called when confirm is clicked
|
52
|
+
*/
|
53
|
+
onConfirm?: () => void;
|
54
|
+
}
|
55
|
+
declare const ConfirmDialog: React.FC<ConfirmDialogProps>;
|
56
|
+
|
57
|
+
interface BaseDrawerProps extends Omit<DrawerProps$1, 'children'> {
|
58
|
+
/**
|
59
|
+
* The drawer title
|
60
|
+
*/
|
61
|
+
title: React.ReactNode;
|
62
|
+
/**
|
63
|
+
* Hide the close button
|
64
|
+
*/
|
65
|
+
hideCloseButton?: boolean;
|
66
|
+
/**
|
67
|
+
* Hide the overflow
|
68
|
+
*/
|
69
|
+
hideOverlay?: boolean;
|
70
|
+
children?: React.ReactNode;
|
71
|
+
}
|
72
|
+
declare const BaseDrawer: React.FC<BaseDrawerProps>;
|
73
|
+
interface DrawerProps extends BaseDrawerProps {
|
74
|
+
/**
|
75
|
+
* Drawer footer content, wrapped with `DrawerFooter`
|
76
|
+
*/
|
77
|
+
footer?: React.ReactNode;
|
78
|
+
}
|
79
|
+
declare const Drawer: React.FC<DrawerProps>;
|
80
|
+
|
81
|
+
interface BaseModalProps extends ModalProps {
|
82
|
+
/**
|
83
|
+
* The modal title
|
84
|
+
*/
|
85
|
+
title?: React.ReactNode;
|
86
|
+
/**
|
87
|
+
* The modal footer
|
88
|
+
*/
|
89
|
+
footer?: React.ReactNode;
|
90
|
+
/**
|
91
|
+
* Hide the close button
|
92
|
+
*/
|
93
|
+
hideCloseButton?: boolean;
|
94
|
+
/**
|
95
|
+
* Hide the overlay
|
96
|
+
*/
|
97
|
+
hideOverlay?: boolean;
|
98
|
+
}
|
99
|
+
declare const BaseModal: React.FC<BaseModalProps>;
|
100
|
+
declare const Modal: React.FC<BaseModalProps>;
|
101
|
+
|
102
|
+
interface MenuDialogProps extends BaseModalProps {
|
103
|
+
/**
|
104
|
+
* The modal footer, wrapped with `ModalFooter`
|
105
|
+
*/
|
106
|
+
footer?: React.ReactNode;
|
107
|
+
}
|
108
|
+
declare const MenuDialog: React.FC<MenuDialogProps>;
|
109
|
+
interface MenuDialogListProps extends Omit<BaseModalProps, 'isOpen' | 'onClose' | 'children' | 'scrollBehavior'>, Omit<MenuListProps, 'title'> {
|
110
|
+
}
|
111
|
+
declare const MenuDialogList: _chakra_ui_system_dist_system_types.ComponentWithAs<"div", MenuDialogListProps>;
|
112
|
+
|
113
|
+
interface FormDialogProps<TFieldValues extends FieldValues = FieldValues, TContext extends object = object> extends Omit<BaseModalProps, 'children'>, Pick<FormProps<TFieldValues, TContext>, 'schema' | 'defaultValues' | 'values' | 'context' | 'onChange' | 'onSubmit' | 'onError' | 'resolver' | 'mode' | 'reValidateMode' | 'shouldFocusError' | 'shouldUnregister' | 'shouldUseNativeValidation' | 'criteriaMode' | 'delayError'> {
|
114
|
+
/**
|
115
|
+
* The modal footer, will be wrapped with `ModalFooter`.
|
116
|
+
* Defaults to a cancel and submit button.
|
117
|
+
*/
|
118
|
+
footer?: React.ReactNode;
|
119
|
+
/**
|
120
|
+
* The cancel button label
|
121
|
+
* @default "Cancel"
|
122
|
+
*/
|
123
|
+
cancelLabel?: React.ReactNode;
|
124
|
+
/**
|
125
|
+
* The submit button label
|
126
|
+
* @default "Submit"
|
127
|
+
*/
|
128
|
+
submitLabel?: React.ReactNode;
|
129
|
+
/**
|
130
|
+
* If no children are passed, this will auto render fields based on the supplied schema.
|
131
|
+
*/
|
132
|
+
children?: React.ReactNode;
|
133
|
+
/**
|
134
|
+
* A schema field resolver used to auto generate form fields.
|
135
|
+
*/
|
136
|
+
fieldResolver?: FieldResolver;
|
137
|
+
}
|
138
|
+
declare const FormDialog: <TFieldValues extends FieldValues>(props: FormDialogProps<TFieldValues, object> & {
|
139
|
+
ref?: React.ForwardedRef<HTMLFormElement> | undefined;
|
140
|
+
}) => React.ReactElement;
|
141
|
+
|
142
|
+
interface ModalsContextValue {
|
143
|
+
open: (options: OpenOptions) => ModalId;
|
144
|
+
drawer: (options: DrawerOptions) => ModalId;
|
145
|
+
alert: (options: ConfirmDialogOptions) => ModalId;
|
146
|
+
confirm: (options: ConfirmDialogOptions) => ModalId;
|
147
|
+
menu: (options: MenuDialogOptions) => ModalId;
|
148
|
+
form: (options: FormDialogOptions) => ModalId;
|
149
|
+
close: (id: ModalId) => void;
|
150
|
+
closeAll: () => void;
|
151
|
+
}
|
152
|
+
declare const ModalsContext: React.Context<ModalsContextValue | null>;
|
153
|
+
interface ModalsProviderProps {
|
154
|
+
children: React.ReactNode;
|
155
|
+
modals?: Record<string, React.FC<any>>;
|
156
|
+
}
|
157
|
+
type ModalId = string | number;
|
158
|
+
interface ModalOptions extends Omit<BaseModalProps, 'onClose' | 'isOpen' | 'children'> {
|
159
|
+
onClose?: (args: {
|
160
|
+
force?: boolean;
|
161
|
+
}) => Promise<boolean | undefined> | void;
|
162
|
+
body?: React.ReactNode;
|
163
|
+
children?: React.ReactNode;
|
164
|
+
[key: string]: any;
|
165
|
+
}
|
166
|
+
interface DrawerOptions extends ModalOptions, Omit<DrawerProps, 'onClose' | 'isOpen' | 'children' | 'title' | 'size'> {
|
167
|
+
}
|
168
|
+
interface ConfirmDialogOptions extends ModalOptions, Omit<ConfirmDialogProps, 'onClose' | 'isOpen' | 'children'> {
|
169
|
+
}
|
170
|
+
interface MenuDialogOptions extends ModalOptions, Omit<MenuDialogProps, 'onClose' | 'isOpen' | 'children'> {
|
171
|
+
}
|
172
|
+
interface FormDialogOptions extends ModalOptions, Omit<FormDialogProps, 'onClose' | 'isOpen' | 'children'> {
|
173
|
+
}
|
174
|
+
interface OpenOptions extends ModalOptions {
|
175
|
+
type?: ModalTypes;
|
176
|
+
scope?: ModalScopes;
|
177
|
+
}
|
178
|
+
type ModalScopes = 'modal' | 'alert';
|
179
|
+
type ModalTypes = 'modal' | 'drawer' | 'alert' | 'confirm' | 'menu' | string;
|
180
|
+
interface ModalConfig<TModalOptions extends ModalOptions = ModalOptions> {
|
181
|
+
/**
|
182
|
+
* The modal id, autogenerated when not set.
|
183
|
+
* Can be used to close modals.
|
184
|
+
*/
|
185
|
+
id?: ModalId | null;
|
186
|
+
/**
|
187
|
+
* The modal props
|
188
|
+
*/
|
189
|
+
props?: TModalOptions | null;
|
190
|
+
/**
|
191
|
+
* The modal scope
|
192
|
+
* Modals can only have one level per scope.
|
193
|
+
* The default scopes are 'modal' and 'alert', alerts can be openend above modals.
|
194
|
+
*/
|
195
|
+
scope?: ModalScopes | string;
|
196
|
+
/**
|
197
|
+
* The modal type to open.
|
198
|
+
* Build in types are 'modal', 'drawer', 'alert', 'confirm'
|
199
|
+
*
|
200
|
+
* Custom types can be configured using the `modals` prop of `ModalProvider`
|
201
|
+
*/
|
202
|
+
type?: ModalTypes;
|
203
|
+
/**
|
204
|
+
* Render a custom modal component.
|
205
|
+
* This will ignore the `type` param.
|
206
|
+
*/
|
207
|
+
component?: React.FC<BaseModalProps>;
|
208
|
+
/**
|
209
|
+
* Whether the modal is open or not.
|
210
|
+
* This is used internally to keep track of the modal state.
|
211
|
+
*/
|
212
|
+
isOpen?: boolean;
|
213
|
+
}
|
214
|
+
declare function ModalsProvider({ children, modals }: ModalsProviderProps): JSX.Element;
|
215
|
+
declare const useModalsContext: () => ModalsContextValue;
|
216
|
+
declare const useModals: () => ModalsContextValue;
|
217
|
+
|
218
|
+
export { BaseDrawer, BaseDrawerProps, BaseModal, BaseModalProps, ConfirmDialog, ConfirmDialogOptions, ConfirmDialogProps, Drawer, DrawerOptions, DrawerProps, FormDialog, FormDialogOptions, FormDialogProps, MenuDialog, MenuDialogList, MenuDialogListProps, MenuDialogOptions, MenuDialogProps, Modal, ModalConfig, ModalId, ModalScopes, ModalTypes, ModalsContext, ModalsContextValue, ModalsProvider, OpenOptions, useModals, useModalsContext };
|