2021-05-06 19:26:50 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
2021-10-26 00:43:02 +02:00
|
|
|
<script lang="ts">
|
2022-02-03 05:52:11 +01:00
|
|
|
import type { SlotHostProps } from "../sveltelib/dynamic-slotting";
|
|
|
|
import { defaultSlotHostContext } from "../sveltelib/dynamic-slotting";
|
2021-05-06 19:26:50 +02:00
|
|
|
|
|
|
|
export let id: string | undefined = undefined;
|
2022-02-03 05:52:11 +01:00
|
|
|
export let hostProps: SlotHostProps | undefined = undefined;
|
2021-05-06 19:26:50 +02:00
|
|
|
|
2022-02-03 05:52:11 +01:00
|
|
|
if (!defaultSlotHostContext.available()) {
|
|
|
|
console.log("Item: should always have a slotHostContext");
|
2021-05-06 19:26:50 +02:00
|
|
|
}
|
2022-02-03 05:52:11 +01:00
|
|
|
|
|
|
|
const { detach } = hostProps ?? defaultSlotHostContext.get().getProps();
|
2021-05-06 19:26:50 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- div is necessary to preserve item position -->
|
2021-10-18 14:01:15 +02:00
|
|
|
<div class="item" {id}>
|
2022-02-03 05:52:11 +01:00
|
|
|
{#if !$detach}
|
2021-05-06 19:26:50 +02:00
|
|
|
<slot />
|
2022-02-03 05:52:11 +01:00
|
|
|
{/if}
|
2021-05-06 19:26:50 +02:00
|
|
|
</div>
|
2021-05-26 01:21:33 +02:00
|
|
|
|
|
|
|
<style lang="scss">
|
2021-10-28 11:37:52 +02:00
|
|
|
.item {
|
|
|
|
display: contents;
|
|
|
|
}
|
2021-05-26 01:21:33 +02:00
|
|
|
</style>
|