mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
30 lines
588 B
JavaScript
30 lines
588 B
JavaScript
module.exports = class Slots {
|
|
constructor (slots = {}) {
|
|
this.slots = slots;
|
|
}
|
|
|
|
add (name, slot) {
|
|
this.slots[name] = slot;
|
|
return this;
|
|
}
|
|
|
|
get definitions () {
|
|
return this.slots;
|
|
}
|
|
|
|
/**
|
|
* @return {*[]}
|
|
*/
|
|
get bindings () {
|
|
const normalizeBindings = bindings => {
|
|
return Object.values(bindings)
|
|
.map(binding => binding.replace(/ *\([^)]*\) */g, ''));
|
|
};
|
|
|
|
return Object
|
|
.values(this.slots)
|
|
.map(({bindings}) => normalizeBindings(bindings))
|
|
.reduce((store, bindings) => [...store, ...bindings], []);
|
|
}
|
|
};
|