diff --git a/resources/scripts/components/dashboard/search/SearchContainer.tsx b/resources/scripts/components/dashboard/search/SearchContainer.tsx index 475d65510..ef3ae48db 100644 --- a/resources/scripts/components/dashboard/search/SearchContainer.tsx +++ b/resources/scripts/components/dashboard/search/SearchContainer.tsx @@ -19,7 +19,7 @@ export default () => { <> {visible && setVisible(false)} /> diff --git a/resources/scripts/components/dashboard/search/SearchModal.tsx b/resources/scripts/components/dashboard/search/SearchModal.tsx index 9c1777df3..ac4c2b1bd 100644 --- a/resources/scripts/components/dashboard/search/SearchModal.tsx +++ b/resources/scripts/components/dashboard/search/SearchModal.tsx @@ -13,6 +13,7 @@ import { httpErrorToHuman } from '@/api/http'; import { Link } from 'react-router-dom'; import styled from 'styled-components/macro'; import tw from 'twin.macro'; +import Input from '@/components/elements/Input'; type Props = RequiredModalProps; @@ -94,11 +95,7 @@ export default ({ ...props }: Props) => { > - + diff --git a/resources/scripts/components/elements/Field.tsx b/resources/scripts/components/elements/Field.tsx index c6941cc4d..f89b01343 100644 --- a/resources/scripts/components/elements/Field.tsx +++ b/resources/scripts/components/elements/Field.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { forwardRef } from 'react'; import { Field as FormikField, FieldProps } from 'formik'; import Input from '@/components/elements/Input'; import Label from '@/components/elements/Label'; @@ -13,8 +13,8 @@ interface OwnProps { type Props = OwnProps & Omit, 'name'>; -const Field = ({ id, name, light = false, label, description, validate, className, ...props }: Props) => ( - +const Field = forwardRef(({ id, name, light = false, label, description, validate, className, ...props }, ref) => ( + { ({ field, form: { errors, touched } }: FieldProps) => ( @@ -39,6 +39,7 @@ const Field = ({ id, name, light = false, label, description, validate, classNam ) } -); +)); +Field.displayName = 'Field'; export default Field; diff --git a/resources/scripts/components/elements/FormikFieldWrapper.tsx b/resources/scripts/components/elements/FormikFieldWrapper.tsx index ec6a0fb13..aeaf1b6d0 100644 --- a/resources/scripts/components/elements/FormikFieldWrapper.tsx +++ b/resources/scripts/components/elements/FormikFieldWrapper.tsx @@ -2,6 +2,8 @@ import React from 'react'; import { Field, FieldProps } from 'formik'; import classNames from 'classnames'; import InputError from '@/components/elements/InputError'; +import Label from '@/components/elements/Label'; +import tw from 'twin.macro'; interface Props { id?: string; @@ -18,10 +20,10 @@ const FormikFieldWrapper = ({ id, name, label, className, description, validate, { ({ field, form: { errors, touched } }: FieldProps) => (
- {label && } + {label && } {children} - {description ?

{description}

: null} + {description || null}
) diff --git a/resources/scripts/components/elements/InputError.tsx b/resources/scripts/components/elements/InputError.tsx index df5bc7369..02758350e 100644 --- a/resources/scripts/components/elements/InputError.tsx +++ b/resources/scripts/components/elements/InputError.tsx @@ -1,17 +1,18 @@ import React from 'react'; import capitalize from 'lodash-es/capitalize'; import { FormikErrors, FormikTouched } from 'formik'; +import tw from 'twin.macro'; interface Props { errors: FormikErrors; touched: FormikTouched; name: string; - children?: React.ReactNode; + children?: string | number | null | undefined; } const InputError = ({ errors, touched, name, children }: Props) => ( touched[name] && errors[name] ? -

+

{typeof errors[name] === 'string' ? capitalize(errors[name] as string) : @@ -19,9 +20,9 @@ const InputError = ({ errors, touched, name, children }: Props) => ( }

: - - {children} - + <> + {children ?

{children}

: null} + ); export default InputError; diff --git a/resources/scripts/components/elements/InputSpinner.tsx b/resources/scripts/components/elements/InputSpinner.tsx index dabd4f8ff..32f1b18d9 100644 --- a/resources/scripts/components/elements/InputSpinner.tsx +++ b/resources/scripts/components/elements/InputSpinner.tsx @@ -1,20 +1,21 @@ import React from 'react'; import Spinner from '@/components/elements/Spinner'; import { CSSTransition } from 'react-transition-group'; +import Fade from '@/components/elements/Fade'; +import tw from 'twin.macro'; const InputSpinner = ({ visible, children }: { visible: boolean, children: React.ReactNode }) => ( -
- + -
+
- + {children}
);