Sha256: 4fdbd2dc177e3be71aa7657c6ecab60265684ade5e73dd55efd7c10d9c31bbe0

Contents?: true

Size: 591 Bytes

Versions: 1

Compression:

Stored size: 591 Bytes

Contents

import { UseFormRegister, FieldValues, RegisterOptions, Path } from 'react-hook-form'

export type HookFormProps<T extends FieldValues = FieldValues> = {
  register?: UseFormRegister<T>
  rules?: RegisterOptions
  name: Path<T>
}

export const withHookForm = <T extends FieldValues = FieldValues>(
  props: HookFormProps<T>
) => {
  const { register, name, rules } = props
  if (!register) return {}
  
  const registration = register(name, rules)
  return {
    onChange: registration.onChange,
    onBlur: registration.onBlur,
    ref: registration.ref,
    name: registration.name,
  }
} 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
playbook_ui-14.9.0.pre.alpha.PLAY16264952 app/pb_kits/playbook/utilities/hookFormProps.ts