2021-04-08 16:57:24 +02:00
|
|
|
<script>
|
|
|
|
import StringRenderer from "./StringRenderer.svelte"
|
|
|
|
import BooleanRenderer from "./BooleanRenderer.svelte"
|
|
|
|
import DateTimeRenderer from "./DateTimeRenderer.svelte"
|
|
|
|
import RelationshipRenderer from "./RelationshipRenderer.svelte"
|
|
|
|
import AttachmentRenderer from "./AttachmentRenderer.svelte"
|
2021-08-19 17:54:44 +02:00
|
|
|
import ArrayRenderer from "./ArrayRenderer.svelte"
|
2021-10-13 10:29:01 +02:00
|
|
|
|
2021-04-12 16:12:59 +02:00
|
|
|
export let row
|
2021-04-08 16:57:24 +02:00
|
|
|
export let schema
|
|
|
|
export let value
|
2021-04-09 15:21:27 +02:00
|
|
|
export let customRenderers = []
|
2021-04-08 16:57:24 +02:00
|
|
|
|
2021-10-12 18:32:15 +02:00
|
|
|
let renderer
|
2021-04-12 16:24:33 +02:00
|
|
|
const typeMap = {
|
|
|
|
boolean: BooleanRenderer,
|
|
|
|
datetime: DateTimeRenderer,
|
|
|
|
link: RelationshipRenderer,
|
|
|
|
attachment: AttachmentRenderer,
|
|
|
|
string: StringRenderer,
|
|
|
|
options: StringRenderer,
|
|
|
|
number: StringRenderer,
|
|
|
|
longform: StringRenderer,
|
2021-08-19 17:54:44 +02:00
|
|
|
array: ArrayRenderer,
|
2021-04-12 16:24:33 +02:00
|
|
|
}
|
2021-04-08 16:57:24 +02:00
|
|
|
$: type = schema?.type ?? "string"
|
2021-05-04 12:32:22 +02:00
|
|
|
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
2021-10-13 12:39:36 +02:00
|
|
|
$: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer
|
2021-04-08 16:57:24 +02:00
|
|
|
</script>
|
|
|
|
|
2021-05-04 12:04:42 +02:00
|
|
|
{#if renderer && (customRenderer || (value != null && value !== ""))}
|
2021-04-12 16:24:33 +02:00
|
|
|
<svelte:component this={renderer} {row} {schema} {value} on:clickrelationship>
|
|
|
|
<slot />
|
|
|
|
</svelte:component>
|
2021-04-08 16:57:24 +02:00
|
|
|
{/if}
|