Skip to content

Commit

Permalink
feat : input placeholder can be customized
Browse files Browse the repository at this point in the history
  • Loading branch information
ElvisAns committed Aug 10, 2024
1 parent 5492d68 commit f283e63
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const viewUserSelection = (data: Object) => {
</setup>
<template>
<VuePredictiveSearch @selected="viewUserSelection" inputClasses="searchInput" :source="books" label="title" :fieldsToSearchFrom="['title', 'author', 'genre']" :fieldsToReturnOnMatch="['title', 'author', 'genre', 'price', 'publicationYear','id']">
<VuePredictiveSearch @selected="viewUserSelection" inputClasses="searchInput" :source="books" label="title" :fieldsToSearchFrom="['title', 'author', 'genre']" :fieldsToReturnOnMatch="['title', 'author', 'genre', 'price', 'publicationYear','id']" inputPlaceholder="What book are you looking for?">
<template #no-element-found>
<p>No element found</p>
</template>
Expand All @@ -45,6 +45,7 @@ const viewUserSelection = (data: Object) => {
- __fieldsToSearchFrom__: Array of field names to search from.
- __fieldsToReturnOnMatch__: Array of field names to return when a match is found.
- __inputClasses (Optional)__: Custom classes for the search input.
- __inputPlaceholder__ : The placeholder for the search input, default to : 'What are you looking for?'

📌 The component is using slots to allow a high customization, you will bring your own UI, just make sure to attach everything to the proper named slot

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/ElvisAns/VuePredictiveSearch"
},
"license": "MIT",
"version": "1.0.6",
"version": "1.0.7",
"description": "The most flexible search component for vuejs applications with auto suggestion and fuzzy search feature",
"main": "./dist/vue-predictive-search.umd.cjs",
"module": "./dist/vue-predictive-search.js",
Expand Down
8 changes: 6 additions & 2 deletions src/components/VuePredictiveSearch.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<input :class="inputClasses" @input="updateSuggestionList" type="search" v-model="search" placeholder="what are you looking for?" />
<input :class="inputClasses" @input="updateSuggestionList" type="search" v-model="search" :placeholder="inputPlaceholder" />
<div v-if="!items.length && !hasNeverSearch">
<slot name="no-element-found"></slot>
</div>
Expand All @@ -23,7 +23,11 @@ const props = defineProps({
label: { type: String, required: true },
fieldsToSearchFrom: { type: Array, required: true },
fieldsToReturnOnMatch: { type: Array, required: true },
inputClasses: String
inputClasses: String,
inputPlaceholder : {
type : String,
default : 'What are you looking for?'
}
})
var searchEngine;
const items = ref([])
Expand Down

0 comments on commit f283e63

Please sign in to comment.