fluid-dnd
Version:
An agnostic drag and drop library to sort all kind of lists. With current support for vue, react and svelte
34 lines (33 loc) • 846 B
JavaScript
export class SvelteListCondig {
items;
parent;
constructor(items) {
this.items = items;
}
setParent(parent) {
this.parent = parent;
}
removeAtEvent(index) {
const listValue = this.items;
if (listValue.length <= 0) {
return;
}
const [deletedItem] = listValue.splice(index, 1);
return deletedItem;
}
insertEvent(index, value) {
const listValue = this.items;
listValue.splice(index, 0, value);
}
getLength() {
return this.items.length;
}
getValue(index) {
return this.items[index];
}
insertToListEmpty(config, index, value) {
import('../../core/events/insert').then(({ insertToListEmpty }) => {
insertToListEmpty(config, this.parent, index, value);
});
}
}