const selectMulti = document.querySelector(".select__multi");
const choicesMulti = new Choices(selectMulti, {
searchEnabled: false,
itemSelectText: "",
shouldSort: false,
renderSelectedChoices: "always",
silent: true,
callbackOnCreateTemplates: function (template) {
return {
item: ({ classNames }, data) => {
return template(`
<div class="${classNames.item} ${
data.highlighted
? classNames.highlightedState
: classNames.itemSelectable
} ${
data.placeholder ? classNames.placeholder : ""
}" data-item data-id="${data.id}" data-value="${data.value}" ${
data.active ? 'aria-selected="true"' : ""
} ${data.disabled ? 'aria-disabled="true"' : ""}>
<div class="form__select-wrapper">
<div class="select__text">${String(data.label)}</div>
</div>
</div>
`);
},
choice: ({ classNames }, data) => {
return template(`
<div class="${classNames.item} ${classNames.itemChoice} ${
data.disabled ? classNames.itemDisabled : classNames.itemSelectable
}" data-select-text="${this.config.itemSelectText}" data-choice ${
data.disabled
? 'data-choice-disabled aria-disabled="true"'
: "data-choice-selectable"
} data-id="${data.id}" data-value="${data.value}" ${
data.groupId > 0 ? 'role="treeitem"' : 'role="option"'
}>
<div class="select__wrapper">
<div class="form__select-checkbox">
<label class="form__checkbox-label">
<div class="form__checkbox-text">
${String(data.label)}
</div>
<input class="form__checkbox-input" type="checkbox" name="checkbox" checked onclick="event.stopPropagation()">
<span class="form__checkbox-box"></span>
</label>
</div>
</div>
</div>
`);
},
};
},
});
<div class="form__field form__field-select">
<select class="select__multi select--multiple" multiple>
<option>Ww</option>
<option>Eu</option>
<option>Asia</option>
<option>AFRICA</option>
<option>LATAM</option>
<option>MENA</option>
<option>Australia</option>
</select>
<div class="form__multiple-arrow">
</div>
<div class="form__field-icon">
</div>
<label class="form__field-label form__field-label--messenger"></label>
>What GEO can you cover?</label
>
</div>
.form {
&__checkbox-label {
position: relative;
display: flex;
align-items: center;
}
&__checkbox-input {
position: absolute;
left: 2rem;
width: 0.1rem;
height: 0.1rem;
}
&__checkbox-box {
position: absolute;
left: 0;
top: 0;
overflow: hidden;
border: 0.1rem solid var(--clr-default-900);
width: 2rem;
height: 2rem;
}
&__checkbox-input:checked + &__checkbox-box {
background-color: red;
}
}
callbackOnCreateTemplates: function(template) {
return {
item: ({ classNames }, data) => {
return template(`
<div class="${classNames.item} ${
data.highlighted
? classNames.highlightedState
: classNames.itemSelectable
} ${
data.placeholder ? classNames.placeholder : ''
}" data-item data-id="${data.id}" data-value="${data.value}" ${
data.active ? 'aria-selected="true"' : ''
} ${data.disabled ? 'aria-disabled="true"' : ''}>
${data.label}
<button type="button" class="choices__button" aria-label="Удалить марку: ${data.label}" data-button="">Удалить марку</button>
</div>
`);
},
choice: ({ classNames }, data) => {
var icon = (data.selected) ? 'checked' : 'unchecked';
return template(`
<div class="${classNames.item} ${classNames.itemChoice} ${
data.disabled ? classNames.itemDisabled : classNames.itemSelectable
}" data-select-text="${this.config.itemSelectText}" data-choice ${
data.disabled
? 'data-choice-disabled aria-disabled="true"'
: 'data-choice-selectable'
} data-id="${data.id}" data-value="${data.value}" ${
data.groupId > 0 ? 'role="treeitem"' : 'role="option"'
}>
<i class="flaticon-${icon}"></i>
${data.label}
<span>${data.customProperties.num}</span>
</div>
`);
},
};
},