diff --git a/src/lib/select/Select.svelte b/src/lib/select/Select.svelte new file mode 100644 index 0000000..08cb5d6 --- /dev/null +++ b/src/lib/select/Select.svelte @@ -0,0 +1,82 @@ + + +{#if typeof as === "string"} + + {@render children?.(snippetProps)} + +{:else} + {@const AsComponent = as} + + {@render children?.(snippetProps)} + +{/if} diff --git a/src/lib/select/select.dom.test.ts b/src/lib/select/select.dom.test.ts new file mode 100644 index 0000000..947d1fd --- /dev/null +++ b/src/lib/select/select.dom.test.ts @@ -0,0 +1,18 @@ +import Select from "./Select.svelte"; +import { getInput, getSelect } from "../../test-utils/accessibility-assertions"; +import { focus, type, word } from "../../test-utils/interactions"; +import { + commonControlScenarios, + commonFormScenarios, + commonRenderingScenarios, +} from "../../test-utils/scenarios.dom"; + +commonRenderingScenarios(Select, { getElement: getSelect }); +commonControlScenarios(Select); +commonFormScenarios(Select, { + async performUserInteraction(control) { + if (control instanceof HTMLSelectElement) { + control.value = 'alice' + } + }, +}); diff --git a/src/routes/(main)/nav.svelte b/src/routes/(main)/nav.svelte index bcd3b14..c1a84c7 100644 --- a/src/routes/(main)/nav.svelte +++ b/src/routes/(main)/nav.svelte @@ -1,5 +1,5 @@ diff --git a/src/routes/examples/select/+page.svelte b/src/routes/examples/select/+page.svelte new file mode 100644 index 0000000..5031693 --- /dev/null +++ b/src/routes/examples/select/+page.svelte @@ -0,0 +1,28 @@ + + + + + Project status + + + + Active + Paused + Delayed + Canceled + + + + + +