mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-26 17:31:02 +02:00
e6882f3e4b
* Add wrapped element getters + fix some types * Remove comment * Add missing config options to types * Add types to constants * Rename sortFn to sorter * Update PR template * Add refactor to PR template * Add passed element types to constants * Add js doc comments to actions * Add "returns" to js doc comments * Add missing choice prop to type * Add types to store.js * Add jsdoc comments to components * Ignore strict null checks * Move loading action into misc.js * Further type def additions * Rename itemCompare to valueCompare * Update badges * Rename scrollToChoice to scrollToChildElement
39 lines
868 B
JavaScript
39 lines
868 B
JavaScript
import WrappedElement from './wrapped-element';
|
|
|
|
/**
|
|
* @typedef {import('../../../types/index').Choices.ClassNames} ClassNames
|
|
* @typedef {import('../../../types/index').Choices.Item} Item
|
|
*/
|
|
|
|
export default class WrappedInput extends WrappedElement {
|
|
/**
|
|
* @param {{
|
|
* element: HTMLInputElement,
|
|
* classNames: ClassNames,
|
|
* delimiter: string
|
|
* }} args
|
|
*/
|
|
constructor({ element, classNames, delimiter }) {
|
|
super({ element, classNames });
|
|
this.delimiter = delimiter;
|
|
}
|
|
|
|
/**
|
|
* @returns {string}
|
|
*/
|
|
get value() {
|
|
return this.element.value;
|
|
}
|
|
|
|
/**
|
|
* @param {Item[]} items
|
|
*/
|
|
set value(items) {
|
|
const itemValues = items.map(({ value }) => value);
|
|
const joinedValues = itemValues.join(this.delimiter);
|
|
|
|
this.element.setAttribute('value', joinedValues);
|
|
this.element.value = joinedValues;
|
|
}
|
|
}
|