From 7beb1466bf31aebca197d5d5277bb017d29688e5 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 5 Apr 2022 14:25:58 +0200 Subject: [PATCH] (archi) organize react-hook-form components in a separate folder --- .../authentication-provider/provider-form.tsx | 8 ++++---- .../{base/rhf-input.tsx => form/form-input.tsx} | 12 ++++++------ .../form-multi-select.tsx} | 10 +++++----- .../{base/fab-select.tsx => form/form-select.tsx} | 12 ++++++------ .../plan-categories/plan-category-form.tsx | 6 +++--- app/frontend/src/stylesheets/application.scss | 3 ++- .../{base/rhf-input.scss => form/form-input.scss} | 2 +- .../{base/fab-select.scss => form/form-select.scss} | 4 ++-- 8 files changed, 29 insertions(+), 28 deletions(-) rename app/frontend/src/javascript/components/{base/rhf-input.tsx => form/form-input.tsx} (72%) rename app/frontend/src/javascript/components/{base/fab-multi-select.tsx => form/form-multi-select.tsx} (74%) rename app/frontend/src/javascript/components/{base/fab-select.tsx => form/form-select.tsx} (72%) rename app/frontend/src/stylesheets/modules/{base/rhf-input.scss => form/form-input.scss} (99%) rename app/frontend/src/stylesheets/modules/{base/fab-select.scss => form/form-select.scss} (98%) diff --git a/app/frontend/src/javascript/components/authentication-provider/provider-form.tsx b/app/frontend/src/javascript/components/authentication-provider/provider-form.tsx index f628f7a92..14675b889 100644 --- a/app/frontend/src/javascript/components/authentication-provider/provider-form.tsx +++ b/app/frontend/src/javascript/components/authentication-provider/provider-form.tsx @@ -4,9 +4,9 @@ import { react2angular } from 'react2angular'; import { AuthenticationProvider } from '../../models/authentication-provider'; import { Loader } from '../base/loader'; import { IApplication } from '../../models/application'; -import { RHFInput } from '../base/rhf-input'; +import { FormInput } from '../form/form-input'; import { useTranslation } from 'react-i18next'; -import { FabSelect } from '../base/fab-select'; +import { FormSelect } from '../form/form-select'; declare const Application: IApplication; @@ -46,8 +46,8 @@ export const ProviderForm: React.FC = ({ action, provider, on return (
- - + + ); diff --git a/app/frontend/src/javascript/components/base/rhf-input.tsx b/app/frontend/src/javascript/components/form/form-input.tsx similarity index 72% rename from app/frontend/src/javascript/components/base/rhf-input.tsx rename to app/frontend/src/javascript/components/form/form-input.tsx index cb2acb672..456be40c7 100644 --- a/app/frontend/src/javascript/components/base/rhf-input.tsx +++ b/app/frontend/src/javascript/components/form/form-input.tsx @@ -4,7 +4,7 @@ import { FieldValues } from 'react-hook-form/dist/types/fields'; import { FieldPath } from 'react-hook-form/dist/types/path'; import { FormComponent } from '../../models/form-component'; -interface RHFInputProps extends InputHTMLAttributes, FormComponent{ +interface FormInputProps extends InputHTMLAttributes, FormComponent{ id: string, label?: string, tooltip?: string, @@ -16,10 +16,10 @@ interface RHFInputProps extends InputHTMLAttributes({ id, register, label, tooltip, defaultValue, icon, className, rules, readOnly, disabled, type, addOn, addOnClassName, placeholder, error, step }: RHFInputProps) => { +export const FormInput = ({ id, register, label, tooltip, defaultValue, icon, className, rules, readOnly, disabled, type, addOn, addOnClassName, placeholder, error, step }: FormInputProps) => { // Compose classnames from props const classNames = ` - rhf-input ${className || ''} + form-input ${className || ''} ${error && error[id] ? 'is-incorrect' : ''} ${rules && rules.required ? 'is-required' : ''} ${readOnly ? 'is-readOnly' : ''} @@ -27,12 +27,12 @@ export const RHFInput = ({ id, register, label return (