2024-01-22 13:12:21 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import { debounce } from 'lodash';
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
import { useEntity } from '$lib/entity';
|
2024-02-06 22:32:10 +01:00
|
|
|
import type { WidgetChange } from '$lib/types/base';
|
2024-01-22 13:12:21 +01:00
|
|
|
import LabelBorder from './LabelBorder.svelte';
|
2024-02-06 22:32:10 +01:00
|
|
|
const dispatch = createEventDispatcher<{ change: WidgetChange }>();
|
2024-01-22 13:12:21 +01:00
|
|
|
|
|
|
|
export let address: string;
|
|
|
|
|
|
|
|
$: ({ entity } = useEntity(address));
|
|
|
|
|
2024-02-06 22:32:10 +01:00
|
|
|
$: notes = $entity?.get('NOTE')?.toString();
|
2024-01-22 13:12:21 +01:00
|
|
|
|
|
|
|
let contentEl: HTMLDivElement;
|
|
|
|
|
|
|
|
const update = debounce(() => {
|
2024-02-06 22:32:10 +01:00
|
|
|
dispatch('change', {
|
|
|
|
type: 'upsert',
|
|
|
|
attribute: 'NOTE',
|
|
|
|
value: { t: 'String', c: contentEl.innerText }
|
|
|
|
});
|
2024-01-22 13:12:21 +01:00
|
|
|
}, 500);
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<LabelBorder hide={!notes?.length}>
|
|
|
|
<span slot="header">Notes</span>
|
|
|
|
<div class="notes" contenteditable on:input={update} bind:this={contentEl}>
|
|
|
|
{notes ? notes : ''}
|
|
|
|
</div>
|
|
|
|
</LabelBorder>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.notes {
|
|
|
|
background: var(--background);
|
|
|
|
border-radius: 4px;
|
|
|
|
padding: 0.5em !important;
|
|
|
|
}
|
|
|
|
</style>
|