Skip to content

Commit

Permalink
feat(rdom-components): update dropdown generics
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jul 9, 2022
1 parent 6be320a commit 11809c7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/rdom-components/src/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export interface DropdownOpts<T> {
value: Fn<T, string>;
}

export const dynamicDropdown = <T = string>(
export const dynamicDropdown = <T = string, S extends string = string>(
items: ISubscribable<T[]>,
sel: Subscription<string, string>,
sel: Subscription<S, S>,
opts?: Partial<DropdownOpts<T>>
) => {
opts = {
Expand All @@ -28,9 +28,9 @@ export const dynamicDropdown = <T = string>(
);
};

export const staticDropdown = <T = string>(
export const staticDropdown = <T = string, S extends string = string>(
items: T[],
sel: Subscription<string, string>,
sel: Subscription<S, S>,
opts?: Partial<DropdownOpts<T>>
) => {
opts = {
Expand All @@ -45,7 +45,10 @@ export const staticDropdown = <T = string>(
};

const $option =
<T>(sel: Subscription<string, string>, { label, value }: DropdownOpts<T>) =>
<T, S extends string>(
sel: Subscription<S, S>,
{ label, value }: DropdownOpts<T>
) =>
(x: T) => {
let v = value(x);
return option(
Expand Down

0 comments on commit 11809c7

Please sign in to comment.