import Button from 'react-bootstrap/Button'
import InputGroup from 'react-bootstrap/InputGroup'
import BootstrapForm from 'react-bootstrap/Form'
import Alert from 'react-bootstrap/Alert'
import { Formik, Form as FormikForm, useFormikContext, useField } from 'formik'
import { useRef, useState } from 'react'
import copy from 'clipboard-copy'
import Thumb from '../svgs/thumb-up-fill.svg'
export function SubmitButton ({ children, variant, ...props }) {
const { isSubmitting } = useFormikContext()
return (
)
}
export function CopyInput (props) {
const [copied, setCopied] = useState(false)
const handleClick = () => {
copy(props.placeholder)
setCopied(true)
setTimeout(() => setCopied(false), 1500)
}
return (
{copied ? : 'copy'}}
{...props}
/>
)
}
export function InputSkeleton ({ label }) {
return (
{label && {label}}
)
}
export function Input ({ label, prepend, append, hint, showValid, noBottomMargin, ...props }) {
const [field, meta] = props.readOnly ? [{}, {}] : useField(props)
return (
{label && {label}}
{prepend && (
{prepend}
)}
{append && (
{append}
)}
{meta.touched && meta.error}
{hint && (
{hint}
)}
)
}
export function Form ({
initial, schema, onSubmit, children, initialError, ...props
}) {
const [error, setError] = useState(initialError)
return (
onSubmit && onSubmit(...args).catch(e => setError(e.message || e))}
>
{error && setError(undefined)} dismissible>{error}}
{children}
)
}
export function SyncForm ({
initial, schema, children, action, ...props
}) {
const ref = useRef(null)
return (
ref.current.submit()}
>
{props => (
)}
)
}