@saas-ui/forms 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - fe754e6: Fixed Hook Form 7.33 compatibility.
8
+ - Updated dependencies [fe1e333]
9
+ - @saas-ui/input-right-button@1.0.1
10
+ - @saas-ui/password-input@1.0.1
11
+
3
12
  ## 1.0.1
4
13
 
5
14
  ### Patch Changes
package/ajv/package.json CHANGED
@@ -11,8 +11,8 @@
11
11
  "license": "MIT",
12
12
  "peerDependencies": {
13
13
  "@chakra-ui/utils": "^2.0.2",
14
- "@hookform/resolvers": "^2.9.0",
15
- "react-hook-form": "^7.31.3",
14
+ "@hookform/resolvers": "^2.9.3",
15
+ "react-hook-form": "^7.33.1",
16
16
  "ajv": "^8.11.0"
17
17
  }
18
18
  }
package/dist/form.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { HTMLChakraProps } from '@chakra-ui/react';
3
- import { UseFormProps, UseFormReturn, FieldValues, SubmitHandler, SubmitErrorHandler, UnpackNestedValue, ResolverOptions, ResolverResult } from 'react-hook-form';
3
+ import { UseFormProps, UseFormReturn, FieldValues, SubmitHandler, SubmitErrorHandler, ResolverOptions, ResolverResult } from 'react-hook-form';
4
4
  import { FieldResolver } from './field-resolver';
5
5
  export type { UseFormReturn, FieldValues, SubmitHandler };
6
6
  interface FormOptions<TFieldValues extends FieldValues = FieldValues> {
@@ -34,6 +34,6 @@ export declare const Form: (<TFieldValues extends FieldValues>(props: FormProps<
34
34
  getResolver?: GetResolver | undefined;
35
35
  getFieldResolver: GetFieldResolver;
36
36
  };
37
- export declare type GetResolver = (schema: any) => <TFieldValues extends FieldValues, TContext>(values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;
37
+ export declare type GetResolver = (schema: any) => <TFieldValues extends FieldValues, TContext>(values: TFieldValues, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<ResolverResult<TFieldValues>>;
38
38
  export declare type GetFieldResolver = (schema: any) => FieldResolver;
39
39
  //# sourceMappingURL=form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAU,eAAe,EAAc,MAAM,kBAAkB,CAAA;AAGtE,OAAO,EAGL,YAAY,EACZ,aAAa,EACb,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAuB,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA;AAEzD,UAAU,WAAW,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW;IAClE;;OAEG;IACH,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ;;OAEG;IACH,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IACrC;;OAEG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAA;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAA;CAC3C;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,YAAY,SAAS,WAAW,GAAG,WAAW,CACvE,SAAQ,YAAY,CAAC,YAAY,CAAC,EAChC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC,EACrD,WAAW,CAAC,YAAY,CAAC;CAAG;AAEhC,eAAO,MAAM,IAAI;;MA8DZ,MAAM,YAAY;;;sBAGH,gBAAgB;CACnC,CAAA;AAQD,oBAAY,WAAW,GAAG,C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AAY,CAAC;CAAG;AAEhC,eAAO,MAAM,IAAI;;MA8DZ,MAAM,YAAY;;;sBAGH,gBAAgB;CACnC,CAAA;AAQD,oBAAY,WAAW,GAAG,CACxB,MAAM,EAAE,GAAG,KACR,CAAC,YAAY,SAAS,WAAW,EAAE,QAAQ,EAC9C,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,QAAQ,GAAG,SAAS,EAC7B,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,KACnC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAA;AAE1C,oBAAY,gBAAgB,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,aAAa,CAAA"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/display-field.tsx","../src/field.tsx","../src/field-resolver.ts","../src/form.tsx","../src/layout.tsx","../src/utils.ts","../src/use-array-field.tsx","../src/array-field.tsx","../src/object-field.tsx","../src/fields.tsx","../src/submit-button.tsx","../src/auto-form.tsx","../src/display-if.tsx","../src/use-step-form.tsx","../src/step-form.tsx"],"sourcesContent":["import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { useFormContext } from 'react-hook-form'\n\nimport {\n Text,\n FormControl,\n FormControlProps,\n FormLabel,\n} from '@chakra-ui/react'\n\nimport { FieldProps } from './field'\n\nexport interface DisplayFieldProps\n extends FormControlProps,\n Omit<FieldProps, 'type' | 'label'> {}\n\nexport const DisplayField: React.FC<DisplayFieldProps> = ({\n name,\n label,\n placeholder,\n ...props\n}) => {\n return (\n <FormControl {...props}>\n {label ? <FormLabel htmlFor={name}>{label}</FormLabel> : null}\n <Text fontSize=\"md\">\n <FormValue name={name} />\n </Text>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n DisplayField.displayName = 'DisplayField'\n}\n\nexport const FormValue: React.FC<{ name: string }> = ({ name }) => {\n const { getValues } = useFormContext()\n return getValues(name) || null\n}\n\nif (__DEV__) {\n FormValue.displayName = 'FormValue'\n}\n","import * as React from 'react'\nimport {\n useFormContext,\n FormState,\n Controller,\n get,\n RegisterOptions,\n FieldValues,\n FieldPath,\n} from 'react-hook-form'\n\nimport {\n forwardRef,\n Box,\n FormControl,\n FormControlProps,\n FormLabel,\n FormHelperText,\n FormErrorMessage,\n Input,\n Textarea,\n Checkbox,\n Switch,\n useMergeRefs,\n InputGroup,\n InputProps,\n TextareaProps,\n SwitchProps,\n CheckboxProps,\n PinInputField,\n HStack,\n PinInput,\n UsePinInputProps,\n SystemProps,\n} from '@chakra-ui/react'\nimport { __DEV__, FocusableElement } from '@chakra-ui/utils'\n\nimport { NumberInput, NumberInputProps } from '@saas-ui/number-input'\nimport { PasswordInput, PasswordInputProps } from '@saas-ui/password-input'\nimport { RadioInput, RadioInputProps } from '@saas-ui/radio'\n\nimport {\n Select,\n SelectProps,\n NativeSelect,\n NativeSelectProps,\n} from '@saas-ui/select'\n\nexport interface Option {\n value: string\n label?: string\n [key: string]: unknown\n}\n\nexport type FieldRules = Pick<\n RegisterOptions,\n 'required' | 'min' | 'max' | 'maxLength' | 'minLength' | 'pattern'\n>\n\nexport interface FieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends Omit<FormControlProps, 'label' | 'type'> {\n /**\n * The field name\n */\n name: TName\n /**\n * The field label\n */\n label?: string\n /**\n * Hide the field label\n */\n hideLabel?: boolean\n /**\n * Field help text\n */\n help?: string\n /**\n * React hook form rules\n */\n rules?: Omit<\n RegisterOptions<TFieldValues, TName>,\n 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'\n >\n /**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\n type?: string\n /**\n * The input placeholder\n */\n placeholder?: string\n}\n\nconst inputTypes: Record<string, React.FC<any>> = {}\n\nconst defaultInputType = 'text'\n\nconst getInput = (type: string) => {\n return inputTypes[type] || inputTypes[defaultInputType]\n}\n\nconst getError = (name: string, formState: FormState<{ [x: string]: any }>) => {\n return get(formState.errors, name)\n}\n\nconst isTouched = (\n name: string,\n formState: FormState<{ [x: string]: any }>\n) => {\n return get(formState.touchedFields, name)\n}\n\nexport const BaseField: React.FC<FieldProps> = (props) => {\n const { name, label, help, variant, hideLabel, children, ...controlProps } =\n props\n\n const { formState } = useFormContext()\n\n const error = getError(name, formState)\n\n return (\n <FormControl variant={variant} {...controlProps} isInvalid={!!error}>\n {label && !hideLabel ? (\n <FormLabel variant={variant}>{label}</FormLabel>\n ) : null}\n <Box>\n {children}\n {help && !error?.message ? (\n <FormHelperText>{help}</FormHelperText>\n ) : null}\n {error?.message && (\n <FormErrorMessage>{error?.message}</FormErrorMessage>\n )}\n </Box>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n BaseField.displayName = 'BaseField'\n}\n\nexport type As<Props = any> = React.ElementType<Props>\n\nexport type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {\n type?: FieldTypes\n}\n\n/**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\nexport const Field = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FieldProps<TFieldValues> | FieldTypeProps,\n ref: React.ForwardedRef<FocusableElement>\n ) => {\n const { type = defaultInputType } = props\n const InputComponent = getInput(type)\n\n return <InputComponent ref={ref} {...props} />\n }\n) as (<TFieldValues extends FieldValues>(\n props: FieldProps<TFieldValues> &\n FieldTypeProps & {\n ref?: React.ForwardedRef<FocusableElement>\n }\n) => React.ReactElement) & {\n displayName?: string\n}\n\ninterface CreateFieldProps {\n displayName: string\n hideLabel?: boolean\n BaseField: React.FC<any>\n}\n\nconst createField = (\n InputComponent: React.FC<any>,\n { displayName, hideLabel, BaseField }: CreateFieldProps\n) => {\n const Field = forwardRef((props, ref) => {\n const {\n id,\n name,\n label,\n help,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n rules,\n variant,\n ...inputProps\n } = props\n\n const inputRules = {\n required: isRequired,\n ...rules,\n }\n\n return (\n <BaseField\n id={id}\n name={name}\n label={label}\n help={help}\n hideLabel={hideLabel}\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n variant={variant}\n >\n <InputComponent\n ref={ref}\n id={id}\n name={name}\n label={hideLabel ? label : undefined} // Only pass down the label when it should be inline.\n rules={inputRules}\n {...inputProps}\n />\n </BaseField>\n )\n })\n Field.displayName = displayName\n\n return Field\n}\n\nexport const withControlledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { control } = useFormContext()\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ field: { ref: _ref, ...field } }) => (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )}\n />\n )\n }\n )\n}\n\nexport const withUncontrolledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { register } = useFormContext()\n\n const { ref: _ref, ...field } = register(name, rules)\n\n return (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )\n }\n )\n}\n\nexport interface RegisterFieldTypeOptions {\n isControlled?: boolean\n hideLabel?: boolean\n BaseField?: React.FC<any>\n}\n\n/**\n * Register a new field type\n * @param type The name for this field in kebab-case, eg `email` or `array-field`\n * @param component The React component\n * @param options\n * @param options.isControlled Set this to true if this is a controlled field.\n * @param options.hideLabel Hide the field label, for example for the checkbox field.\n */\nexport const registerFieldType = <T extends object>(\n type: string,\n component: React.FC<T>,\n options?: RegisterFieldTypeOptions\n) => {\n let InputComponent\n if (options?.isControlled) {\n InputComponent = withControlledInput(component)\n } else {\n InputComponent = withUncontrolledInput(component)\n }\n\n const Field = createField(InputComponent, {\n displayName: `${type\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')}Field`,\n hideLabel: options?.hideLabel,\n BaseField: options?.BaseField || BaseField,\n }) as React.FC<T & FieldProps>\n\n inputTypes[type] = Field\n\n return Field\n}\n\nexport interface InputFieldProps extends InputProps {\n type?: string\n leftAddon?: React.ReactNode\n rightAddon?: React.ReactNode\n}\n\nexport const InputField = registerFieldType<InputFieldProps>(\n 'text',\n forwardRef(({ type = 'text', leftAddon, rightAddon, size, ...rest }, ref) => {\n const input = <Input type={type} size={size} {...rest} ref={ref} />\n if (leftAddon || rightAddon) {\n return (\n <InputGroup size={size}>\n {leftAddon}\n {input}\n {rightAddon}\n </InputGroup>\n )\n }\n return input\n })\n)\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n type: 'number'\n}\n\nexport const NumberInputField = registerFieldType<NumberInputFieldProps>(\n 'number',\n NumberInput,\n {\n isControlled: true,\n }\n)\n\nexport const PasswordInputField = registerFieldType<PasswordInputProps>(\n 'password',\n forwardRef((props, ref) => <PasswordInput ref={ref} {...props} />)\n)\n\nexport const TextareaField = registerFieldType<TextareaProps>(\n 'textarea',\n Textarea\n)\n\nexport const SwitchField = registerFieldType<SwitchProps>(\n 'switch',\n forwardRef(({ type, ...rest }, ref) => {\n return <Switch {...rest} ref={ref} />\n }),\n {\n isControlled: true,\n }\n)\n\nexport const SelectField = registerFieldType<SelectProps>('select', Select, {\n isControlled: true,\n})\n\nexport const CheckboxField = registerFieldType<CheckboxProps>(\n 'checkbox',\n forwardRef(({ label, type, ...props }, ref) => {\n return (\n <Checkbox ref={ref} {...props}>\n {label}\n </Checkbox>\n )\n }),\n {\n hideLabel: true,\n }\n)\n\nexport const RadioField = registerFieldType<RadioInputProps>(\n 'radio',\n RadioInput,\n {\n isControlled: true,\n }\n)\n\nexport const NativeSelectField = registerFieldType<NativeSelectProps>(\n 'native-select',\n NativeSelect,\n { isControlled: true }\n)\n\nexport interface PinFieldProps extends Omit<UsePinInputProps, 'type'> {\n pinLength?: number\n pinType?: 'alphanumeric' | 'number'\n spacing?: SystemProps['margin']\n}\n\nexport const PinField = registerFieldType<PinFieldProps>(\n 'pin',\n forwardRef((props, ref) => {\n const { pinLength = 4, pinType, spacing, ...inputProps } = props\n\n const inputs: React.ReactNode[] = []\n for (let i = 0; i < pinLength; i++) {\n inputs.push(<PinInputField key={i} ref={ref} />)\n }\n\n return (\n <HStack spacing={spacing}>\n <PinInput {...inputProps} type={pinType}>\n {inputs}\n </PinInput>\n </HStack>\n )\n }),\n {\n isControlled: true,\n }\n)\n\nconst fieldTypes = {\n text: InputField,\n email: InputField,\n url: InputField,\n phone: InputField,\n number: NumberInputField,\n password: PasswordInputField,\n textarea: TextareaField,\n switch: SwitchField,\n checkbox: CheckboxField,\n radio: RadioField,\n pin: PinField,\n select: SelectField,\n 'native-select': NativeSelectField,\n}\n\ntype FieldTypes = typeof fieldTypes\n\ntype FieldType<Props = any> = React.ElementType<Props>\n\ntype TypeProps<P extends FieldType, T> = React.ComponentPropsWithoutRef<P> & {\n type: T\n}\n\ntype FieldTypeProps =\n | {\n [Property in keyof FieldTypes]: TypeProps<FieldTypes[Property], Property>\n }[keyof FieldTypes]\n | { type?: string }\n","import { FieldProps } from './field'\n\nimport { get } from '@chakra-ui/utils'\n\nexport type FieldResolver = {\n getFields(): FieldProps[]\n getNestedFields(name: string): FieldProps[]\n}\n\ninterface SchemaField extends FieldProps {\n items?: SchemaField[]\n properties?: Record<string, SchemaField>\n}\n\nexport type ObjectSchema = Record<string, SchemaField>\n\nconst mapFields = (schema: ObjectSchema): FieldProps[] =>\n schema &&\n Object.entries(schema).map(([name, { items, label, title, ...field }]) => {\n return {\n ...field,\n name,\n label: label || title, // json schema compatibility\n }\n })\n\nexport const objectFieldResolver = (schema: ObjectSchema): FieldResolver => {\n const getFields = () => {\n return mapFields(schema)\n }\n const getNestedFields = (name: string) => {\n const field = get(schema, name)\n\n if (!field) return []\n\n if (field.items?.type === 'object') {\n return mapFields(field.items.properties)\n } else if (field.type === 'object') {\n return mapFields(field.properties)\n }\n return [field.items]\n }\n\n return { getFields, getNestedFields }\n}\n","import * as React from 'react'\n\nimport { chakra, HTMLChakraProps, forwardRef } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n useForm,\n FormProvider,\n UseFormProps,\n UseFormReturn,\n FieldValues,\n SubmitHandler,\n SubmitErrorHandler,\n UnpackNestedValue,\n ResolverOptions,\n ResolverResult,\n} from 'react-hook-form'\nimport { objectFieldResolver, FieldResolver } from './field-resolver'\n\nexport type { UseFormReturn, FieldValues, SubmitHandler }\n\ninterface FormOptions<TFieldValues extends FieldValues = FieldValues> {\n /**\n * The form schema, currently supports Yup schema only.\n */\n schema?: any\n /**\n * The submit handler.\n */\n onSubmit: SubmitHandler<TFieldValues>\n /**\n * Triggers when there are validation errors.\n */\n onError?: SubmitErrorHandler<TFieldValues>\n /**\n * Ref on the HTMLFormElement.\n */\n formRef?: React.RefObject<HTMLFormElement>\n}\n\n/**\n * @todo Figure out how to pass down FieldValues to all Field components,\n * if at all possible.\n */\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseFormProps<TFieldValues>,\n Omit<HTMLChakraProps<'form'>, 'onSubmit' | 'onError'>,\n FormOptions<TFieldValues> {}\n\nexport const Form = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n mode = 'all',\n resolver,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n schema,\n defaultValues,\n onSubmit,\n onError,\n formRef,\n children,\n ...rest\n } = props\n\n const form = {\n mode,\n resolver,\n defaultValues,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n }\n\n if (schema && !resolver) {\n form.resolver = Form.getResolver?.(schema)\n }\n\n const methods = useForm<TFieldValues>(form)\n const { handleSubmit } = methods\n\n // This exposes the useForm api through the forwarded ref\n React.useImperativeHandle(ref, () => methods, [ref, methods])\n\n return (\n <FormProvider {...methods}>\n <chakra.form\n ref={formRef}\n onSubmit={handleSubmit(onSubmit, onError)}\n {...rest}\n className={cx('saas-form', props.className)}\n >\n {children}\n </chakra.form>\n </FormProvider>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: FormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getResolver?: GetResolver\n getFieldResolver: GetFieldResolver\n}\n\nForm.getFieldResolver = objectFieldResolver\n\nif (__DEV__) {\n Form.displayName = 'Form'\n}\n\nexport type GetResolver = (\n schema: any\n) => <TFieldValues extends FieldValues, TContext>(\n values: UnpackNestedValue<TFieldValues>,\n context: TContext | undefined,\n options: ResolverOptions<TFieldValues>\n) => Promise<ResolverResult<TFieldValues>>\n\nexport type GetFieldResolver = (schema: any) => FieldResolver\n","import * as React from 'react'\n\nimport { chakra, SimpleGrid, SimpleGridProps, useTheme } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nexport type FormLayoutProps = SimpleGridProps\n\ninterface FormLayoutItemProps {\n children: React.ReactNode\n}\n\nconst FormLayoutItem: React.FC<FormLayoutItemProps> = ({ children }) => {\n return <chakra.div>{children}</chakra.div>\n}\n\nif (__DEV__) {\n FormLayoutItem.displayName = 'FormLayoutItem'\n}\n\n/**\n * FormLayout\n *\n * Renders form items in a `SimpleGrid`\n * @see https://chakra-ui.com/docs/layout/simple-grid\n */\nexport const FormLayout = ({ children, ...props }: FormLayoutProps) => {\n const theme = useTheme()\n\n const defaultProps = theme.components?.FormLayout?.defaultProps ?? {\n spacing: 4,\n }\n\n const gridProps = {\n ...defaultProps,\n ...props,\n }\n\n return (\n <SimpleGrid\n {...gridProps}\n className={cx('saas-form__layout', props.className)}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return <FormLayoutItem>{child}</FormLayoutItem>\n }\n return child\n })}\n </SimpleGrid>\n )\n}\n\nif (__DEV__) {\n FormLayout.displayName = 'FormLayout'\n}\n","import * as React from 'react'\n\nexport const mapNestedFields = (name: string, children: React.ReactNode) => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.props.name) {\n return React.cloneElement(child, {\n ...child.props,\n name: `${name}.${child.props.name}`,\n })\n }\n return child\n })\n}\n","import * as React from 'react'\nimport {\n useFieldArray,\n useFormContext,\n UseFieldArrayReturn,\n} from 'react-hook-form'\n\nimport { createContext } from '@chakra-ui/react-utils'\n\nexport interface UseArrayFieldReturn extends UseFieldArrayReturn {\n /**\n * The array field name\n */\n name: string\n /**\n * The default value for new items\n */\n defaultValue: Record<string, any>\n /**\n * Min amount of items\n */\n min?: number\n /**\n * Max amount of items\n */\n max?: number\n}\n\nexport const [ArrayFieldProvider, useArrayFieldContext] =\n createContext<UseArrayFieldReturn>({\n name: 'ArrayFieldContext',\n })\n\nexport interface UseArrayFieldRowReturn {\n /**\n * Name of the array field including the index, eg 'field.0'\n */\n name: string\n /**\n * The field index\n */\n index: number\n /**\n * Remove this array item\n */\n remove: () => void\n /**\n * True if this is the first item\n */\n isFirst: boolean\n /**\n * True if this is the last item\n */\n isLast: boolean\n}\n\nexport const [ArrayFieldRowProvider, useArrayFieldRowContext] =\n createContext<UseArrayFieldRowReturn>({\n name: 'ArrayFieldRowContext',\n })\n\nexport interface ArrayFieldOptions {\n /**\n * The field name\n */\n name: string\n /**\n * Default value for new values in the array\n */\n defaultValue?: Record<string, any>\n /**\n * Default key name for rows, change this if your data uses a different 'id' field\n * @default \"id\"\n */\n keyName?: string\n min?: number\n max?: number\n}\n\nexport const useArrayField = ({\n name,\n defaultValue = {},\n keyName,\n min,\n max,\n}: ArrayFieldOptions) => {\n const { control } = useFormContext()\n const context = useFieldArray({\n control,\n name,\n keyName,\n })\n\n return {\n ...context,\n name,\n defaultValue,\n min,\n max,\n }\n}\n\nexport interface UseArrayFieldRowProps {\n index: number\n}\n\nexport const useArrayFieldRow = ({ index }: UseArrayFieldRowProps) => {\n const { clearErrors } = useFormContext()\n const { name, remove, fields } = useArrayFieldContext()\n\n React.useEffect(() => {\n // reset errors, to make sure min/max errors reset correctly\n clearErrors(name)\n }, [])\n\n return {\n index,\n isFirst: index === 0,\n isLast: index === fields.length - 1,\n name: `${name}.${index}`,\n remove: React.useCallback(() => {\n clearErrors(name)\n remove(index)\n }, [index]),\n }\n}\n\nexport const useArrayFieldRemoveButton = () => {\n const { isFirst, remove } = useArrayFieldRowContext()\n const { min, fields } = useArrayFieldContext()\n\n const isDisabled = isFirst && !!(min && fields.length <= min)\n\n return {\n onClick: () => remove(),\n isDisabled,\n }\n}\n\nexport const useArrayFieldAddButton = () => {\n const { append, defaultValue, max, fields } = useArrayFieldContext()\n\n const isDisabled = !!(max && fields.length >= max)\n\n return {\n onClick: () =>\n append(defaultValue, {\n shouldFocus: false,\n }),\n isDisabled,\n }\n}\n","import * as React from 'react'\n\nimport { chakra, ResponsiveValue, forwardRef } from '@chakra-ui/system'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { AddIcon, MinusIcon } from '@chakra-ui/icons'\nimport { IconButton, ButtonProps } from '@saas-ui/button'\n\nimport { FormLayout, FormLayoutProps } from './layout'\nimport { BaseField, FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nimport {\n useArrayField,\n useArrayFieldRow,\n useArrayFieldContext,\n ArrayFieldProvider,\n ArrayFieldOptions,\n ArrayFieldRowProvider,\n useArrayFieldRowContext,\n useArrayFieldRemoveButton,\n useArrayFieldAddButton,\n UseArrayFieldReturn,\n} from './use-array-field'\n\ninterface ArrayField {\n id: string\n [key: string]: unknown\n}\n\ninterface ArrayFieldRowProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The array index\n */\n index: number\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRow: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n ...rowFieldsProps\n}) => {\n return (\n <ArrayFieldRowContainer index={index}>\n <ArrayFieldRowFields {...rowFieldsProps}>{children}</ArrayFieldRowFields>\n <ArrayFieldRemoveButton />\n </ArrayFieldRowContainer>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRow.displayName = 'ArrayFieldRow'\n}\n\nexport interface ArrayFieldRowFieldsProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRowFields: React.FC<ArrayFieldRowFieldsProps> = ({\n children,\n ...layoutProps\n}) => {\n const { name } = useArrayFieldRowContext()\n return (\n <FormLayout flex=\"1\" mr=\"2\" {...layoutProps}>\n {mapNestedFields(name, children)}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowFields.displayName = 'ArrayFieldRowFields'\n}\n\nexport const ArrayFieldRowContainer: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n}) => {\n const context = useArrayFieldRow({ index })\n\n const styles = {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'flex-end',\n width: '100%',\n mb: 4,\n }\n\n return (\n <ArrayFieldRowProvider value={context}>\n <chakra.div __css={styles}>{children}</chakra.div>\n </ArrayFieldRowProvider>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowContainer.displayName = 'ArrayFieldRowContainer'\n}\n\nexport const ArrayFieldRemoveButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<MinusIcon />}\n aria-label=\"Remove row\"\n {...useArrayFieldRemoveButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldRemoveButton.displayName = 'ArrayFieldRemoveButton'\n}\n\nexport const ArrayFieldAddButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<AddIcon />}\n aria-label=\"Add row\"\n float=\"right\"\n {...useArrayFieldAddButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldAddButton.displayName = 'ArrayFieldAddButton'\n}\n\nexport interface ArrayFieldProps\n extends ArrayFieldOptions,\n Omit<FieldProps, 'defaultValue'> {}\n\nexport const ArrayField = forwardRef(\n (props: ArrayFieldProps, ref: React.ForwardedRef<UseArrayFieldReturn>) => {\n const { children, ...containerProps } = props\n\n return (\n <ArrayFieldContainer ref={ref} {...containerProps}>\n <ArrayFieldRows>\n {(fields: ArrayField[]) => (\n <>\n {fields.map(({ id }, index: number) => (\n <ArrayFieldRow key={id} index={index}>\n {children}\n </ArrayFieldRow>\n ))}\n </>\n )}\n </ArrayFieldRows>\n <ArrayFieldAddButton />\n </ArrayFieldContainer>\n )\n }\n) as ((\n props: ArrayFieldProps & {\n ref?: React.ForwardedRef<UseArrayFieldReturn>\n }\n) => React.ReactElement) & {\n displayName: string\n}\n\nif (__DEV__) {\n ArrayField.displayName = 'ArrayField'\n}\n\nexport interface ArrayFieldRowsProps {\n children: (fields: ArrayField[]) => React.ReactElement | null\n}\n\nexport const ArrayFieldRows = ({\n children,\n}: ArrayFieldRowsProps): React.ReactElement | null => {\n const { fields } = useArrayFieldContext()\n return children(fields)\n}\n\nif (__DEV__) {\n ArrayFieldRows.displayName = 'ArrayFieldRows'\n}\n\nexport const ArrayFieldContainer = React.forwardRef(\n (\n {\n name,\n defaultValue,\n keyName,\n min,\n max,\n children,\n ...fieldProps\n }: ArrayFieldProps,\n ref: React.ForwardedRef<UseArrayFieldReturn>\n ) => {\n const context = useArrayField({\n name,\n defaultValue,\n keyName,\n min,\n max,\n })\n\n // This exposes the useArrayField api through the forwarded ref\n React.useImperativeHandle(ref, () => context, [ref, context])\n\n return (\n <ArrayFieldProvider value={context}>\n <BaseField name={name} {...fieldProps}>\n {children}\n </BaseField>\n </ArrayFieldProvider>\n )\n }\n)\n\nif (__DEV__) {\n ArrayFieldContainer.displayName = 'ArrayFieldContainer'\n}\n","import * as React from 'react'\nimport {\n FormControl,\n FormLabel,\n FormLabelProps,\n ResponsiveValue,\n useStyleConfig,\n} from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { FormLayout } from './layout'\nimport { FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nexport interface ObjectFieldProps extends FieldProps {\n name: string\n children: React.ReactNode\n columns?: ResponsiveValue<number>\n spacing?: ResponsiveValue<string | number>\n}\n\nexport const FormLegend = (props: FormLabelProps) => {\n const styles = useStyleConfig('FormLegend')\n return <FormLabel as=\"legend\" sx={styles} {...props} />\n}\n\nexport const ObjectField: React.FC<ObjectFieldProps> = (props) => {\n const { name, label, hideLabel, children, columns, spacing, ...fieldProps } =\n props\n\n return (\n <FormControl name={name} as=\"fieldset\" {...fieldProps}>\n <FormLegend display={hideLabel ? 'none' : 'block'}>{label}</FormLegend>\n <FormLayout columns={columns} gridGap={spacing}>\n {mapNestedFields(name, children)}\n </FormLayout>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n ObjectField.displayName = 'ObjectField'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form } from './form'\nimport { FormLayout } from './layout'\nimport { Field, FieldProps } from './field'\n\nimport { ArrayField } from './array-field'\nimport { ObjectField } from './object-field'\nimport { FieldResolver } from './field-resolver'\nimport { useFormContext } from 'react-hook-form'\n\nexport interface FieldsProps {\n schema: any\n fieldResolver?: FieldResolver\n focusFirstField?: boolean\n}\n\nconst mapNestedFields = (resolver: FieldResolver, name: string) => {\n return resolver\n .getNestedFields(name)\n ?.map(\n ({ name, type, ...nestedFieldProps }: FieldProps, i): React.ReactNode => (\n <Field key={name || i} name={name} type={type} {...nestedFieldProps} />\n )\n )\n}\n\nexport const Fields: React.FC<FieldsProps> = ({\n schema,\n fieldResolver,\n focusFirstField,\n ...props\n}) => {\n const resolver = React.useMemo(\n () => fieldResolver || Form.getFieldResolver(schema),\n [schema, fieldResolver]\n )\n\n const fields = React.useMemo(() => resolver.getFields(), [resolver])\n\n const form = useFormContext()\n\n React.useEffect(() => {\n if (focusFirstField && fields[0]?.name) {\n form.setFocus(fields[0].name)\n }\n }, [schema, fieldResolver, focusFirstField])\n\n return (\n <FormLayout {...props}>\n {fields.map(\n ({\n name,\n type,\n defaultValue,\n ...fieldProps\n }: FieldProps): React.ReactNode => {\n if (type === 'array') {\n return (\n <ArrayField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ArrayField>\n )\n } else if (type === 'object') {\n return (\n <ObjectField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ObjectField>\n )\n }\n\n return <Field key={name} name={name} type={type} {...fieldProps} />\n }\n )}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n Fields.displayName = 'Fields'\n}\n","import * as React from 'react'\n\nimport { useFormContext } from 'react-hook-form'\n\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { __DEV__ } from '@chakra-ui/utils'\n\nexport interface SubmitButtonProps extends ButtonProps {\n /**\n * Disable the submit button if the form is untouched.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfUntouched`\n */\n disableIfUntouched?: boolean\n /**\n * Disable the submit button if the form is invalid.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfInvalid`\n */\n disableIfInvalid?: boolean\n}\n\nexport const SubmitButton = React.forwardRef<\n HTMLButtonElement,\n SubmitButtonProps\n>((props, ref) => {\n const {\n children,\n disableIfUntouched,\n disableIfInvalid,\n isDisabled: isDisabledProp,\n isLoading,\n ...rest\n } = props\n const { formState } = useFormContext()\n\n const isDisabled =\n (disableIfUntouched && !formState.isDirty) ||\n (disableIfInvalid && !formState.isValid) ||\n isDisabledProp\n\n return (\n <Button\n {...rest}\n ref={ref}\n variant=\"primary\"\n type=\"submit\"\n isLoading={formState.isSubmitting || isLoading}\n isDisabled={isDisabled}\n >\n {children}\n </Button>\n )\n})\n\nSubmitButton.defaultProps = {\n label: 'Submit',\n disableIfUntouched: false,\n disableIfInvalid: false,\n}\n\nif (__DEV__) {\n SubmitButton.displayName = 'SubmitButton'\n}\n","import * as React from 'react'\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\nimport { forwardRef } from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form, FormProps } from './form'\nimport { FormLayout } from './layout'\nimport { Fields } from './fields'\nimport { SubmitButton } from './submit-button'\nimport { FieldResolver } from '.'\n\ninterface AutoFormOptions {\n /**\n * The submit button label.\n * Pass `null` to render no submit button.\n */\n submitLabel?: React.ReactNode\n /**\n * The schema.\n * Supports object schema, Yup or Zod.\n * @see https://www.saas-ui.dev/docs/forms/auto-form\n */\n schema: any\n /**\n * The field resolver.\n */\n fieldResolver?: any\n}\n\nexport interface AutoFormProps<TFieldValues extends FieldValues>\n extends Omit<FormProps<TFieldValues>, 'schema'>,\n AutoFormOptions {}\n\nexport const AutoForm = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: AutoFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n schema,\n submitLabel = 'Submit',\n fieldResolver,\n children,\n ...rest\n } = props\n\n return (\n <Form {...rest} schema={schema} ref={ref}>\n <FormLayout>\n {<Fields schema={schema} fieldResolver={fieldResolver} />}\n {submitLabel && <SubmitButton>{submitLabel}</SubmitButton>}\n {children}\n </FormLayout>\n </Form>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: AutoFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getFieldResolver?: (schema: any) => FieldResolver\n}\n\nif (__DEV__) {\n AutoForm.displayName = 'AutoForm'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport {\n useFormContext,\n useWatch,\n FieldValues,\n UseFormReturn,\n} from 'react-hook-form'\n\nexport interface DisplayIfProps<TFieldValues> {\n children: React.ReactElement\n name: string\n defaultValue?: unknown\n isDisabled?: boolean\n isExact?: boolean\n condition?: (value: unknown, context: UseFormReturn<TFieldValues>) => boolean\n}\n\nexport const DisplayIf = <TFieldValues extends FieldValues = FieldValues>({\n children,\n name,\n defaultValue,\n isDisabled,\n isExact,\n condition = (value) => !!value,\n}: DisplayIfProps<TFieldValues>) => {\n const value = useWatch({\n name,\n defaultValue,\n disabled: isDisabled,\n exact: isExact,\n })\n const context = useFormContext<TFieldValues>()\n return condition(value, context) ? children : null\n}\n\nif (__DEV__) {\n DisplayIf.displayName = 'DisplayIf'\n}\n","import * as React from 'react'\nimport { FieldValues, SubmitHandler, UnpackNestedValue } from 'react-hook-form'\nimport { createContext, MaybeRenderProp } from '@chakra-ui/react-utils'\nimport {\n useStepper,\n useStep,\n UseStepperProps,\n UseStepperReturn,\n} from '@saas-ui/stepper'\n\nexport interface StepState {\n name: string\n schema?: any\n resolver?: any\n isActive?: boolean\n isCompleted?: boolean\n onSubmit?: FormStepSubmitHandler\n}\n\nexport type FormStepSubmitHandler<\n TFieldValues extends FieldValues = FieldValues\n> = (\n data: UnpackNestedValue<TFieldValues>,\n stepper: UseStepperReturn\n) => Promise<void>\n\nexport interface StepFormContext extends UseStepperReturn {\n updateStep(state: StepState): void\n steps: Record<string, StepState>\n}\n\nexport const [StepFormProvider, useStepFormContext] =\n createContext<StepFormContext>({\n name: 'StepFormContext',\n errorMessage:\n 'useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`',\n })\n\nimport { FormProps } from './form'\n\nexport interface UseStepFormProps<\n TFieldValues extends FieldValues = FieldValues\n> extends Omit<UseStepperProps, 'onChange'>,\n Omit<FormProps<TFieldValues>, 'children'> {\n children: MaybeRenderProp<UseStepFormReturn<TFieldValues>>\n}\n\nexport interface UseStepFormReturn<\n TFieldValues extends FieldValues = FieldValues\n> extends UseStepperReturn {\n getFormProps(): {\n onSubmit: SubmitHandler<TFieldValues>\n schema?: any\n resolver?: any\n }\n updateStep(step: any): void\n steps: Record<string, any>\n}\n\nexport function useStepForm<TFieldValues extends FieldValues = FieldValues>(\n props: UseStepFormProps<TFieldValues>\n): UseStepFormReturn<TFieldValues> {\n const { onChange, ...rest } = props\n const stepper = useStepper(rest)\n\n const { activeStep, isLastStep, nextStep } = stepper\n\n const [steps, updateSteps] = React.useState<Record<string, StepState>>({})\n\n const onSubmitStep: SubmitHandler<TFieldValues> = React.useCallback(\n async (data) => {\n const step = steps[activeStep]\n\n if (isLastStep) {\n return props\n .onSubmit?.(data)\n .then(() => {\n updateStep({\n ...step,\n isCompleted: true,\n })\n })\n .then(nextStep) // Show completed step\n }\n\n try {\n await step.onSubmit?.(data, stepper)\n\n nextStep()\n } catch (e) {\n // Step submission failed.\n }\n },\n [steps, activeStep, isLastStep]\n )\n\n const getFormProps = React.useCallback(() => {\n const step = steps[activeStep]\n return {\n onSubmit: onSubmitStep,\n schema: step?.schema,\n resolver: step?.resolver,\n }\n }, [steps, onSubmitStep, activeStep])\n\n const updateStep = React.useCallback(\n (step: StepState) => {\n updateSteps((steps) => {\n return {\n ...steps,\n [step.name]: step,\n }\n })\n },\n [steps]\n )\n\n return {\n getFormProps,\n updateStep,\n steps,\n ...stepper,\n }\n}\n\nexport interface UseFormStepProps {\n name: string\n schema?: any\n resolver?: any\n onSubmit?: FormStepSubmitHandler\n}\n\nexport function useFormStep(props: UseFormStepProps): StepState {\n const { name, schema, resolver, onSubmit } = props\n const step = useStep({ name })\n\n const { steps, updateStep } = useStepFormContext()\n\n React.useEffect(() => {\n updateStep({ name, schema, resolver, onSubmit })\n }, [name, schema])\n\n return {\n ...step,\n ...(steps[name] || { name, schema }),\n }\n}\n","import * as React from 'react'\n\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\n\nimport { chakra, HTMLChakraProps } from '@chakra-ui/system'\n\nimport { callAllHandlers, runIfFn, cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n StepperProvider,\n StepperSteps,\n StepperStepsProps,\n StepperStep,\n useStepperContext,\n StepperContainer,\n} from '@saas-ui/stepper'\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { Form } from './form'\nimport { SubmitButton } from './submit-button'\n\nimport {\n useStepForm,\n useFormStep,\n StepFormProvider,\n UseStepFormProps,\n FormStepSubmitHandler,\n} from './use-step-form'\n\nexport interface StepFormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseStepFormProps<TFieldValues> {}\n\nexport const StepForm = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: StepFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const { children, ...rest } = props\n\n const stepper = useStepForm<TFieldValues>(props)\n\n const { getFormProps, ...ctx } = stepper\n\n const context = React.useMemo(() => ctx, [ctx])\n\n return (\n <StepperProvider value={context}>\n <StepFormProvider value={context}>\n <Form ref={ref} {...rest} {...getFormProps()}>\n {runIfFn(children, stepper)}\n </Form>\n </StepFormProvider>\n </StepperProvider>\n )\n }\n) as <TFieldValues extends FieldValues>(\n props: StepFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement\n\nexport interface FormStepOptions {\n /**\n * The step name\n */\n name: string\n /**\n * Schema\n */\n schema?: any\n /**\n * Hook Form Resolver\n */\n resolver?: any\n}\n\nexport const FormStepper: React.FC<StepperStepsProps> = (props) => {\n const { activeIndex, setIndex } = useStepperContext()\n\n const { children, orientation } = props\n\n const elements = React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child?.type === FormStep) {\n const { isCompleted } = useFormStep(child.props) // Register this step\n return (\n <StepperStep\n name={child.props.name}\n title={child.props.title}\n isCompleted={isCompleted}\n >\n {child.props.children}\n </StepperStep>\n )\n }\n return child\n })\n\n const onChange = React.useCallback((i: number) => {\n setIndex(i)\n }, [])\n\n return (\n <StepperContainer\n orientation={orientation}\n step={activeIndex}\n onChange={onChange}\n >\n <StepperSteps mb=\"4\" {...props}>\n {elements}\n </StepperSteps>\n </StepperContainer>\n )\n}\n\nexport interface FormStepProps\n extends FormStepOptions,\n Omit<HTMLChakraProps<'div'>, 'onSubmit'> {\n onSubmit?: FormStepSubmitHandler\n}\n\nexport const FormStep: React.FC<FormStepProps> = (props) => {\n const { name, schema, resolver, children, className, onSubmit, ...rest } =\n props\n const step = useFormStep({ name, schema, resolver, onSubmit })\n\n const { isActive } = step\n\n return isActive ? (\n <chakra.div {...rest} className={cx('saas-form__step', className)}>\n {children}\n </chakra.div>\n ) : null\n}\n\nif (__DEV__) {\n FormStep.displayName = 'FormStep'\n}\n\nexport const PrevButton: React.FC<ButtonProps> = (props) => {\n const { isFirstStep, isCompleted, prevStep } = useStepperContext()\n\n return (\n <Button\n isDisabled={isFirstStep || isCompleted}\n label=\"Back\"\n {...props}\n className={cx('saas-form__prev-button', props.className)}\n onClick={callAllHandlers(props.onClick, prevStep)}\n />\n )\n}\n\nif (__DEV__) {\n PrevButton.displayName = 'PrevButton'\n}\n\nexport interface NextButtonProps extends ButtonProps {\n submitLabel?: string\n}\n\nexport const NextButton: React.FC<NextButtonProps> = (props) => {\n const { label = 'Next', submitLabel = 'Complete', ...rest } = props\n const { isLastStep, isCompleted } = useStepperContext()\n\n return (\n <SubmitButton\n {...rest}\n isDisabled={isCompleted}\n className={cx('saas-form__next-button', props.className)}\n >\n {isLastStep || isCompleted ? submitLabel : label}\n </SubmitButton>\n )\n}\n\nif (__DEV__) {\n NextButton.displayName = 'NextButton'\n}\n"],"names":["_excluded","DisplayField","_ref","name","label","props","React","createElement","FormControl","FormLabel","htmlFor","Text","fontSize","FormValue","__DEV__","displayName","_ref2","getValues","useFormContext","_excluded2","_excluded3","_excluded4","_excluded5","_excluded6","_excluded7","_excluded8","_excluded9","_excluded10","inputTypes","help","variant","hideLabel","children","controlProps","formState","get","errors","getError","_extends","isInvalid","error","Box","message","FormHelperText","FormErrorMessage","BaseField","Field","forwardRef","ref","_props$type","type","defaultInputType","withControlledInput","InputComponent","rules","_ref3","inputProps","_objectWithoutPropertiesLoose","_useFormContext2","Controller","control","render","field","_ref4$field","useMergeRefs","withUncontrolledInput","_ref5","_register","register","component","options","id","isDisabled","isReadOnly","isRequired","inputRules","required","undefined","createField","isControlled","split","map","part","charAt","toUpperCase","slice","join","registerFieldType","_ref6","_ref6$type","leftAddon","rightAddon","size","rest","input","Input","InputGroup","NumberInputField","NumberInput","PasswordInputField","PasswordInput","Textarea","SwitchField","_ref7","Switch","SelectField","Select","CheckboxField","_ref8","Checkbox","RadioField","RadioInput","NativeSelectField","NativeSelect","pinLength","_props$pinLength","pinType","spacing","inputs","i","push","PinInputField","key","HStack","PinInput","schema","Object","entries","title","_ref$","objectFieldResolver","getFields","getNestedFields","_field$items","items","mapFields","properties","Form","mode","_props$mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","defaultValues","onSubmit","onError","formRef","form","getResolver","methods","useForm","handleSubmit","useImperativeHandle","FormProvider","chakra","className","cx","getFieldResolver","FormLayoutItem","div","FormLayout","_theme$components$For","_theme$components","_theme$components$For2","gridProps","theme","useTheme","components","defaultProps","SimpleGrid","Children","child","isValidElement","mapNestedFields","cloneElement","createContext","ArrayFieldProvider","useArrayFieldContext","_createContext","ArrayFieldRowProvider","useArrayFieldRowContext","useArrayField","_ref$defaultValue","defaultValue","keyName","min","max","context","useFieldArray","useArrayFieldRow","index","clearErrors","_useArrayFieldContext","remove","fields","useEffect","isFirst","isLast","length","useCallback","useArrayFieldRemoveButton","_useArrayFieldRowCont","_useArrayFieldContext2","onClick","append","_useArrayFieldContext3","shouldFocus","ArrayFieldRow","rowFieldsProps","ArrayFieldRowContainer","ArrayFieldRowFields","ArrayFieldRemoveButton","layoutProps","flex","mr","value","__css","display","flexDirection","alignItems","width","mb","IconButton","icon","MinusIcon","ArrayFieldAddButton","AddIcon","float","useArrayFieldAddButton","ArrayField","containerProps","ArrayFieldContainer","ArrayFieldRows","Fragment","_ref4","fieldProps","FormLegend","styles","useStyleConfig","as","sx","columns","gridGap","ObjectField","_resolver$getNestedFi","nestedFieldProps","Fields","fieldResolver","focusFirstField","useMemo","_fields$","setFocus","SubmitButton","disableIfUntouched","disableIfInvalid","isDisabledProp","isLoading","Button","isSubmitting","isDirty","isValid","AutoForm","submitLabel","_props$submitLabel","DisplayIf","condition","_ref$condition","useWatch","disabled","exact","isExact","errorMessage","StepFormProvider","useStepFormContext","onChange","stepper","useStepper","activeStep","isLastStep","nextStep","_React$useState","useState","steps","updateSteps","onSubmitStep","data","step","Promise","resolve","then","updateStep","isCompleted","_temp2","_catch","e","reject","getFormProps","_extends2","useStep","_useStepFormContext","useStepForm","ctx","StepperProvider","runIfFn","FormStep","useFormStep","isActive","PrevButton","_useStepperContext2","useStepperContext","prevStep","isFirstStep","callAllHandlers","NextButton","_props$label","_useStepperContext3","_useStepperContext","activeIndex","setIndex","orientation","elements","StepperStep","StepperContainer","StepperSteps"],"mappings":"okCAAA,IAAAA,EAAA,CAAA,OAAA,QAAA,eAiByBC,EAAgC,SAAAC,GACvDC,IAAAA,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,MAEGC,sBAEH,OACEC,EAAAC,cAACC,EAADA,YAAiBH,EACdD,eAAQE,EAACC,cAAAE,EAADA,UAAW,CAAAC,QAASP,GAAOC,GAAqB,kBACzDE,EAAAC,cAACI,EAADA,KAAA,CAAMC,SAAS,mBACbN,EAACC,cAAAM,EAAU,CAAAV,KAAMA,OAMrBW,EAAAA,UACFb,EAAac,YAAc,gBAGhBF,MAAwC,SAAAG,GAAGb,IAAAA,EAAAA,EAAAA,KAEtD,OAAOc,EADeC,EAAcA,iBAA5BD,WACSd,IAAS,MAGxBW,EAAAA,UACFD,EAAUE,YAAc,aC3C1B,IAAAf,EAAA,CAAA,OAAA,QAAA,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sources":["../src/display-field.tsx","../src/field.tsx","../src/field-resolver.ts","../src/form.tsx","../src/layout.tsx","../src/utils.ts","../src/use-array-field.tsx","../src/array-field.tsx","../src/object-field.tsx","../src/fields.tsx","../src/submit-button.tsx","../src/auto-form.tsx","../src/display-if.tsx","../src/use-step-form.tsx","../src/step-form.tsx"],"sourcesContent":["import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { useFormContext } from 'react-hook-form'\n\nimport {\n Text,\n FormControl,\n FormControlProps,\n FormLabel,\n} from '@chakra-ui/react'\n\nimport { FieldProps } from './field'\n\nexport interface DisplayFieldProps\n extends FormControlProps,\n Omit<FieldProps, 'type' | 'label'> {}\n\nexport const DisplayField: React.FC<DisplayFieldProps> = ({\n name,\n label,\n placeholder,\n ...props\n}) => {\n return (\n <FormControl {...props}>\n {label ? <FormLabel htmlFor={name}>{label}</FormLabel> : null}\n <Text fontSize=\"md\">\n <FormValue name={name} />\n </Text>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n DisplayField.displayName = 'DisplayField'\n}\n\nexport const FormValue: React.FC<{ name: string }> = ({ name }) => {\n const { getValues } = useFormContext()\n return getValues(name) || null\n}\n\nif (__DEV__) {\n FormValue.displayName = 'FormValue'\n}\n","import * as React from 'react'\nimport {\n useFormContext,\n FormState,\n Controller,\n get,\n RegisterOptions,\n FieldValues,\n FieldPath,\n} from 'react-hook-form'\n\nimport {\n forwardRef,\n Box,\n FormControl,\n FormControlProps,\n FormLabel,\n FormHelperText,\n FormErrorMessage,\n Input,\n Textarea,\n Checkbox,\n Switch,\n useMergeRefs,\n InputGroup,\n InputProps,\n TextareaProps,\n SwitchProps,\n CheckboxProps,\n PinInputField,\n HStack,\n PinInput,\n UsePinInputProps,\n SystemProps,\n} from '@chakra-ui/react'\nimport { __DEV__, FocusableElement } from '@chakra-ui/utils'\n\nimport { NumberInput, NumberInputProps } from '@saas-ui/number-input'\nimport { PasswordInput, PasswordInputProps } from '@saas-ui/password-input'\nimport { RadioInput, RadioInputProps } from '@saas-ui/radio'\n\nimport {\n Select,\n SelectProps,\n NativeSelect,\n NativeSelectProps,\n} from '@saas-ui/select'\n\nexport interface Option {\n value: string\n label?: string\n [key: string]: unknown\n}\n\nexport type FieldRules = Pick<\n RegisterOptions,\n 'required' | 'min' | 'max' | 'maxLength' | 'minLength' | 'pattern'\n>\n\nexport interface FieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends Omit<FormControlProps, 'label' | 'type'> {\n /**\n * The field name\n */\n name: TName\n /**\n * The field label\n */\n label?: string\n /**\n * Hide the field label\n */\n hideLabel?: boolean\n /**\n * Field help text\n */\n help?: string\n /**\n * React hook form rules\n */\n rules?: Omit<\n RegisterOptions<TFieldValues, TName>,\n 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'\n >\n /**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\n type?: string\n /**\n * The input placeholder\n */\n placeholder?: string\n}\n\nconst inputTypes: Record<string, React.FC<any>> = {}\n\nconst defaultInputType = 'text'\n\nconst getInput = (type: string) => {\n return inputTypes[type] || inputTypes[defaultInputType]\n}\n\nconst getError = (name: string, formState: FormState<{ [x: string]: any }>) => {\n return get(formState.errors, name)\n}\n\nconst isTouched = (\n name: string,\n formState: FormState<{ [x: string]: any }>\n) => {\n return get(formState.touchedFields, name)\n}\n\nexport const BaseField: React.FC<FieldProps> = (props) => {\n const { name, label, help, variant, hideLabel, children, ...controlProps } =\n props\n\n const { formState } = useFormContext()\n\n const error = getError(name, formState)\n\n return (\n <FormControl variant={variant} {...controlProps} isInvalid={!!error}>\n {label && !hideLabel ? (\n <FormLabel variant={variant}>{label}</FormLabel>\n ) : null}\n <Box>\n {children}\n {help && !error?.message ? (\n <FormHelperText>{help}</FormHelperText>\n ) : null}\n {error?.message && (\n <FormErrorMessage>{error?.message}</FormErrorMessage>\n )}\n </Box>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n BaseField.displayName = 'BaseField'\n}\n\nexport type As<Props = any> = React.ElementType<Props>\n\nexport type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {\n type?: FieldTypes\n}\n\n/**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\nexport const Field = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FieldProps<TFieldValues> | FieldTypeProps,\n ref: React.ForwardedRef<FocusableElement>\n ) => {\n const { type = defaultInputType } = props\n const InputComponent = getInput(type)\n\n return <InputComponent ref={ref} {...props} />\n }\n) as (<TFieldValues extends FieldValues>(\n props: FieldProps<TFieldValues> &\n FieldTypeProps & {\n ref?: React.ForwardedRef<FocusableElement>\n }\n) => React.ReactElement) & {\n displayName?: string\n}\n\ninterface CreateFieldProps {\n displayName: string\n hideLabel?: boolean\n BaseField: React.FC<any>\n}\n\nconst createField = (\n InputComponent: React.FC<any>,\n { displayName, hideLabel, BaseField }: CreateFieldProps\n) => {\n const Field = forwardRef((props, ref) => {\n const {\n id,\n name,\n label,\n help,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n rules,\n variant,\n ...inputProps\n } = props\n\n const inputRules = {\n required: isRequired,\n ...rules,\n }\n\n return (\n <BaseField\n id={id}\n name={name}\n label={label}\n help={help}\n hideLabel={hideLabel}\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n variant={variant}\n >\n <InputComponent\n ref={ref}\n id={id}\n name={name}\n label={hideLabel ? label : undefined} // Only pass down the label when it should be inline.\n rules={inputRules}\n {...inputProps}\n />\n </BaseField>\n )\n })\n Field.displayName = displayName\n\n return Field\n}\n\nexport const withControlledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { control } = useFormContext()\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ field: { ref: _ref, ...field } }) => (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )}\n />\n )\n }\n )\n}\n\nexport const withUncontrolledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { register } = useFormContext()\n\n const { ref: _ref, ...field } = register(name, rules)\n\n return (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )\n }\n )\n}\n\nexport interface RegisterFieldTypeOptions {\n isControlled?: boolean\n hideLabel?: boolean\n BaseField?: React.FC<any>\n}\n\n/**\n * Register a new field type\n * @param type The name for this field in kebab-case, eg `email` or `array-field`\n * @param component The React component\n * @param options\n * @param options.isControlled Set this to true if this is a controlled field.\n * @param options.hideLabel Hide the field label, for example for the checkbox field.\n */\nexport const registerFieldType = <T extends object>(\n type: string,\n component: React.FC<T>,\n options?: RegisterFieldTypeOptions\n) => {\n let InputComponent\n if (options?.isControlled) {\n InputComponent = withControlledInput(component)\n } else {\n InputComponent = withUncontrolledInput(component)\n }\n\n const Field = createField(InputComponent, {\n displayName: `${type\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')}Field`,\n hideLabel: options?.hideLabel,\n BaseField: options?.BaseField || BaseField,\n }) as React.FC<T & FieldProps>\n\n inputTypes[type] = Field\n\n return Field\n}\n\nexport interface InputFieldProps extends InputProps {\n type?: string\n leftAddon?: React.ReactNode\n rightAddon?: React.ReactNode\n}\n\nexport const InputField = registerFieldType<InputFieldProps>(\n 'text',\n forwardRef(({ type = 'text', leftAddon, rightAddon, size, ...rest }, ref) => {\n const input = <Input type={type} size={size} {...rest} ref={ref} />\n if (leftAddon || rightAddon) {\n return (\n <InputGroup size={size}>\n {leftAddon}\n {input}\n {rightAddon}\n </InputGroup>\n )\n }\n return input\n })\n)\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n type: 'number'\n}\n\nexport const NumberInputField = registerFieldType<NumberInputFieldProps>(\n 'number',\n NumberInput,\n {\n isControlled: true,\n }\n)\n\nexport const PasswordInputField = registerFieldType<PasswordInputProps>(\n 'password',\n forwardRef((props, ref) => <PasswordInput ref={ref} {...props} />)\n)\n\nexport const TextareaField = registerFieldType<TextareaProps>(\n 'textarea',\n Textarea\n)\n\nexport const SwitchField = registerFieldType<SwitchProps>(\n 'switch',\n forwardRef(({ type, ...rest }, ref) => {\n return <Switch {...rest} ref={ref} />\n }),\n {\n isControlled: true,\n }\n)\n\nexport const SelectField = registerFieldType<SelectProps>('select', Select, {\n isControlled: true,\n})\n\nexport const CheckboxField = registerFieldType<CheckboxProps>(\n 'checkbox',\n forwardRef(({ label, type, ...props }, ref) => {\n return (\n <Checkbox ref={ref} {...props}>\n {label}\n </Checkbox>\n )\n }),\n {\n hideLabel: true,\n }\n)\n\nexport const RadioField = registerFieldType<RadioInputProps>(\n 'radio',\n RadioInput,\n {\n isControlled: true,\n }\n)\n\nexport const NativeSelectField = registerFieldType<NativeSelectProps>(\n 'native-select',\n NativeSelect,\n { isControlled: true }\n)\n\nexport interface PinFieldProps extends Omit<UsePinInputProps, 'type'> {\n pinLength?: number\n pinType?: 'alphanumeric' | 'number'\n spacing?: SystemProps['margin']\n}\n\nexport const PinField = registerFieldType<PinFieldProps>(\n 'pin',\n forwardRef((props, ref) => {\n const { pinLength = 4, pinType, spacing, ...inputProps } = props\n\n const inputs: React.ReactNode[] = []\n for (let i = 0; i < pinLength; i++) {\n inputs.push(<PinInputField key={i} ref={ref} />)\n }\n\n return (\n <HStack spacing={spacing}>\n <PinInput {...inputProps} type={pinType}>\n {inputs}\n </PinInput>\n </HStack>\n )\n }),\n {\n isControlled: true,\n }\n)\n\nconst fieldTypes = {\n text: InputField,\n email: InputField,\n url: InputField,\n phone: InputField,\n number: NumberInputField,\n password: PasswordInputField,\n textarea: TextareaField,\n switch: SwitchField,\n checkbox: CheckboxField,\n radio: RadioField,\n pin: PinField,\n select: SelectField,\n 'native-select': NativeSelectField,\n}\n\ntype FieldTypes = typeof fieldTypes\n\ntype FieldType<Props = any> = React.ElementType<Props>\n\ntype TypeProps<P extends FieldType, T> = React.ComponentPropsWithoutRef<P> & {\n type: T\n}\n\ntype FieldTypeProps =\n | {\n [Property in keyof FieldTypes]: TypeProps<FieldTypes[Property], Property>\n }[keyof FieldTypes]\n | { type?: string }\n","import { FieldProps } from './field'\n\nimport { get } from '@chakra-ui/utils'\n\nexport type FieldResolver = {\n getFields(): FieldProps[]\n getNestedFields(name: string): FieldProps[]\n}\n\ninterface SchemaField extends FieldProps {\n items?: SchemaField[]\n properties?: Record<string, SchemaField>\n}\n\nexport type ObjectSchema = Record<string, SchemaField>\n\nconst mapFields = (schema: ObjectSchema): FieldProps[] =>\n schema &&\n Object.entries(schema).map(([name, { items, label, title, ...field }]) => {\n return {\n ...field,\n name,\n label: label || title, // json schema compatibility\n }\n })\n\nexport const objectFieldResolver = (schema: ObjectSchema): FieldResolver => {\n const getFields = () => {\n return mapFields(schema)\n }\n const getNestedFields = (name: string) => {\n const field = get(schema, name)\n\n if (!field) return []\n\n if (field.items?.type === 'object') {\n return mapFields(field.items.properties)\n } else if (field.type === 'object') {\n return mapFields(field.properties)\n }\n return [field.items]\n }\n\n return { getFields, getNestedFields }\n}\n","import * as React from 'react'\n\nimport { chakra, HTMLChakraProps, forwardRef } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n useForm,\n FormProvider,\n UseFormProps,\n UseFormReturn,\n FieldValues,\n SubmitHandler,\n SubmitErrorHandler,\n ResolverOptions,\n ResolverResult,\n} from 'react-hook-form'\nimport { objectFieldResolver, FieldResolver } from './field-resolver'\n\nexport type { UseFormReturn, FieldValues, SubmitHandler }\n\ninterface FormOptions<TFieldValues extends FieldValues = FieldValues> {\n /**\n * The form schema, currently supports Yup schema only.\n */\n schema?: any\n /**\n * The submit handler.\n */\n onSubmit: SubmitHandler<TFieldValues>\n /**\n * Triggers when there are validation errors.\n */\n onError?: SubmitErrorHandler<TFieldValues>\n /**\n * Ref on the HTMLFormElement.\n */\n formRef?: React.RefObject<HTMLFormElement>\n}\n\n/**\n * @todo Figure out how to pass down FieldValues to all Field components,\n * if at all possible.\n */\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseFormProps<TFieldValues>,\n Omit<HTMLChakraProps<'form'>, 'onSubmit' | 'onError'>,\n FormOptions<TFieldValues> {}\n\nexport const Form = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n mode = 'all',\n resolver,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n schema,\n defaultValues,\n onSubmit,\n onError,\n formRef,\n children,\n ...rest\n } = props\n\n const form = {\n mode,\n resolver,\n defaultValues,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n }\n\n if (schema && !resolver) {\n form.resolver = Form.getResolver?.(schema)\n }\n\n const methods = useForm<TFieldValues>(form)\n const { handleSubmit } = methods\n\n // This exposes the useForm api through the forwarded ref\n React.useImperativeHandle(ref, () => methods, [ref, methods])\n\n return (\n <FormProvider {...methods}>\n <chakra.form\n ref={formRef}\n onSubmit={handleSubmit(onSubmit, onError)}\n {...rest}\n className={cx('saas-form', props.className)}\n >\n {children}\n </chakra.form>\n </FormProvider>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: FormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getResolver?: GetResolver\n getFieldResolver: GetFieldResolver\n}\n\nForm.getFieldResolver = objectFieldResolver\n\nif (__DEV__) {\n Form.displayName = 'Form'\n}\n\nexport type GetResolver = (\n schema: any\n) => <TFieldValues extends FieldValues, TContext>(\n values: TFieldValues,\n context: TContext | undefined,\n options: ResolverOptions<TFieldValues>\n) => Promise<ResolverResult<TFieldValues>>\n\nexport type GetFieldResolver = (schema: any) => FieldResolver\n","import * as React from 'react'\n\nimport { chakra, SimpleGrid, SimpleGridProps, useTheme } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nexport type FormLayoutProps = SimpleGridProps\n\ninterface FormLayoutItemProps {\n children: React.ReactNode\n}\n\nconst FormLayoutItem: React.FC<FormLayoutItemProps> = ({ children }) => {\n return <chakra.div>{children}</chakra.div>\n}\n\nif (__DEV__) {\n FormLayoutItem.displayName = 'FormLayoutItem'\n}\n\n/**\n * FormLayout\n *\n * Renders form items in a `SimpleGrid`\n * @see https://chakra-ui.com/docs/layout/simple-grid\n */\nexport const FormLayout = ({ children, ...props }: FormLayoutProps) => {\n const theme = useTheme()\n\n const defaultProps = theme.components?.FormLayout?.defaultProps ?? {\n spacing: 4,\n }\n\n const gridProps = {\n ...defaultProps,\n ...props,\n }\n\n return (\n <SimpleGrid\n {...gridProps}\n className={cx('saas-form__layout', props.className)}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return <FormLayoutItem>{child}</FormLayoutItem>\n }\n return child\n })}\n </SimpleGrid>\n )\n}\n\nif (__DEV__) {\n FormLayout.displayName = 'FormLayout'\n}\n","import * as React from 'react'\n\nexport const mapNestedFields = (name: string, children: React.ReactNode) => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.props.name) {\n return React.cloneElement(child, {\n ...child.props,\n name: `${name}.${child.props.name}`,\n })\n }\n return child\n })\n}\n","import * as React from 'react'\nimport {\n useFieldArray,\n useFormContext,\n UseFieldArrayReturn,\n} from 'react-hook-form'\n\nimport { createContext } from '@chakra-ui/react-utils'\n\nexport interface UseArrayFieldReturn extends UseFieldArrayReturn {\n /**\n * The array field name\n */\n name: string\n /**\n * The default value for new items\n */\n defaultValue: Record<string, any>\n /**\n * Min amount of items\n */\n min?: number\n /**\n * Max amount of items\n */\n max?: number\n}\n\nexport const [ArrayFieldProvider, useArrayFieldContext] =\n createContext<UseArrayFieldReturn>({\n name: 'ArrayFieldContext',\n })\n\nexport interface UseArrayFieldRowReturn {\n /**\n * Name of the array field including the index, eg 'field.0'\n */\n name: string\n /**\n * The field index\n */\n index: number\n /**\n * Remove this array item\n */\n remove: () => void\n /**\n * True if this is the first item\n */\n isFirst: boolean\n /**\n * True if this is the last item\n */\n isLast: boolean\n}\n\nexport const [ArrayFieldRowProvider, useArrayFieldRowContext] =\n createContext<UseArrayFieldRowReturn>({\n name: 'ArrayFieldRowContext',\n })\n\nexport interface ArrayFieldOptions {\n /**\n * The field name\n */\n name: string\n /**\n * Default value for new values in the array\n */\n defaultValue?: Record<string, any>\n /**\n * Default key name for rows, change this if your data uses a different 'id' field\n * @default \"id\"\n */\n keyName?: string\n min?: number\n max?: number\n}\n\nexport const useArrayField = ({\n name,\n defaultValue = {},\n keyName,\n min,\n max,\n}: ArrayFieldOptions) => {\n const { control } = useFormContext()\n const context = useFieldArray({\n control,\n name,\n keyName,\n })\n\n return {\n ...context,\n name,\n defaultValue,\n min,\n max,\n }\n}\n\nexport interface UseArrayFieldRowProps {\n index: number\n}\n\nexport const useArrayFieldRow = ({ index }: UseArrayFieldRowProps) => {\n const { clearErrors } = useFormContext()\n const { name, remove, fields } = useArrayFieldContext()\n\n React.useEffect(() => {\n // reset errors, to make sure min/max errors reset correctly\n clearErrors(name)\n }, [])\n\n return {\n index,\n isFirst: index === 0,\n isLast: index === fields.length - 1,\n name: `${name}.${index}`,\n remove: React.useCallback(() => {\n clearErrors(name)\n remove(index)\n }, [index]),\n }\n}\n\nexport const useArrayFieldRemoveButton = () => {\n const { isFirst, remove } = useArrayFieldRowContext()\n const { min, fields } = useArrayFieldContext()\n\n const isDisabled = isFirst && !!(min && fields.length <= min)\n\n return {\n onClick: () => remove(),\n isDisabled,\n }\n}\n\nexport const useArrayFieldAddButton = () => {\n const { append, defaultValue, max, fields } = useArrayFieldContext()\n\n const isDisabled = !!(max && fields.length >= max)\n\n return {\n onClick: () =>\n append(defaultValue, {\n shouldFocus: false,\n }),\n isDisabled,\n }\n}\n","import * as React from 'react'\n\nimport { chakra, ResponsiveValue, forwardRef } from '@chakra-ui/system'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { AddIcon, MinusIcon } from '@chakra-ui/icons'\nimport { IconButton, ButtonProps } from '@saas-ui/button'\n\nimport { FormLayout, FormLayoutProps } from './layout'\nimport { BaseField, FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nimport {\n useArrayField,\n useArrayFieldRow,\n useArrayFieldContext,\n ArrayFieldProvider,\n ArrayFieldOptions,\n ArrayFieldRowProvider,\n useArrayFieldRowContext,\n useArrayFieldRemoveButton,\n useArrayFieldAddButton,\n UseArrayFieldReturn,\n} from './use-array-field'\n\ninterface ArrayField {\n id: string\n [key: string]: unknown\n}\n\ninterface ArrayFieldRowProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The array index\n */\n index: number\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRow: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n ...rowFieldsProps\n}) => {\n return (\n <ArrayFieldRowContainer index={index}>\n <ArrayFieldRowFields {...rowFieldsProps}>{children}</ArrayFieldRowFields>\n <ArrayFieldRemoveButton />\n </ArrayFieldRowContainer>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRow.displayName = 'ArrayFieldRow'\n}\n\nexport interface ArrayFieldRowFieldsProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRowFields: React.FC<ArrayFieldRowFieldsProps> = ({\n children,\n ...layoutProps\n}) => {\n const { name } = useArrayFieldRowContext()\n return (\n <FormLayout flex=\"1\" mr=\"2\" {...layoutProps}>\n {mapNestedFields(name, children)}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowFields.displayName = 'ArrayFieldRowFields'\n}\n\nexport const ArrayFieldRowContainer: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n}) => {\n const context = useArrayFieldRow({ index })\n\n const styles = {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'flex-end',\n width: '100%',\n mb: 4,\n }\n\n return (\n <ArrayFieldRowProvider value={context}>\n <chakra.div __css={styles}>{children}</chakra.div>\n </ArrayFieldRowProvider>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowContainer.displayName = 'ArrayFieldRowContainer'\n}\n\nexport const ArrayFieldRemoveButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<MinusIcon />}\n aria-label=\"Remove row\"\n {...useArrayFieldRemoveButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldRemoveButton.displayName = 'ArrayFieldRemoveButton'\n}\n\nexport const ArrayFieldAddButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<AddIcon />}\n aria-label=\"Add row\"\n float=\"right\"\n {...useArrayFieldAddButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldAddButton.displayName = 'ArrayFieldAddButton'\n}\n\nexport interface ArrayFieldProps\n extends ArrayFieldOptions,\n Omit<FieldProps, 'defaultValue'> {}\n\nexport const ArrayField = forwardRef(\n (props: ArrayFieldProps, ref: React.ForwardedRef<UseArrayFieldReturn>) => {\n const { children, ...containerProps } = props\n\n return (\n <ArrayFieldContainer ref={ref} {...containerProps}>\n <ArrayFieldRows>\n {(fields: ArrayField[]) => (\n <>\n {fields.map(({ id }, index: number) => (\n <ArrayFieldRow key={id} index={index}>\n {children}\n </ArrayFieldRow>\n ))}\n </>\n )}\n </ArrayFieldRows>\n <ArrayFieldAddButton />\n </ArrayFieldContainer>\n )\n }\n) as ((\n props: ArrayFieldProps & {\n ref?: React.ForwardedRef<UseArrayFieldReturn>\n }\n) => React.ReactElement) & {\n displayName: string\n}\n\nif (__DEV__) {\n ArrayField.displayName = 'ArrayField'\n}\n\nexport interface ArrayFieldRowsProps {\n children: (fields: ArrayField[]) => React.ReactElement | null\n}\n\nexport const ArrayFieldRows = ({\n children,\n}: ArrayFieldRowsProps): React.ReactElement | null => {\n const { fields } = useArrayFieldContext()\n return children(fields)\n}\n\nif (__DEV__) {\n ArrayFieldRows.displayName = 'ArrayFieldRows'\n}\n\nexport const ArrayFieldContainer = React.forwardRef(\n (\n {\n name,\n defaultValue,\n keyName,\n min,\n max,\n children,\n ...fieldProps\n }: ArrayFieldProps,\n ref: React.ForwardedRef<UseArrayFieldReturn>\n ) => {\n const context = useArrayField({\n name,\n defaultValue,\n keyName,\n min,\n max,\n })\n\n // This exposes the useArrayField api through the forwarded ref\n React.useImperativeHandle(ref, () => context, [ref, context])\n\n return (\n <ArrayFieldProvider value={context}>\n <BaseField name={name} {...fieldProps}>\n {children}\n </BaseField>\n </ArrayFieldProvider>\n )\n }\n)\n\nif (__DEV__) {\n ArrayFieldContainer.displayName = 'ArrayFieldContainer'\n}\n","import * as React from 'react'\nimport {\n FormControl,\n FormLabel,\n FormLabelProps,\n ResponsiveValue,\n useStyleConfig,\n} from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { FormLayout } from './layout'\nimport { FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nexport interface ObjectFieldProps extends FieldProps {\n name: string\n children: React.ReactNode\n columns?: ResponsiveValue<number>\n spacing?: ResponsiveValue<string | number>\n}\n\nexport const FormLegend = (props: FormLabelProps) => {\n const styles = useStyleConfig('FormLegend')\n return <FormLabel as=\"legend\" sx={styles} {...props} />\n}\n\nexport const ObjectField: React.FC<ObjectFieldProps> = (props) => {\n const { name, label, hideLabel, children, columns, spacing, ...fieldProps } =\n props\n\n return (\n <FormControl name={name} as=\"fieldset\" {...fieldProps}>\n <FormLegend display={hideLabel ? 'none' : 'block'}>{label}</FormLegend>\n <FormLayout columns={columns} gridGap={spacing}>\n {mapNestedFields(name, children)}\n </FormLayout>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n ObjectField.displayName = 'ObjectField'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form } from './form'\nimport { FormLayout } from './layout'\nimport { Field, FieldProps } from './field'\n\nimport { ArrayField } from './array-field'\nimport { ObjectField } from './object-field'\nimport { FieldResolver } from './field-resolver'\nimport { useFormContext } from 'react-hook-form'\n\nexport interface FieldsProps {\n schema: any\n fieldResolver?: FieldResolver\n focusFirstField?: boolean\n}\n\nconst mapNestedFields = (resolver: FieldResolver, name: string) => {\n return resolver\n .getNestedFields(name)\n ?.map(\n ({ name, type, ...nestedFieldProps }: FieldProps, i): React.ReactNode => (\n <Field key={name || i} name={name} type={type} {...nestedFieldProps} />\n )\n )\n}\n\nexport const Fields: React.FC<FieldsProps> = ({\n schema,\n fieldResolver,\n focusFirstField,\n ...props\n}) => {\n const resolver = React.useMemo(\n () => fieldResolver || Form.getFieldResolver(schema),\n [schema, fieldResolver]\n )\n\n const fields = React.useMemo(() => resolver.getFields(), [resolver])\n\n const form = useFormContext()\n\n React.useEffect(() => {\n if (focusFirstField && fields[0]?.name) {\n form.setFocus(fields[0].name)\n }\n }, [schema, fieldResolver, focusFirstField])\n\n return (\n <FormLayout {...props}>\n {fields.map(\n ({\n name,\n type,\n defaultValue,\n ...fieldProps\n }: FieldProps): React.ReactNode => {\n if (type === 'array') {\n return (\n <ArrayField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ArrayField>\n )\n } else if (type === 'object') {\n return (\n <ObjectField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ObjectField>\n )\n }\n\n return <Field key={name} name={name} type={type} {...fieldProps} />\n }\n )}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n Fields.displayName = 'Fields'\n}\n","import * as React from 'react'\n\nimport { useFormContext } from 'react-hook-form'\n\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { __DEV__ } from '@chakra-ui/utils'\n\nexport interface SubmitButtonProps extends ButtonProps {\n /**\n * Disable the submit button if the form is untouched.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfUntouched`\n */\n disableIfUntouched?: boolean\n /**\n * Disable the submit button if the form is invalid.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfInvalid`\n */\n disableIfInvalid?: boolean\n}\n\nexport const SubmitButton = React.forwardRef<\n HTMLButtonElement,\n SubmitButtonProps\n>((props, ref) => {\n const {\n children,\n disableIfUntouched,\n disableIfInvalid,\n isDisabled: isDisabledProp,\n isLoading,\n ...rest\n } = props\n const { formState } = useFormContext()\n\n const isDisabled =\n (disableIfUntouched && !formState.isDirty) ||\n (disableIfInvalid && !formState.isValid) ||\n isDisabledProp\n\n return (\n <Button\n {...rest}\n ref={ref}\n variant=\"primary\"\n type=\"submit\"\n isLoading={formState.isSubmitting || isLoading}\n isDisabled={isDisabled}\n >\n {children}\n </Button>\n )\n})\n\nSubmitButton.defaultProps = {\n label: 'Submit',\n disableIfUntouched: false,\n disableIfInvalid: false,\n}\n\nif (__DEV__) {\n SubmitButton.displayName = 'SubmitButton'\n}\n","import * as React from 'react'\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\nimport { forwardRef } from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form, FormProps } from './form'\nimport { FormLayout } from './layout'\nimport { Fields } from './fields'\nimport { SubmitButton } from './submit-button'\nimport { FieldResolver } from '.'\n\ninterface AutoFormOptions {\n /**\n * The submit button label.\n * Pass `null` to render no submit button.\n */\n submitLabel?: React.ReactNode\n /**\n * The schema.\n * Supports object schema, Yup or Zod.\n * @see https://www.saas-ui.dev/docs/forms/auto-form\n */\n schema: any\n /**\n * The field resolver.\n */\n fieldResolver?: any\n}\n\nexport interface AutoFormProps<TFieldValues extends FieldValues>\n extends Omit<FormProps<TFieldValues>, 'schema'>,\n AutoFormOptions {}\n\nexport const AutoForm = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: AutoFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n schema,\n submitLabel = 'Submit',\n fieldResolver,\n children,\n ...rest\n } = props\n\n return (\n <Form {...rest} schema={schema} ref={ref}>\n <FormLayout>\n {<Fields schema={schema} fieldResolver={fieldResolver} />}\n {submitLabel && <SubmitButton>{submitLabel}</SubmitButton>}\n {children}\n </FormLayout>\n </Form>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: AutoFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getFieldResolver?: (schema: any) => FieldResolver\n}\n\nif (__DEV__) {\n AutoForm.displayName = 'AutoForm'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport {\n useFormContext,\n useWatch,\n FieldValues,\n UseFormReturn,\n} from 'react-hook-form'\n\nexport interface DisplayIfProps<TFieldValues> {\n children: React.ReactElement\n name: string\n defaultValue?: unknown\n isDisabled?: boolean\n isExact?: boolean\n condition?: (value: unknown, context: UseFormReturn<TFieldValues>) => boolean\n}\n\nexport const DisplayIf = <TFieldValues extends FieldValues = FieldValues>({\n children,\n name,\n defaultValue,\n isDisabled,\n isExact,\n condition = (value) => !!value,\n}: DisplayIfProps<TFieldValues>) => {\n const value = useWatch({\n name,\n defaultValue,\n disabled: isDisabled,\n exact: isExact,\n })\n const context = useFormContext<TFieldValues>()\n return condition(value, context) ? children : null\n}\n\nif (__DEV__) {\n DisplayIf.displayName = 'DisplayIf'\n}\n","import * as React from 'react'\nimport { FieldValues, SubmitHandler } from 'react-hook-form'\nimport { createContext, MaybeRenderProp } from '@chakra-ui/react-utils'\nimport {\n useStepper,\n useStep,\n UseStepperProps,\n UseStepperReturn,\n} from '@saas-ui/stepper'\n\nexport interface StepState {\n name: string\n schema?: any\n resolver?: any\n isActive?: boolean\n isCompleted?: boolean\n onSubmit?: FormStepSubmitHandler\n}\n\nexport type FormStepSubmitHandler<\n TFieldValues extends FieldValues = FieldValues\n> = (data: TFieldValues, stepper: UseStepperReturn) => Promise<void>\n\nexport interface StepFormContext extends UseStepperReturn {\n updateStep(state: StepState): void\n steps: Record<string, StepState>\n}\n\nexport const [StepFormProvider, useStepFormContext] =\n createContext<StepFormContext>({\n name: 'StepFormContext',\n errorMessage:\n 'useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`',\n })\n\nimport { FormProps } from './form'\n\nexport interface UseStepFormProps<\n TFieldValues extends FieldValues = FieldValues\n> extends Omit<UseStepperProps, 'onChange'>,\n Omit<FormProps<TFieldValues>, 'children'> {\n children: MaybeRenderProp<UseStepFormReturn<TFieldValues>>\n}\n\nexport interface UseStepFormReturn<\n TFieldValues extends FieldValues = FieldValues\n> extends UseStepperReturn {\n getFormProps(): {\n onSubmit: SubmitHandler<TFieldValues>\n schema?: any\n resolver?: any\n }\n updateStep(step: any): void\n steps: Record<string, any>\n}\n\nexport function useStepForm<TFieldValues extends FieldValues = FieldValues>(\n props: UseStepFormProps<TFieldValues>\n): UseStepFormReturn<TFieldValues> {\n const { onChange, ...rest } = props\n const stepper = useStepper(rest)\n\n const { activeStep, isLastStep, nextStep } = stepper\n\n const [steps, updateSteps] = React.useState<Record<string, StepState>>({})\n\n const onSubmitStep: SubmitHandler<TFieldValues> = React.useCallback(\n async (data) => {\n const step = steps[activeStep]\n\n if (isLastStep) {\n return props\n .onSubmit?.(data)\n .then(() => {\n updateStep({\n ...step,\n isCompleted: true,\n })\n })\n .then(nextStep) // Show completed step\n }\n\n try {\n await step.onSubmit?.(data, stepper)\n\n nextStep()\n } catch (e) {\n // Step submission failed.\n }\n },\n [steps, activeStep, isLastStep]\n )\n\n const getFormProps = React.useCallback(() => {\n const step = steps[activeStep]\n return {\n onSubmit: onSubmitStep,\n schema: step?.schema,\n resolver: step?.resolver,\n }\n }, [steps, onSubmitStep, activeStep])\n\n const updateStep = React.useCallback(\n (step: StepState) => {\n updateSteps((steps) => {\n return {\n ...steps,\n [step.name]: step,\n }\n })\n },\n [steps]\n )\n\n return {\n getFormProps,\n updateStep,\n steps,\n ...stepper,\n }\n}\n\nexport interface UseFormStepProps {\n name: string\n schema?: any\n resolver?: any\n onSubmit?: FormStepSubmitHandler\n}\n\nexport function useFormStep(props: UseFormStepProps): StepState {\n const { name, schema, resolver, onSubmit } = props\n const step = useStep({ name })\n\n const { steps, updateStep } = useStepFormContext()\n\n React.useEffect(() => {\n updateStep({ name, schema, resolver, onSubmit })\n }, [name, schema])\n\n return {\n ...step,\n ...(steps[name] || { name, schema }),\n }\n}\n","import * as React from 'react'\n\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\n\nimport { chakra, HTMLChakraProps } from '@chakra-ui/system'\n\nimport { callAllHandlers, runIfFn, cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n StepperProvider,\n StepperSteps,\n StepperStepsProps,\n StepperStep,\n useStepperContext,\n StepperContainer,\n} from '@saas-ui/stepper'\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { Form } from './form'\nimport { SubmitButton } from './submit-button'\n\nimport {\n useStepForm,\n useFormStep,\n StepFormProvider,\n UseStepFormProps,\n FormStepSubmitHandler,\n} from './use-step-form'\n\nexport interface StepFormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseStepFormProps<TFieldValues> {}\n\nexport const StepForm = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: StepFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const { children, ...rest } = props\n\n const stepper = useStepForm<TFieldValues>(props)\n\n const { getFormProps, ...ctx } = stepper\n\n const context = React.useMemo(() => ctx, [ctx])\n\n return (\n <StepperProvider value={context}>\n <StepFormProvider value={context}>\n <Form ref={ref} {...rest} {...getFormProps()}>\n {runIfFn(children, stepper)}\n </Form>\n </StepFormProvider>\n </StepperProvider>\n )\n }\n) as <TFieldValues extends FieldValues>(\n props: StepFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement\n\nexport interface FormStepOptions {\n /**\n * The step name\n */\n name: string\n /**\n * Schema\n */\n schema?: any\n /**\n * Hook Form Resolver\n */\n resolver?: any\n}\n\nexport const FormStepper: React.FC<StepperStepsProps> = (props) => {\n const { activeIndex, setIndex } = useStepperContext()\n\n const { children, orientation } = props\n\n const elements = React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child?.type === FormStep) {\n const { isCompleted } = useFormStep(child.props) // Register this step\n return (\n <StepperStep\n name={child.props.name}\n title={child.props.title}\n isCompleted={isCompleted}\n >\n {child.props.children}\n </StepperStep>\n )\n }\n return child\n })\n\n const onChange = React.useCallback((i: number) => {\n setIndex(i)\n }, [])\n\n return (\n <StepperContainer\n orientation={orientation}\n step={activeIndex}\n onChange={onChange}\n >\n <StepperSteps mb=\"4\" {...props}>\n {elements}\n </StepperSteps>\n </StepperContainer>\n )\n}\n\nexport interface FormStepProps\n extends FormStepOptions,\n Omit<HTMLChakraProps<'div'>, 'onSubmit'> {\n onSubmit?: FormStepSubmitHandler\n}\n\nexport const FormStep: React.FC<FormStepProps> = (props) => {\n const { name, schema, resolver, children, className, onSubmit, ...rest } =\n props\n const step = useFormStep({ name, schema, resolver, onSubmit })\n\n const { isActive } = step\n\n return isActive ? (\n <chakra.div {...rest} className={cx('saas-form__step', className)}>\n {children}\n </chakra.div>\n ) : null\n}\n\nif (__DEV__) {\n FormStep.displayName = 'FormStep'\n}\n\nexport const PrevButton: React.FC<ButtonProps> = (props) => {\n const { isFirstStep, isCompleted, prevStep } = useStepperContext()\n\n return (\n <Button\n isDisabled={isFirstStep || isCompleted}\n label=\"Back\"\n {...props}\n className={cx('saas-form__prev-button', props.className)}\n onClick={callAllHandlers(props.onClick, prevStep)}\n />\n )\n}\n\nif (__DEV__) {\n PrevButton.displayName = 'PrevButton'\n}\n\nexport interface NextButtonProps extends ButtonProps {\n submitLabel?: string\n}\n\nexport const NextButton: React.FC<NextButtonProps> = (props) => {\n const { label = 'Next', submitLabel = 'Complete', ...rest } = props\n const { isLastStep, isCompleted } = useStepperContext()\n\n return (\n <SubmitButton\n {...rest}\n isDisabled={isCompleted}\n className={cx('saas-form__next-button', props.className)}\n >\n {isLastStep || isCompleted ? submitLabel : label}\n </SubmitButton>\n )\n}\n\nif (__DEV__) {\n NextButton.displayName = 'NextButton'\n}\n"],"names":["_excluded","DisplayField","_ref","name","label","props","React","createElement","FormControl","FormLabel","htmlFor","Text","fontSize","FormValue","__DEV__","displayName","_ref2","getValues","useFormContext","_excluded2","_excluded3","_excluded4","_excluded5","_excluded6","_excluded7","_excluded8","_excluded9","_excluded10","inputTypes","help","variant","hideLabel","children","controlProps","formState","get","errors","getError","_extends","isInvalid","error","Box","message","FormHelperText","FormErrorMessage","BaseField","Field","forwardRef","ref","_props$type","type","defaultInputType","withControlledInput","InputComponent","rules","_ref3","inputProps","_objectWithoutPropertiesLoose","_useFormContext2","Controller","control","render","field","_ref4$field","useMergeRefs","withUncontrolledInput","_ref5","_register","register","component","options","id","isDisabled","isReadOnly","isRequired","inputRules","required","undefined","createField","isControlled","split","map","part","charAt","toUpperCase","slice","join","registerFieldType","_ref6","_ref6$type","leftAddon","rightAddon","size","rest","input","Input","InputGroup","NumberInputField","NumberInput","PasswordInputField","PasswordInput","Textarea","SwitchField","_ref7","Switch","SelectField","Select","CheckboxField","_ref8","Checkbox","RadioField","RadioInput","NativeSelectField","NativeSelect","pinLength","_props$pinLength","pinType","spacing","inputs","i","push","PinInputField","key","HStack","PinInput","schema","Object","entries","title","_ref$","objectFieldResolver","getFields","getNestedFields","_field$items","items","mapFields","properties","Form","mode","_props$mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","defaultValues","onSubmit","onError","formRef","form","getResolver","methods","useForm","handleSubmit","useImperativeHandle","FormProvider","chakra","className","cx","getFieldResolver","FormLayoutItem","div","FormLayout","_theme$components$For","_theme$components","_theme$components$For2","gridProps","theme","useTheme","components","defaultProps","SimpleGrid","Children","child","isValidElement","mapNestedFields","cloneElement","createContext","ArrayFieldProvider","useArrayFieldContext","_createContext","ArrayFieldRowProvider","useArrayFieldRowContext","useArrayField","_ref$defaultValue","defaultValue","keyName","min","max","context","useFieldArray","useArrayFieldRow","index","clearErrors","_useArrayFieldContext","remove","fields","useEffect","isFirst","isLast","length","useCallback","useArrayFieldRemoveButton","_useArrayFieldRowCont","_useArrayFieldContext2","onClick","append","_useArrayFieldContext3","shouldFocus","ArrayFieldRow","rowFieldsProps","ArrayFieldRowContainer","ArrayFieldRowFields","ArrayFieldRemoveButton","layoutProps","flex","mr","value","__css","display","flexDirection","alignItems","width","mb","IconButton","icon","MinusIcon","ArrayFieldAddButton","AddIcon","float","useArrayFieldAddButton","ArrayField","containerProps","ArrayFieldContainer","ArrayFieldRows","Fragment","_ref4","fieldProps","FormLegend","styles","useStyleConfig","as","sx","columns","gridGap","ObjectField","_resolver$getNestedFi","nestedFieldProps","Fields","fieldResolver","focusFirstField","useMemo","_fields$","setFocus","SubmitButton","disableIfUntouched","disableIfInvalid","isDisabledProp","isLoading","Button","isSubmitting","isDirty","isValid","AutoForm","submitLabel","_props$submitLabel","DisplayIf","condition","_ref$condition","useWatch","disabled","exact","isExact","errorMessage","StepFormProvider","useStepFormContext","onChange","stepper","useStepper","activeStep","isLastStep","nextStep","_React$useState","useState","steps","updateSteps","onSubmitStep","data","step","Promise","resolve","then","updateStep","isCompleted","_temp2","_catch","e","reject","getFormProps","_extends2","useStep","_useStepFormContext","useStepForm","ctx","StepperProvider","runIfFn","FormStep","useFormStep","isActive","PrevButton","_useStepperContext2","useStepperContext","prevStep","isFirstStep","callAllHandlers","NextButton","_props$label","_useStepperContext3","_useStepperContext","activeIndex","setIndex","orientation","elements","StepperStep","StepperContainer","StepperSteps"],"mappings":"okCAAA,IAAAA,EAAA,CAAA,OAAA,QAAA,eAiByBC,EAAgC,SAAAC,GACvDC,IAAAA,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,MAEGC,sBAEH,OACEC,EAAAC,cAACC,EAADA,YAAiBH,EACdD,eAAQE,EAACC,cAAAE,EAADA,UAAW,CAAAC,QAASP,GAAOC,GAAqB,kBACzDE,EAAAC,cAACI,EAADA,KAAA,CAAMC,SAAS,mBACbN,EAACC,cAAAM,EAAU,CAAAV,KAAMA,OAMrBW,EAAAA,UACFb,EAAac,YAAc,gBAGhBF,MAAwC,SAAAG,GAAGb,IAAAA,EAAAA,EAAAA,KAEtD,OAAOc,EADeC,EAAcA,iBAA5BD,WACSd,IAAS,MAGxBW,EAAAA,UACFD,EAAUE,YAAc,aC3C1B,IAAAf,EAAA,CAAA,OAAA,QAAA,OAAA,UAAA,YAAA,YAAAmB,EAAA,CAAA,KAAA,OAAA,QAAA,OAAA,aAAA,YAAA,aAAA,aAAA,QAAA,WAAAC,EAAA,CAAA,OAAA,SAAAC,EAAA,CAAA,OAAAC,EAAA,CAAA,OAAA,SAAAC,EAAA,CAAA,OAAAC,EAAA,CAAA,OAAA,YAAA,aAAA,QAAAC,EAAA,CAAA,QAAAC,EAAA,CAAA,QAAA,QAAAC,EAAA,CAAA,YAAA,UAAA,WA4GMC,EAA4C,KAmBH,SAACvB,GAC9C,MACEA,EADMF,KAAMC,EACZC,EADYD,MAAOyB,EACnBxB,EADmBwB,KAAMC,EACzBzB,EADyByB,QAASC,EAClC1B,EADkC0B,UAAWC,EAC7C3B,EAD6C2B,SAAaC,EAC1D5B,EAAAA,OAba,SAACF,EAAc+B,GAC9B,OAAUC,EAAAA,IAACD,E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BApG6B,SAACV,GACvD,IAAA2T,EAAkCP,EAAAA,oBAA1BQ,IAAAA,YAAaC,EAArBF,EAAqBE,SAEHC,EAAgB9T,EAAhB8T,YAEZC,EAAW9T,EAAMwK,SAAS7F,IAFE5E,EAA1B2B,SAEsC,SAAC+I,GAC7C,GAAIzK,EAAM0K,eAAeD,KAAU,MAAAA,OAAA,EAAAA,EAAO7H,QAASkQ,GAAU,CAC3D,IAAwBC,EAAAA,GAAYtI,EAAM1K,oBAC1C,OACEC,EAAAC,cAAC8T,EAADA,YACE,CAAAlU,KAAM4K,EAAM1K,MAAMF,KAClB6H,MAAO+C,EAAM1K,MAAM2H,MACnBuK,cALIA,aAOHxH,EAAM1K,MAAM2B,UAInB,OAAO+I,IAGHuG,EAAWhR,EAAMqM,YAAY,SAACpF,GAClC2M,EAAS3M,IACR,iBAEH,OACEjH,EAACC,cAAA+T,EAADA,kBACEH,YAAaA,EACbjC,KAAM+B,EACN3C,SAAUA,gBAEVhR,EAAAC,cAACgU,EAAAA,aAADjS,EAAA,CAAc2L,GAAG,KAAQ5N,GACtB+T"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.mjs","sources":["../src/display-field.tsx","../src/field.tsx","../src/field-resolver.ts","../src/form.tsx","../src/layout.tsx","../src/utils.ts","../src/use-array-field.tsx","../src/array-field.tsx","../src/object-field.tsx","../src/fields.tsx","../src/submit-button.tsx","../src/auto-form.tsx","../src/display-if.tsx","../src/use-step-form.tsx","../src/step-form.tsx"],"sourcesContent":["import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { useFormContext } from 'react-hook-form'\n\nimport {\n Text,\n FormControl,\n FormControlProps,\n FormLabel,\n} from '@chakra-ui/react'\n\nimport { FieldProps } from './field'\n\nexport interface DisplayFieldProps\n extends FormControlProps,\n Omit<FieldProps, 'type' | 'label'> {}\n\nexport const DisplayField: React.FC<DisplayFieldProps> = ({\n name,\n label,\n placeholder,\n ...props\n}) => {\n return (\n <FormControl {...props}>\n {label ? <FormLabel htmlFor={name}>{label}</FormLabel> : null}\n <Text fontSize=\"md\">\n <FormValue name={name} />\n </Text>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n DisplayField.displayName = 'DisplayField'\n}\n\nexport const FormValue: React.FC<{ name: string }> = ({ name }) => {\n const { getValues } = useFormContext()\n return getValues(name) || null\n}\n\nif (__DEV__) {\n FormValue.displayName = 'FormValue'\n}\n","import * as React from 'react'\nimport {\n useFormContext,\n FormState,\n Controller,\n get,\n RegisterOptions,\n FieldValues,\n FieldPath,\n} from 'react-hook-form'\n\nimport {\n forwardRef,\n Box,\n FormControl,\n FormControlProps,\n FormLabel,\n FormHelperText,\n FormErrorMessage,\n Input,\n Textarea,\n Checkbox,\n Switch,\n useMergeRefs,\n InputGroup,\n InputProps,\n TextareaProps,\n SwitchProps,\n CheckboxProps,\n PinInputField,\n HStack,\n PinInput,\n UsePinInputProps,\n SystemProps,\n} from '@chakra-ui/react'\nimport { __DEV__, FocusableElement } from '@chakra-ui/utils'\n\nimport { NumberInput, NumberInputProps } from '@saas-ui/number-input'\nimport { PasswordInput, PasswordInputProps } from '@saas-ui/password-input'\nimport { RadioInput, RadioInputProps } from '@saas-ui/radio'\n\nimport {\n Select,\n SelectProps,\n NativeSelect,\n NativeSelectProps,\n} from '@saas-ui/select'\n\nexport interface Option {\n value: string\n label?: string\n [key: string]: unknown\n}\n\nexport type FieldRules = Pick<\n RegisterOptions,\n 'required' | 'min' | 'max' | 'maxLength' | 'minLength' | 'pattern'\n>\n\nexport interface FieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends Omit<FormControlProps, 'label' | 'type'> {\n /**\n * The field name\n */\n name: TName\n /**\n * The field label\n */\n label?: string\n /**\n * Hide the field label\n */\n hideLabel?: boolean\n /**\n * Field help text\n */\n help?: string\n /**\n * React hook form rules\n */\n rules?: Omit<\n RegisterOptions<TFieldValues, TName>,\n 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'\n >\n /**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\n type?: string\n /**\n * The input placeholder\n */\n placeholder?: string\n}\n\nconst inputTypes: Record<string, React.FC<any>> = {}\n\nconst defaultInputType = 'text'\n\nconst getInput = (type: string) => {\n return inputTypes[type] || inputTypes[defaultInputType]\n}\n\nconst getError = (name: string, formState: FormState<{ [x: string]: any }>) => {\n return get(formState.errors, name)\n}\n\nconst isTouched = (\n name: string,\n formState: FormState<{ [x: string]: any }>\n) => {\n return get(formState.touchedFields, name)\n}\n\nexport const BaseField: React.FC<FieldProps> = (props) => {\n const { name, label, help, variant, hideLabel, children, ...controlProps } =\n props\n\n const { formState } = useFormContext()\n\n const error = getError(name, formState)\n\n return (\n <FormControl variant={variant} {...controlProps} isInvalid={!!error}>\n {label && !hideLabel ? (\n <FormLabel variant={variant}>{label}</FormLabel>\n ) : null}\n <Box>\n {children}\n {help && !error?.message ? (\n <FormHelperText>{help}</FormHelperText>\n ) : null}\n {error?.message && (\n <FormErrorMessage>{error?.message}</FormErrorMessage>\n )}\n </Box>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n BaseField.displayName = 'BaseField'\n}\n\nexport type As<Props = any> = React.ElementType<Props>\n\nexport type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {\n type?: FieldTypes\n}\n\n/**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\nexport const Field = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FieldProps<TFieldValues> | FieldTypeProps,\n ref: React.ForwardedRef<FocusableElement>\n ) => {\n const { type = defaultInputType } = props\n const InputComponent = getInput(type)\n\n return <InputComponent ref={ref} {...props} />\n }\n) as (<TFieldValues extends FieldValues>(\n props: FieldProps<TFieldValues> &\n FieldTypeProps & {\n ref?: React.ForwardedRef<FocusableElement>\n }\n) => React.ReactElement) & {\n displayName?: string\n}\n\ninterface CreateFieldProps {\n displayName: string\n hideLabel?: boolean\n BaseField: React.FC<any>\n}\n\nconst createField = (\n InputComponent: React.FC<any>,\n { displayName, hideLabel, BaseField }: CreateFieldProps\n) => {\n const Field = forwardRef((props, ref) => {\n const {\n id,\n name,\n label,\n help,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n rules,\n variant,\n ...inputProps\n } = props\n\n const inputRules = {\n required: isRequired,\n ...rules,\n }\n\n return (\n <BaseField\n id={id}\n name={name}\n label={label}\n help={help}\n hideLabel={hideLabel}\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n variant={variant}\n >\n <InputComponent\n ref={ref}\n id={id}\n name={name}\n label={hideLabel ? label : undefined} // Only pass down the label when it should be inline.\n rules={inputRules}\n {...inputProps}\n />\n </BaseField>\n )\n })\n Field.displayName = displayName\n\n return Field\n}\n\nexport const withControlledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { control } = useFormContext()\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ field: { ref: _ref, ...field } }) => (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )}\n />\n )\n }\n )\n}\n\nexport const withUncontrolledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { register } = useFormContext()\n\n const { ref: _ref, ...field } = register(name, rules)\n\n return (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )\n }\n )\n}\n\nexport interface RegisterFieldTypeOptions {\n isControlled?: boolean\n hideLabel?: boolean\n BaseField?: React.FC<any>\n}\n\n/**\n * Register a new field type\n * @param type The name for this field in kebab-case, eg `email` or `array-field`\n * @param component The React component\n * @param options\n * @param options.isControlled Set this to true if this is a controlled field.\n * @param options.hideLabel Hide the field label, for example for the checkbox field.\n */\nexport const registerFieldType = <T extends object>(\n type: string,\n component: React.FC<T>,\n options?: RegisterFieldTypeOptions\n) => {\n let InputComponent\n if (options?.isControlled) {\n InputComponent = withControlledInput(component)\n } else {\n InputComponent = withUncontrolledInput(component)\n }\n\n const Field = createField(InputComponent, {\n displayName: `${type\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')}Field`,\n hideLabel: options?.hideLabel,\n BaseField: options?.BaseField || BaseField,\n }) as React.FC<T & FieldProps>\n\n inputTypes[type] = Field\n\n return Field\n}\n\nexport interface InputFieldProps extends InputProps {\n type?: string\n leftAddon?: React.ReactNode\n rightAddon?: React.ReactNode\n}\n\nexport const InputField = registerFieldType<InputFieldProps>(\n 'text',\n forwardRef(({ type = 'text', leftAddon, rightAddon, size, ...rest }, ref) => {\n const input = <Input type={type} size={size} {...rest} ref={ref} />\n if (leftAddon || rightAddon) {\n return (\n <InputGroup size={size}>\n {leftAddon}\n {input}\n {rightAddon}\n </InputGroup>\n )\n }\n return input\n })\n)\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n type: 'number'\n}\n\nexport const NumberInputField = registerFieldType<NumberInputFieldProps>(\n 'number',\n NumberInput,\n {\n isControlled: true,\n }\n)\n\nexport const PasswordInputField = registerFieldType<PasswordInputProps>(\n 'password',\n forwardRef((props, ref) => <PasswordInput ref={ref} {...props} />)\n)\n\nexport const TextareaField = registerFieldType<TextareaProps>(\n 'textarea',\n Textarea\n)\n\nexport const SwitchField = registerFieldType<SwitchProps>(\n 'switch',\n forwardRef(({ type, ...rest }, ref) => {\n return <Switch {...rest} ref={ref} />\n }),\n {\n isControlled: true,\n }\n)\n\nexport const SelectField = registerFieldType<SelectProps>('select', Select, {\n isControlled: true,\n})\n\nexport const CheckboxField = registerFieldType<CheckboxProps>(\n 'checkbox',\n forwardRef(({ label, type, ...props }, ref) => {\n return (\n <Checkbox ref={ref} {...props}>\n {label}\n </Checkbox>\n )\n }),\n {\n hideLabel: true,\n }\n)\n\nexport const RadioField = registerFieldType<RadioInputProps>(\n 'radio',\n RadioInput,\n {\n isControlled: true,\n }\n)\n\nexport const NativeSelectField = registerFieldType<NativeSelectProps>(\n 'native-select',\n NativeSelect,\n { isControlled: true }\n)\n\nexport interface PinFieldProps extends Omit<UsePinInputProps, 'type'> {\n pinLength?: number\n pinType?: 'alphanumeric' | 'number'\n spacing?: SystemProps['margin']\n}\n\nexport const PinField = registerFieldType<PinFieldProps>(\n 'pin',\n forwardRef((props, ref) => {\n const { pinLength = 4, pinType, spacing, ...inputProps } = props\n\n const inputs: React.ReactNode[] = []\n for (let i = 0; i < pinLength; i++) {\n inputs.push(<PinInputField key={i} ref={ref} />)\n }\n\n return (\n <HStack spacing={spacing}>\n <PinInput {...inputProps} type={pinType}>\n {inputs}\n </PinInput>\n </HStack>\n )\n }),\n {\n isControlled: true,\n }\n)\n\nconst fieldTypes = {\n text: InputField,\n email: InputField,\n url: InputField,\n phone: InputField,\n number: NumberInputField,\n password: PasswordInputField,\n textarea: TextareaField,\n switch: SwitchField,\n checkbox: CheckboxField,\n radio: RadioField,\n pin: PinField,\n select: SelectField,\n 'native-select': NativeSelectField,\n}\n\ntype FieldTypes = typeof fieldTypes\n\ntype FieldType<Props = any> = React.ElementType<Props>\n\ntype TypeProps<P extends FieldType, T> = React.ComponentPropsWithoutRef<P> & {\n type: T\n}\n\ntype FieldTypeProps =\n | {\n [Property in keyof FieldTypes]: TypeProps<FieldTypes[Property], Property>\n }[keyof FieldTypes]\n | { type?: string }\n","import { FieldProps } from './field'\n\nimport { get } from '@chakra-ui/utils'\n\nexport type FieldResolver = {\n getFields(): FieldProps[]\n getNestedFields(name: string): FieldProps[]\n}\n\ninterface SchemaField extends FieldProps {\n items?: SchemaField[]\n properties?: Record<string, SchemaField>\n}\n\nexport type ObjectSchema = Record<string, SchemaField>\n\nconst mapFields = (schema: ObjectSchema): FieldProps[] =>\n schema &&\n Object.entries(schema).map(([name, { items, label, title, ...field }]) => {\n return {\n ...field,\n name,\n label: label || title, // json schema compatibility\n }\n })\n\nexport const objectFieldResolver = (schema: ObjectSchema): FieldResolver => {\n const getFields = () => {\n return mapFields(schema)\n }\n const getNestedFields = (name: string) => {\n const field = get(schema, name)\n\n if (!field) return []\n\n if (field.items?.type === 'object') {\n return mapFields(field.items.properties)\n } else if (field.type === 'object') {\n return mapFields(field.properties)\n }\n return [field.items]\n }\n\n return { getFields, getNestedFields }\n}\n","import * as React from 'react'\n\nimport { chakra, HTMLChakraProps, forwardRef } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n useForm,\n FormProvider,\n UseFormProps,\n UseFormReturn,\n FieldValues,\n SubmitHandler,\n SubmitErrorHandler,\n UnpackNestedValue,\n ResolverOptions,\n ResolverResult,\n} from 'react-hook-form'\nimport { objectFieldResolver, FieldResolver } from './field-resolver'\n\nexport type { UseFormReturn, FieldValues, SubmitHandler }\n\ninterface FormOptions<TFieldValues extends FieldValues = FieldValues> {\n /**\n * The form schema, currently supports Yup schema only.\n */\n schema?: any\n /**\n * The submit handler.\n */\n onSubmit: SubmitHandler<TFieldValues>\n /**\n * Triggers when there are validation errors.\n */\n onError?: SubmitErrorHandler<TFieldValues>\n /**\n * Ref on the HTMLFormElement.\n */\n formRef?: React.RefObject<HTMLFormElement>\n}\n\n/**\n * @todo Figure out how to pass down FieldValues to all Field components,\n * if at all possible.\n */\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseFormProps<TFieldValues>,\n Omit<HTMLChakraProps<'form'>, 'onSubmit' | 'onError'>,\n FormOptions<TFieldValues> {}\n\nexport const Form = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n mode = 'all',\n resolver,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n schema,\n defaultValues,\n onSubmit,\n onError,\n formRef,\n children,\n ...rest\n } = props\n\n const form = {\n mode,\n resolver,\n defaultValues,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n }\n\n if (schema && !resolver) {\n form.resolver = Form.getResolver?.(schema)\n }\n\n const methods = useForm<TFieldValues>(form)\n const { handleSubmit } = methods\n\n // This exposes the useForm api through the forwarded ref\n React.useImperativeHandle(ref, () => methods, [ref, methods])\n\n return (\n <FormProvider {...methods}>\n <chakra.form\n ref={formRef}\n onSubmit={handleSubmit(onSubmit, onError)}\n {...rest}\n className={cx('saas-form', props.className)}\n >\n {children}\n </chakra.form>\n </FormProvider>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: FormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getResolver?: GetResolver\n getFieldResolver: GetFieldResolver\n}\n\nForm.getFieldResolver = objectFieldResolver\n\nif (__DEV__) {\n Form.displayName = 'Form'\n}\n\nexport type GetResolver = (\n schema: any\n) => <TFieldValues extends FieldValues, TContext>(\n values: UnpackNestedValue<TFieldValues>,\n context: TContext | undefined,\n options: ResolverOptions<TFieldValues>\n) => Promise<ResolverResult<TFieldValues>>\n\nexport type GetFieldResolver = (schema: any) => FieldResolver\n","import * as React from 'react'\n\nimport { chakra, SimpleGrid, SimpleGridProps, useTheme } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nexport type FormLayoutProps = SimpleGridProps\n\ninterface FormLayoutItemProps {\n children: React.ReactNode\n}\n\nconst FormLayoutItem: React.FC<FormLayoutItemProps> = ({ children }) => {\n return <chakra.div>{children}</chakra.div>\n}\n\nif (__DEV__) {\n FormLayoutItem.displayName = 'FormLayoutItem'\n}\n\n/**\n * FormLayout\n *\n * Renders form items in a `SimpleGrid`\n * @see https://chakra-ui.com/docs/layout/simple-grid\n */\nexport const FormLayout = ({ children, ...props }: FormLayoutProps) => {\n const theme = useTheme()\n\n const defaultProps = theme.components?.FormLayout?.defaultProps ?? {\n spacing: 4,\n }\n\n const gridProps = {\n ...defaultProps,\n ...props,\n }\n\n return (\n <SimpleGrid\n {...gridProps}\n className={cx('saas-form__layout', props.className)}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return <FormLayoutItem>{child}</FormLayoutItem>\n }\n return child\n })}\n </SimpleGrid>\n )\n}\n\nif (__DEV__) {\n FormLayout.displayName = 'FormLayout'\n}\n","import * as React from 'react'\n\nexport const mapNestedFields = (name: string, children: React.ReactNode) => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.props.name) {\n return React.cloneElement(child, {\n ...child.props,\n name: `${name}.${child.props.name}`,\n })\n }\n return child\n })\n}\n","import * as React from 'react'\nimport {\n useFieldArray,\n useFormContext,\n UseFieldArrayReturn,\n} from 'react-hook-form'\n\nimport { createContext } from '@chakra-ui/react-utils'\n\nexport interface UseArrayFieldReturn extends UseFieldArrayReturn {\n /**\n * The array field name\n */\n name: string\n /**\n * The default value for new items\n */\n defaultValue: Record<string, any>\n /**\n * Min amount of items\n */\n min?: number\n /**\n * Max amount of items\n */\n max?: number\n}\n\nexport const [ArrayFieldProvider, useArrayFieldContext] =\n createContext<UseArrayFieldReturn>({\n name: 'ArrayFieldContext',\n })\n\nexport interface UseArrayFieldRowReturn {\n /**\n * Name of the array field including the index, eg 'field.0'\n */\n name: string\n /**\n * The field index\n */\n index: number\n /**\n * Remove this array item\n */\n remove: () => void\n /**\n * True if this is the first item\n */\n isFirst: boolean\n /**\n * True if this is the last item\n */\n isLast: boolean\n}\n\nexport const [ArrayFieldRowProvider, useArrayFieldRowContext] =\n createContext<UseArrayFieldRowReturn>({\n name: 'ArrayFieldRowContext',\n })\n\nexport interface ArrayFieldOptions {\n /**\n * The field name\n */\n name: string\n /**\n * Default value for new values in the array\n */\n defaultValue?: Record<string, any>\n /**\n * Default key name for rows, change this if your data uses a different 'id' field\n * @default \"id\"\n */\n keyName?: string\n min?: number\n max?: number\n}\n\nexport const useArrayField = ({\n name,\n defaultValue = {},\n keyName,\n min,\n max,\n}: ArrayFieldOptions) => {\n const { control } = useFormContext()\n const context = useFieldArray({\n control,\n name,\n keyName,\n })\n\n return {\n ...context,\n name,\n defaultValue,\n min,\n max,\n }\n}\n\nexport interface UseArrayFieldRowProps {\n index: number\n}\n\nexport const useArrayFieldRow = ({ index }: UseArrayFieldRowProps) => {\n const { clearErrors } = useFormContext()\n const { name, remove, fields } = useArrayFieldContext()\n\n React.useEffect(() => {\n // reset errors, to make sure min/max errors reset correctly\n clearErrors(name)\n }, [])\n\n return {\n index,\n isFirst: index === 0,\n isLast: index === fields.length - 1,\n name: `${name}.${index}`,\n remove: React.useCallback(() => {\n clearErrors(name)\n remove(index)\n }, [index]),\n }\n}\n\nexport const useArrayFieldRemoveButton = () => {\n const { isFirst, remove } = useArrayFieldRowContext()\n const { min, fields } = useArrayFieldContext()\n\n const isDisabled = isFirst && !!(min && fields.length <= min)\n\n return {\n onClick: () => remove(),\n isDisabled,\n }\n}\n\nexport const useArrayFieldAddButton = () => {\n const { append, defaultValue, max, fields } = useArrayFieldContext()\n\n const isDisabled = !!(max && fields.length >= max)\n\n return {\n onClick: () =>\n append(defaultValue, {\n shouldFocus: false,\n }),\n isDisabled,\n }\n}\n","import * as React from 'react'\n\nimport { chakra, ResponsiveValue, forwardRef } from '@chakra-ui/system'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { AddIcon, MinusIcon } from '@chakra-ui/icons'\nimport { IconButton, ButtonProps } from '@saas-ui/button'\n\nimport { FormLayout, FormLayoutProps } from './layout'\nimport { BaseField, FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nimport {\n useArrayField,\n useArrayFieldRow,\n useArrayFieldContext,\n ArrayFieldProvider,\n ArrayFieldOptions,\n ArrayFieldRowProvider,\n useArrayFieldRowContext,\n useArrayFieldRemoveButton,\n useArrayFieldAddButton,\n UseArrayFieldReturn,\n} from './use-array-field'\n\ninterface ArrayField {\n id: string\n [key: string]: unknown\n}\n\ninterface ArrayFieldRowProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The array index\n */\n index: number\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRow: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n ...rowFieldsProps\n}) => {\n return (\n <ArrayFieldRowContainer index={index}>\n <ArrayFieldRowFields {...rowFieldsProps}>{children}</ArrayFieldRowFields>\n <ArrayFieldRemoveButton />\n </ArrayFieldRowContainer>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRow.displayName = 'ArrayFieldRow'\n}\n\nexport interface ArrayFieldRowFieldsProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRowFields: React.FC<ArrayFieldRowFieldsProps> = ({\n children,\n ...layoutProps\n}) => {\n const { name } = useArrayFieldRowContext()\n return (\n <FormLayout flex=\"1\" mr=\"2\" {...layoutProps}>\n {mapNestedFields(name, children)}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowFields.displayName = 'ArrayFieldRowFields'\n}\n\nexport const ArrayFieldRowContainer: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n}) => {\n const context = useArrayFieldRow({ index })\n\n const styles = {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'flex-end',\n width: '100%',\n mb: 4,\n }\n\n return (\n <ArrayFieldRowProvider value={context}>\n <chakra.div __css={styles}>{children}</chakra.div>\n </ArrayFieldRowProvider>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowContainer.displayName = 'ArrayFieldRowContainer'\n}\n\nexport const ArrayFieldRemoveButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<MinusIcon />}\n aria-label=\"Remove row\"\n {...useArrayFieldRemoveButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldRemoveButton.displayName = 'ArrayFieldRemoveButton'\n}\n\nexport const ArrayFieldAddButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<AddIcon />}\n aria-label=\"Add row\"\n float=\"right\"\n {...useArrayFieldAddButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldAddButton.displayName = 'ArrayFieldAddButton'\n}\n\nexport interface ArrayFieldProps\n extends ArrayFieldOptions,\n Omit<FieldProps, 'defaultValue'> {}\n\nexport const ArrayField = forwardRef(\n (props: ArrayFieldProps, ref: React.ForwardedRef<UseArrayFieldReturn>) => {\n const { children, ...containerProps } = props\n\n return (\n <ArrayFieldContainer ref={ref} {...containerProps}>\n <ArrayFieldRows>\n {(fields: ArrayField[]) => (\n <>\n {fields.map(({ id }, index: number) => (\n <ArrayFieldRow key={id} index={index}>\n {children}\n </ArrayFieldRow>\n ))}\n </>\n )}\n </ArrayFieldRows>\n <ArrayFieldAddButton />\n </ArrayFieldContainer>\n )\n }\n) as ((\n props: ArrayFieldProps & {\n ref?: React.ForwardedRef<UseArrayFieldReturn>\n }\n) => React.ReactElement) & {\n displayName: string\n}\n\nif (__DEV__) {\n ArrayField.displayName = 'ArrayField'\n}\n\nexport interface ArrayFieldRowsProps {\n children: (fields: ArrayField[]) => React.ReactElement | null\n}\n\nexport const ArrayFieldRows = ({\n children,\n}: ArrayFieldRowsProps): React.ReactElement | null => {\n const { fields } = useArrayFieldContext()\n return children(fields)\n}\n\nif (__DEV__) {\n ArrayFieldRows.displayName = 'ArrayFieldRows'\n}\n\nexport const ArrayFieldContainer = React.forwardRef(\n (\n {\n name,\n defaultValue,\n keyName,\n min,\n max,\n children,\n ...fieldProps\n }: ArrayFieldProps,\n ref: React.ForwardedRef<UseArrayFieldReturn>\n ) => {\n const context = useArrayField({\n name,\n defaultValue,\n keyName,\n min,\n max,\n })\n\n // This exposes the useArrayField api through the forwarded ref\n React.useImperativeHandle(ref, () => context, [ref, context])\n\n return (\n <ArrayFieldProvider value={context}>\n <BaseField name={name} {...fieldProps}>\n {children}\n </BaseField>\n </ArrayFieldProvider>\n )\n }\n)\n\nif (__DEV__) {\n ArrayFieldContainer.displayName = 'ArrayFieldContainer'\n}\n","import * as React from 'react'\nimport {\n FormControl,\n FormLabel,\n FormLabelProps,\n ResponsiveValue,\n useStyleConfig,\n} from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { FormLayout } from './layout'\nimport { FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nexport interface ObjectFieldProps extends FieldProps {\n name: string\n children: React.ReactNode\n columns?: ResponsiveValue<number>\n spacing?: ResponsiveValue<string | number>\n}\n\nexport const FormLegend = (props: FormLabelProps) => {\n const styles = useStyleConfig('FormLegend')\n return <FormLabel as=\"legend\" sx={styles} {...props} />\n}\n\nexport const ObjectField: React.FC<ObjectFieldProps> = (props) => {\n const { name, label, hideLabel, children, columns, spacing, ...fieldProps } =\n props\n\n return (\n <FormControl name={name} as=\"fieldset\" {...fieldProps}>\n <FormLegend display={hideLabel ? 'none' : 'block'}>{label}</FormLegend>\n <FormLayout columns={columns} gridGap={spacing}>\n {mapNestedFields(name, children)}\n </FormLayout>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n ObjectField.displayName = 'ObjectField'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form } from './form'\nimport { FormLayout } from './layout'\nimport { Field, FieldProps } from './field'\n\nimport { ArrayField } from './array-field'\nimport { ObjectField } from './object-field'\nimport { FieldResolver } from './field-resolver'\nimport { useFormContext } from 'react-hook-form'\n\nexport interface FieldsProps {\n schema: any\n fieldResolver?: FieldResolver\n focusFirstField?: boolean\n}\n\nconst mapNestedFields = (resolver: FieldResolver, name: string) => {\n return resolver\n .getNestedFields(name)\n ?.map(\n ({ name, type, ...nestedFieldProps }: FieldProps, i): React.ReactNode => (\n <Field key={name || i} name={name} type={type} {...nestedFieldProps} />\n )\n )\n}\n\nexport const Fields: React.FC<FieldsProps> = ({\n schema,\n fieldResolver,\n focusFirstField,\n ...props\n}) => {\n const resolver = React.useMemo(\n () => fieldResolver || Form.getFieldResolver(schema),\n [schema, fieldResolver]\n )\n\n const fields = React.useMemo(() => resolver.getFields(), [resolver])\n\n const form = useFormContext()\n\n React.useEffect(() => {\n if (focusFirstField && fields[0]?.name) {\n form.setFocus(fields[0].name)\n }\n }, [schema, fieldResolver, focusFirstField])\n\n return (\n <FormLayout {...props}>\n {fields.map(\n ({\n name,\n type,\n defaultValue,\n ...fieldProps\n }: FieldProps): React.ReactNode => {\n if (type === 'array') {\n return (\n <ArrayField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ArrayField>\n )\n } else if (type === 'object') {\n return (\n <ObjectField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ObjectField>\n )\n }\n\n return <Field key={name} name={name} type={type} {...fieldProps} />\n }\n )}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n Fields.displayName = 'Fields'\n}\n","import * as React from 'react'\n\nimport { useFormContext } from 'react-hook-form'\n\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { __DEV__ } from '@chakra-ui/utils'\n\nexport interface SubmitButtonProps extends ButtonProps {\n /**\n * Disable the submit button if the form is untouched.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfUntouched`\n */\n disableIfUntouched?: boolean\n /**\n * Disable the submit button if the form is invalid.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfInvalid`\n */\n disableIfInvalid?: boolean\n}\n\nexport const SubmitButton = React.forwardRef<\n HTMLButtonElement,\n SubmitButtonProps\n>((props, ref) => {\n const {\n children,\n disableIfUntouched,\n disableIfInvalid,\n isDisabled: isDisabledProp,\n isLoading,\n ...rest\n } = props\n const { formState } = useFormContext()\n\n const isDisabled =\n (disableIfUntouched && !formState.isDirty) ||\n (disableIfInvalid && !formState.isValid) ||\n isDisabledProp\n\n return (\n <Button\n {...rest}\n ref={ref}\n variant=\"primary\"\n type=\"submit\"\n isLoading={formState.isSubmitting || isLoading}\n isDisabled={isDisabled}\n >\n {children}\n </Button>\n )\n})\n\nSubmitButton.defaultProps = {\n label: 'Submit',\n disableIfUntouched: false,\n disableIfInvalid: false,\n}\n\nif (__DEV__) {\n SubmitButton.displayName = 'SubmitButton'\n}\n","import * as React from 'react'\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\nimport { forwardRef } from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form, FormProps } from './form'\nimport { FormLayout } from './layout'\nimport { Fields } from './fields'\nimport { SubmitButton } from './submit-button'\nimport { FieldResolver } from '.'\n\ninterface AutoFormOptions {\n /**\n * The submit button label.\n * Pass `null` to render no submit button.\n */\n submitLabel?: React.ReactNode\n /**\n * The schema.\n * Supports object schema, Yup or Zod.\n * @see https://www.saas-ui.dev/docs/forms/auto-form\n */\n schema: any\n /**\n * The field resolver.\n */\n fieldResolver?: any\n}\n\nexport interface AutoFormProps<TFieldValues extends FieldValues>\n extends Omit<FormProps<TFieldValues>, 'schema'>,\n AutoFormOptions {}\n\nexport const AutoForm = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: AutoFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n schema,\n submitLabel = 'Submit',\n fieldResolver,\n children,\n ...rest\n } = props\n\n return (\n <Form {...rest} schema={schema} ref={ref}>\n <FormLayout>\n {<Fields schema={schema} fieldResolver={fieldResolver} />}\n {submitLabel && <SubmitButton>{submitLabel}</SubmitButton>}\n {children}\n </FormLayout>\n </Form>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: AutoFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getFieldResolver?: (schema: any) => FieldResolver\n}\n\nif (__DEV__) {\n AutoForm.displayName = 'AutoForm'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport {\n useFormContext,\n useWatch,\n FieldValues,\n UseFormReturn,\n} from 'react-hook-form'\n\nexport interface DisplayIfProps<TFieldValues> {\n children: React.ReactElement\n name: string\n defaultValue?: unknown\n isDisabled?: boolean\n isExact?: boolean\n condition?: (value: unknown, context: UseFormReturn<TFieldValues>) => boolean\n}\n\nexport const DisplayIf = <TFieldValues extends FieldValues = FieldValues>({\n children,\n name,\n defaultValue,\n isDisabled,\n isExact,\n condition = (value) => !!value,\n}: DisplayIfProps<TFieldValues>) => {\n const value = useWatch({\n name,\n defaultValue,\n disabled: isDisabled,\n exact: isExact,\n })\n const context = useFormContext<TFieldValues>()\n return condition(value, context) ? children : null\n}\n\nif (__DEV__) {\n DisplayIf.displayName = 'DisplayIf'\n}\n","import * as React from 'react'\nimport { FieldValues, SubmitHandler, UnpackNestedValue } from 'react-hook-form'\nimport { createContext, MaybeRenderProp } from '@chakra-ui/react-utils'\nimport {\n useStepper,\n useStep,\n UseStepperProps,\n UseStepperReturn,\n} from '@saas-ui/stepper'\n\nexport interface StepState {\n name: string\n schema?: any\n resolver?: any\n isActive?: boolean\n isCompleted?: boolean\n onSubmit?: FormStepSubmitHandler\n}\n\nexport type FormStepSubmitHandler<\n TFieldValues extends FieldValues = FieldValues\n> = (\n data: UnpackNestedValue<TFieldValues>,\n stepper: UseStepperReturn\n) => Promise<void>\n\nexport interface StepFormContext extends UseStepperReturn {\n updateStep(state: StepState): void\n steps: Record<string, StepState>\n}\n\nexport const [StepFormProvider, useStepFormContext] =\n createContext<StepFormContext>({\n name: 'StepFormContext',\n errorMessage:\n 'useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`',\n })\n\nimport { FormProps } from './form'\n\nexport interface UseStepFormProps<\n TFieldValues extends FieldValues = FieldValues\n> extends Omit<UseStepperProps, 'onChange'>,\n Omit<FormProps<TFieldValues>, 'children'> {\n children: MaybeRenderProp<UseStepFormReturn<TFieldValues>>\n}\n\nexport interface UseStepFormReturn<\n TFieldValues extends FieldValues = FieldValues\n> extends UseStepperReturn {\n getFormProps(): {\n onSubmit: SubmitHandler<TFieldValues>\n schema?: any\n resolver?: any\n }\n updateStep(step: any): void\n steps: Record<string, any>\n}\n\nexport function useStepForm<TFieldValues extends FieldValues = FieldValues>(\n props: UseStepFormProps<TFieldValues>\n): UseStepFormReturn<TFieldValues> {\n const { onChange, ...rest } = props\n const stepper = useStepper(rest)\n\n const { activeStep, isLastStep, nextStep } = stepper\n\n const [steps, updateSteps] = React.useState<Record<string, StepState>>({})\n\n const onSubmitStep: SubmitHandler<TFieldValues> = React.useCallback(\n async (data) => {\n const step = steps[activeStep]\n\n if (isLastStep) {\n return props\n .onSubmit?.(data)\n .then(() => {\n updateStep({\n ...step,\n isCompleted: true,\n })\n })\n .then(nextStep) // Show completed step\n }\n\n try {\n await step.onSubmit?.(data, stepper)\n\n nextStep()\n } catch (e) {\n // Step submission failed.\n }\n },\n [steps, activeStep, isLastStep]\n )\n\n const getFormProps = React.useCallback(() => {\n const step = steps[activeStep]\n return {\n onSubmit: onSubmitStep,\n schema: step?.schema,\n resolver: step?.resolver,\n }\n }, [steps, onSubmitStep, activeStep])\n\n const updateStep = React.useCallback(\n (step: StepState) => {\n updateSteps((steps) => {\n return {\n ...steps,\n [step.name]: step,\n }\n })\n },\n [steps]\n )\n\n return {\n getFormProps,\n updateStep,\n steps,\n ...stepper,\n }\n}\n\nexport interface UseFormStepProps {\n name: string\n schema?: any\n resolver?: any\n onSubmit?: FormStepSubmitHandler\n}\n\nexport function useFormStep(props: UseFormStepProps): StepState {\n const { name, schema, resolver, onSubmit } = props\n const step = useStep({ name })\n\n const { steps, updateStep } = useStepFormContext()\n\n React.useEffect(() => {\n updateStep({ name, schema, resolver, onSubmit })\n }, [name, schema])\n\n return {\n ...step,\n ...(steps[name] || { name, schema }),\n }\n}\n","import * as React from 'react'\n\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\n\nimport { chakra, HTMLChakraProps } from '@chakra-ui/system'\n\nimport { callAllHandlers, runIfFn, cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n StepperProvider,\n StepperSteps,\n StepperStepsProps,\n StepperStep,\n useStepperContext,\n StepperContainer,\n} from '@saas-ui/stepper'\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { Form } from './form'\nimport { SubmitButton } from './submit-button'\n\nimport {\n useStepForm,\n useFormStep,\n StepFormProvider,\n UseStepFormProps,\n FormStepSubmitHandler,\n} from './use-step-form'\n\nexport interface StepFormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseStepFormProps<TFieldValues> {}\n\nexport const StepForm = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: StepFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const { children, ...rest } = props\n\n const stepper = useStepForm<TFieldValues>(props)\n\n const { getFormProps, ...ctx } = stepper\n\n const context = React.useMemo(() => ctx, [ctx])\n\n return (\n <StepperProvider value={context}>\n <StepFormProvider value={context}>\n <Form ref={ref} {...rest} {...getFormProps()}>\n {runIfFn(children, stepper)}\n </Form>\n </StepFormProvider>\n </StepperProvider>\n )\n }\n) as <TFieldValues extends FieldValues>(\n props: StepFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement\n\nexport interface FormStepOptions {\n /**\n * The step name\n */\n name: string\n /**\n * Schema\n */\n schema?: any\n /**\n * Hook Form Resolver\n */\n resolver?: any\n}\n\nexport const FormStepper: React.FC<StepperStepsProps> = (props) => {\n const { activeIndex, setIndex } = useStepperContext()\n\n const { children, orientation } = props\n\n const elements = React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child?.type === FormStep) {\n const { isCompleted } = useFormStep(child.props) // Register this step\n return (\n <StepperStep\n name={child.props.name}\n title={child.props.title}\n isCompleted={isCompleted}\n >\n {child.props.children}\n </StepperStep>\n )\n }\n return child\n })\n\n const onChange = React.useCallback((i: number) => {\n setIndex(i)\n }, [])\n\n return (\n <StepperContainer\n orientation={orientation}\n step={activeIndex}\n onChange={onChange}\n >\n <StepperSteps mb=\"4\" {...props}>\n {elements}\n </StepperSteps>\n </StepperContainer>\n )\n}\n\nexport interface FormStepProps\n extends FormStepOptions,\n Omit<HTMLChakraProps<'div'>, 'onSubmit'> {\n onSubmit?: FormStepSubmitHandler\n}\n\nexport const FormStep: React.FC<FormStepProps> = (props) => {\n const { name, schema, resolver, children, className, onSubmit, ...rest } =\n props\n const step = useFormStep({ name, schema, resolver, onSubmit })\n\n const { isActive } = step\n\n return isActive ? (\n <chakra.div {...rest} className={cx('saas-form__step', className)}>\n {children}\n </chakra.div>\n ) : null\n}\n\nif (__DEV__) {\n FormStep.displayName = 'FormStep'\n}\n\nexport const PrevButton: React.FC<ButtonProps> = (props) => {\n const { isFirstStep, isCompleted, prevStep } = useStepperContext()\n\n return (\n <Button\n isDisabled={isFirstStep || isCompleted}\n label=\"Back\"\n {...props}\n className={cx('saas-form__prev-button', props.className)}\n onClick={callAllHandlers(props.onClick, prevStep)}\n />\n )\n}\n\nif (__DEV__) {\n PrevButton.displayName = 'PrevButton'\n}\n\nexport interface NextButtonProps extends ButtonProps {\n submitLabel?: string\n}\n\nexport const NextButton: React.FC<NextButtonProps> = (props) => {\n const { label = 'Next', submitLabel = 'Complete', ...rest } = props\n const { isLastStep, isCompleted } = useStepperContext()\n\n return (\n <SubmitButton\n {...rest}\n isDisabled={isCompleted}\n className={cx('saas-form__next-button', props.className)}\n >\n {isLastStep || isCompleted ? submitLabel : label}\n </SubmitButton>\n )\n}\n\nif (__DEV__) {\n NextButton.displayName = 'NextButton'\n}\n"],"names":["DisplayField","_ref","name","label","props","_objectWithoutPropertiesLoose","_excluded","React","createElement","FormControl","FormLabel","htmlFor","Text","fontSize","FormValue","__DEV__","displayName","getValues","useFormContext","_excluded2","_excluded3","_excluded4","_excluded5","_excluded6","_excluded7","_excluded8","_excluded9","_excluded10","defaultInputType","BaseField","help","variant","hideLabel","children","controlProps","formState","error","get","errors","getError","_extends","isInvalid","Box","message","FormHelperText","FormErrorMessage","Field","forwardRef","ref","type","InputComponent","inputTypes","getInput","_ref2","rules","inputProps","control","Controller","render","_ref3","field","useMergeRefs","withUncontrolledInput","_ref4","register","_register","registerFieldType","component","options","isControlled","withControlledInput","id","isDisabled","isReadOnly","isRequired","inputRules","required","undefined","createField","split","map","part","charAt","toUpperCase","slice","join","InputField","leftAddon","rightAddon","size","rest","_ref5","input","Input","InputGroup","NumberInputField","NumberInput","PasswordInputField","PasswordInput","TextareaField","Textarea","SwitchField","_ref6","Switch","SelectField","Select","_ref7","Checkbox","RadioField","RadioInput","NativeSelectField","NativeSelect","PinField","pinLength","pinType","spacing","inputs","i","push","PinInputField","key","HStack","PinInput","mapFields","schema","Object","entries","title","getFields","getNestedFields","_field$items","items","properties","Form","mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","defaultValues","onSubmit","onError","formRef","form","getResolver","methods","useForm","handleSubmit","useImperativeHandle","FormProvider","chakra","className","cx","getFieldResolver","objectFieldResolver","FormLayoutItem","div","FormLayout","_theme$components$For","_theme$components","_theme$components$For2","defaultProps","theme","useTheme","components","SimpleGrid","gridProps","Children","child","isValidElement","mapNestedFields","cloneElement","ArrayFieldProvider","useArrayFieldContext","createContext","ArrayFieldRowProvider","useArrayFieldRowContext","useArrayField","defaultValue","keyName","min","max","context","useFieldArray","useArrayFieldRow","index","clearErrors","remove","fields","useEffect","isFirst","isLast","length","useCallback","useArrayFieldRemoveButton","onClick","useArrayFieldAddButton","append","shouldFocus","ArrayFieldRow","rowFieldsProps","ArrayFieldRowContainer","ArrayFieldRowFields","ArrayFieldRemoveButton","layoutProps","flex","mr","value","__css","display","flexDirection","alignItems","width","mb","IconButton","icon","MinusIcon","ArrayFieldAddButton","AddIcon","float","ArrayField","containerProps","ArrayFieldContainer","ArrayFieldRows","fieldProps","FormLegend","styles","useStyleConfig","as","sx","ObjectField","columns","gridGap","_resolver$getNestedFi","nestedFieldProps","fieldResolver","focusFirstField","useMemo","_fields$","setFocus","Fields","disableIfUntouched","disableIfInvalid","isDisabledProp","isLoading","Button","isSubmitting","isDirty","isValid","SubmitButton","AutoForm","submitLabel","DisplayIf","isExact","condition","useWatch","disabled","exact","StepFormProvider","useStepFormContext","errorMessage","useStepForm","stepper","useStepper","activeStep","isLastStep","nextStep","steps","updateSteps","useState","onSubmitStep","async","step","data","then","updateStep","isCompleted","e","getFormProps","useFormStep","useStep","StepForm","ctx","StepperProvider","runIfFn","FormStepper","activeIndex","setIndex","useStepperContext","orientation","elements","FormStep","StepperStep","onChange","StepperContainer","StepperSteps","isActive","PrevButton","isFirstStep","prevStep","callAllHandlers","NextButton"],"mappings":"4lDAiBaA,GAA4CC,QAACC,KACxDA,EADwDC,MAExDA,GAGGF,EADAG,EACAC,EAAAJ,EAAAK,iBACH,OACEC,EAAAC,cAACC,EAAgBL,EACdD,eAAQI,EAACC,cAAAE,EAAU,CAAAC,QAAST,GAAOC,GAAqB,kBACzDI,EAACC,cAAAI,GAAKC,SAAS,mBACbN,EAACC,cAAAM,GAAU,CAAAZ,KAAMA,OAMrBa,IACFf,GAAagB,YAAc,gBAGhBF,MAAAA,GAAwC,EAAGZ,KAAAA,MACtD,MAAMe,UAAEA,GAAcC,IACtB,OAAgBD,EAACf,IAAS,MAGxBa,IACFD,GAAUE,YAAc,aC3C1B,MAAAV,GAAA,CAAA,OAAA,QAAA,OAAA,UAAA,YAAA,YAAAa,GAAA,CAAA,KAAA,OAAA,QAAA,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GAAgBkD,EAAhB,CAAsBgE,UAAWC,EAAG,kBAAmBD,KACpDzH,GAED,MAGFlB,IACFuR,GAAStR,YAAc,YAGZ4R,MAAUA,GAA2BxS,IAChD,MAAMyS,YAAEA,EAAFtB,YAAeA,EAAfuB,SAA4BA,GAAaX,iBAE/C,OACE5R,EAACC,cAAAgP,EACChN,EAAA,CAAAgC,WAAYqO,GAAetB,EAC3BpR,MAAM,QACFC,EACJ,CAAAsJ,UAAWC,EAAG,yBAA0BvJ,EAAMsJ,WAC9C4C,QAASyG,EAAgB3S,EAAMkM,QAASwG,OAK1C/R,IACF6R,GAAW5R,YAAc,cAOdgS,MAAAA,GAAyC5S,IACpD,MAAMD,MAAEA,EAAQ,OAAV2P,YAAkBA,EAAc,YAAwB1P,EAATsF,EAAStF,EAAAA,EAC9DiB,KAAMuP,WAAEA,EAAFW,YAAcA,GAAgBY,iBAEpC,OACE5R,EAAAC,cAACoP,GAADpN,EAAA,GACMkD,EACJ,CAAAlB,WAAY+M,EACZ7H,UAAWC,EAAG,yBAA0BvJ,EAAMsJ,aAE7CkH,GAAcW,EAAczB,EAAc3P,IAK7CY,IACFiS,GAAWhS,YAAc"}
1
+ {"version":3,"file":"index.modern.mjs","sources":["../src/display-field.tsx","../src/field.tsx","../src/field-resolver.ts","../src/form.tsx","../src/layout.tsx","../src/utils.ts","../src/use-array-field.tsx","../src/array-field.tsx","../src/object-field.tsx","../src/fields.tsx","../src/submit-button.tsx","../src/auto-form.tsx","../src/display-if.tsx","../src/use-step-form.tsx","../src/step-form.tsx"],"sourcesContent":["import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { useFormContext } from 'react-hook-form'\n\nimport {\n Text,\n FormControl,\n FormControlProps,\n FormLabel,\n} from '@chakra-ui/react'\n\nimport { FieldProps } from './field'\n\nexport interface DisplayFieldProps\n extends FormControlProps,\n Omit<FieldProps, 'type' | 'label'> {}\n\nexport const DisplayField: React.FC<DisplayFieldProps> = ({\n name,\n label,\n placeholder,\n ...props\n}) => {\n return (\n <FormControl {...props}>\n {label ? <FormLabel htmlFor={name}>{label}</FormLabel> : null}\n <Text fontSize=\"md\">\n <FormValue name={name} />\n </Text>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n DisplayField.displayName = 'DisplayField'\n}\n\nexport const FormValue: React.FC<{ name: string }> = ({ name }) => {\n const { getValues } = useFormContext()\n return getValues(name) || null\n}\n\nif (__DEV__) {\n FormValue.displayName = 'FormValue'\n}\n","import * as React from 'react'\nimport {\n useFormContext,\n FormState,\n Controller,\n get,\n RegisterOptions,\n FieldValues,\n FieldPath,\n} from 'react-hook-form'\n\nimport {\n forwardRef,\n Box,\n FormControl,\n FormControlProps,\n FormLabel,\n FormHelperText,\n FormErrorMessage,\n Input,\n Textarea,\n Checkbox,\n Switch,\n useMergeRefs,\n InputGroup,\n InputProps,\n TextareaProps,\n SwitchProps,\n CheckboxProps,\n PinInputField,\n HStack,\n PinInput,\n UsePinInputProps,\n SystemProps,\n} from '@chakra-ui/react'\nimport { __DEV__, FocusableElement } from '@chakra-ui/utils'\n\nimport { NumberInput, NumberInputProps } from '@saas-ui/number-input'\nimport { PasswordInput, PasswordInputProps } from '@saas-ui/password-input'\nimport { RadioInput, RadioInputProps } from '@saas-ui/radio'\n\nimport {\n Select,\n SelectProps,\n NativeSelect,\n NativeSelectProps,\n} from '@saas-ui/select'\n\nexport interface Option {\n value: string\n label?: string\n [key: string]: unknown\n}\n\nexport type FieldRules = Pick<\n RegisterOptions,\n 'required' | 'min' | 'max' | 'maxLength' | 'minLength' | 'pattern'\n>\n\nexport interface FieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends Omit<FormControlProps, 'label' | 'type'> {\n /**\n * The field name\n */\n name: TName\n /**\n * The field label\n */\n label?: string\n /**\n * Hide the field label\n */\n hideLabel?: boolean\n /**\n * Field help text\n */\n help?: string\n /**\n * React hook form rules\n */\n rules?: Omit<\n RegisterOptions<TFieldValues, TName>,\n 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'\n >\n /**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\n type?: string\n /**\n * The input placeholder\n */\n placeholder?: string\n}\n\nconst inputTypes: Record<string, React.FC<any>> = {}\n\nconst defaultInputType = 'text'\n\nconst getInput = (type: string) => {\n return inputTypes[type] || inputTypes[defaultInputType]\n}\n\nconst getError = (name: string, formState: FormState<{ [x: string]: any }>) => {\n return get(formState.errors, name)\n}\n\nconst isTouched = (\n name: string,\n formState: FormState<{ [x: string]: any }>\n) => {\n return get(formState.touchedFields, name)\n}\n\nexport const BaseField: React.FC<FieldProps> = (props) => {\n const { name, label, help, variant, hideLabel, children, ...controlProps } =\n props\n\n const { formState } = useFormContext()\n\n const error = getError(name, formState)\n\n return (\n <FormControl variant={variant} {...controlProps} isInvalid={!!error}>\n {label && !hideLabel ? (\n <FormLabel variant={variant}>{label}</FormLabel>\n ) : null}\n <Box>\n {children}\n {help && !error?.message ? (\n <FormHelperText>{help}</FormHelperText>\n ) : null}\n {error?.message && (\n <FormErrorMessage>{error?.message}</FormErrorMessage>\n )}\n </Box>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n BaseField.displayName = 'BaseField'\n}\n\nexport type As<Props = any> = React.ElementType<Props>\n\nexport type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {\n type?: FieldTypes\n}\n\n/**\n * Build-in types:\n * - text\n * - number\n * - password\n * - textarea\n * - select\n * - native-select\n * - checkbox\n * - radio\n * - switch\n * - pin\n *\n * Will default to a text field if there is no matching type.\n */\nexport const Field = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FieldProps<TFieldValues> | FieldTypeProps,\n ref: React.ForwardedRef<FocusableElement>\n ) => {\n const { type = defaultInputType } = props\n const InputComponent = getInput(type)\n\n return <InputComponent ref={ref} {...props} />\n }\n) as (<TFieldValues extends FieldValues>(\n props: FieldProps<TFieldValues> &\n FieldTypeProps & {\n ref?: React.ForwardedRef<FocusableElement>\n }\n) => React.ReactElement) & {\n displayName?: string\n}\n\ninterface CreateFieldProps {\n displayName: string\n hideLabel?: boolean\n BaseField: React.FC<any>\n}\n\nconst createField = (\n InputComponent: React.FC<any>,\n { displayName, hideLabel, BaseField }: CreateFieldProps\n) => {\n const Field = forwardRef((props, ref) => {\n const {\n id,\n name,\n label,\n help,\n isDisabled,\n isInvalid,\n isReadOnly,\n isRequired,\n rules,\n variant,\n ...inputProps\n } = props\n\n const inputRules = {\n required: isRequired,\n ...rules,\n }\n\n return (\n <BaseField\n id={id}\n name={name}\n label={label}\n help={help}\n hideLabel={hideLabel}\n isDisabled={isDisabled}\n isInvalid={isInvalid}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n variant={variant}\n >\n <InputComponent\n ref={ref}\n id={id}\n name={name}\n label={hideLabel ? label : undefined} // Only pass down the label when it should be inline.\n rules={inputRules}\n {...inputProps}\n />\n </BaseField>\n )\n })\n Field.displayName = displayName\n\n return Field\n}\n\nexport const withControlledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { control } = useFormContext()\n\n return (\n <Controller\n name={name}\n control={control}\n rules={rules}\n render={({ field: { ref: _ref, ...field } }) => (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )}\n />\n )\n }\n )\n}\n\nexport const withUncontrolledInput = (InputComponent: React.FC<any>) => {\n return forwardRef<FieldProps, typeof InputComponent>(\n ({ name, rules, ...inputProps }, ref) => {\n const { register } = useFormContext()\n\n const { ref: _ref, ...field } = register(name, rules)\n\n return (\n <InputComponent\n {...field}\n {...inputProps}\n ref={useMergeRefs(ref, _ref)}\n />\n )\n }\n )\n}\n\nexport interface RegisterFieldTypeOptions {\n isControlled?: boolean\n hideLabel?: boolean\n BaseField?: React.FC<any>\n}\n\n/**\n * Register a new field type\n * @param type The name for this field in kebab-case, eg `email` or `array-field`\n * @param component The React component\n * @param options\n * @param options.isControlled Set this to true if this is a controlled field.\n * @param options.hideLabel Hide the field label, for example for the checkbox field.\n */\nexport const registerFieldType = <T extends object>(\n type: string,\n component: React.FC<T>,\n options?: RegisterFieldTypeOptions\n) => {\n let InputComponent\n if (options?.isControlled) {\n InputComponent = withControlledInput(component)\n } else {\n InputComponent = withUncontrolledInput(component)\n }\n\n const Field = createField(InputComponent, {\n displayName: `${type\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')}Field`,\n hideLabel: options?.hideLabel,\n BaseField: options?.BaseField || BaseField,\n }) as React.FC<T & FieldProps>\n\n inputTypes[type] = Field\n\n return Field\n}\n\nexport interface InputFieldProps extends InputProps {\n type?: string\n leftAddon?: React.ReactNode\n rightAddon?: React.ReactNode\n}\n\nexport const InputField = registerFieldType<InputFieldProps>(\n 'text',\n forwardRef(({ type = 'text', leftAddon, rightAddon, size, ...rest }, ref) => {\n const input = <Input type={type} size={size} {...rest} ref={ref} />\n if (leftAddon || rightAddon) {\n return (\n <InputGroup size={size}>\n {leftAddon}\n {input}\n {rightAddon}\n </InputGroup>\n )\n }\n return input\n })\n)\n\nexport interface NumberInputFieldProps extends NumberInputProps {\n type: 'number'\n}\n\nexport const NumberInputField = registerFieldType<NumberInputFieldProps>(\n 'number',\n NumberInput,\n {\n isControlled: true,\n }\n)\n\nexport const PasswordInputField = registerFieldType<PasswordInputProps>(\n 'password',\n forwardRef((props, ref) => <PasswordInput ref={ref} {...props} />)\n)\n\nexport const TextareaField = registerFieldType<TextareaProps>(\n 'textarea',\n Textarea\n)\n\nexport const SwitchField = registerFieldType<SwitchProps>(\n 'switch',\n forwardRef(({ type, ...rest }, ref) => {\n return <Switch {...rest} ref={ref} />\n }),\n {\n isControlled: true,\n }\n)\n\nexport const SelectField = registerFieldType<SelectProps>('select', Select, {\n isControlled: true,\n})\n\nexport const CheckboxField = registerFieldType<CheckboxProps>(\n 'checkbox',\n forwardRef(({ label, type, ...props }, ref) => {\n return (\n <Checkbox ref={ref} {...props}>\n {label}\n </Checkbox>\n )\n }),\n {\n hideLabel: true,\n }\n)\n\nexport const RadioField = registerFieldType<RadioInputProps>(\n 'radio',\n RadioInput,\n {\n isControlled: true,\n }\n)\n\nexport const NativeSelectField = registerFieldType<NativeSelectProps>(\n 'native-select',\n NativeSelect,\n { isControlled: true }\n)\n\nexport interface PinFieldProps extends Omit<UsePinInputProps, 'type'> {\n pinLength?: number\n pinType?: 'alphanumeric' | 'number'\n spacing?: SystemProps['margin']\n}\n\nexport const PinField = registerFieldType<PinFieldProps>(\n 'pin',\n forwardRef((props, ref) => {\n const { pinLength = 4, pinType, spacing, ...inputProps } = props\n\n const inputs: React.ReactNode[] = []\n for (let i = 0; i < pinLength; i++) {\n inputs.push(<PinInputField key={i} ref={ref} />)\n }\n\n return (\n <HStack spacing={spacing}>\n <PinInput {...inputProps} type={pinType}>\n {inputs}\n </PinInput>\n </HStack>\n )\n }),\n {\n isControlled: true,\n }\n)\n\nconst fieldTypes = {\n text: InputField,\n email: InputField,\n url: InputField,\n phone: InputField,\n number: NumberInputField,\n password: PasswordInputField,\n textarea: TextareaField,\n switch: SwitchField,\n checkbox: CheckboxField,\n radio: RadioField,\n pin: PinField,\n select: SelectField,\n 'native-select': NativeSelectField,\n}\n\ntype FieldTypes = typeof fieldTypes\n\ntype FieldType<Props = any> = React.ElementType<Props>\n\ntype TypeProps<P extends FieldType, T> = React.ComponentPropsWithoutRef<P> & {\n type: T\n}\n\ntype FieldTypeProps =\n | {\n [Property in keyof FieldTypes]: TypeProps<FieldTypes[Property], Property>\n }[keyof FieldTypes]\n | { type?: string }\n","import { FieldProps } from './field'\n\nimport { get } from '@chakra-ui/utils'\n\nexport type FieldResolver = {\n getFields(): FieldProps[]\n getNestedFields(name: string): FieldProps[]\n}\n\ninterface SchemaField extends FieldProps {\n items?: SchemaField[]\n properties?: Record<string, SchemaField>\n}\n\nexport type ObjectSchema = Record<string, SchemaField>\n\nconst mapFields = (schema: ObjectSchema): FieldProps[] =>\n schema &&\n Object.entries(schema).map(([name, { items, label, title, ...field }]) => {\n return {\n ...field,\n name,\n label: label || title, // json schema compatibility\n }\n })\n\nexport const objectFieldResolver = (schema: ObjectSchema): FieldResolver => {\n const getFields = () => {\n return mapFields(schema)\n }\n const getNestedFields = (name: string) => {\n const field = get(schema, name)\n\n if (!field) return []\n\n if (field.items?.type === 'object') {\n return mapFields(field.items.properties)\n } else if (field.type === 'object') {\n return mapFields(field.properties)\n }\n return [field.items]\n }\n\n return { getFields, getNestedFields }\n}\n","import * as React from 'react'\n\nimport { chakra, HTMLChakraProps, forwardRef } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n useForm,\n FormProvider,\n UseFormProps,\n UseFormReturn,\n FieldValues,\n SubmitHandler,\n SubmitErrorHandler,\n ResolverOptions,\n ResolverResult,\n} from 'react-hook-form'\nimport { objectFieldResolver, FieldResolver } from './field-resolver'\n\nexport type { UseFormReturn, FieldValues, SubmitHandler }\n\ninterface FormOptions<TFieldValues extends FieldValues = FieldValues> {\n /**\n * The form schema, currently supports Yup schema only.\n */\n schema?: any\n /**\n * The submit handler.\n */\n onSubmit: SubmitHandler<TFieldValues>\n /**\n * Triggers when there are validation errors.\n */\n onError?: SubmitErrorHandler<TFieldValues>\n /**\n * Ref on the HTMLFormElement.\n */\n formRef?: React.RefObject<HTMLFormElement>\n}\n\n/**\n * @todo Figure out how to pass down FieldValues to all Field components,\n * if at all possible.\n */\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseFormProps<TFieldValues>,\n Omit<HTMLChakraProps<'form'>, 'onSubmit' | 'onError'>,\n FormOptions<TFieldValues> {}\n\nexport const Form = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: FormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n mode = 'all',\n resolver,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n schema,\n defaultValues,\n onSubmit,\n onError,\n formRef,\n children,\n ...rest\n } = props\n\n const form = {\n mode,\n resolver,\n defaultValues,\n reValidateMode,\n shouldFocusError,\n shouldUnregister,\n shouldUseNativeValidation,\n criteriaMode,\n delayError,\n }\n\n if (schema && !resolver) {\n form.resolver = Form.getResolver?.(schema)\n }\n\n const methods = useForm<TFieldValues>(form)\n const { handleSubmit } = methods\n\n // This exposes the useForm api through the forwarded ref\n React.useImperativeHandle(ref, () => methods, [ref, methods])\n\n return (\n <FormProvider {...methods}>\n <chakra.form\n ref={formRef}\n onSubmit={handleSubmit(onSubmit, onError)}\n {...rest}\n className={cx('saas-form', props.className)}\n >\n {children}\n </chakra.form>\n </FormProvider>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: FormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getResolver?: GetResolver\n getFieldResolver: GetFieldResolver\n}\n\nForm.getFieldResolver = objectFieldResolver\n\nif (__DEV__) {\n Form.displayName = 'Form'\n}\n\nexport type GetResolver = (\n schema: any\n) => <TFieldValues extends FieldValues, TContext>(\n values: TFieldValues,\n context: TContext | undefined,\n options: ResolverOptions<TFieldValues>\n) => Promise<ResolverResult<TFieldValues>>\n\nexport type GetFieldResolver = (schema: any) => FieldResolver\n","import * as React from 'react'\n\nimport { chakra, SimpleGrid, SimpleGridProps, useTheme } from '@chakra-ui/react'\nimport { cx, __DEV__ } from '@chakra-ui/utils'\n\nexport type FormLayoutProps = SimpleGridProps\n\ninterface FormLayoutItemProps {\n children: React.ReactNode\n}\n\nconst FormLayoutItem: React.FC<FormLayoutItemProps> = ({ children }) => {\n return <chakra.div>{children}</chakra.div>\n}\n\nif (__DEV__) {\n FormLayoutItem.displayName = 'FormLayoutItem'\n}\n\n/**\n * FormLayout\n *\n * Renders form items in a `SimpleGrid`\n * @see https://chakra-ui.com/docs/layout/simple-grid\n */\nexport const FormLayout = ({ children, ...props }: FormLayoutProps) => {\n const theme = useTheme()\n\n const defaultProps = theme.components?.FormLayout?.defaultProps ?? {\n spacing: 4,\n }\n\n const gridProps = {\n ...defaultProps,\n ...props,\n }\n\n return (\n <SimpleGrid\n {...gridProps}\n className={cx('saas-form__layout', props.className)}\n >\n {React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return <FormLayoutItem>{child}</FormLayoutItem>\n }\n return child\n })}\n </SimpleGrid>\n )\n}\n\nif (__DEV__) {\n FormLayout.displayName = 'FormLayout'\n}\n","import * as React from 'react'\n\nexport const mapNestedFields = (name: string, children: React.ReactNode) => {\n return React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child.props.name) {\n return React.cloneElement(child, {\n ...child.props,\n name: `${name}.${child.props.name}`,\n })\n }\n return child\n })\n}\n","import * as React from 'react'\nimport {\n useFieldArray,\n useFormContext,\n UseFieldArrayReturn,\n} from 'react-hook-form'\n\nimport { createContext } from '@chakra-ui/react-utils'\n\nexport interface UseArrayFieldReturn extends UseFieldArrayReturn {\n /**\n * The array field name\n */\n name: string\n /**\n * The default value for new items\n */\n defaultValue: Record<string, any>\n /**\n * Min amount of items\n */\n min?: number\n /**\n * Max amount of items\n */\n max?: number\n}\n\nexport const [ArrayFieldProvider, useArrayFieldContext] =\n createContext<UseArrayFieldReturn>({\n name: 'ArrayFieldContext',\n })\n\nexport interface UseArrayFieldRowReturn {\n /**\n * Name of the array field including the index, eg 'field.0'\n */\n name: string\n /**\n * The field index\n */\n index: number\n /**\n * Remove this array item\n */\n remove: () => void\n /**\n * True if this is the first item\n */\n isFirst: boolean\n /**\n * True if this is the last item\n */\n isLast: boolean\n}\n\nexport const [ArrayFieldRowProvider, useArrayFieldRowContext] =\n createContext<UseArrayFieldRowReturn>({\n name: 'ArrayFieldRowContext',\n })\n\nexport interface ArrayFieldOptions {\n /**\n * The field name\n */\n name: string\n /**\n * Default value for new values in the array\n */\n defaultValue?: Record<string, any>\n /**\n * Default key name for rows, change this if your data uses a different 'id' field\n * @default \"id\"\n */\n keyName?: string\n min?: number\n max?: number\n}\n\nexport const useArrayField = ({\n name,\n defaultValue = {},\n keyName,\n min,\n max,\n}: ArrayFieldOptions) => {\n const { control } = useFormContext()\n const context = useFieldArray({\n control,\n name,\n keyName,\n })\n\n return {\n ...context,\n name,\n defaultValue,\n min,\n max,\n }\n}\n\nexport interface UseArrayFieldRowProps {\n index: number\n}\n\nexport const useArrayFieldRow = ({ index }: UseArrayFieldRowProps) => {\n const { clearErrors } = useFormContext()\n const { name, remove, fields } = useArrayFieldContext()\n\n React.useEffect(() => {\n // reset errors, to make sure min/max errors reset correctly\n clearErrors(name)\n }, [])\n\n return {\n index,\n isFirst: index === 0,\n isLast: index === fields.length - 1,\n name: `${name}.${index}`,\n remove: React.useCallback(() => {\n clearErrors(name)\n remove(index)\n }, [index]),\n }\n}\n\nexport const useArrayFieldRemoveButton = () => {\n const { isFirst, remove } = useArrayFieldRowContext()\n const { min, fields } = useArrayFieldContext()\n\n const isDisabled = isFirst && !!(min && fields.length <= min)\n\n return {\n onClick: () => remove(),\n isDisabled,\n }\n}\n\nexport const useArrayFieldAddButton = () => {\n const { append, defaultValue, max, fields } = useArrayFieldContext()\n\n const isDisabled = !!(max && fields.length >= max)\n\n return {\n onClick: () =>\n append(defaultValue, {\n shouldFocus: false,\n }),\n isDisabled,\n }\n}\n","import * as React from 'react'\n\nimport { chakra, ResponsiveValue, forwardRef } from '@chakra-ui/system'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport { AddIcon, MinusIcon } from '@chakra-ui/icons'\nimport { IconButton, ButtonProps } from '@saas-ui/button'\n\nimport { FormLayout, FormLayoutProps } from './layout'\nimport { BaseField, FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nimport {\n useArrayField,\n useArrayFieldRow,\n useArrayFieldContext,\n ArrayFieldProvider,\n ArrayFieldOptions,\n ArrayFieldRowProvider,\n useArrayFieldRowContext,\n useArrayFieldRemoveButton,\n useArrayFieldAddButton,\n UseArrayFieldReturn,\n} from './use-array-field'\n\ninterface ArrayField {\n id: string\n [key: string]: unknown\n}\n\ninterface ArrayFieldRowProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The array index\n */\n index: number\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRow: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n ...rowFieldsProps\n}) => {\n return (\n <ArrayFieldRowContainer index={index}>\n <ArrayFieldRowFields {...rowFieldsProps}>{children}</ArrayFieldRowFields>\n <ArrayFieldRemoveButton />\n </ArrayFieldRowContainer>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRow.displayName = 'ArrayFieldRow'\n}\n\nexport interface ArrayFieldRowFieldsProps extends FormLayoutProps {\n /**\n * Amount of field columns\n */\n columns?: ResponsiveValue<number>\n /**\n * Spacing between fields\n */\n spacing?: ResponsiveValue<string | number>\n /**\n * The fields\n */\n children: React.ReactNode\n}\n\nexport const ArrayFieldRowFields: React.FC<ArrayFieldRowFieldsProps> = ({\n children,\n ...layoutProps\n}) => {\n const { name } = useArrayFieldRowContext()\n return (\n <FormLayout flex=\"1\" mr=\"2\" {...layoutProps}>\n {mapNestedFields(name, children)}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowFields.displayName = 'ArrayFieldRowFields'\n}\n\nexport const ArrayFieldRowContainer: React.FC<ArrayFieldRowProps> = ({\n children,\n index,\n}) => {\n const context = useArrayFieldRow({ index })\n\n const styles = {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'flex-end',\n width: '100%',\n mb: 4,\n }\n\n return (\n <ArrayFieldRowProvider value={context}>\n <chakra.div __css={styles}>{children}</chakra.div>\n </ArrayFieldRowProvider>\n )\n}\n\nif (__DEV__) {\n ArrayFieldRowContainer.displayName = 'ArrayFieldRowContainer'\n}\n\nexport const ArrayFieldRemoveButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<MinusIcon />}\n aria-label=\"Remove row\"\n {...useArrayFieldRemoveButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldRemoveButton.displayName = 'ArrayFieldRemoveButton'\n}\n\nexport const ArrayFieldAddButton: React.FC<ButtonProps> = (props) => {\n return (\n <IconButton\n icon={<AddIcon />}\n aria-label=\"Add row\"\n float=\"right\"\n {...useArrayFieldAddButton()}\n {...props}\n />\n )\n}\n\nif (__DEV__) {\n ArrayFieldAddButton.displayName = 'ArrayFieldAddButton'\n}\n\nexport interface ArrayFieldProps\n extends ArrayFieldOptions,\n Omit<FieldProps, 'defaultValue'> {}\n\nexport const ArrayField = forwardRef(\n (props: ArrayFieldProps, ref: React.ForwardedRef<UseArrayFieldReturn>) => {\n const { children, ...containerProps } = props\n\n return (\n <ArrayFieldContainer ref={ref} {...containerProps}>\n <ArrayFieldRows>\n {(fields: ArrayField[]) => (\n <>\n {fields.map(({ id }, index: number) => (\n <ArrayFieldRow key={id} index={index}>\n {children}\n </ArrayFieldRow>\n ))}\n </>\n )}\n </ArrayFieldRows>\n <ArrayFieldAddButton />\n </ArrayFieldContainer>\n )\n }\n) as ((\n props: ArrayFieldProps & {\n ref?: React.ForwardedRef<UseArrayFieldReturn>\n }\n) => React.ReactElement) & {\n displayName: string\n}\n\nif (__DEV__) {\n ArrayField.displayName = 'ArrayField'\n}\n\nexport interface ArrayFieldRowsProps {\n children: (fields: ArrayField[]) => React.ReactElement | null\n}\n\nexport const ArrayFieldRows = ({\n children,\n}: ArrayFieldRowsProps): React.ReactElement | null => {\n const { fields } = useArrayFieldContext()\n return children(fields)\n}\n\nif (__DEV__) {\n ArrayFieldRows.displayName = 'ArrayFieldRows'\n}\n\nexport const ArrayFieldContainer = React.forwardRef(\n (\n {\n name,\n defaultValue,\n keyName,\n min,\n max,\n children,\n ...fieldProps\n }: ArrayFieldProps,\n ref: React.ForwardedRef<UseArrayFieldReturn>\n ) => {\n const context = useArrayField({\n name,\n defaultValue,\n keyName,\n min,\n max,\n })\n\n // This exposes the useArrayField api through the forwarded ref\n React.useImperativeHandle(ref, () => context, [ref, context])\n\n return (\n <ArrayFieldProvider value={context}>\n <BaseField name={name} {...fieldProps}>\n {children}\n </BaseField>\n </ArrayFieldProvider>\n )\n }\n)\n\nif (__DEV__) {\n ArrayFieldContainer.displayName = 'ArrayFieldContainer'\n}\n","import * as React from 'react'\nimport {\n FormControl,\n FormLabel,\n FormLabelProps,\n ResponsiveValue,\n useStyleConfig,\n} from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { FormLayout } from './layout'\nimport { FieldProps } from './field'\n\nimport { mapNestedFields } from './utils'\n\nexport interface ObjectFieldProps extends FieldProps {\n name: string\n children: React.ReactNode\n columns?: ResponsiveValue<number>\n spacing?: ResponsiveValue<string | number>\n}\n\nexport const FormLegend = (props: FormLabelProps) => {\n const styles = useStyleConfig('FormLegend')\n return <FormLabel as=\"legend\" sx={styles} {...props} />\n}\n\nexport const ObjectField: React.FC<ObjectFieldProps> = (props) => {\n const { name, label, hideLabel, children, columns, spacing, ...fieldProps } =\n props\n\n return (\n <FormControl name={name} as=\"fieldset\" {...fieldProps}>\n <FormLegend display={hideLabel ? 'none' : 'block'}>{label}</FormLegend>\n <FormLayout columns={columns} gridGap={spacing}>\n {mapNestedFields(name, children)}\n </FormLayout>\n </FormControl>\n )\n}\n\nif (__DEV__) {\n ObjectField.displayName = 'ObjectField'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form } from './form'\nimport { FormLayout } from './layout'\nimport { Field, FieldProps } from './field'\n\nimport { ArrayField } from './array-field'\nimport { ObjectField } from './object-field'\nimport { FieldResolver } from './field-resolver'\nimport { useFormContext } from 'react-hook-form'\n\nexport interface FieldsProps {\n schema: any\n fieldResolver?: FieldResolver\n focusFirstField?: boolean\n}\n\nconst mapNestedFields = (resolver: FieldResolver, name: string) => {\n return resolver\n .getNestedFields(name)\n ?.map(\n ({ name, type, ...nestedFieldProps }: FieldProps, i): React.ReactNode => (\n <Field key={name || i} name={name} type={type} {...nestedFieldProps} />\n )\n )\n}\n\nexport const Fields: React.FC<FieldsProps> = ({\n schema,\n fieldResolver,\n focusFirstField,\n ...props\n}) => {\n const resolver = React.useMemo(\n () => fieldResolver || Form.getFieldResolver(schema),\n [schema, fieldResolver]\n )\n\n const fields = React.useMemo(() => resolver.getFields(), [resolver])\n\n const form = useFormContext()\n\n React.useEffect(() => {\n if (focusFirstField && fields[0]?.name) {\n form.setFocus(fields[0].name)\n }\n }, [schema, fieldResolver, focusFirstField])\n\n return (\n <FormLayout {...props}>\n {fields.map(\n ({\n name,\n type,\n defaultValue,\n ...fieldProps\n }: FieldProps): React.ReactNode => {\n if (type === 'array') {\n return (\n <ArrayField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ArrayField>\n )\n } else if (type === 'object') {\n return (\n <ObjectField key={name} name={name} {...fieldProps}>\n {mapNestedFields(resolver, name)}\n </ObjectField>\n )\n }\n\n return <Field key={name} name={name} type={type} {...fieldProps} />\n }\n )}\n </FormLayout>\n )\n}\n\nif (__DEV__) {\n Fields.displayName = 'Fields'\n}\n","import * as React from 'react'\n\nimport { useFormContext } from 'react-hook-form'\n\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { __DEV__ } from '@chakra-ui/utils'\n\nexport interface SubmitButtonProps extends ButtonProps {\n /**\n * Disable the submit button if the form is untouched.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfUntouched`\n */\n disableIfUntouched?: boolean\n /**\n * Disable the submit button if the form is invalid.\n *\n * Change the default behavior by updating\n * `SubmitButton.defaultProps.disableIfInvalid`\n */\n disableIfInvalid?: boolean\n}\n\nexport const SubmitButton = React.forwardRef<\n HTMLButtonElement,\n SubmitButtonProps\n>((props, ref) => {\n const {\n children,\n disableIfUntouched,\n disableIfInvalid,\n isDisabled: isDisabledProp,\n isLoading,\n ...rest\n } = props\n const { formState } = useFormContext()\n\n const isDisabled =\n (disableIfUntouched && !formState.isDirty) ||\n (disableIfInvalid && !formState.isValid) ||\n isDisabledProp\n\n return (\n <Button\n {...rest}\n ref={ref}\n variant=\"primary\"\n type=\"submit\"\n isLoading={formState.isSubmitting || isLoading}\n isDisabled={isDisabled}\n >\n {children}\n </Button>\n )\n})\n\nSubmitButton.defaultProps = {\n label: 'Submit',\n disableIfUntouched: false,\n disableIfInvalid: false,\n}\n\nif (__DEV__) {\n SubmitButton.displayName = 'SubmitButton'\n}\n","import * as React from 'react'\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\nimport { forwardRef } from '@chakra-ui/react'\nimport { __DEV__ } from '@chakra-ui/utils'\n\nimport { Form, FormProps } from './form'\nimport { FormLayout } from './layout'\nimport { Fields } from './fields'\nimport { SubmitButton } from './submit-button'\nimport { FieldResolver } from '.'\n\ninterface AutoFormOptions {\n /**\n * The submit button label.\n * Pass `null` to render no submit button.\n */\n submitLabel?: React.ReactNode\n /**\n * The schema.\n * Supports object schema, Yup or Zod.\n * @see https://www.saas-ui.dev/docs/forms/auto-form\n */\n schema: any\n /**\n * The field resolver.\n */\n fieldResolver?: any\n}\n\nexport interface AutoFormProps<TFieldValues extends FieldValues>\n extends Omit<FormProps<TFieldValues>, 'schema'>,\n AutoFormOptions {}\n\nexport const AutoForm = forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: AutoFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const {\n schema,\n submitLabel = 'Submit',\n fieldResolver,\n children,\n ...rest\n } = props\n\n return (\n <Form {...rest} schema={schema} ref={ref}>\n <FormLayout>\n {<Fields schema={schema} fieldResolver={fieldResolver} />}\n {submitLabel && <SubmitButton>{submitLabel}</SubmitButton>}\n {children}\n </FormLayout>\n </Form>\n )\n }\n) as (<TFieldValues extends FieldValues>(\n props: AutoFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement) & {\n displayName?: string\n getFieldResolver?: (schema: any) => FieldResolver\n}\n\nif (__DEV__) {\n AutoForm.displayName = 'AutoForm'\n}\n","import * as React from 'react'\nimport { __DEV__ } from '@chakra-ui/utils'\nimport {\n useFormContext,\n useWatch,\n FieldValues,\n UseFormReturn,\n} from 'react-hook-form'\n\nexport interface DisplayIfProps<TFieldValues> {\n children: React.ReactElement\n name: string\n defaultValue?: unknown\n isDisabled?: boolean\n isExact?: boolean\n condition?: (value: unknown, context: UseFormReturn<TFieldValues>) => boolean\n}\n\nexport const DisplayIf = <TFieldValues extends FieldValues = FieldValues>({\n children,\n name,\n defaultValue,\n isDisabled,\n isExact,\n condition = (value) => !!value,\n}: DisplayIfProps<TFieldValues>) => {\n const value = useWatch({\n name,\n defaultValue,\n disabled: isDisabled,\n exact: isExact,\n })\n const context = useFormContext<TFieldValues>()\n return condition(value, context) ? children : null\n}\n\nif (__DEV__) {\n DisplayIf.displayName = 'DisplayIf'\n}\n","import * as React from 'react'\nimport { FieldValues, SubmitHandler } from 'react-hook-form'\nimport { createContext, MaybeRenderProp } from '@chakra-ui/react-utils'\nimport {\n useStepper,\n useStep,\n UseStepperProps,\n UseStepperReturn,\n} from '@saas-ui/stepper'\n\nexport interface StepState {\n name: string\n schema?: any\n resolver?: any\n isActive?: boolean\n isCompleted?: boolean\n onSubmit?: FormStepSubmitHandler\n}\n\nexport type FormStepSubmitHandler<\n TFieldValues extends FieldValues = FieldValues\n> = (data: TFieldValues, stepper: UseStepperReturn) => Promise<void>\n\nexport interface StepFormContext extends UseStepperReturn {\n updateStep(state: StepState): void\n steps: Record<string, StepState>\n}\n\nexport const [StepFormProvider, useStepFormContext] =\n createContext<StepFormContext>({\n name: 'StepFormContext',\n errorMessage:\n 'useStepFormContext: `context` is undefined. Seems you forgot to wrap step form components in `<StepForm />`',\n })\n\nimport { FormProps } from './form'\n\nexport interface UseStepFormProps<\n TFieldValues extends FieldValues = FieldValues\n> extends Omit<UseStepperProps, 'onChange'>,\n Omit<FormProps<TFieldValues>, 'children'> {\n children: MaybeRenderProp<UseStepFormReturn<TFieldValues>>\n}\n\nexport interface UseStepFormReturn<\n TFieldValues extends FieldValues = FieldValues\n> extends UseStepperReturn {\n getFormProps(): {\n onSubmit: SubmitHandler<TFieldValues>\n schema?: any\n resolver?: any\n }\n updateStep(step: any): void\n steps: Record<string, any>\n}\n\nexport function useStepForm<TFieldValues extends FieldValues = FieldValues>(\n props: UseStepFormProps<TFieldValues>\n): UseStepFormReturn<TFieldValues> {\n const { onChange, ...rest } = props\n const stepper = useStepper(rest)\n\n const { activeStep, isLastStep, nextStep } = stepper\n\n const [steps, updateSteps] = React.useState<Record<string, StepState>>({})\n\n const onSubmitStep: SubmitHandler<TFieldValues> = React.useCallback(\n async (data) => {\n const step = steps[activeStep]\n\n if (isLastStep) {\n return props\n .onSubmit?.(data)\n .then(() => {\n updateStep({\n ...step,\n isCompleted: true,\n })\n })\n .then(nextStep) // Show completed step\n }\n\n try {\n await step.onSubmit?.(data, stepper)\n\n nextStep()\n } catch (e) {\n // Step submission failed.\n }\n },\n [steps, activeStep, isLastStep]\n )\n\n const getFormProps = React.useCallback(() => {\n const step = steps[activeStep]\n return {\n onSubmit: onSubmitStep,\n schema: step?.schema,\n resolver: step?.resolver,\n }\n }, [steps, onSubmitStep, activeStep])\n\n const updateStep = React.useCallback(\n (step: StepState) => {\n updateSteps((steps) => {\n return {\n ...steps,\n [step.name]: step,\n }\n })\n },\n [steps]\n )\n\n return {\n getFormProps,\n updateStep,\n steps,\n ...stepper,\n }\n}\n\nexport interface UseFormStepProps {\n name: string\n schema?: any\n resolver?: any\n onSubmit?: FormStepSubmitHandler\n}\n\nexport function useFormStep(props: UseFormStepProps): StepState {\n const { name, schema, resolver, onSubmit } = props\n const step = useStep({ name })\n\n const { steps, updateStep } = useStepFormContext()\n\n React.useEffect(() => {\n updateStep({ name, schema, resolver, onSubmit })\n }, [name, schema])\n\n return {\n ...step,\n ...(steps[name] || { name, schema }),\n }\n}\n","import * as React from 'react'\n\nimport { FieldValues, UseFormReturn } from 'react-hook-form'\n\nimport { chakra, HTMLChakraProps } from '@chakra-ui/system'\n\nimport { callAllHandlers, runIfFn, cx, __DEV__ } from '@chakra-ui/utils'\n\nimport {\n StepperProvider,\n StepperSteps,\n StepperStepsProps,\n StepperStep,\n useStepperContext,\n StepperContainer,\n} from '@saas-ui/stepper'\nimport { Button, ButtonProps } from '@saas-ui/button'\n\nimport { Form } from './form'\nimport { SubmitButton } from './submit-button'\n\nimport {\n useStepForm,\n useFormStep,\n StepFormProvider,\n UseStepFormProps,\n FormStepSubmitHandler,\n} from './use-step-form'\n\nexport interface StepFormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseStepFormProps<TFieldValues> {}\n\nexport const StepForm = React.forwardRef(\n <TFieldValues extends FieldValues = FieldValues>(\n props: StepFormProps<TFieldValues>,\n ref: React.ForwardedRef<UseFormReturn<TFieldValues>>\n ) => {\n const { children, ...rest } = props\n\n const stepper = useStepForm<TFieldValues>(props)\n\n const { getFormProps, ...ctx } = stepper\n\n const context = React.useMemo(() => ctx, [ctx])\n\n return (\n <StepperProvider value={context}>\n <StepFormProvider value={context}>\n <Form ref={ref} {...rest} {...getFormProps()}>\n {runIfFn(children, stepper)}\n </Form>\n </StepFormProvider>\n </StepperProvider>\n )\n }\n) as <TFieldValues extends FieldValues>(\n props: StepFormProps<TFieldValues> & {\n ref?: React.ForwardedRef<UseFormReturn<TFieldValues>>\n }\n) => React.ReactElement\n\nexport interface FormStepOptions {\n /**\n * The step name\n */\n name: string\n /**\n * Schema\n */\n schema?: any\n /**\n * Hook Form Resolver\n */\n resolver?: any\n}\n\nexport const FormStepper: React.FC<StepperStepsProps> = (props) => {\n const { activeIndex, setIndex } = useStepperContext()\n\n const { children, orientation } = props\n\n const elements = React.Children.map(children, (child) => {\n if (React.isValidElement(child) && child?.type === FormStep) {\n const { isCompleted } = useFormStep(child.props) // Register this step\n return (\n <StepperStep\n name={child.props.name}\n title={child.props.title}\n isCompleted={isCompleted}\n >\n {child.props.children}\n </StepperStep>\n )\n }\n return child\n })\n\n const onChange = React.useCallback((i: number) => {\n setIndex(i)\n }, [])\n\n return (\n <StepperContainer\n orientation={orientation}\n step={activeIndex}\n onChange={onChange}\n >\n <StepperSteps mb=\"4\" {...props}>\n {elements}\n </StepperSteps>\n </StepperContainer>\n )\n}\n\nexport interface FormStepProps\n extends FormStepOptions,\n Omit<HTMLChakraProps<'div'>, 'onSubmit'> {\n onSubmit?: FormStepSubmitHandler\n}\n\nexport const FormStep: React.FC<FormStepProps> = (props) => {\n const { name, schema, resolver, children, className, onSubmit, ...rest } =\n props\n const step = useFormStep({ name, schema, resolver, onSubmit })\n\n const { isActive } = step\n\n return isActive ? (\n <chakra.div {...rest} className={cx('saas-form__step', className)}>\n {children}\n </chakra.div>\n ) : null\n}\n\nif (__DEV__) {\n FormStep.displayName = 'FormStep'\n}\n\nexport const PrevButton: React.FC<ButtonProps> = (props) => {\n const { isFirstStep, isCompleted, prevStep } = useStepperContext()\n\n return (\n <Button\n isDisabled={isFirstStep || isCompleted}\n label=\"Back\"\n {...props}\n className={cx('saas-form__prev-button', props.className)}\n onClick={callAllHandlers(props.onClick, prevStep)}\n />\n )\n}\n\nif (__DEV__) {\n PrevButton.displayName = 'PrevButton'\n}\n\nexport interface NextButtonProps extends ButtonProps {\n submitLabel?: string\n}\n\nexport const NextButton: React.FC<NextButtonProps> = (props) => {\n const { label = 'Next', submitLabel = 'Complete', ...rest } = props\n const { isLastStep, isCompleted } = useStepperContext()\n\n return (\n <SubmitButton\n {...rest}\n isDisabled={isCompleted}\n className={cx('saas-form__next-button', props.className)}\n >\n {isLastStep || isCompleted ? submitLabel : label}\n </SubmitButton>\n )\n}\n\nif (__DEV__) {\n NextButton.displayName = 'NextButton'\n}\n"],"names":["DisplayField","_ref","name","label","props","_objectWithoutPropertiesLoose","_excluded","React","createElement","FormControl","FormLabel","htmlFor","Text","fontSize","FormValue","__DEV__","displayName","getValues","useFormContext","_excluded2","_excluded3","_excluded4","_excluded5","_excluded6","_excluded7","_excluded8","_excluded9","_excluded10","defaultInputType","BaseField","help","variant","hideLabel","children","controlProps","formState","error","get","errors","getError","_extends","isInvalid","Box","message","FormHelperText","FormErrorMessage","Field","forwardRef","ref","type","InputComponent","inputTypes","getInput","_ref2","rules","inputProps","control","Controller","render","_ref3","field","useMergeRefs","withUncontrolledInput","_ref4","register","_register","registerFieldType","component","options","isControlled","withControlledInput","id","isDisabled","isReadOnly","isRequired","inputRules","required","undefined","createField","split","map","part","charAt","toUpperCase","slice","join","InputField","leftAddon","rightAddon","size","rest","_ref5","input","Input","InputGroup","NumberInputField","NumberInput","PasswordInputField","PasswordInput","TextareaField","Textarea","SwitchField","_ref6","Switch","SelectField","Select","_ref7","Checkbox","RadioField","RadioInput","NativeSelectField","NativeSelect","PinField","pinLength","pinType","spacing","inputs","i","push","PinInputField","key","HStack","PinInput","mapFields","schema","Object","entries","title","getFields","getNestedFields","_field$items","items","properties","Form","mode","resolver","reValidateMode","shouldFocusError","shouldUnregister","shouldUseNativeValidation","criteriaMode","delayError","defaultValues","onSubmit","onError","formRef","form","getResolver","methods","useForm","handleSubmit","useImperativeHandle","FormProvider","chakra","className","cx","getFieldResolver","objectFieldResolver","FormLayoutItem","div","FormLayout","_theme$components$For","_theme$components","_theme$components$For2","defaultProps","theme","useTheme","components","SimpleGrid","gridProps","Children","child","isValidElement","mapNestedFields","cloneElement","ArrayFieldProvider","useArrayFieldContext","createContext","ArrayFieldRowProvider","useArrayFieldRowContext","useArrayField","defaultValue","keyName","min","max","context","useFieldArray","useArrayFieldRow","index","clearErrors","remove","fields","useEffect","isFirst","isLast","length","useCallback","useArrayFieldRemoveButton","onClick","useArrayFieldAddButton","append","shouldFocus","ArrayFieldRow","rowFieldsProps","ArrayFieldRowContainer","ArrayFieldRowFields","ArrayFieldRemoveButton","layoutProps","flex","mr","value","__css","display","flexDirection","alignItems","width","mb","IconButton","icon","MinusIcon","ArrayFieldAddButton","AddIcon","float","ArrayField","containerProps","ArrayFieldContainer","ArrayFieldRows","fieldProps","FormLegend","styles","useStyleConfig","as","sx","ObjectField","columns","gridGap","_resolver$getNestedFi","nestedFieldProps","fieldResolver","focusFirstField","useMemo","_fields$","setFocus","Fields","disableIfUntouched","disableIfInvalid","isDisabledProp","isLoading","Button","isSubmitting","isDirty","isValid","SubmitButton","AutoForm","submitLabel","DisplayIf","isExact","condition","useWatch","disabled","exact","StepFormProvider","useStepFormContext","errorMessage","useStepForm","stepper","useStepper","activeStep","isLastStep","nextStep","steps","updateSteps","useState","onSubmitStep","async","step","data","then","updateStep","isCompleted","e","getFormProps","useFormStep","useStep","StepForm","ctx","StepperProvider","runIfFn","FormStepper","activeIndex","setIndex","useStepperContext","orientation","elements","FormStep","StepperStep","onChange","StepperContainer","StepperSteps","isActive","PrevButton","isFirstStep","prevStep","callAllHandlers","NextButton"],"mappings":"4lDAiBaA,GAA4CC,QAACC,KACxDA,EADwDC,MAExDA,GAGGF,EADAG,EACAC,EAAAJ,EAAAK,iBACH,OACEC,EAAAC,cAACC,EAAgBL,EACdD,eAAQI,EAACC,cAAAE,EAAU,CAAAC,QAAST,GAAOC,GAAqB,kBACzDI,EAACC,cAAAI,GAAKC,SAAS,mBACbN,EAACC,cAAAM,GAAU,CAAAZ,KAAMA,OAMrBa,IACFf,GAAagB,YAAc,gBAGhBF,MAAAA,GAAwC,EAAGZ,KAAAA,MACtD,MAAMe,UAAEA,GAAcC,IACtB,OAAgBD,EAACf,IAAS,MAGxBa,IACFD,GAAUE,YAAc,aC3C1B,MAAAV,GAAA,CAAA,OAAA,QAAA,OAAA,UAAA,YAAA,YAAAa,GAAA,CAAA,KAAA,OAAA,QAAA,OAAA,aAAA,YAAA,aAAA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E,UAAWC,EAAG,kBAAmBD,KACpDzH,GAED,MAGFlB,IACFuR,GAAStR,YAAc,YAGZ4R,MAAUA,GAA2BxS,IAChD,MAAMyS,YAAEA,EAAFtB,YAAeA,EAAfuB,SAA4BA,GAAaX,iBAE/C,OACE5R,EAACC,cAAAgP,EACChN,EAAA,CAAAgC,WAAYqO,GAAetB,EAC3BpR,MAAM,QACFC,EACJ,CAAAsJ,UAAWC,EAAG,yBAA0BvJ,EAAMsJ,WAC9C4C,QAASyG,EAAgB3S,EAAMkM,QAASwG,OAK1C/R,IACF6R,GAAW5R,YAAc,cAOdgS,MAAAA,GAAyC5S,IACpD,MAAMD,MAAEA,EAAQ,OAAV2P,YAAkBA,EAAc,YAAwB1P,EAATsF,EAAStF,EAAAA,EAC9DiB,KAAMuP,WAAEA,EAAFW,YAAcA,GAAgBY,iBAEpC,OACE5R,EAAAC,cAACoP,GAADpN,EAAA,GACMkD,EACJ,CAAAlB,WAAY+M,EACZ7H,UAAWC,EAAG,yBAA0BvJ,EAAMsJ,aAE7CkH,GAAcW,EAAczB,EAAc3P,IAK7CY,IACFiS,GAAWhS,YAAc"}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { FieldValues, SubmitHandler, UnpackNestedValue } from 'react-hook-form';
2
+ import { FieldValues, SubmitHandler } from 'react-hook-form';
3
3
  import { MaybeRenderProp } from '@chakra-ui/react-utils';
4
4
  import { UseStepperProps, UseStepperReturn } from '@saas-ui/stepper';
5
5
  export interface StepState {
@@ -10,7 +10,7 @@ export interface StepState {
10
10
  isCompleted?: boolean;
11
11
  onSubmit?: FormStepSubmitHandler;
12
12
  }
13
- export declare type FormStepSubmitHandler<TFieldValues extends FieldValues = FieldValues> = (data: UnpackNestedValue<TFieldValues>, stepper: UseStepperReturn) => Promise<void>;
13
+ export declare type FormStepSubmitHandler<TFieldValues extends FieldValues = FieldValues> = (data: TFieldValues, stepper: UseStepperReturn) => Promise<void>;
14
14
  export interface StepFormContext extends UseStepperReturn {
15
15
  updateStep(state: StepState): void;
16
16
  steps: Record<string, StepState>;
@@ -1 +1 @@
1
- {"version":3,"file":"use-step-form.d.ts","sourceRoot":"","sources":["../src/use-step-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAC/E,OAAO,EAAiB,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAGL,eAAe,EACf,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AAEzB,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,EAAE,qBAAqB,CAAA;CACjC;AAED,oBAAY,qBAAqB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,IAC5C,CACF,IAAI,EAAE,iBAAiB,CAAC,YAAY,CAAC,EACrC,OAAO,EAAE,gBAAgB,KACtB,OAAO,CAAC,IAAI,CAAC,CAAA;AAElB,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAA;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CACjC;AAED,eAAO,MAAO,gBAAgB,mCAAE,kBAAkB,uBAK9C,CAAA;AAEJ,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,MAAM,WAAW,gBAAgB,CAC/B,YAAY,SAAS,WAAW,GAAG,WAAW,CAC9C,SAAQ,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,EACvC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC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,gBAAgB,CAAC,YAAY,CAAC,GACpC,iBAAiB,CAAC,YAAY,CAAC,CA8DjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,QAAQ,CAAC,EAAE,qBAAqB,CAAA;CACjC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CAc9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saas-ui/forms",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Fully functional forms for Chakra UI.",
5
5
  "source": "src/index.ts",
6
6
  "exports": {
@@ -94,15 +94,15 @@
94
94
  "@chakra-ui/utils": "^2.0.2",
95
95
  "@hookform/resolvers": "^2.9.0",
96
96
  "@saas-ui/button": "1.0.0",
97
- "@saas-ui/input-right-button": "1.0.0",
97
+ "@saas-ui/input-right-button": "1.0.1",
98
98
  "@saas-ui/number-input": "1.0.0",
99
- "@saas-ui/password-input": "1.0.0",
99
+ "@saas-ui/password-input": "1.0.1",
100
100
  "@saas-ui/pin-input": "1.0.0",
101
101
  "@saas-ui/radio": "1.0.0",
102
102
  "@saas-ui/react-utils": "1.0.0",
103
103
  "@saas-ui/select": "1.0.0",
104
104
  "@saas-ui/stepper": "1.0.0",
105
- "react-hook-form": "^7.31.3"
105
+ "react-hook-form": "^7.33.1"
106
106
  },
107
107
  "peerDependencies": {
108
108
  "@chakra-ui/react": ">=2.1.0",
package/src/form.tsx CHANGED
@@ -11,7 +11,6 @@ import {
11
11
  FieldValues,
12
12
  SubmitHandler,
13
13
  SubmitErrorHandler,
14
- UnpackNestedValue,
15
14
  ResolverOptions,
16
15
  ResolverResult,
17
16
  } from 'react-hook-form'
@@ -124,7 +123,7 @@ if (__DEV__) {
124
123
  export type GetResolver = (
125
124
  schema: any
126
125
  ) => <TFieldValues extends FieldValues, TContext>(
127
- values: UnpackNestedValue<TFieldValues>,
126
+ values: TFieldValues,
128
127
  context: TContext | undefined,
129
128
  options: ResolverOptions<TFieldValues>
130
129
  ) => Promise<ResolverResult<TFieldValues>>
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react'
2
- import { FieldValues, SubmitHandler, UnpackNestedValue } from 'react-hook-form'
2
+ import { FieldValues, SubmitHandler } from 'react-hook-form'
3
3
  import { createContext, MaybeRenderProp } from '@chakra-ui/react-utils'
4
4
  import {
5
5
  useStepper,
@@ -19,10 +19,7 @@ export interface StepState {
19
19
 
20
20
  export type FormStepSubmitHandler<
21
21
  TFieldValues extends FieldValues = FieldValues
22
- > = (
23
- data: UnpackNestedValue<TFieldValues>,
24
- stepper: UseStepperReturn
25
- ) => Promise<void>
22
+ > = (data: TFieldValues, stepper: UseStepperReturn) => Promise<void>
26
23
 
27
24
  export interface StepFormContext extends UseStepperReturn {
28
25
  updateStep(state: StepState): void
package/yup/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  "author": "Eelco Wiersma <eelco@appulse.nl>",
11
11
  "license": "MIT",
12
12
  "peerDependencies": {
13
- "@hookform/resolvers": "^2.9.0",
14
- "react-hook-form": "^7.31.3",
13
+ "@hookform/resolvers": "^2.9.3",
14
+ "react-hook-form": "^7.33.1",
15
15
  "yup": "^0.32.11"
16
16
  }
17
17
  }
package/zod/package.json CHANGED
@@ -11,8 +11,8 @@
11
11
  "license": "MIT",
12
12
  "peerDependencies": {
13
13
  "@chakra-ui/utils": "^2.0.2",
14
- "@hookform/resolvers": "^2.9.0",
15
- "react-hook-form": "^7.31.3",
14
+ "@hookform/resolvers": "^2.9.3",
15
+ "react-hook-form": "^7.33.1",
16
16
  "zod": "^3.17.3"
17
17
  }
18
18
  }