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

Commit

Permalink
feat(Select): emptyString and by default show name
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 c520de3 commit 63a9ba2
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
export let chips = false;
export let disabled = null;
export let closeOnClick = !multiple;
export let format = (val) => (Array.isArray(val) ? val.join(', ') : val);
export let emptyString = '';
export let format = (val) => Array.isArray(val) ? val.map(v => getSelectString(v)).join(', ') : getSelectString(val);
const getSelectString = (v) => {
const item = items.find(item => item.value === v);
return item ? item.name : emptyString;
}
const dispatch = createEventDispatcher();
$: dispatch('change', value);
</script>
Expand Down

0 comments on commit 63a9ba2

Please sign in to comment.