diff --git a/README.md b/README.md index f91f62e2..08d735ce 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,12 @@ Currently, the following components are supported: - IconSkeleton - InlineLoading - Link +- ListBox + - ListBoxField + - ListBoxMenu + - ListBoxMenuIcon + - ListBoxMenuItem + - ListBoxSelection - ListItem - Loading - Modal diff --git a/src/components/ListBox/ListBox.svelte b/src/components/ListBox/ListBox.svelte new file mode 100644 index 00000000..dab0acc5 --- /dev/null +++ b/src/components/ListBox/ListBox.svelte @@ -0,0 +1,33 @@ + + +
{ + if (event.key === 'Escape') { + event.stopPropagation(); + } + }} + on:click|preventDefault|stopPropagation + {style}> + +
+{#if invalid} +
{invalidText}
+{/if} diff --git a/src/components/ListBox/ListBoxField.svelte b/src/components/ListBox/ListBoxField.svelte new file mode 100644 index 00000000..76a26826 --- /dev/null +++ b/src/components/ListBox/ListBoxField.svelte @@ -0,0 +1,32 @@ + + +
+ +
diff --git a/src/components/ListBox/ListBoxMenu.svelte b/src/components/ListBox/ListBoxMenu.svelte new file mode 100644 index 00000000..8d166cd7 --- /dev/null +++ b/src/components/ListBox/ListBoxMenu.svelte @@ -0,0 +1,14 @@ + + +
+ +
diff --git a/src/components/ListBox/ListBoxMenuIcon.svelte b/src/components/ListBox/ListBoxMenuIcon.svelte new file mode 100644 index 00000000..65fea09f --- /dev/null +++ b/src/components/ListBox/ListBoxMenuIcon.svelte @@ -0,0 +1,22 @@ + + +
+ +
diff --git a/src/components/ListBox/ListBoxMenuItem.svelte b/src/components/ListBox/ListBoxMenuItem.svelte new file mode 100644 index 00000000..3ed2b7d9 --- /dev/null +++ b/src/components/ListBox/ListBoxMenuItem.svelte @@ -0,0 +1,17 @@ + + +
+
+ +
+
diff --git a/src/components/ListBox/ListBoxSelection.svelte b/src/components/ListBox/ListBoxSelection.svelte new file mode 100644 index 00000000..16248b0a --- /dev/null +++ b/src/components/ListBox/ListBoxSelection.svelte @@ -0,0 +1,45 @@ + + +
{ + if (!disabled) { + dispatch('clear', event); + } + }} + on:keydown + on:keydown|stopPropagation={event => { + if (!disabled && event.key === 'Enter') { + dispatch('clear', event); + } + }} + {style}> + {selectionCount} + +
diff --git a/src/components/ListBox/index.js b/src/components/ListBox/index.js new file mode 100644 index 00000000..7bf4f8ea --- /dev/null +++ b/src/components/ListBox/index.js @@ -0,0 +1,8 @@ +import ListBox from './ListBox.svelte'; + +export default ListBox; +export { default as ListBoxField } from './ListBoxField.svelte'; +export { default as ListBoxMenu } from './ListBoxMenu.svelte'; +export { default as ListBoxMenuIcon } from './ListBoxMenuIcon.svelte'; +export { default as ListBoxMenuItem } from './ListBoxMenuItem.svelte'; +export { default as ListBoxSelection } from './ListBoxSelection.svelte'; diff --git a/src/index.js b/src/index.js index 4bd68d5e..c4fd2688 100644 --- a/src/index.js +++ b/src/index.js @@ -22,6 +22,13 @@ import FormLabel from './components/FormLabel'; import Icon, { IconSkeleton } from './components/Icon'; import InlineLoading from './components/InlineLoading'; import Link from './components/Link'; +import ListBox, { + ListBoxField, + ListBoxMenu, + ListBoxMenuIcon, + ListBoxMenuItem, + ListBoxSelection +} from './components/ListBox'; import ListItem from './components/ListItem'; import Loading from './components/Loading'; import Modal from './components/Modal'; @@ -117,6 +124,12 @@ export { Modal, InlineNotification, Link, + ListBox, + ListBoxField, + ListBoxMenu, + ListBoxMenuIcon, + ListBoxMenuItem, + ListBoxSelection, ListItem, Loading, NotificationActionButton,