blob: aae258c8d173c0f507e2b01c22a93a4ac23a9c04 (
plain) (
blame)
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
|
<script lang="ts">
import PhLightningFill from "virtual:icons/ph/lightning-fill";
import { t } from "$lib/translations";
import { tick } from "svelte";
import Numpad from "$comp/Numpad.svelte";
let {
amount = $bindable(),
none = $t("accounts.none"),
desc = "",
currency,
rate,
label = "",
name = "",
locale = undefined,
submit = undefined,
element = undefined,
}: any = $props();
let setting = $state();
let set = () => {
setting = false;
};
let done = $state();
let startSetting = async () => {
setting = true;
await tick();
numpad.focus();
};
let numpad: HTMLDivElement = $state() as HTMLDivElement;
</script>
<div>
<label for="name" class="font-bold mb-1 block">{label}</label>
{#if desc}
<p class="text-secondary my-2">{desc}</p>
{/if}
<button type="button" class="flex w-full" onclick={startSetting}>
<div class="p-4 border rounded-2xl rounded-r-none border-r-0 bg-base-200">
<PhLightningFill width="20" class="text-yellow-300" />
</div>
<div class="border-l-0 rounded-l-none pl-2 w-full p-4 border rounded-2xl text-left">
{amount || none}
</div>
<input type="hidden" {name} bind:value={amount} />
</button>
</div>
{#if setting}
<div class="fixed bg-base-100/90 inset-0 overflow-y-auto h-full w-full z-50 max-w-lg mx-auto">
<div class="relative p-5 border shadow-lg rounded-md bg-base-100 space-y-5">
<h1 class="text-center text-2xl font-semibold">{label}</h1>
<Numpad bind:amount {currency} {rate} {locale} bind:submit={done} bind:element={numpad} />
<button bind:this={done} type="button" onclick={set} class="btn">Ok</button>
</div>
</div>
{/if}
|