-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathevent-details-row.svelte
More file actions
62 lines (57 loc) · 1.88 KB
/
event-details-row.svelte
File metadata and controls
62 lines (57 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<script lang="ts">
import { twMerge as merge } from 'tailwind-merge';
import PayloadInline from '$lib/components/payload/payload-inline.svelte';
import Badge from '$lib/holocene/badge.svelte';
import Copyable from '$lib/holocene/copyable/index.svelte';
import { translate } from '$lib/i18n/translate';
import type { Payloads } from '$lib/types';
import { format } from '$lib/utilities/format-camel-case';
import type { CombinedAttributes } from '$lib/utilities/format-event-attributes';
import { displayLinkType } from '$lib/utilities/get-single-attribute-for-event';
import EventDetailsLink from './event-details-link.svelte';
export let key: string;
export let value: string | Record<string, unknown> | Payloads;
export let attributes: CombinedAttributes;
export let showKey = true;
$: linkType = displayLinkType(key, attributes);
</script>
{#if key}
<div
class="flex max-w-xl items-center gap-2 first:pt-0 last:border-b-0 md:w-auto"
>
{#if showKey}
<p class="whitespace-nowrap text-right text-xs">
{format(key)}
</p>
{/if}
{#if typeof value === 'object'}
<div
class="flex max-w-sm items-center justify-between gap-2 overflow-hidden pr-1 xl:flex-nowrap"
>
<PayloadInline
{value}
fieldName="payloads"
class={merge($$props.class)}
/>
</div>
{:else if linkType !== 'none'}
<Copyable
copyIconTitle={translate('common.copy-icon-title')}
copySuccessIconTitle={translate('common.copy-success-icon-title')}
content={value}
container-class="truncate"
>
<EventDetailsLink
{value}
{attributes}
type={linkType}
class="truncate"
/>
</Copyable>
{:else}
<Badge type="subtle" class="block select-none truncate">
{value}
</Badge>
{/if}
</div>
{/if}