@saas-ui/forms 1.2.2 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +26 -0
- package/dist/ajv/index.js +86 -96
- package/dist/ajv/index.js.map +1 -1
- package/dist/ajv/index.modern.js +86 -96
- package/dist/ajv/index.modern.js.map +1 -1
- package/dist/display-if.d.ts +1 -1
- package/dist/display-if.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/step-form.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/yup/yup-resolver.d.ts +1 -1
- package/dist/zod/zod-resolver.d.ts +1 -1
- package/package.json +16 -16
- package/src/display-if.tsx +3 -1
- package/src/step-form.tsx +4 -1
package/dist/index.modern.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.modern.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","../src/watch-field.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, callAllHandlers } 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, hideLabel, children, ...controlProps } = props\n\n const { formState } = useFormContext()\n\n const error = getError(name, formState)\n\n return (\n <FormControl {...controlProps} isInvalid={!!error}>\n {label && !hideLabel ? <FormLabel>{label}</FormLabel> : 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 ...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 >\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 onChange={callAllHandlers(inputProps.onChange, field.onChange)}\n onBlur={callAllHandlers(inputProps.onBlur, field.onBlur)}\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 onChange={callAllHandlers(inputProps.onChange, field.onChange)}\n onBlur={callAllHandlers(inputProps.onBlur, field.onBlur)}\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, MaybeFunction, runIfFn, __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 ChangeHandler,\n WatchObserver,\n} from 'react-hook-form'\nimport { objectFieldResolver, FieldResolver } from './field-resolver'\nimport { MaybeRenderProp } from '@chakra-ui/react-utils'\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 * Triggers when any of the field change.\n */\n onChange?: WatchObserver<TFieldValues>\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 * The form children, can be a render prop or a ReactNode.\n */\n children?: MaybeRenderProp<UseFormReturn<TFieldValues>>\n}\n\n// @todo Figure out how to pass down FieldValues to all Field components, if at all possible.\n\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseFormProps<TFieldValues>,\n Omit<\n HTMLChakraProps<'form'>,\n 'children' | 'onChange' | 'onSubmit' | 'onError'\n >,\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 onChange,\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 React.useEffect(() => {\n let subscription: any\n if (onChange) {\n subscription = methods.watch(onChange)\n }\n return () => subscription?.unsubscribe()\n }, [methods, onChange])\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 {runIfFn(children, methods)}\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, Zod, Yup or Ajv (JSON Schema).\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' | 'children'>,\n AutoFormOptions {\n children?: React.ReactNode\n}\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 try {\n const step = steps[activeStep]\n\n if (isLastStep) {\n await props.onSubmit?.(data)\n\n updateStep({\n ...step,\n isCompleted: true,\n })\n\n nextStep() // show completed step\n return\n }\n\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, ThemingProps } 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 StepperProps,\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 interface FormStepperProps\n extends StepperStepsProps,\n ThemingProps<'Stepper'> {}\n\nexport const FormStepper: React.FC<FormStepperProps> = (props) => {\n const { activeIndex, setIndex } = useStepperContext()\n\n const { children, orientation, variant, colorScheme, size, ...rest } = 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 {...rest}\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 variant={variant}\n colorScheme={colorScheme}\n size={size}\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","import {\n FieldValues,\n useFormContext,\n UseFormReturn,\n useWatch,\n} from 'react-hook-form'\n\nexport interface WatchFieldProps<\n Value = unknown,\n TFieldValues extends FieldValues = FieldValues\n> {\n name: string\n defaultValue?: Value\n isDisabled?: boolean\n isExact?: boolean\n children: (\n value: Value,\n form: UseFormReturn<TFieldValues>\n ) => React.ReactElement | void\n}\n\nexport const WatchField = <\n Value = unknown,\n TFieldValues extends FieldValues = FieldValues\n>(\n props: WatchFieldProps<Value, TFieldValues>\n) => {\n const { name, defaultValue, isDisabled, isExact } = props\n const form = useFormContext<TFieldValues>()\n\n const field = useWatch({\n name,\n defaultValue,\n disabled: isDisabled,\n exact: isExact,\n })\n\n return props.children(field, form) || null\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","inputTypes","defaultInputType","BaseField","help","hideLabel","children","controlProps","formState","error","get","errors","getError","isInvalid","Box","message","FormHelperText","FormErrorMessage","Field","forwardRef","ref","type","InputComponent","getInput","_extends","withControlledInput","_ref2","rules","inputProps","control","Controller","render","_ref3","field","onChange","callAllHandlers","onBlur","useMergeRefs","withUncontrolledInput","_ref4","register","_register","registerFieldType","component","options","isControlled","id","isDisabled","isReadOnly","isRequired","inputRules","required","undefined","createField","split","map","part","charAt","toUpperCase","slice","join","InputField","leftAddon","rightAddon","size","_ref5","rest","input","Input","InputGroup","NumberInputField","NumberInput","PasswordInput","TextareaField","Textarea","SwitchField","Switch","Select","CheckboxField","_ref7","Checkbox","RadioField","RadioInput","NativeSelectField","NativeSelect","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","useEffect","subscription","watch","_subscription","unsubscribe","FormProvider","chakra","className","cx","runIfFn","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","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","variant","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","data","updateStep","step","isCompleted","e","getFormProps","useFormStep","useStep","StepForm","ctx","StepperProvider","FormStepper","activeIndex","setIndex","useStepperContext","orientation","colorScheme","elements","FormStep","StepperStep","StepperContainer","StepperSteps","isActive","PrevButton","isFirstStep","prevStep","NextButton","WatchField"],"mappings":"uuDAiBaA,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,KAHrB,EASAa,IACFf,GAAagB,YAAc,gBAGhBF,MAAAA,GAAwC,EAAGZ,WACtD,MAAMe,UAAEA,GAAcC,IACtB,OAAgBD,EAACf,IAAS,MAGxBa,IACFD,GAAUE,YAAc,aC3C1B,MAAAV,GAAA,CAAA,OAAA,QAAA,OAAA,YAAA,YAAAa,GAAA,CAAA,KAAA,OAAA,QAAA,OAAA,aAAA,YAAA,aAAA,aAAA,SAAAC,GAAA,CAAA,OAAA,SAAAC,GAAA,CAAA,OAAAC,GAAA,CAAA,OAAA,SAAAC,GAAA,CAAA,OAAAC,GAAA,CAAA,OAAA,YAAA,aAAA,QAAAC,GAAA,CAAA,QAAAC,GAAA,CAAA,QAAA,QAAAC,GAAA,CAAA,YAAA,UAAA,WA4GMC,GAA4C,CAAlD,EAEMC,GAAmB,OAiBHC,GAA0B1B,IAC9C,MAAMF,KAAEA,EAAFC,MAAQA,EAAR4B,KAAeA,EAAfC,UAAqBA,EAArBC,SAAgCA,GAA8B7B,EAAjB8B,EAA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AAUQ,cAE7CgK,SAAEA,GAAapB,EAErB,OAAeoB,eACbvS,EAACC,cAAAqJ,EAAOO,IAAQvE,EAAAA,GAAAA,EAAM,CAAAiE,UAAWC,EAAG,kBAAmBD,KACpD7H,GAED,MAGFlB,IACF2R,GAAS1R,YAAc,YAGZ+R,MAAAA,GAAqC3S,IAChD,MAAM4S,YAAEA,EAAFrB,YAAeA,EAAfsB,SAA4BA,GAAaX,iBAE/C,OACE/R,EAAAC,cAACoP,EAADzM,EAAA,CACEuB,WAAYsO,GAAerB,EAC3BxR,MAAM,QACFC,GACJ0J,UAAWC,EAAG,yBAA0B3J,EAAM0J,WAC9C4C,QAAS5I,EAAgB1D,EAAMsM,QAASuG,KAG7C,EAEGlS,IACFgS,GAAW/R,YAAc,cAOdkS,MAAAA,GAAyC9S,IACpD,MAAMD,MAAEA,EAAQ,OAAVgQ,YAAkBA,EAAc,YAAwB/P,EAATyF,EAASzF,EAAAA,EAC9DkB,KAAM2P,WAAEA,EAAFU,YAAcA,GAAgBW,iBAEpC,OACE/R,EAACC,cAAAyP,QACKpK,EADN,CAEEnB,WAAYiN,EACZ7H,UAAWC,EAAG,yBAA0B3J,EAAM0J,aAE7CmH,GAAcU,EAAcxB,EAAchQ,EAL7C,EAUAY,IACFmS,GAAWlS,YAAc,cCpKdmS,MAAUA,GAIrB/S,IAEA,MAAMF,KAAEA,EAAFwL,aAAQA,EAARhH,WAAsBA,EAAtB2L,QAAkCA,GAAYjQ,EAC1C6I,EAAG/H,IAEF0C,EAAG2M,EAAS,CACrBrQ,OACAwL,eACA8E,SAAU9L,EACV+L,MAAOJ,IAGT,OAAYjQ,EAAC6B,SAAS2B,EAAOqF,IAAS"}
|
1
|
+
{"version":3,"file":"index.modern.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","../src/watch-field.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, callAllHandlers } 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, hideLabel, children, ...controlProps } = props\n\n const { formState } = useFormContext()\n\n const error = getError(name, formState)\n\n return (\n <FormControl {...controlProps} isInvalid={!!error}>\n {label && !hideLabel ? <FormLabel>{label}</FormLabel> : 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 ...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 >\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 onChange={callAllHandlers(inputProps.onChange, field.onChange)}\n onBlur={callAllHandlers(inputProps.onBlur, field.onBlur)}\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 onChange={callAllHandlers(inputProps.onChange, field.onChange)}\n onBlur={callAllHandlers(inputProps.onBlur, field.onBlur)}\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, MaybeFunction, runIfFn, __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 ChangeHandler,\n WatchObserver,\n} from 'react-hook-form'\nimport { objectFieldResolver, FieldResolver } from './field-resolver'\nimport { MaybeRenderProp } from '@chakra-ui/react-utils'\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 * Triggers when any of the field change.\n */\n onChange?: WatchObserver<TFieldValues>\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 * The form children, can be a render prop or a ReactNode.\n */\n children?: MaybeRenderProp<UseFormReturn<TFieldValues>>\n}\n\n// @todo Figure out how to pass down FieldValues to all Field components, if at all possible.\n\nexport interface FormProps<TFieldValues extends FieldValues = FieldValues>\n extends UseFormProps<TFieldValues>,\n Omit<\n HTMLChakraProps<'form'>,\n 'children' | 'onChange' | 'onSubmit' | 'onError'\n >,\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 onChange,\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 React.useEffect(() => {\n let subscription: any\n if (onChange) {\n subscription = methods.watch(onChange)\n }\n return () => subscription?.unsubscribe()\n }, [methods, onChange])\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 {runIfFn(children, methods)}\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, Zod, Yup or Ajv (JSON Schema).\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' | 'children'>,\n AutoFormOptions {\n children?: React.ReactNode\n}\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<\n TFieldValues extends FieldValues = FieldValues\n> {\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 try {\n const step = steps[activeStep]\n\n if (isLastStep) {\n await props.onSubmit?.(data)\n\n updateStep({\n ...step,\n isCompleted: true,\n })\n\n nextStep() // show completed step\n return\n }\n\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, ThemingProps } 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 StepperProps,\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 interface FormStepperProps\n extends StepperStepsProps,\n ThemingProps<'Stepper'> {}\n\nexport const FormStepper: React.FC<FormStepperProps> = (props) => {\n const { activeIndex, setIndex } = useStepperContext()\n\n const { children, orientation, variant, colorScheme, size, ...rest } = props\n\n const elements = React.Children.map(children, (child) => {\n if (\n React.isValidElement<FormStepProps>(child) &&\n child?.type === FormStep\n ) {\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 {...rest}\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 variant={variant}\n colorScheme={colorScheme}\n size={size}\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","import {\n FieldValues,\n useFormContext,\n UseFormReturn,\n useWatch,\n} from 'react-hook-form'\n\nexport interface WatchFieldProps<\n Value = unknown,\n TFieldValues extends FieldValues = FieldValues\n> {\n name: string\n defaultValue?: Value\n isDisabled?: boolean\n isExact?: boolean\n children: (\n value: Value,\n form: UseFormReturn<TFieldValues>\n ) => React.ReactElement | void\n}\n\nexport const WatchField = <\n Value = unknown,\n TFieldValues extends FieldValues = FieldValues\n>(\n props: WatchFieldProps<Value, TFieldValues>\n) => {\n const { name, defaultValue, isDisabled, isExact } = props\n const form = useFormContext<TFieldValues>()\n\n const field = useWatch({\n name,\n defaultValue,\n disabled: isDisabled,\n exact: isExact,\n })\n\n return props.children(field, form) || null\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","inputTypes","defaultInputType","BaseField","help","hideLabel","children","controlProps","formState","error","get","errors","getError","isInvalid","Box","message","FormHelperText","FormErrorMessage","Field","forwardRef","ref","type","InputComponent","getInput","_extends","withControlledInput","_ref2","rules","inputProps","control","Controller","render","_ref3","field","onChange","callAllHandlers","onBlur","useMergeRefs","withUncontrolledInput","_ref4","register","_register","registerFieldType","component","options","isControlled","id","isDisabled","isReadOnly","isRequired","inputRules","required","undefined","createField","split","map","part","charAt","toUpperCase","slice","join","InputField","leftAddon","rightAddon","size","_ref5","rest","input","Input","InputGroup","NumberInputField","NumberInput","PasswordInput","TextareaField","Textarea","SwitchField","Switch","Select","CheckboxField","_ref7","Checkbox","RadioField","RadioInput","NativeSelectField","NativeSelect","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","useEffect","subscription","watch","_subscription","unsubscribe","FormProvider","chakra","className","cx","runIfFn","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","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","variant","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","data","updateStep","step","isCompleted","e","getFormProps","useFormStep","useStep","StepForm","ctx","StepperProvider","FormStepper","activeIndex","setIndex","useStepperContext","orientation","colorScheme","elements","FormStep","StepperStep","StepperContainer","StepperSteps","isActive","PrevButton","isFirstStep","prevStep","NextButton","WatchField"],"mappings":"uuDAiBaA,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,KAHrB,EASAa,IACFf,GAAagB,YAAc,gBAGhBF,MAAAA,GAAwC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AAU,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAY5C,CAAA;AAMD,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAahD,CAAA"}
|
package/dist/utils.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
export declare const mapNestedFields: (name: string, children: React.ReactNode) => (string | number | React.ReactElement<
|
2
|
+
export declare const mapNestedFields: (name: string, children: React.ReactNode) => (string | number | React.ReactFragment | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>)[] | null | undefined;
|
3
3
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,eAAO,MAAM,eAAe,SAAU,MAAM,YAAY,MAAM,SAAS,
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,eAAO,MAAM,eAAe,SAAU,MAAM,YAAY,MAAM,SAAS,0IAUtE,CAAA"}
|
@@ -20,7 +20,7 @@ export declare const yupFieldResolver: (schema: AnyObjectSchema) => {
|
|
20
20
|
};
|
21
21
|
export declare const yupForm: (schema: AnyObjectSchema, schemaOptions?: {}, resolverOptions?: {}) => {
|
22
22
|
schema: AnyObjectSchema;
|
23
|
-
resolver: <TFieldValues extends import("@saas-ui/forms").FieldValues, TContext>(values:
|
23
|
+
resolver: <TFieldValues extends import("@saas-ui/forms").FieldValues, TContext>(values: TFieldValues, context: TContext | undefined, options: import("@saas-ui/forms").ResolverOptions<TFieldValues>) => Promise<import("@saas-ui/forms").ResolverResult<TFieldValues>>;
|
24
24
|
fieldResolver: {
|
25
25
|
getFields(): FieldProps<import("@saas-ui/forms").FieldValues, string>[];
|
26
26
|
getNestedFields(name: string): FieldProps<import("@saas-ui/forms").FieldValues, string>[];
|
@@ -20,7 +20,7 @@ export declare const zodFieldResolver: <T extends z.ZodTypeAny>(schema: T) => {
|
|
20
20
|
};
|
21
21
|
export declare const zodForm: <T extends z.ZodTypeAny>(schema: T, schemaOptions?: {}, resolverOptions?: {}) => {
|
22
22
|
schema: T;
|
23
|
-
resolver: <TFieldValues extends import("@saas-ui/forms").FieldValues, TContext>(values:
|
23
|
+
resolver: <TFieldValues extends import("@saas-ui/forms").FieldValues, TContext>(values: TFieldValues, context: TContext | undefined, options: import("@saas-ui/forms").ResolverOptions<TFieldValues>) => Promise<import("@saas-ui/forms").ResolverResult<TFieldValues>>;
|
24
24
|
fieldResolver: {
|
25
25
|
getFields(): FieldProps<import("@saas-ui/forms").FieldValues, string>[];
|
26
26
|
getNestedFields(name: string): FieldProps<import("@saas-ui/forms").FieldValues, string>[];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@saas-ui/forms",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.1",
|
4
4
|
"description": "Fully functional forms for Chakra UI.",
|
5
5
|
"source": "src/index.ts",
|
6
6
|
"exports": {
|
@@ -89,20 +89,20 @@
|
|
89
89
|
"url": "https://storybook.saas-ui.dev"
|
90
90
|
},
|
91
91
|
"dependencies": {
|
92
|
-
"@chakra-ui/icons": "^2.0.
|
93
|
-
"@chakra-ui/react-utils": "^2.0.
|
94
|
-
"@chakra-ui/utils": "^2.0.
|
95
|
-
"@hookform/resolvers": "^2.9.
|
96
|
-
"@saas-ui/button": "1.
|
97
|
-
"@saas-ui/input-right-button": "1.
|
98
|
-
"@saas-ui/number-input": "1.
|
99
|
-
"@saas-ui/password-input": "1.
|
100
|
-
"@saas-ui/pin-input": "1.
|
101
|
-
"@saas-ui/radio": "1.
|
102
|
-
"@saas-ui/react-utils": "1.1.
|
103
|
-
"@saas-ui/select": "1.
|
104
|
-
"@saas-ui/stepper": "1.1
|
105
|
-
"react-hook-form": "^7.
|
92
|
+
"@chakra-ui/icons": "^2.0.11",
|
93
|
+
"@chakra-ui/react-utils": "^2.0.8",
|
94
|
+
"@chakra-ui/utils": "^2.0.11",
|
95
|
+
"@hookform/resolvers": "^2.9.10",
|
96
|
+
"@saas-ui/button": "1.2.0",
|
97
|
+
"@saas-ui/input-right-button": "1.2.0",
|
98
|
+
"@saas-ui/number-input": "1.2.0",
|
99
|
+
"@saas-ui/password-input": "1.2.0",
|
100
|
+
"@saas-ui/pin-input": "1.2.0",
|
101
|
+
"@saas-ui/radio": "1.2.0",
|
102
|
+
"@saas-ui/react-utils": "1.1.1",
|
103
|
+
"@saas-ui/select": "1.2.0",
|
104
|
+
"@saas-ui/stepper": "1.2.1",
|
105
|
+
"react-hook-form": "^7.38.0"
|
106
106
|
},
|
107
107
|
"peerDependencies": {
|
108
108
|
"@chakra-ui/react": ">=2.1.0",
|
@@ -112,6 +112,6 @@
|
|
112
112
|
"devDependencies": {
|
113
113
|
"ajv": "^8.11.0",
|
114
114
|
"yup": "^0.32.11",
|
115
|
-
"zod": "^3.
|
115
|
+
"zod": "^3.19.1"
|
116
116
|
}
|
117
117
|
}
|
package/src/display-if.tsx
CHANGED
@@ -7,7 +7,9 @@ import {
|
|
7
7
|
UseFormReturn,
|
8
8
|
} from 'react-hook-form'
|
9
9
|
|
10
|
-
export interface DisplayIfProps<
|
10
|
+
export interface DisplayIfProps<
|
11
|
+
TFieldValues extends FieldValues = FieldValues
|
12
|
+
> {
|
11
13
|
children: React.ReactElement
|
12
14
|
name: string
|
13
15
|
defaultValue?: unknown
|
package/src/step-form.tsx
CHANGED
@@ -85,7 +85,10 @@ export const FormStepper: React.FC<FormStepperProps> = (props) => {
|
|
85
85
|
const { children, orientation, variant, colorScheme, size, ...rest } = props
|
86
86
|
|
87
87
|
const elements = React.Children.map(children, (child) => {
|
88
|
-
if (
|
88
|
+
if (
|
89
|
+
React.isValidElement<FormStepProps>(child) &&
|
90
|
+
child?.type === FormStep
|
91
|
+
) {
|
89
92
|
const { isCompleted } = useFormStep(child.props) // Register this step
|
90
93
|
return (
|
91
94
|
<StepperStep
|