From d0c4be178d5e84d8a20a4daa42969adfc96e7532 Mon Sep 17 00:00:00 2001 From: Michael Paradis Date: Wed, 4 Dec 2024 12:26:58 -0800 Subject: [PATCH] refactor(components): Expose Reusable hooks and components used in FormField [JOB-110812] (#2184) --------- Co-authored-by: Scott Thompson <145565743+scotttjob@users.noreply.github.com> --- .../InputValidation/Web.stories.tsx | 65 +++-- .../src/FormField/FormField.test.tsx | 39 ++- .../components/src/FormField/FormField.tsx | 188 ++++-------- .../src/FormField/FormFieldAffix.tsx | 3 +- .../src/FormField/FormFieldDescription.tsx | 6 +- .../src/FormField/FormFieldPostFix.tsx | 8 +- .../src/FormField/FormFieldTypes.ts | 17 ++ .../src/FormField/FormFieldWrapper.tsx | 267 +++++++++--------- .../src/FormField/components/ClearAction.tsx | 8 +- .../FormField/hooks/useAtlantisFormField.ts | 129 +++++++++ .../hooks/useAtlantisFormFieldActions.ts | 106 +++++++ .../hooks/useAtlantisFormFieldName.ts | 16 ++ .../hooks/useAtlantisReactHookForm.ts | 61 ++++ .../hooks/useFormFieldWrapperStyles.ts | 138 +++++++++ packages/components/src/FormField/index.ts | 9 + .../InputValidation/InputValidation.test.tsx | 51 +--- .../src/InputValidation/InputValidation.tsx | 8 +- packages/components/src/utils/meta/meta.json | 1 + 18 files changed, 788 insertions(+), 332 deletions(-) create mode 100644 packages/components/src/FormField/hooks/useAtlantisFormField.ts create mode 100644 packages/components/src/FormField/hooks/useAtlantisFormFieldActions.ts create mode 100644 packages/components/src/FormField/hooks/useAtlantisFormFieldName.ts create mode 100644 packages/components/src/FormField/hooks/useAtlantisReactHookForm.ts create mode 100644 packages/components/src/FormField/hooks/useFormFieldWrapperStyles.ts diff --git a/docs/components/InputValidation/Web.stories.tsx b/docs/components/InputValidation/Web.stories.tsx index 17c71c2542..7352c5e450 100644 --- a/docs/components/InputValidation/Web.stories.tsx +++ b/docs/components/InputValidation/Web.stories.tsx @@ -3,6 +3,8 @@ import { ComponentMeta, ComponentStory } from "@storybook/react"; import { InputValidation } from "@jobber/components/InputValidation"; import { InputText } from "@jobber/components/InputText"; import { Text } from "@jobber/components/Text"; +import { Button } from "@jobber/components/Button"; +import { Content } from "@jobber/components/Content"; export default { title: "Components/Forms and Inputs/InputValidation/Web", @@ -15,30 +17,51 @@ export default { const BasicTemplate: ComponentStory = args => { const [validationMessages, setValidationMessages] = useState(args.message); + const [displayError, setDisplayError] = useState(true); return ( - <> - - My name is - setValidationMessages(message)} - size="small" - inline={true} - maxLength={4} + + + + My name is + setValidationMessages(message)} + size="small" + inline={true} + maxLength={4} + /> + + - - {validationMessages && } - + + + + InputValidation can also be toggled using the visible prop + + + +