From 4a7e9a28751cab0b6472ab2cca65c8a09a059c70 Mon Sep 17 00:00:00 2001 From: DTCurrie Date: Tue, 29 Aug 2023 10:36:01 -0400 Subject: [PATCH] Add stories and cleanup --- packages/core/src/lib/index.ts | 8 +- .../src/lib/select/searchable-select.svelte | 7 +- .../select/labeled-searchable-select.svelte | 30 +++++ .../select/searchable-select.stories.mdx | 109 ++++++++++++++++++ .../src/stories/select/select.stories.mdx | 4 +- 5 files changed, 148 insertions(+), 10 deletions(-) create mode 100644 packages/storybook/src/stories/select/labeled-searchable-select.svelte create mode 100644 packages/storybook/src/stories/select/searchable-select.stories.mdx diff --git a/packages/core/src/lib/index.ts b/packages/core/src/lib/index.ts index 646cc719e..7843a3152 100644 --- a/packages/core/src/lib/index.ts +++ b/packages/core/src/lib/index.ts @@ -11,6 +11,7 @@ export { default as Pill } from './pill.svelte'; export { default as Switch } from './switch.svelte'; export { default as Radio } from './radio.svelte'; export { default as Tabs } from './tabs.svelte'; +export { useUniqueId } from './unique-id'; export { default as Tooltip, @@ -34,12 +35,13 @@ export { type TextInputTypes, } from './input/text-input.svelte'; +export { default as Select, type SelectState } from './select/select.svelte'; +export { default as SearchableSelect } from './select/searchable-select.svelte'; +export { type SortOptions } from './select/search'; + export { default as Table, type TableVariant } from './table/table.svelte'; export { default as TableHeader } from './table/table-header.svelte'; export { default as TableHeaderCell } from './table/table-header-cell.svelte'; export { default as TableBody } from './table/table-body.svelte'; export { default as TableRow } from './table/table-row.svelte'; export { default as TableCell } from './table/table-cell.svelte'; -export { default as Select, type SelectState } from './select/select.svelte'; - -export * from './unique-id'; diff --git a/packages/core/src/lib/select/searchable-select.svelte b/packages/core/src/lib/select/searchable-select.svelte index f6036431e..b8c75d8d0 100644 --- a/packages/core/src/lib/select/searchable-select.svelte +++ b/packages/core/src/lib/select/searchable-select.svelte @@ -19,8 +19,8 @@ export let options: string[] = []; export let value: string | undefined = undefined; export let disabled = false; export let state: SelectState = 'none'; -export let button: { text: string; icon: string } | undefined = undefined; export let sort: SortOptions = 'default'; +export let button: { text: string; icon: string } | undefined = undefined; export let heading = ''; const dispatch = createEventDispatcher<{ @@ -31,8 +31,6 @@ const dispatch = createEventDispatcher<{ }>(); const menuId = useUniqueId('searchable-select'); - -let wrapper: Element; let menu: HTMLUListElement; let open = false; @@ -166,7 +164,6 @@ $: {
@@ -175,7 +172,7 @@ $: { bind:value role="combobox" aria-controls={menuId} - aria-expanded={open ? true : undefined} + aria-expanded={open} readonly={disabled ? true : undefined} aria-disabled={disabled ? true : undefined} type="text" diff --git a/packages/storybook/src/stories/select/labeled-searchable-select.svelte b/packages/storybook/src/stories/select/labeled-searchable-select.svelte new file mode 100644 index 000000000..95cedc8ba --- /dev/null +++ b/packages/storybook/src/stories/select/labeled-searchable-select.svelte @@ -0,0 +1,30 @@ + + + diff --git a/packages/storybook/src/stories/select/searchable-select.stories.mdx b/packages/storybook/src/stories/select/searchable-select.stories.mdx new file mode 100644 index 000000000..c2f82341e --- /dev/null +++ b/packages/storybook/src/stories/select/searchable-select.stories.mdx @@ -0,0 +1,109 @@ +import { Canvas, Meta, Story } from '@storybook/addon-docs'; +import { SearchableSelect } from '@viamrobotics/prime-core'; +import LabeledSelect from './labeled-searchable-select.svelte'; + + + +# Searchable Select + +A simple user input for selecting from a list of options. This is an implementation +of the native HTML `` with our styles applied. ## Labels For accessibility, consider wrapping your `