CI / changes (push) Successful in 6s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 43s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, , evobgp-web) (push) Successful in 1m2s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, evobgp-all, evobgp-web-all) (push) Successful in 1m5s
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 16s
CI / docker-go-prime (push) Successful in 23s
CI / docker-go (deploy/docker/evobgp-agent/Dockerfile, , evobgp-agent) (push) Successful in 1m0s
CI / docker-go (evobgp-all, 1, deploy/docker/gobinary/Dockerfile, , evobgp-all) (push) Successful in 2m12s
CI / docker-go (evobgp-api, 1, deploy/docker/gobinary/Dockerfile, , evobgp-api) (push) Successful in 1m22s
CI / docker-go (evobgp-deploy, 0, deploy/docker/gobinary/Dockerfile, , evobgp-deploy) (push) Successful in 1m18s
CI / docker-go (evobgp-ingest, 0, deploy/docker/gobinary/Dockerfile, , evobgp-ingest) (push) Successful in 1m21s
CI / docker-go (evobgp-node, 0, deploy/docker/gobinary/Dockerfile, , evobgp-node) (push) Successful in 1m5s
CI / docker-go (evobgp-render, 0, deploy/docker/gobinary/Dockerfile, , evobgp-render) (push) Successful in 1m25s
CI / docker-go (evobgp-scheduler, 0, deploy/docker/gobinary/Dockerfile, , evobgp-scheduler) (push) Successful in 1m29s
41 lines
1.5 KiB
Svelte
41 lines
1.5 KiB
Svelte
<script
|
|
lang="ts"
|
|
generics="TData, TValue, TContext extends HeaderContext<TData, TValue> | CellContext<TData, TValue>"
|
|
>
|
|
import type { CellContext, ColumnDefTemplate, HeaderContext } from "@tanstack/table-core";
|
|
import { RenderComponentConfig, RenderSnippetConfig } from "./render-helpers.js";
|
|
import type { Attachment } from "svelte/attachments";
|
|
type Props = {
|
|
/** The cell or header field of the current cell's column definition. */
|
|
content?: TContext extends HeaderContext<TData, TValue>
|
|
? ColumnDefTemplate<HeaderContext<TData, TValue>>
|
|
: TContext extends CellContext<TData, TValue>
|
|
? ColumnDefTemplate<CellContext<TData, TValue>>
|
|
: never;
|
|
/** The result of the `getContext()` function of the header or cell */
|
|
context: TContext;
|
|
|
|
/** Used to pass attachments that can't be gotten through context */
|
|
attach?: Attachment;
|
|
};
|
|
|
|
let { content, context, attach }: Props = $props();
|
|
</script>
|
|
|
|
{#if typeof content === "string"}
|
|
{content}
|
|
{:else if content instanceof Function}
|
|
<!-- It's unlikely that a CellContext will be passed to a Header -->
|
|
<!-- eslint-disable-next-line @typescript-eslint/no-explicit-any -->
|
|
{@const result = content(context as any)}
|
|
{#if result instanceof RenderComponentConfig}
|
|
{@const { component: Component, props } = result}
|
|
<Component {...props} {attach} />
|
|
{:else if result instanceof RenderSnippetConfig}
|
|
{@const { snippet, params } = result}
|
|
{@render snippet({ ...params, attach })}
|
|
{:else}
|
|
{result}
|
|
{/if}
|
|
{/if}
|