{
let e = detail.detail
dependents = getDependentComponents(e.id, $flowStore)
const cb = () => {
push(history, $flowStore)
selectNextId(e.id)
removeAtId($flowStore.value.modules, e.id)
$flowStore = $flowStore
}
if (Object.keys(dependents).length > 0) {
deleteCallback = cb
} else {
cb()
}
}}
on:insert={async ({ detail }) => {
if (detail.modules) {
await tick()
if ($moving) {
push(history, $flowStore)
let indexToRemove = $moving.modules.findIndex((m) => $moving?.module?.id == m.id)
$moving.modules.splice(indexToRemove, 1)
detail.modules.splice(detail.index, 0, $moving.module)
$selectedId = $moving.module.id
$moving = undefined
} else {
await insertNewModuleAtIndex(detail.modules, detail.index ?? 0, detail.detail)
$selectedId = detail.modules[detail.index ?? 0].id
}
$flowStore = $flowStore
}
}}
on:newBranch={async ({ detail }) => {
if (detail.module) {
await addBranch(detail.module)
$flowStore = $flowStore
}
}}
on:deleteBranch={async ({ detail }) => {
if (detail.module) {
await removeBranch(detail.module, detail.index)
$flowStore = $flowStore
$selectedId = detail.module.id
}
}}
on:move={async ({ detail }) => {
if (!$moving || $moving.module.id !== detail.module.id) {
if (detail.module && detail.modules) {
console.log('MOVE+')
$moving = { module: detail.module, modules: detail.modules }
}
} else {
$moving = undefined
}
}}
/>