From 3b86b3bd82c27d3cf41476a109544b26301a5d59 Mon Sep 17 00:00:00 2001 From: Stephen Lee Date: Wed, 22 May 2024 12:43:16 -0700 Subject: [PATCH] Extend errorMessage and successMessage types in number input, text area, and text input (#2347) --- .changeset/sharp-chicken-change.md | 7 +++++++ packages/number-input/src/NumberInput/NumberInput.types.ts | 4 ++-- packages/text-area/src/TextArea/TextArea.types.ts | 4 ++-- packages/text-input/src/TextInput/TextInput.types.ts | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 .changeset/sharp-chicken-change.md diff --git a/.changeset/sharp-chicken-change.md b/.changeset/sharp-chicken-change.md new file mode 100644 index 0000000000..1fb245dac6 --- /dev/null +++ b/.changeset/sharp-chicken-change.md @@ -0,0 +1,7 @@ +--- +'@leafygreen-ui/number-input': minor +'@leafygreen-ui/text-input': minor +'@leafygreen-ui/text-area': minor +--- + +Allow type of `ReactNode` for `errorMessage` and `successMessage` props in `NumberInput`, `TextArea`, and `TextInput` diff --git a/packages/number-input/src/NumberInput/NumberInput.types.ts b/packages/number-input/src/NumberInput/NumberInput.types.ts index dc9598ce10..6ba47169f3 100644 --- a/packages/number-input/src/NumberInput/NumberInput.types.ts +++ b/packages/number-input/src/NumberInput/NumberInput.types.ts @@ -136,12 +136,12 @@ export interface BaseNumberInputProps /** * The message shown below the input element if the value is invalid. */ - errorMessage?: string; + errorMessage?: React.ReactNode; /** * The message shown below the input element if the value is valid. */ - successMessage?: string; + successMessage?: React.ReactNode; /** * Determines the font size and padding. diff --git a/packages/text-area/src/TextArea/TextArea.types.ts b/packages/text-area/src/TextArea/TextArea.types.ts index 4cbc26b191..e1048888e4 100644 --- a/packages/text-area/src/TextArea/TextArea.types.ts +++ b/packages/text-area/src/TextArea/TextArea.types.ts @@ -58,12 +58,12 @@ export interface BaseTextAreaProps /** * The message shown below the input element if the value is invalid. */ - errorMessage?: string; + errorMessage?: React.ReactNode; /** * The message shown below the input element if the value is valid. */ - successMessage?: string; + successMessage?: React.ReactNode; /** * Callback called whenever validation should be run. diff --git a/packages/text-input/src/TextInput/TextInput.types.ts b/packages/text-input/src/TextInput/TextInput.types.ts index 6016ea8c5c..d442f3a8d8 100644 --- a/packages/text-input/src/TextInput/TextInput.types.ts +++ b/packages/text-input/src/TextInput/TextInput.types.ts @@ -116,12 +116,12 @@ export interface BaseTextInputProps /** * The message shown below the input field if the value is invalid. */ - errorMessage?: string; + errorMessage?: React.ReactNode; /** * The message shown below the input field if the value is valid. */ - successMessage?: string; + successMessage?: React.ReactNode; /** * The current state of the TextInput. This can be none, valid, or error.