From c431d1be46c78ae672d6816490b91a11a3c34507 Mon Sep 17 00:00:00 2001
From: Diaconu Radu-Mihai <52667211+radudiaconu0@users.noreply.github.com>
Date: Wed, 26 Mar 2025 19:00:09 +0200
Subject: [PATCH 1/4] feat(FwbInput): Add direct error message support
- Add errorMessage and successMessage props for direct message support
- Fix slot validation in computed properties ($slots not available in props)
- Add fallback for validation message slots without status
- Implement hideDetails prop to control message visibility
- Maintain backward compatibility with existing slot-based approach
This implementation makes error handling more versatile and
similar to other libraries like Vuetify, improving developer
experience while preserving existing functionality.
---
src/components/FwbInput/FwbInput.vue | 43 ++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/components/FwbInput/FwbInput.vue b/src/components/FwbInput/FwbInput.vue
index 1d49b2bc..aa87707d 100644
--- a/src/components/FwbInput/FwbInput.vue
+++ b/src/components/FwbInput/FwbInput.vue
@@ -30,12 +30,32 @@
+
+
+ {{ errorMessage }}
+
+
+
+
+
+ {{ successMessage }}
+
+
+
+
+
+ errorMessage?: string // New prop for direct error messaging
+ successMessage?: string // New prop for success messaging
+ hideDetails?: boolean // To control visibility of error/helper messages
}
defineOptions({
@@ -85,16 +108,30 @@ const props = withDefaults(defineProps(), {
autocomplete: 'off',
validationStatus: undefined,
blockClasses: undefined,
+ errorMessage: '',
+ successMessage: '',
+ hideDetails: false,
})
const model = useVModel(props, 'modelValue')
const { inputClasses, inputBlockClasses, labelClasses } = useInputClasses(toRefs(props))
+// Computed properties to determine visibility of messages
+const showErrorMessage = computed(() =>
+ !props.hideDetails &&
+ (props.validationStatus === validationStatusMap.Error || props.errorMessage)
+)
+
+const showSuccessMessage = computed(() =>
+ !props.hideDetails &&
+ props.validationStatus === validationStatusMap.Success &&
+ props.successMessage
+)
+
const validationWrapperClasses = computed(() => twMerge(
'mt-2 text-sm',
props.validationStatus === validationStatusMap.Success ? 'text-green-600 dark:text-green-500' : '',
props.validationStatus === validationStatusMap.Error ? 'text-red-600 dark:text-red-500' : '',
-
))
-
+
\ No newline at end of file
From 0fe66c92241e50443f00f7d61c352544162f870d Mon Sep 17 00:00:00 2001
From: Diaconu Radu-Mihai <52667211+radudiaconu0@users.noreply.github.com>
Date: Wed, 26 Mar 2025 19:05:11 +0200
Subject: [PATCH 2/4] add example
---
.../examples/FwbInputExampleErrorMessage.vue | 131 ++++++++++++++++++
1 file changed, 131 insertions(+)
create mode 100644 docs/components/input/examples/FwbInputExampleErrorMessage.vue
diff --git a/docs/components/input/examples/FwbInputExampleErrorMessage.vue b/docs/components/input/examples/FwbInputExampleErrorMessage.vue
new file mode 100644
index 00000000..2ad4b200
--- /dev/null
+++ b/docs/components/input/examples/FwbInputExampleErrorMessage.vue
@@ -0,0 +1,131 @@
+
+
+
Error Messages Examples
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Using error-message prop
+
+
+
+
+
Using validation slot
+
+
+
+
+
+
+ Please enter your full address
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From e44869a1e7987d99ca526442390b157eb773d858 Mon Sep 17 00:00:00 2001
From: Diaconu Radu-Mihai <52667211+radudiaconu0@users.noreply.github.com>
Date: Wed, 26 Mar 2025 19:11:17 +0200
Subject: [PATCH 3/4] added example in input page
---
docs/components/input.md | 68 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/docs/components/input.md b/docs/components/input.md
index 88e07265..5e48b5db 100644
--- a/docs/components/input.md
+++ b/docs/components/input.md
@@ -245,3 +245,71 @@ import { FwbInput } from 'flowbite-vue'
const email = ref('')
```
+## Error Messages
+
+- Set validation status via `validationStatus` prop, which accepts `'success'` or `'error'`.
+- Add error messages directly via `error-message` prop.
+- Add success messages directly via `success-message` prop.
+- Control visibility of messages with the `hide-details` prop.
+
+
+```vue
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
\ No newline at end of file
From 4efc44236ae29be05beead2e0ef98d8e6b1416cd Mon Sep 17 00:00:00 2001
From: Diaconu Radu-Mihai <52667211+radudiaconu0@users.noreply.github.com>
Date: Wed, 26 Mar 2025 19:13:31 +0200
Subject: [PATCH 4/4] replace the example from pages
---
docs/components/input.md | 137 ++++++++++++++++++++-------------------
1 file changed, 69 insertions(+), 68 deletions(-)
diff --git a/docs/components/input.md b/docs/components/input.md
index 5e48b5db..2bcc927a 100644
--- a/docs/components/input.md
+++ b/docs/components/input.md
@@ -104,6 +104,75 @@ const name = ref('')
```
+## Error Messages
+
+- Set validation status via `validationStatus` prop, which accepts `'success'` or `'error'`.
+- Add error messages directly via `error-message` prop.
+- Add success messages directly via `success-message` prop.
+- Control visibility of messages with the `hide-details` prop.
+
+
+```vue
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
+
## Extra CSS classes
Sometimes it is required to add some customization to the input or the input wrapper.
@@ -245,71 +314,3 @@ import { FwbInput } from 'flowbite-vue'
const email = ref('')
```
-## Error Messages
-
-- Set validation status via `validationStatus` prop, which accepts `'success'` or `'error'`.
-- Add error messages directly via `error-message` prop.
-- Add success messages directly via `success-message` prop.
-- Control visibility of messages with the `hide-details` prop.
-
-
-```vue
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-```
\ No newline at end of file