<script lang="ts">
    import type {CellAction, GetCellAction} from "../types";
    import {TextButton} from "../../button";

    export let data: any;
    export let getAction: GetCellAction;

    $: action = getAction?.(data);

    const handleClick = async (event: MouseEvent) => {
        await action?.handle(data)
    }

</script>
{#if action}
    <div style="width: 100; overflow: hidden;">
        <TextButton type={action.type ?? "primary"} label={action.text} onclick={handleClick}></TextButton>
    </div>
{/if}