Mobile-first PWA: groups via key-in-fragment links, encrypted outbox and sync over SSE, all split modes, currencies with ECB rate prefill, photos, comments, history and rewind, stats, recurring expenses, CSV and backup, EN/CS, dark/light theme, Web Push decrypted in the service worker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
37 lines
1.3 KiB
Svelte
37 lines
1.3 KiB
Svelte
<script lang="ts">
|
|
import { currencyList } from '../lib/rates.ts';
|
|
import { currencyName } from '../lib/format.ts';
|
|
|
|
let { value = $bindable(), disabled = false, id }: { value: string; disabled?: boolean; id?: string } = $props();
|
|
let lists = $state<{ ecb: string[]; other: string[] }>({ ecb: [], other: [] });
|
|
currencyList().then((l) => (lists = l));
|
|
|
|
const recent = (() => {
|
|
try {
|
|
return JSON.parse(localStorage.getItem('oweme.recentCurrencies') ?? '[]') as string[];
|
|
} catch {
|
|
return [];
|
|
}
|
|
})();
|
|
// Keep the current value selectable even before the lists load, or if
|
|
// it's a code this browser doesn't know.
|
|
const ecb = $derived(
|
|
[...lists.ecb, ...lists.other, ...recent].includes(value) ? lists.ecb : [value, ...lists.ecb],
|
|
);
|
|
</script>
|
|
|
|
<select bind:value {disabled} {id}>
|
|
{#if recent.length}
|
|
<optgroup label="★">
|
|
{#each recent as c}<option value={c}>{c} · {currencyName(c)}</option>{/each}
|
|
</optgroup>
|
|
{/if}
|
|
<optgroup label="ECB">
|
|
{#each ecb as c}<option value={c}>{c} · {currencyName(c)}</option>{/each}
|
|
</optgroup>
|
|
{#if lists.other.length}
|
|
<optgroup label="…">
|
|
{#each lists.other as c}<option value={c}>{c} · {currencyName(c)}</option>{/each}
|
|
</optgroup>
|
|
{/if}
|
|
</select>
|