-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove previous diacritic unicodes and add
diacriticParser
(#190
- Loading branch information
1 parent
65ccbac
commit aaa9d92
Showing
9 changed files
with
178 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<div class="row mb-2"> | ||
<div class="col-md-12 title-desc"> | ||
<h2 class="bd-title"> | ||
Custom Diacritic Parser | ||
<span class="float-end links"> | ||
Code <span class="fa fa-link"></span> | ||
<span class="small"> | ||
<a | ||
target="_blank" | ||
href="https://github.com/ghiscoding/multiple-select-vanilla/blob/main/demo/src/options/options35.html" | ||
>html</a | ||
> | ||
| | ||
<a target="_blank" href="https://github.com/ghiscoding/multiple-select-vanilla/blob/main/demo/src/options/options35.ts" | ||
>ts</a | ||
> | ||
</span> | ||
</span> | ||
</h2> | ||
<div class="demo-subtitle"> | ||
Use <code>diacriticParser</code> callback option to remove diacritic signs (accents) from text while filtering items. | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<div class="mb-3 row align-middle"> | ||
<label class="col-sm-2 py-1 text-end">in/out parsing</label> | ||
<div class="col-sm-3"> | ||
<input class="form-control in-log" readonly style="background-color: #f0f0f0"/> | ||
</div> | ||
<div class="py-1 col-sm-1 w-35px">=></div> | ||
<div class="col-sm-3 text-start"> | ||
<input class="form-control out-log" readonly style="background-color: #f0f0f0"/> | ||
</div> | ||
</div> | ||
|
||
<hr/> | ||
|
||
<div class="mb-3 row"> | ||
<label class="col-sm-2 text-end">Select</label> | ||
|
||
<div class="col-sm-9"> | ||
<select id="select1" multiple="multiple" data-test="select1" class="full-width"> | ||
<option value="1">Janvier</option> | ||
<option value="2">Février</option> | ||
<option value="3">Mars</option> | ||
<option value="4">Avril</option> | ||
<option value="5">Mai</option> | ||
<option value="6">Juin</option> | ||
<option value="7">Juillet</option> | ||
<option value="8">Août</option> | ||
<option value="9">Septembre</option> | ||
<option value="10">Octobre</option> | ||
<option value="11">Novembre</option> | ||
<option value="12">Décembre</option> | ||
</select> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { multipleSelect, MultipleSelectInstance } from 'multiple-select-vanilla'; | ||
|
||
// map of diacritic signs against each alphabetical character | ||
const diacritics = { | ||
a: 'ÀÁÂÃÄÅàáâãäåĀāąĄ', | ||
c: 'ÇçćĆčČ', | ||
d: 'đĐďĎ', | ||
e: 'ÈÉÊËèéêëěĚĒēęĘ', | ||
i: 'ÌÍÎÏìíîïĪī', | ||
l: 'łŁ', | ||
n: 'ÑñňŇńŃ', | ||
o: 'ÒÓÔÕÕÖØòóôõöøŌō', | ||
r: 'řŘ', | ||
s: 'ŠšśŚ', | ||
t: 'ťŤ', | ||
u: 'ÙÚÛÜùúûüůŮŪū', | ||
y: 'ŸÿýÝ', | ||
z: 'ŽžżŻźŹ', | ||
}; | ||
|
||
export default class Example { | ||
ms1?: MultipleSelectInstance; | ||
inLogElm!: HTMLInputElement; | ||
outLogElm!: HTMLInputElement; | ||
|
||
mount() { | ||
this.inLogElm = document.querySelector('input.in-log') as HTMLInputElement; | ||
this.outLogElm = document.querySelector('input.out-log') as HTMLInputElement; | ||
this.ms1 = multipleSelect('#select1', { | ||
filter: true, | ||
showSearchClear: true, | ||
placeholder: 'search with "é" or "û"', | ||
diacriticParser: (text: string) => { | ||
const output = text | ||
.split('') | ||
.map((l) => Object.keys(diacritics).find((k) => diacritics[k as keyof typeof diacritics].includes(l)) || l) | ||
.join(''); | ||
|
||
this.inLogElm.value = text; | ||
this.outLogElm.value = output; | ||
return output; | ||
}, | ||
}) as MultipleSelectInstance; | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms1?.destroy(); | ||
this.ms1 = undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,3 +146,7 @@ $side-menu-width: 250px; | |
top: -2px; | ||
// margin: 0 5px; | ||
} | ||
|
||
.w-35px { | ||
width: 35px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.