Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Commit

Permalink
feat(Select): basic usage
Browse files Browse the repository at this point in the history
Signed-off-by: Florian-Schoenherr <florian.schoenherr99@gmail.com>
  • Loading branch information
Florian-Schoenherr committed Mar 21, 2021
1 parent 94f925f commit 7490744
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/svelte-materialify/src/components/Select/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
export let format = (val) => Array.isArray(val) ? val.map(v => getSelectString(v)).join(', ') : getSelectString(val);
const getSelectString = (v) => {
if(typeof v !== Object) return v;
const item = items.find(item => item.value === v);
return item ? item.name : emptyString;
}
Expand Down Expand Up @@ -56,7 +57,7 @@

<slot />
<div slot="content">
{#if chips}
{#if chips && value}
<span class="s-select__chips">
{#each Array.isArray(value) ? value : [value] as v}
<Chip>{v}</Chip>
Expand All @@ -73,14 +74,18 @@
<ListItemGroup bind:value {mandatory} {multiple} {max}>
{#each items as item}
<slot name="item" {item}>
<ListItem {dense} value={item.value}>
<span slot="prepend">
{#if multiple}
<Checkbox checked={value.includes(item.value)} />
{/if}
</span>
{item.name}
</ListItem>
{#if item.value}
<ListItem {dense} value={item.value}>
<span slot="prepend">
{#if multiple}
<Checkbox checked={value.includes(item.value)} />
{/if}
</span>
{item.name}
</ListItem>
{:else}
<ListItem value={item}>{item}</ListItem>
{/if}
</slot>
{/each}
</ListItemGroup>
Expand Down

0 comments on commit 7490744

Please sign in to comment.