feat(component): add MultiSelect

Closes #19
This commit is contained in:
Eric Liu 2019-12-31 12:55:57 -08:00
commit 02ba8cb6ee
10 changed files with 410 additions and 6 deletions

View file

@ -7,21 +7,28 @@
export let translateWithId = id => defaultTranslations[id];
export let style = undefined;
import { createEventDispatcher } from 'svelte';
import { createEventDispatcher, getContext } from 'svelte';
import Close16 from 'carbon-icons-svelte/lib/Close16';
import { cx } from '../../lib';
const dispatch = createEventDispatcher();
const defaultTranslations = {
[translationIds.clearAll]: 'Clear all selected items',
[translationIds.clearSelection]: 'Clear selected item'
};
const dispatch = createEventDispatcher();
const ctx = getContext('MultiSelect');
let selectionRef = undefined;
$: if (ctx && selectionRef) {
ctx.declareRef({ key: 'selection', ref: selectionRef });
}
$: description = selectionCount ? translateWithId('clearAll') : translateWithId('clearSelection');
</script>
<div
bind:this={selectionRef}
role="button"
aria-label="Clear Selection"
tabindex={disabled ? '-1' : '0'}