Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Merge 92203da into d0bc765
Browse files Browse the repository at this point in the history
  • Loading branch information
doijunior committed Nov 1, 2019
2 parents d0bc765 + 92203da commit faeedab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default {
Name | Type | Default | Description
--- | --- | --- | ---
data | `Array` | | Array of data to be available for querying. **Required**
diacritcs | `Boolean` | | If is set true the input is diacritics insensitive (the listing is still diacritcs sensitive)
serializer | `Function` | `input => input` | Function used to convert the entries in the `data` array into a text string.
size | `String` | | Size of the `input-group`. Valid values: `sm` or `lg`
backgroundVariant | `String` | | Background color for the autocomplete result `list-group` items. [See valid values](http://getbootstrap.com/docs/4.1/utilities/colors/#background-color)
Expand Down
5 changes: 5 additions & 0 deletions src/components/VueBootstrapTypeahead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
:text-variant="textVariant"
:maxMatches="maxMatches"
:minMatchingChars="minMatchingChars"
:removeDiacritcs="removeDiacritcs"
@hit="handleHit"
>
<!-- pass down all scoped slots -->
Expand Down Expand Up @@ -92,6 +93,10 @@ export default {
type: Number,
default: 2
},
removeDiacritcs: {
type: Boolean,
default: false,
},
placeholder: String,
prepend: String,
append: String
Expand Down
14 changes: 12 additions & 2 deletions src/components/VueBootstrapTypeaheadList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<script>
import VueBootstrapTypeaheadListItem from './VueBootstrapTypeaheadListItem.vue'
function normalize(text) {
return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
}
function sanitize(text) {
return text.replace(/</g, '&lt;').replace(/>/g, '&gt;')
}
Expand Down Expand Up @@ -56,7 +60,10 @@ export default {
minMatchingChars: {
type: Number,
default: 2
}
},
removeDiacritcs: {
type: Boolean,
},
},
computed: {
Expand All @@ -73,7 +80,10 @@ export default {
},
escapedQuery() {
return escapeRegExp(sanitize(this.query))
if(this.removeDiacritcs)
return escapeRegExp( normalize( sanitize(this.query) ) )
else
return escapeRegExp( sanitize(this.query) )
},
matchedItems() {
Expand Down

0 comments on commit faeedab

Please sign in to comment.