-
Notifications
You must be signed in to change notification settings - Fork 158
/
Copy pathradioBoxes.svelte
41 lines (38 loc) · 1.25 KB
/
radioBoxes.svelte
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
<script lang="ts">
import { InputRadio } from '$lib/elements/forms';
export let total: number;
export let variableName: string = '$id';
export let elements: Record<string, unknown>[];
export let group: string;
export let name: string;
export let disabledCondition: string = null;
</script>
<div class:boxes-wrapper={total} data-private>
{#if total}
{#each elements as element}
{@const value = element[variableName]?.toString()}
<div class="box" data-private>
<InputRadio
id={`${name}-${value}`}
{value}
{name}
bind:group
disabled={disabledCondition ? value === disabledCondition : false}>
<slot name="element" {element} />
</InputRadio>
</div>
{/each}
{/if}
<div class="box">
{#if total}
<InputRadio id="payment-method" value={null} {name} bind:group>
<slot name="new">
<span style="padding-inline:0.25rem">Add new {name}</span>
</slot>
</InputRadio>
{/if}
{#if group === null}
<slot />
{/if}
</div>
</div>