Skip to content

Commit

Permalink
feat: add <T> to SelectOptionType and update Select and MultiSelect (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
shinokada authored Sep 10, 2023
1 parent a804f71 commit bf97642
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/lib/forms/MultiSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
const dispatch = createEventDispatcher();
export let items: SelectOptionType[] = [];
export let items: SelectOptionType<any>[] = [];
export let value: (string | number)[] = [];
export let size: FormSizeType = 'md';
export let dropdownClass: string = '';
let selectItems: SelectOptionType[] = [];
let selectItems: SelectOptionType<any>[] = [];
let show: boolean = false;
const sizes = {
Expand Down Expand Up @@ -44,7 +44,7 @@
}
});
const selectOption = (select: SelectOptionType) => {
const selectOption = (select: SelectOptionType<any>) => {
if (selectItems.includes(select)) {
clearThisOption(select);
} else {
Expand All @@ -63,7 +63,7 @@
dispatch('selected', selectItems);
};
const clearThisOption = (select: SelectOptionType) => {
const clearThisOption = (select: SelectOptionType<any>) => {
if (selectItems.includes(select)) {
selectItems = selectItems.filter((o) => o !== select);
dispatch('selected', selectItems);
Expand Down Expand Up @@ -119,7 +119,7 @@
@component
[Go to docs](https://flowbite-svelte.com/)
## Props
@prop export let items: SelectOptionType[] = [];
@prop export let items: SelectOptionType<any>[] = [];
@prop export let value: (string | number)[] = [];
@prop export let size: FormSizeType = 'md';
@prop export let dropdownClass: string = '';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/forms/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { twMerge } from 'tailwind-merge';
import type { SelectOptionType } from '../types';
export let items: SelectOptionType[] = [];
export let items: SelectOptionType<any>[] = [];
export let value: any = undefined;
export let placeholder: string = 'Choose option ...';
export let underline: boolean = false;
Expand Down Expand Up @@ -39,7 +39,7 @@
@component
[Go to docs](https://flowbite-svelte.com/)
## Props
@prop export let items: SelectOptionType[] = [];
@prop export let items: SelectOptionType<any>[] = [];
@prop export let value: any = undefined;
@prop export let placeholder: string = 'Choose option ...';
@prop export let underline: boolean = false;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export type ReviewType = {
item3: string | undefined;
};

export type SelectOptionType = {
export type SelectOptionType<T> = {
name: string | number;
value: string | number;
value: T;
};

export type TransitionTypes = 'fade' | 'fly' | 'slide' | 'blur' | 'in:fly' | 'out:fly' | 'in:slide' | 'out:slide' | 'in:fade' | 'out:fade' | 'in:blur' | 'out:blur';
Expand Down

2 comments on commit bf97642

@vercel
Copy link

@vercel vercel bot commented on bf97642 Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on bf97642 Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.