Description
TsSelect2 is a version of Select2 written in typescript without any dependencies. It supports searching, remote data sets, and infinite scrolling of results.
Use the TsSelect2 library for development only, not production for now.
Installation - NPM
npm i ts-select2
Installation - Browser
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://unpkg.com/ts-select2@0.2.3/dist/ts-select2.min.js"></script>
Usage
Add the following libraries to the page:
Add the following stylesheets from Select2 to the page:
Initialisation
<select data-placeholder="Select something" multiple="multiple" class="form-control select-access-multiple-enable">
<option value="AK">Alaska</option>
<option value="CA">California</option>
<option value="AZ" selected>Arizona</option>
<option value="CO">Colorado</option>
<option value="ID">Idaho</option>
<option value="WY" selected>Wyoming</option>
<option value="CT">Connecticut</option>
</select>
To initialise the select, call TsSelect2 on the element:
const select2 = new TsSelect2(select, {minimumResultsForSearch: Infinity, width: `250px`});
select2.open();
select2.close();
select2.toggleDropdown();
select2.isEnabled();
select2.isDisabled();
select2.isOpen();
select2.focus();
select2.data();
select2.destroy();
select2.select2('open');