# Usage
Browser
<script src="./sortable.min.js"></script>
<script src="./tag-picker/index.min.js"></script>
<script src="./tag-picker.sort/index.min.js"></script>
<script>
const picker = new TagPicker(document.querySelector('input'), {
with: [TagPicker.Sort]
});
</script>
CommonJS
const TagPicker = require('@taufik-nurrohman/tag-picker').default;
const TagPickerSort = require('@taufik-nurrohman/tag-picker.sort').default;
if ('undefined' === typeof Sortable) {
throw new ReferenceError('Missing `Sortable` library.');
}
const picker = new TagPicker(document.querySelector('input'), {
with: [TagPickerSort]
});
ECMAScript
import TagPicker = from '@taufik-nurrohman/tag-picker';
import TagPickerSort from '@taufik-nurrohman/tag-picker.sort';
import Sortable from 'sortablejs';
window.Sortable = Sortable; // Expose `Sortable` class to `window` (optional)
const picker = new TagPicker(document.querySelector('input'), {
with: [TagPickerSort]
});
# Methods
Instance Methods
picker.reverse()
Reverses the order of the current tag items.
picker.reverse();
picker.sort(method)
Sorts the current tag items in alphabetical order (by default).
picker.sort();
picker.sort((a, b) => {
return a.localeCompare(b, undefined, {
numeric: true,
sensitivity: 'base'
});
});