| 1 |
<script lang="ts"> |
| 2 |
import AutocompleteInput from "../AutocompleteInput.svelte"; |
| 3 |
import type { Balance, EntryMetadata } from "../entries"; |
| 4 |
import { _ } from "../i18n"; |
| 5 |
import { currencies } from "../stores"; |
| 6 |
import AccountInput from "./AccountInput.svelte"; |
| 7 |
import AddMetadataButton from "./AddMetadataButton.svelte"; |
| 8 |
import EntryMetadataSvelte from "./EntryMetadata.svelte"; |
| 9 |
|
| 10 |
interface Props { |
| 11 |
entry: Balance; |
| 12 |
} |
| 13 |
|
| 14 |
let { entry = $bindable() }: Props = $props(); |
| 15 |
</script> |
| 16 |
|
| 17 |
<div> |
| 18 |
<div class="flex-row"> |
| 19 |
<input |
| 20 |
type="date" |
| 21 |
bind:value={ |
| 22 |
() => entry.date, |
| 23 |
(date: string) => { |
| 24 |
entry = entry.set("date", date); |
| 25 |
} |
| 26 |
} |
| 27 |
required |
| 28 |
/> |
| 29 |
<h4>{_("Balance")}</h4> |
| 30 |
<AccountInput |
| 31 |
className="grow" |
| 32 |
bind:value={ |
| 33 |
() => entry.account, |
| 34 |
(account: string) => { |
| 35 |
entry = entry.set("account", account); |
| 36 |
} |
| 37 |
} |
| 38 |
date={entry.date} |
| 39 |
required |
| 40 |
/> |
| 41 |
<input |
| 42 |
type="tel" |
| 43 |
pattern="-?[0-9.,]*" |
| 44 |
placeholder={_("Number")} |
| 45 |
size={10} |
| 46 |
bind:value={ |
| 47 |
() => entry.amount.number, |
| 48 |
(number: string) => { |
| 49 |
entry = entry.set("amount", { ...entry.amount, number }); |
| 50 |
} |
| 51 |
} |
| 52 |
required |
| 53 |
/> |
| 54 |
<AutocompleteInput |
| 55 |
className="currency" |
| 56 |
placeholder={_("Currency")} |
| 57 |
suggestions={$currencies} |
| 58 |
bind:value={ |
| 59 |
() => entry.amount.currency, |
| 60 |
(currency: string) => { |
| 61 |
entry = entry.set("amount", { ...entry.amount, currency }); |
| 62 |
} |
| 63 |
} |
| 64 |
required |
| 65 |
/> |
| 66 |
<AddMetadataButton |
| 67 |
bind:meta={ |
| 68 |
() => entry.meta, |
| 69 |
(meta: EntryMetadata) => { |
| 70 |
entry = entry.set("meta", meta); |
| 71 |
} |
| 72 |
} |
| 73 |
/> |
| 74 |
</div> |
| 75 |
<EntryMetadataSvelte |
| 76 |
bind:meta={ |
| 77 |
() => entry.meta, |
| 78 |
(meta: EntryMetadata) => { |
| 79 |
entry = entry.set("meta", meta); |
| 80 |
} |
| 81 |
} |
| 82 |
/> |
| 83 |
</div> |
| 84 |
|
| 85 |
<style> |
| 86 |
div :global(.currency) { |
| 87 |
width: 6em; |
| 88 |
} |
| 89 |
</style> |