Keep track of ICE and police locations in your city. Very much a work-in-progress and not ready yet, stay tuned I guess?
at main 40 lines 1.5 kB view raw
1<script 2 lang="ts" 3 generics="TData, TValue, TContext extends HeaderContext<TData, TValue> | CellContext<TData, TValue>" 4> 5 import type { CellContext, ColumnDefTemplate, HeaderContext } from "@tanstack/table-core"; 6 import { RenderComponentConfig, RenderSnippetConfig } from "./render-helpers.js"; 7 import type { Attachment } from "svelte/attachments"; 8 type Props = { 9 /** The cell or header field of the current cell's column definition. */ 10 content?: TContext extends HeaderContext<TData, TValue> 11 ? ColumnDefTemplate<HeaderContext<TData, TValue>> 12 : TContext extends CellContext<TData, TValue> 13 ? ColumnDefTemplate<CellContext<TData, TValue>> 14 : never; 15 /** The result of the `getContext()` function of the header or cell */ 16 context: TContext; 17 18 /** Used to pass attachments that can't be gotten through context */ 19 attach?: Attachment; 20 }; 21 22 let { content, context, attach }: Props = $props(); 23</script> 24 25{#if typeof content === "string"} 26 {content} 27{:else if content instanceof Function} 28 <!-- It's unlikely that a CellContext will be passed to a Header --> 29 <!-- eslint-disable-next-line @typescript-eslint/no-explicit-any --> 30 {@const result = content(context as any)} 31 {#if result instanceof RenderComponentConfig} 32 {@const { component: Component, props } = result} 33 <Component {...props} {attach} /> 34 {:else if result instanceof RenderSnippetConfig} 35 {@const { snippet, params } = result} 36 {@render snippet({ ...params, attach })} 37 {:else} 38 {result} 39 {/if} 40{/if}