@coreui/vue-pro
Version:
UI Components Library for Vue.js
53 lines (49 loc) • 1.79 kB
JavaScript
var vue = require('vue');
const CMultiSelectNativeSelect = vue.defineComponent({
name: 'CMultiSelectGroupOption',
props: {
id: String,
multiple: {
type: Boolean,
default: true,
},
name: String,
options: {
type: Array,
default: () => [],
},
required: Boolean,
value: [Number, String, Array],
},
emits: ['change'],
setup(props, { emit }) {
const nativeSelectRef = vue.inject('nativeSelectRef');
const createNativeOptions = (options) => {
return options.map((option) => {
return option.options
? vue.h('optgroup', { label: option.label }, createNativeOptions(option.options))
: vue.h('option', { disabled: option.disabled, value: option.value });
});
};
const handleChange = (event) => {
const target = event.target;
emit('change', Number(target.value));
};
return () => vue.h('select', {
className: 'multi-select-new',
id: props.id,
...(props.id && !props.name && { name: `${props.id}-multi-select` }), // TODO: remove in v6
...(props.name && { name: props.name }), // TODO: change to `name: props.name` in v6
multiple: props.multiple,
tabIndex: '-1',
style: { display: 'none' },
required: props.required,
value: props.value,
ref: nativeSelectRef,
onChange: handleChange,
}, props.options && createNativeOptions(props.options));
},
});
exports.CMultiSelectNativeSelect = CMultiSelectNativeSelect;
//# sourceMappingURL=CMultiSelectNativeSelect.js.map
;