Skip to content

Commit aa464ce

Browse files
committed
fix: #1631
fix: change MultiSelectProps extends to HTMLAttributes HTMLDivElement and move ...restProps to div
1 parent 311cf73 commit aa464ce

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/lib/forms/select/MultiSelect.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@
9292
</script>
9393

9494
<!-- Hidden select for form submission -->
95-
<select {...restProps} {value} hidden multiple>
95+
<select {value} hidden multiple>
9696
{#each items as { value, name, disabled }}
9797
<option {value} {disabled}>{name}</option>
9898
{/each}
9999
</select>
100-
<div onclick={toggleDropdown} onfocusout={closeDropdown} onkeydown={handleKeyDown} tabindex="0" role="listbox" class={cn(base({ size }), className)}>
100+
<div {...restProps} onclick={toggleDropdown} onfocusout={closeDropdown} onkeydown={handleKeyDown} tabindex="0" role="listbox" class={cn(base({ size }), className)}>
101101
{#if !selectItems.length}
102102
<span class="text-gray-400">{placeholder}</span>
103103
{/if}

src/lib/types.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { fade, fly, scale, slide } from "svelte/transition";
22
import type { Coords, Middleware, Placement, Strategy } from "@floating-ui/dom";
33
import type { ClassValue } from "clsx";
44
import type { Component, Snippet } from "svelte";
5-
import type { HTMLAnchorAttributes, HTMLAttributes, HTMLBlockquoteAttributes, HTMLButtonAttributes, HTMLDialogAttributes, HTMLImgAttributes, HTMLInputAttributes, HTMLLabelAttributes, HTMLLiAttributes, HTMLOlAttributes, HTMLProgressAttributes, HTMLSelectAttributes, HTMLSourceAttributes, HTMLTableAttributes, HTMLTdAttributes, HTMLTextareaAttributes, HTMLThAttributes, HTMLTrackAttributes, HTMLVideoAttributes, SVGAttributes } from "svelte/elements";
5+
import type { HTMLAnchorAttributes, HTMLAttributes, HTMLBlockquoteAttributes, HTMLButtonAttributes, HTMLDialogAttributes, HTMLImgAttributes, HTMLInputAttributes, HTMLLabelAttributes, HTMLLiAttributes, HTMLOlAttributes, HTMLProgressAttributes, HTMLSelectAttributes, HTMLSourceAttributes, HTMLTableAttributes, HTMLTdAttributes, HTMLTextareaAttributes, HTMLThAttributes, HTMLTrackAttributes, HTMLVideoAttributes, SVGAttributes, FullAutoFill } from "svelte/elements";
66
import { type Writable } from "svelte/store";
77
import type { BlurParams, EasingFunction, FadeParams, FlyParams, ScaleParams, SlideParams, TransitionConfig } from "svelte/transition";
88
import { tv, type VariantProps } from "tailwind-variants";
@@ -854,13 +854,28 @@ export interface SelectProps<T> extends SelectVariants, Omit<HTMLSelectAttribute
854854
disabled?: boolean;
855855
}
856856

857-
export interface MultiSelectProps<T> extends MultiSelectVariants, Omit<HTMLSelectAttributes, "size" | "children"> {
857+
// export interface MultiSelectProps<T> extends MultiSelectVariants, Omit<HTMLSelectAttributes, "size" | "children"> {
858+
// children?: Snippet<[{ item: SelectOptionType<T>; clear: () => void }]>;
859+
// items: SelectOptionType<T>[];
860+
// value: T[];
861+
// dropdownClass?: ClassValue;
862+
// placeholder?: string;
863+
// disabled?: boolean;
864+
// }
865+
export interface MultiSelectProps<T> extends
866+
MultiSelectVariants, Omit<HTMLAttributes<HTMLDivElement>, "size" | "children"> {
858867
children?: Snippet<[{ item: SelectOptionType<T>; clear: () => void }]>;
859868
items: SelectOptionType<T>[];
860869
value: T[];
861870
dropdownClass?: ClassValue;
862871
placeholder?: string;
863-
disabled?: boolean;
872+
disabled?: boolean | undefined ;
873+
size?: "sm" | "md" | "lg";
874+
// Select-specific attributes for the hidden select element
875+
name?: string | undefined | null;
876+
form?: string | undefined | null;
877+
required?: boolean | undefined | null;
878+
autocomplete?: FullAutoFill | undefined | null;
864879
}
865880

866881
// Tags

0 commit comments

Comments
 (0)