-
Notifications
You must be signed in to change notification settings - Fork 171
/
Delta.svelte
40 lines (31 loc) · 1.16 KB
/
Delta.svelte
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
<script context="module">
export const evidenceInclude = true;
</script>
<script>
import { QueryLoad } from '../../../atoms/query-load/index.js';
import Delta from './_Delta.svelte';
import EmptyChart from '../core/EmptyChart.svelte';
export let data;
const initialHash = typeof data === 'object' && '__isQueryStore' in data ? data.hash : undefined;
let isInitial = data?.hash === initialHash;
$: isInitial = data?.hash === initialHash;
/** @type {"pass" | "warn" | "error"}*/
export let emptySet = undefined;
/** @type {string}*/
export let emptyMessage = undefined;
let chartType = 'Delta';
// Remove any undefined props (e.g. w/o defaults) to prevent them from being passed
$: spreadProps = Object.fromEntries(Object.entries($$props).filter(([, v]) => v !== undefined));
</script>
<!-- Pass all the props through-->
<QueryLoad {data} let:loaded>
<span slot="empty">
{#if !spreadProps.placeholder}
<EmptyChart {emptyMessage} {emptySet} {chartType} {isInitial} />
{/if}
</span>
<p slot="skeleton" class="text-gray-500">Loading...</p>
<Delta {...spreadProps} data={loaded?.__isQueryStore ? Array.from(loaded) : loaded}>
<slot />
</Delta>
</QueryLoad>