@saas-ui/modals 2.1.41 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,165 @@
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/yup/index.ts
22
+ var yup_exports = {};
23
+ __export(yup_exports, {
24
+ FormDialog: () => FormDialog2,
25
+ createYupFormDialog: () => createYupFormDialog
26
+ });
27
+ module.exports = __toCommonJS(yup_exports);
28
+ var import_yup = require("@saas-ui/forms/yup");
29
+
30
+ // src/form.tsx
31
+ var import_react2 = require("@chakra-ui/react");
32
+ var import_react_utils = require("@saas-ui/react-utils");
33
+ var import_forms = require("@saas-ui/forms");
34
+
35
+ // src/modal.tsx
36
+ var import_react = require("@chakra-ui/react");
37
+ var import_utils = require("@chakra-ui/utils");
38
+ var import_jsx_runtime = require("react/jsx-runtime");
39
+ var BaseModal = (props) => {
40
+ const {
41
+ title,
42
+ footer,
43
+ children,
44
+ isOpen,
45
+ onClose,
46
+ hideCloseButton,
47
+ hideOverlay,
48
+ headerProps,
49
+ contentProps,
50
+ footerProps,
51
+ ...rest
52
+ } = props;
53
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Modal, { isOpen, onClose, ...rest, children: [
54
+ !hideOverlay && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.ModalOverlay, {}),
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.ModalContent, { ...contentProps, children: [
56
+ title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.ModalHeader, { ...headerProps, children: title }),
57
+ !hideCloseButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.ModalCloseButton, {}),
58
+ (0, import_utils.runIfFn)(children, {
59
+ isOpen,
60
+ onClose
61
+ }),
62
+ footer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.ModalFooter, { ...footerProps, children: footer })
63
+ ] })
64
+ ] });
65
+ };
66
+
67
+ // src/form.tsx
68
+ var import_jsx_runtime2 = require("react/jsx-runtime");
69
+ var useFormProps = (props) => {
70
+ const {
71
+ schema,
72
+ resolver,
73
+ fieldResolver,
74
+ defaultValues,
75
+ values,
76
+ context,
77
+ onChange,
78
+ onSubmit,
79
+ onError,
80
+ mode,
81
+ reValidateMode,
82
+ shouldFocusError = true,
83
+ shouldUnregister,
84
+ shouldUseNativeValidation,
85
+ criteriaMode,
86
+ delayError = 100,
87
+ fields,
88
+ formRef,
89
+ ...modalProps
90
+ } = props;
91
+ const formProps = {
92
+ schema,
93
+ resolver,
94
+ defaultValues,
95
+ values,
96
+ context,
97
+ onChange,
98
+ onSubmit,
99
+ onError,
100
+ mode,
101
+ reValidateMode,
102
+ shouldFocusError,
103
+ shouldUnregister,
104
+ shouldUseNativeValidation,
105
+ criteriaMode,
106
+ delayError,
107
+ fields,
108
+ formRef
109
+ };
110
+ return { modalProps, formProps, fields };
111
+ };
112
+ function createFormDialog(Form3) {
113
+ const Dialog = (0, import_react2.forwardRef)((props, ref) => {
114
+ const { isOpen, onClose, footer, children, ...rest } = props;
115
+ const { modalProps, formProps, fields } = useFormProps(rest);
116
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseModal, { ...modalProps, isOpen, onClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
117
+ Form3,
118
+ {
119
+ ref,
120
+ ...formProps,
121
+ flex: "1",
122
+ minHeight: "0px",
123
+ display: "flex",
124
+ flexDirection: "column",
125
+ children: (form) => {
126
+ var _a, _b;
127
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
128
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.ModalBody, { height: "100%", children: (0, import_react_utils.runIfFn)(children, form) || /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_forms.AutoFields, {}) }),
129
+ footer || /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.ModalFooter, { children: [
130
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
131
+ import_react2.Button,
132
+ {
133
+ variant: "ghost",
134
+ mr: 3,
135
+ onClick: onClose,
136
+ ...fields == null ? void 0 : fields.cancel,
137
+ children: (_b = (_a = fields == null ? void 0 : fields.cancel) == null ? void 0 : _a.children) != null ? _b : "Cancel"
138
+ }
139
+ ),
140
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_forms.SubmitButton, { ...fields == null ? void 0 : fields.submit })
141
+ ] })
142
+ ] });
143
+ }
144
+ }
145
+ ) });
146
+ });
147
+ Dialog.displayName = `${Form3.displayName || Form3.name}Dialog`;
148
+ Dialog.id = Form3.id;
149
+ return Dialog;
150
+ }
151
+ var FormDialog = createFormDialog(import_forms.Form);
152
+
153
+ // src/yup/create-yup-form-dialog.ts
154
+ function createYupFormDialog(Form3) {
155
+ return createFormDialog(Form3);
156
+ }
157
+
158
+ // src/yup/index.ts
159
+ var FormDialog2 = createYupFormDialog(import_yup.Form);
160
+ // Annotate the CommonJS export names for ESM import in node:
161
+ 0 && (module.exports = {
162
+ FormDialog,
163
+ createYupFormDialog
164
+ });
165
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/yup/index.ts","../../src/form.tsx","../../src/modal.tsx","../../src/yup/create-yup-form-dialog.ts"],"sourcesContent":["import { Form } from '@saas-ui/forms/yup'\nimport { createYupFormDialog } from './create-yup-form-dialog'\n\nexport { createYupFormDialog }\n\nexport const FormDialog = createYupFormDialog(Form)\n","import * as React from 'react'\n\nimport {\n ModalBody,\n ModalFooter,\n Button,\n forwardRef,\n ButtonProps,\n} from '@chakra-ui/react'\nimport { runIfFn } from '@saas-ui/react-utils'\n\nimport {\n Form,\n AutoFields,\n SubmitButton,\n FormProps,\n FieldValues,\n FieldResolver,\n FieldProps,\n FormType,\n DefaultFieldOverrides,\n} from '@saas-ui/forms'\n\nimport { BaseModal, BaseModalProps } from './modal'\n\nexport type FormDialogFieldOverrides = DefaultFieldOverrides & {\n cancel?: ButtonProps\n}\n\nexport interface FormDialogProps<\n TSchema = any,\n TFieldValues extends FieldValues = FieldValues,\n TContext extends object = object,\n TExtraFieldProps extends object = object,\n TFieldTypes = FieldProps<TFieldValues>,\n> extends Omit<BaseModalProps, 'children'>,\n Pick<\n FormProps<TSchema, TFieldValues, TContext, TExtraFieldProps, TFieldTypes>,\n | 'schema'\n | 'defaultValues'\n | 'values'\n | 'context'\n | 'onChange'\n | 'onSubmit'\n | 'onError'\n | 'resolver'\n | 'mode'\n | 'reValidateMode'\n | 'shouldFocusError'\n | 'shouldUnregister'\n | 'shouldUseNativeValidation'\n | 'criteriaMode'\n | 'delayError'\n | 'resetOptions'\n | 'formRef'\n | 'children'\n > {\n /**\n * The modal footer, will be wrapped with `ModalFooter`.\n * Defaults to a cancel and submit button.\n */\n footer?: React.ReactNode\n /**\n * A schema field resolver used to auto generate form fields.\n */\n fieldResolver?: FieldResolver\n /**\n * Field overrides\n */\n fields?: FormDialogFieldOverrides\n}\n\nconst useFormProps = (props: FormDialogProps) => {\n const {\n schema,\n resolver,\n fieldResolver,\n defaultValues,\n values,\n context,\n onChange,\n onSubmit,\n onError,\n mode,\n reValidateMode,\n shouldFocusError = true,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError = 100,\n fields,\n formRef,\n ...modalProps\n } = props\n\n const formProps = {\n schema,\n resolver,\n defaultValues,\n values,\n context,\n onChange,\n onSubmit,\n onError,\n mode,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n fields,\n formRef,\n }\n\n return { modalProps, formProps, fields }\n}\n\n/**\n * @todo make this dynamic to support other schema types\n */\ntype MergeDialogProps<T> =\n T extends FormType<\n infer FieldDefs,\n infer ExtraProps,\n infer ExtraFieldProps,\n infer ExtraOverrides\n >\n ? FormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n : never\n\ntype IsSchemaType<T, Schema, FieldDefs> =\n T extends DefaultFormType<FieldDefs>\n ? T extends (\n props: FormProps<infer TSchema, infer TFieldValues, infer TContext>\n ) => any\n ? Schema extends TSchema\n ? true\n : false\n : false\n : false\n\nexport type DefaultFormType<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = FormDialogFieldOverrides,\n> = (<\n TSchema = unknown,\n TFieldValues extends Record<string, any> = any,\n TContext extends object = object,\n>(\n props: any\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport function createFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = FormDialogFieldOverrides,\n TFormType extends DefaultFormType<\n FieldDefs,\n ExtraProps,\n ExtraFieldProps,\n ExtraOverrides\n > = DefaultFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>,\n>(Form: TFormType) {\n const Dialog = forwardRef<any, 'div'>((props, ref) => {\n const { isOpen, onClose, footer, children, ...rest } = props\n const { modalProps, formProps, fields } = useFormProps(rest)\n return (\n <BaseModal {...modalProps} isOpen={isOpen} onClose={onClose}>\n <Form\n ref={ref}\n {...(formProps as any)}\n flex=\"1\"\n minHeight=\"0px\"\n display=\"flex\"\n flexDirection=\"column\"\n >\n {(form: any) => (\n <>\n <ModalBody height=\"100%\">\n {runIfFn(children, form) || <AutoFields />}\n </ModalBody>\n\n {footer || (\n <ModalFooter>\n <Button\n variant=\"ghost\"\n mr={3}\n onClick={onClose}\n {...fields?.cancel}\n >\n {fields?.cancel?.children ?? 'Cancel'}\n </Button>\n <SubmitButton {...fields?.submit} />\n </ModalFooter>\n )}\n </>\n )}\n </Form>\n </BaseModal>\n )\n }) as MergeDialogProps<TFormType>\n\n Dialog.displayName = `${Form.displayName || Form.name}Dialog`\n Dialog.id = Form.id\n\n return Dialog\n}\n\n/**\n * Can be used to quickly request information from people without leaving the current page.\n *\n * @see Docs https://saas-ui.dev/docs/components/overlay/form-dialog\n */\nexport const FormDialog = createFormDialog(Form)\n","import * as React from 'react'\n\nimport {\n Modal as ChakraModal,\n ModalOverlay,\n ModalContent,\n ModalHeader,\n ModalFooter,\n ModalBody,\n ModalCloseButton,\n ModalProps as ChakraModalProps,\n ModalContentProps,\n ModalHeaderProps,\n ModalFooterProps,\n} from '@chakra-ui/react'\nimport { MaybeRenderProp } from '@chakra-ui/react-utils'\nimport { runIfFn } from '@chakra-ui/utils'\n\nexport interface BaseModalProps extends Omit<ChakraModalProps, 'children'> {\n /**\n * The modal title\n */\n title?: React.ReactNode\n /**\n * The modal children\n */\n children: MaybeRenderProp<{\n isOpen: boolean\n onClose: () => 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 hideOverlay?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: ModalHeaderProps\n /**\n * Props for the modal content\n */\n contentProps?: ModalContentProps\n /**\n * Props for the modal footer\n */\n footerProps?: ModalFooterProps\n}\n\nexport const BaseModal: React.FC<BaseModalProps> = (props) => {\n const {\n title,\n footer,\n children,\n isOpen,\n onClose,\n hideCloseButton,\n hideOverlay,\n headerProps,\n contentProps,\n footerProps,\n ...rest\n } = props\n return (\n <ChakraModal isOpen={isOpen} onClose={onClose} {...rest}>\n {!hideOverlay && <ModalOverlay />}\n <ModalContent {...contentProps}>\n {title && <ModalHeader {...headerProps}>{title}</ModalHeader>}\n {!hideCloseButton && <ModalCloseButton />}\n {runIfFn(children, {\n isOpen,\n onClose,\n })}\n {footer && <ModalFooter {...footerProps}>{footer}</ModalFooter>}\n </ModalContent>\n </ChakraModal>\n )\n}\n\nexport const Modal: React.FC<BaseModalProps> = (props) => {\n const { children, isOpen, onClose, ...rest } = props\n return (\n <BaseModal {...rest} isOpen={isOpen} onClose={onClose}>\n <ModalBody>\n {runIfFn(children, {\n isOpen,\n onClose,\n })}\n </ModalBody>\n </BaseModal>\n )\n}\n","import type { YupFormType } from '@saas-ui/forms/yup'\nimport { FormDialogFieldOverrides, createFormDialog } from '../form'\n\nimport type { BaseModalProps } from '../modal'\n\nexport function createYupFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n>(Form: YupFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {\n return createFormDialog(Form) as unknown as YupFormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n}\n"],"mappings":"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","names":["FormDialog","import_react","ChakraModal","import_jsx_runtime","Form","Form","FormDialog"]}
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ import {
3
+ createFormDialog
4
+ } from "../chunk-I63K4ILP.mjs";
5
+
6
+ // src/yup/index.ts
7
+ import { Form } from "@saas-ui/forms/yup";
8
+
9
+ // src/yup/create-yup-form-dialog.ts
10
+ function createYupFormDialog(Form2) {
11
+ return createFormDialog(Form2);
12
+ }
13
+
14
+ // src/yup/index.ts
15
+ var FormDialog = createYupFormDialog(Form);
16
+ export {
17
+ FormDialog,
18
+ createYupFormDialog
19
+ };
20
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/yup/index.ts","../../src/yup/create-yup-form-dialog.ts"],"sourcesContent":["import { Form } from '@saas-ui/forms/yup'\nimport { createYupFormDialog } from './create-yup-form-dialog'\n\nexport { createYupFormDialog }\n\nexport const FormDialog = createYupFormDialog(Form)\n","import type { YupFormType } from '@saas-ui/forms/yup'\nimport { FormDialogFieldOverrides, createFormDialog } from '../form'\n\nimport type { BaseModalProps } from '../modal'\n\nexport function createYupFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n>(Form: YupFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {\n return createFormDialog(Form) as unknown as YupFormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n}\n"],"mappings":";;;;;;AAAA,SAAS,YAAY;;;ACKd,SAAS,oBAKdA,OAA2E;AAC3E,SAAO,iBAAiBA,KAAI;AAM9B;;;ADZO,IAAM,aAAa,oBAAoB,IAAI;","names":["Form"]}
@@ -0,0 +1,15 @@
1
+ import * as _saas_ui_forms_zod from '@saas-ui/forms/zod';
2
+ import { ZodFormType } from '@saas-ui/forms/zod';
3
+ import * as _chakra_ui_react from '@chakra-ui/react';
4
+ import * as _saas_ui_forms from '@saas-ui/forms';
5
+ import { B as BaseModalProps, F as FormDialogFieldOverrides } from '../form-Cdu466OH.mjs';
6
+ import 'react';
7
+ import '@chakra-ui/react-utils';
8
+
9
+ declare function createZodFormDialog<FieldDefs = any, ExtraProps = object, ExtraFieldProps extends object = object, ExtraOverrides = object>(Form: ZodFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>): ZodFormType<FieldDefs, ExtraProps & Omit<BaseModalProps, "children">, ExtraFieldProps, ExtraOverrides & FormDialogFieldOverrides>;
10
+
11
+ declare const FormDialog: _saas_ui_forms_zod.ZodFormType<unknown, object & Omit<BaseModalProps, "children">, any, object & _saas_ui_forms.DefaultFieldOverrides & {
12
+ cancel?: _chakra_ui_react.ButtonProps;
13
+ }>;
14
+
15
+ export { FormDialog, createZodFormDialog };
@@ -0,0 +1,15 @@
1
+ import * as _saas_ui_forms_zod from '@saas-ui/forms/zod';
2
+ import { ZodFormType } from '@saas-ui/forms/zod';
3
+ import * as _chakra_ui_react from '@chakra-ui/react';
4
+ import * as _saas_ui_forms from '@saas-ui/forms';
5
+ import { B as BaseModalProps, F as FormDialogFieldOverrides } from '../form-Cdu466OH.js';
6
+ import 'react';
7
+ import '@chakra-ui/react-utils';
8
+
9
+ declare function createZodFormDialog<FieldDefs = any, ExtraProps = object, ExtraFieldProps extends object = object, ExtraOverrides = object>(Form: ZodFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>): ZodFormType<FieldDefs, ExtraProps & Omit<BaseModalProps, "children">, ExtraFieldProps, ExtraOverrides & FormDialogFieldOverrides>;
10
+
11
+ declare const FormDialog: _saas_ui_forms_zod.ZodFormType<unknown, object & Omit<BaseModalProps, "children">, any, object & _saas_ui_forms.DefaultFieldOverrides & {
12
+ cancel?: _chakra_ui_react.ButtonProps;
13
+ }>;
14
+
15
+ export { FormDialog, createZodFormDialog };
@@ -0,0 +1,165 @@
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/zod/index.ts
22
+ var zod_exports = {};
23
+ __export(zod_exports, {
24
+ FormDialog: () => FormDialog2,
25
+ createZodFormDialog: () => createZodFormDialog
26
+ });
27
+ module.exports = __toCommonJS(zod_exports);
28
+ var import_zod = require("@saas-ui/forms/zod");
29
+
30
+ // src/form.tsx
31
+ var import_react2 = require("@chakra-ui/react");
32
+ var import_react_utils = require("@saas-ui/react-utils");
33
+ var import_forms = require("@saas-ui/forms");
34
+
35
+ // src/modal.tsx
36
+ var import_react = require("@chakra-ui/react");
37
+ var import_utils = require("@chakra-ui/utils");
38
+ var import_jsx_runtime = require("react/jsx-runtime");
39
+ var BaseModal = (props) => {
40
+ const {
41
+ title,
42
+ footer,
43
+ children,
44
+ isOpen,
45
+ onClose,
46
+ hideCloseButton,
47
+ hideOverlay,
48
+ headerProps,
49
+ contentProps,
50
+ footerProps,
51
+ ...rest
52
+ } = props;
53
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Modal, { isOpen, onClose, ...rest, children: [
54
+ !hideOverlay && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.ModalOverlay, {}),
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.ModalContent, { ...contentProps, children: [
56
+ title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.ModalHeader, { ...headerProps, children: title }),
57
+ !hideCloseButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.ModalCloseButton, {}),
58
+ (0, import_utils.runIfFn)(children, {
59
+ isOpen,
60
+ onClose
61
+ }),
62
+ footer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.ModalFooter, { ...footerProps, children: footer })
63
+ ] })
64
+ ] });
65
+ };
66
+
67
+ // src/form.tsx
68
+ var import_jsx_runtime2 = require("react/jsx-runtime");
69
+ var useFormProps = (props) => {
70
+ const {
71
+ schema,
72
+ resolver,
73
+ fieldResolver,
74
+ defaultValues,
75
+ values,
76
+ context,
77
+ onChange,
78
+ onSubmit,
79
+ onError,
80
+ mode,
81
+ reValidateMode,
82
+ shouldFocusError = true,
83
+ shouldUnregister,
84
+ shouldUseNativeValidation,
85
+ criteriaMode,
86
+ delayError = 100,
87
+ fields,
88
+ formRef,
89
+ ...modalProps
90
+ } = props;
91
+ const formProps = {
92
+ schema,
93
+ resolver,
94
+ defaultValues,
95
+ values,
96
+ context,
97
+ onChange,
98
+ onSubmit,
99
+ onError,
100
+ mode,
101
+ reValidateMode,
102
+ shouldFocusError,
103
+ shouldUnregister,
104
+ shouldUseNativeValidation,
105
+ criteriaMode,
106
+ delayError,
107
+ fields,
108
+ formRef
109
+ };
110
+ return { modalProps, formProps, fields };
111
+ };
112
+ function createFormDialog(Form3) {
113
+ const Dialog = (0, import_react2.forwardRef)((props, ref) => {
114
+ const { isOpen, onClose, footer, children, ...rest } = props;
115
+ const { modalProps, formProps, fields } = useFormProps(rest);
116
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BaseModal, { ...modalProps, isOpen, onClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
117
+ Form3,
118
+ {
119
+ ref,
120
+ ...formProps,
121
+ flex: "1",
122
+ minHeight: "0px",
123
+ display: "flex",
124
+ flexDirection: "column",
125
+ children: (form) => {
126
+ var _a, _b;
127
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
128
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.ModalBody, { height: "100%", children: (0, import_react_utils.runIfFn)(children, form) || /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_forms.AutoFields, {}) }),
129
+ footer || /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react2.ModalFooter, { children: [
130
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
131
+ import_react2.Button,
132
+ {
133
+ variant: "ghost",
134
+ mr: 3,
135
+ onClick: onClose,
136
+ ...fields == null ? void 0 : fields.cancel,
137
+ children: (_b = (_a = fields == null ? void 0 : fields.cancel) == null ? void 0 : _a.children) != null ? _b : "Cancel"
138
+ }
139
+ ),
140
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_forms.SubmitButton, { ...fields == null ? void 0 : fields.submit })
141
+ ] })
142
+ ] });
143
+ }
144
+ }
145
+ ) });
146
+ });
147
+ Dialog.displayName = `${Form3.displayName || Form3.name}Dialog`;
148
+ Dialog.id = Form3.id;
149
+ return Dialog;
150
+ }
151
+ var FormDialog = createFormDialog(import_forms.Form);
152
+
153
+ // src/zod/create-zod-form-dialog.ts
154
+ function createZodFormDialog(Form3) {
155
+ return createFormDialog(Form3);
156
+ }
157
+
158
+ // src/zod/index.ts
159
+ var FormDialog2 = createZodFormDialog(import_zod.Form);
160
+ // Annotate the CommonJS export names for ESM import in node:
161
+ 0 && (module.exports = {
162
+ FormDialog,
163
+ createZodFormDialog
164
+ });
165
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/zod/index.ts","../../src/form.tsx","../../src/modal.tsx","../../src/zod/create-zod-form-dialog.ts"],"sourcesContent":["import { Form } from '@saas-ui/forms/zod'\nimport { createZodFormDialog } from './create-zod-form-dialog'\n\nexport { createZodFormDialog }\n\nexport const FormDialog = createZodFormDialog(Form)\n","import * as React from 'react'\n\nimport {\n ModalBody,\n ModalFooter,\n Button,\n forwardRef,\n ButtonProps,\n} from '@chakra-ui/react'\nimport { runIfFn } from '@saas-ui/react-utils'\n\nimport {\n Form,\n AutoFields,\n SubmitButton,\n FormProps,\n FieldValues,\n FieldResolver,\n FieldProps,\n FormType,\n DefaultFieldOverrides,\n} from '@saas-ui/forms'\n\nimport { BaseModal, BaseModalProps } from './modal'\n\nexport type FormDialogFieldOverrides = DefaultFieldOverrides & {\n cancel?: ButtonProps\n}\n\nexport interface FormDialogProps<\n TSchema = any,\n TFieldValues extends FieldValues = FieldValues,\n TContext extends object = object,\n TExtraFieldProps extends object = object,\n TFieldTypes = FieldProps<TFieldValues>,\n> extends Omit<BaseModalProps, 'children'>,\n Pick<\n FormProps<TSchema, TFieldValues, TContext, TExtraFieldProps, TFieldTypes>,\n | 'schema'\n | 'defaultValues'\n | 'values'\n | 'context'\n | 'onChange'\n | 'onSubmit'\n | 'onError'\n | 'resolver'\n | 'mode'\n | 'reValidateMode'\n | 'shouldFocusError'\n | 'shouldUnregister'\n | 'shouldUseNativeValidation'\n | 'criteriaMode'\n | 'delayError'\n | 'resetOptions'\n | 'formRef'\n | 'children'\n > {\n /**\n * The modal footer, will be wrapped with `ModalFooter`.\n * Defaults to a cancel and submit button.\n */\n footer?: React.ReactNode\n /**\n * A schema field resolver used to auto generate form fields.\n */\n fieldResolver?: FieldResolver\n /**\n * Field overrides\n */\n fields?: FormDialogFieldOverrides\n}\n\nconst useFormProps = (props: FormDialogProps) => {\n const {\n schema,\n resolver,\n fieldResolver,\n defaultValues,\n values,\n context,\n onChange,\n onSubmit,\n onError,\n mode,\n reValidateMode,\n shouldFocusError = true,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError = 100,\n fields,\n formRef,\n ...modalProps\n } = props\n\n const formProps = {\n schema,\n resolver,\n defaultValues,\n values,\n context,\n onChange,\n onSubmit,\n onError,\n mode,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n fields,\n formRef,\n }\n\n return { modalProps, formProps, fields }\n}\n\n/**\n * @todo make this dynamic to support other schema types\n */\ntype MergeDialogProps<T> =\n T extends FormType<\n infer FieldDefs,\n infer ExtraProps,\n infer ExtraFieldProps,\n infer ExtraOverrides\n >\n ? FormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n : never\n\ntype IsSchemaType<T, Schema, FieldDefs> =\n T extends DefaultFormType<FieldDefs>\n ? T extends (\n props: FormProps<infer TSchema, infer TFieldValues, infer TContext>\n ) => any\n ? Schema extends TSchema\n ? true\n : false\n : false\n : false\n\nexport type DefaultFormType<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = FormDialogFieldOverrides,\n> = (<\n TSchema = unknown,\n TFieldValues extends Record<string, any> = any,\n TContext extends object = object,\n>(\n props: any\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport function createFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = FormDialogFieldOverrides,\n TFormType extends DefaultFormType<\n FieldDefs,\n ExtraProps,\n ExtraFieldProps,\n ExtraOverrides\n > = DefaultFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>,\n>(Form: TFormType) {\n const Dialog = forwardRef<any, 'div'>((props, ref) => {\n const { isOpen, onClose, footer, children, ...rest } = props\n const { modalProps, formProps, fields } = useFormProps(rest)\n return (\n <BaseModal {...modalProps} isOpen={isOpen} onClose={onClose}>\n <Form\n ref={ref}\n {...(formProps as any)}\n flex=\"1\"\n minHeight=\"0px\"\n display=\"flex\"\n flexDirection=\"column\"\n >\n {(form: any) => (\n <>\n <ModalBody height=\"100%\">\n {runIfFn(children, form) || <AutoFields />}\n </ModalBody>\n\n {footer || (\n <ModalFooter>\n <Button\n variant=\"ghost\"\n mr={3}\n onClick={onClose}\n {...fields?.cancel}\n >\n {fields?.cancel?.children ?? 'Cancel'}\n </Button>\n <SubmitButton {...fields?.submit} />\n </ModalFooter>\n )}\n </>\n )}\n </Form>\n </BaseModal>\n )\n }) as MergeDialogProps<TFormType>\n\n Dialog.displayName = `${Form.displayName || Form.name}Dialog`\n Dialog.id = Form.id\n\n return Dialog\n}\n\n/**\n * Can be used to quickly request information from people without leaving the current page.\n *\n * @see Docs https://saas-ui.dev/docs/components/overlay/form-dialog\n */\nexport const FormDialog = createFormDialog(Form)\n","import * as React from 'react'\n\nimport {\n Modal as ChakraModal,\n ModalOverlay,\n ModalContent,\n ModalHeader,\n ModalFooter,\n ModalBody,\n ModalCloseButton,\n ModalProps as ChakraModalProps,\n ModalContentProps,\n ModalHeaderProps,\n ModalFooterProps,\n} from '@chakra-ui/react'\nimport { MaybeRenderProp } from '@chakra-ui/react-utils'\nimport { runIfFn } from '@chakra-ui/utils'\n\nexport interface BaseModalProps extends Omit<ChakraModalProps, 'children'> {\n /**\n * The modal title\n */\n title?: React.ReactNode\n /**\n * The modal children\n */\n children: MaybeRenderProp<{\n isOpen: boolean\n onClose: () => 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 hideOverlay?: boolean\n /**\n * Props for the modal header\n */\n headerProps?: ModalHeaderProps\n /**\n * Props for the modal content\n */\n contentProps?: ModalContentProps\n /**\n * Props for the modal footer\n */\n footerProps?: ModalFooterProps\n}\n\nexport const BaseModal: React.FC<BaseModalProps> = (props) => {\n const {\n title,\n footer,\n children,\n isOpen,\n onClose,\n hideCloseButton,\n hideOverlay,\n headerProps,\n contentProps,\n footerProps,\n ...rest\n } = props\n return (\n <ChakraModal isOpen={isOpen} onClose={onClose} {...rest}>\n {!hideOverlay && <ModalOverlay />}\n <ModalContent {...contentProps}>\n {title && <ModalHeader {...headerProps}>{title}</ModalHeader>}\n {!hideCloseButton && <ModalCloseButton />}\n {runIfFn(children, {\n isOpen,\n onClose,\n })}\n {footer && <ModalFooter {...footerProps}>{footer}</ModalFooter>}\n </ModalContent>\n </ChakraModal>\n )\n}\n\nexport const Modal: React.FC<BaseModalProps> = (props) => {\n const { children, isOpen, onClose, ...rest } = props\n return (\n <BaseModal {...rest} isOpen={isOpen} onClose={onClose}>\n <ModalBody>\n {runIfFn(children, {\n isOpen,\n onClose,\n })}\n </ModalBody>\n </BaseModal>\n )\n}\n","import type { ZodFormType } from '@saas-ui/forms/zod'\nimport { createFormDialog, FormDialogFieldOverrides } from '../form'\nimport type { BaseModalProps } from '../modal'\n\nexport function createZodFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n>(Form: ZodFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {\n return createFormDialog(Form) as unknown as ZodFormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n}\n"],"mappings":"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","names":["FormDialog","import_react","ChakraModal","import_jsx_runtime","Form","Form","FormDialog"]}
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ import {
3
+ createFormDialog
4
+ } from "../chunk-I63K4ILP.mjs";
5
+
6
+ // src/zod/index.ts
7
+ import { Form } from "@saas-ui/forms/zod";
8
+
9
+ // src/zod/create-zod-form-dialog.ts
10
+ function createZodFormDialog(Form2) {
11
+ return createFormDialog(Form2);
12
+ }
13
+
14
+ // src/zod/index.ts
15
+ var FormDialog = createZodFormDialog(Form);
16
+ export {
17
+ FormDialog,
18
+ createZodFormDialog
19
+ };
20
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/zod/index.ts","../../src/zod/create-zod-form-dialog.ts"],"sourcesContent":["import { Form } from '@saas-ui/forms/zod'\nimport { createZodFormDialog } from './create-zod-form-dialog'\n\nexport { createZodFormDialog }\n\nexport const FormDialog = createZodFormDialog(Form)\n","import type { ZodFormType } from '@saas-ui/forms/zod'\nimport { createFormDialog, FormDialogFieldOverrides } from '../form'\nimport type { BaseModalProps } from '../modal'\n\nexport function createZodFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n>(Form: ZodFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {\n return createFormDialog(Form) as unknown as ZodFormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n}\n"],"mappings":";;;;;;AAAA,SAAS,YAAY;;;ACId,SAAS,oBAKdA,OAA2E;AAC3E,SAAO,iBAAiBA,KAAI;AAM9B;;;ADXO,IAAM,aAAa,oBAAoB,IAAI;","names":["Form"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saas-ui/modals",
3
- "version": "2.1.41",
3
+ "version": "2.2.1",
4
4
  "description": "A modal manager for Chakra UI",
5
5
  "source": "src/index.ts",
6
6
  "exports": {
@@ -9,16 +9,49 @@
9
9
  "types": "./dist/index.d.ts",
10
10
  "import": "./dist/index.mjs"
11
11
  },
12
+ "./zod": {
13
+ "require": "./dist/zod/index.js",
14
+ "types": "./dist/zod/index.d.ts",
15
+ "import": "./dist/zod/index.mjs"
16
+ },
17
+ "./zod/src": {
18
+ "default": "./src/zod/index.ts"
19
+ },
20
+ "./yup": {
21
+ "require": "./dist/yup/index.js",
22
+ "types": "./dist/yup/index.d.ts",
23
+ "import": "./dist/yup/index.mjs"
24
+ },
25
+ "./yup/src": {
26
+ "default": "./src/yup/index.ts"
27
+ },
12
28
  "./src": {
13
29
  "default": "./src/index.ts"
14
30
  }
15
31
  },
32
+ "typesVersions": {
33
+ "*": {
34
+ "*": [
35
+ "dist/*"
36
+ ]
37
+ },
38
+ "zod": {
39
+ "*": [
40
+ "dist/zod/*"
41
+ ]
42
+ },
43
+ "yup": {
44
+ "*": [
45
+ "dist/yup/*"
46
+ ]
47
+ }
48
+ },
16
49
  "main": "./dist/index.js",
17
50
  "module": "./dist/index.mjs",
18
51
  "types": "./dist/index.d.ts",
19
52
  "scripts": {
20
53
  "clean": "rimraf dist",
21
- "build": "tsup src/index.ts --config tsup.config.ts",
54
+ "build": "tsup --config tsup.config.ts",
22
55
  "lint": "eslint src --ext .ts,.tsx,.js,.jsx --config ../../.eslintrc.js",
23
56
  "lint:staged": "lint-staged --allow-empty --config ../../lint-staged.config.js",
24
57
  "typecheck": "tsc --noEmit"
@@ -58,10 +91,10 @@
58
91
  },
59
92
  "dependencies": {
60
93
  "@chakra-ui/react-utils": "^2.0.12",
61
- "@chakra-ui/utils": "^2.0.15",
62
- "@saas-ui/forms": "2.6.11",
63
- "@saas-ui/hooks": "2.0.3",
64
- "@saas-ui/react-utils": "2.0.1"
94
+ "@chakra-ui/utils": "^2.2.1",
95
+ "@saas-ui/forms": "2.7.1",
96
+ "@saas-ui/hooks": "2.1.0",
97
+ "@saas-ui/react-utils": "2.1.1"
65
98
  },
66
99
  "peerDependencies": {
67
100
  "@chakra-ui/react": ">=2.4.9",
@@ -0,0 +1,18 @@
1
+ import type { YupFormType } from '@saas-ui/forms/yup'
2
+ import { FormDialogFieldOverrides, createFormDialog } from '../form'
3
+
4
+ import type { BaseModalProps } from '../modal'
5
+
6
+ export function createYupFormDialog<
7
+ FieldDefs = any,
8
+ ExtraProps = object,
9
+ ExtraFieldProps extends object = object,
10
+ ExtraOverrides = object,
11
+ >(Form: YupFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {
12
+ return createFormDialog(Form) as unknown as YupFormType<
13
+ FieldDefs,
14
+ ExtraProps & Omit<BaseModalProps, 'children'>,
15
+ ExtraFieldProps,
16
+ ExtraOverrides & FormDialogFieldOverrides
17
+ >
18
+ }
@@ -0,0 +1,6 @@
1
+ import { Form } from '@saas-ui/forms/yup'
2
+ import { createYupFormDialog } from './create-yup-form-dialog'
3
+
4
+ export { createYupFormDialog }
5
+
6
+ export const FormDialog = createYupFormDialog(Form)
@@ -0,0 +1,17 @@
1
+ import type { ZodFormType } from '@saas-ui/forms/zod'
2
+ import { createFormDialog, FormDialogFieldOverrides } from '../form'
3
+ import type { BaseModalProps } from '../modal'
4
+
5
+ export function createZodFormDialog<
6
+ FieldDefs = any,
7
+ ExtraProps = object,
8
+ ExtraFieldProps extends object = object,
9
+ ExtraOverrides = object,
10
+ >(Form: ZodFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {
11
+ return createFormDialog(Form) as unknown as ZodFormType<
12
+ FieldDefs,
13
+ ExtraProps & Omit<BaseModalProps, 'children'>,
14
+ ExtraFieldProps,
15
+ ExtraOverrides & FormDialogFieldOverrides
16
+ >
17
+ }
@@ -0,0 +1,6 @@
1
+ import { Form } from '@saas-ui/forms/zod'
2
+ import { createZodFormDialog } from './create-zod-form-dialog'
3
+
4
+ export { createZodFormDialog }
5
+
6
+ export const FormDialog = createZodFormDialog(Form)