<script lang="ts">
	export let onLeave = () => {
		return;
	};
	export let card = true;
	export let smallCard = false;
	export let fullscreen = false;
	export let show = true;
	export let locked = false;

	const handleClickOutside = (event: any) => {
		if (!locked && event.target.classList.contains('popup')) {
			show = false;

			onLeave();
		}
	};
</script>

<svelte:window on:click={handleClickOutside} />

{#if show}
	<div class={`popup ${fullscreen ? 'popup-fullscreen' : ''}`}>
		<span class={card ? `card ${smallCard ? 'card-small' : ''}` : ''}>
			<slot />
		</span>
	</div>
{/if}

<style>
	.popup {
		z-index: 3;
	}
</style>
