OpenSource Projekt-Management-Software
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

29 lines
613 B

<script>
let { editable = false, currency, value = $bindable(null) } = $props();
let editing = $state(false);
function toggleEdit(){
editing = !editing;
if (editing){
value /= 100;
}
}
function typed(ev){
if (ev.keyCode == 13) {
toggleEdit();
value *= 100;
}
}
</script>
<style>
input{width:100px}
</style>
{#if editable && editing}
<input type="number" step=".01" bind:value onkeyup={typed} />&nbsp;{currency}
{:else}
<div onclick={toggleEdit}>{Number(value/100).toFixed(2)}&nbsp;{currency}</div>
{/if}