-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update deps * move lib types to new src/lib/types.ts * MultiSelect don't import from src/lib/index.ts * rename GenericOption -> T
- Loading branch information
Showing
4 changed files
with
61 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
export type Option = string | number | ObjectOption | ||
|
||
export type ObjectOption = { | ||
label: string | number // user-displayed text | ||
value?: unknown // associated value, can be anything incl. objects (defaults to label if undefined) | ||
title?: string // on-hover tooltip | ||
disabled?: boolean // make this option unselectable | ||
preselected?: boolean // make this option selected on page load (before any user interaction) | ||
disabledTitle?: string // override the default disabledTitle = 'This option is disabled' | ||
selectedTitle?: string // tooltip to display when this option is selected and hovered | ||
[key: string]: unknown // allow any other keys users might want | ||
} | ||
|
||
export type DispatchEvents<T = Option> = { | ||
add: { option: T } | ||
create: { option: T } | ||
remove: { option: T } | ||
removeAll: { options: T[] } | ||
change: { | ||
option?: T | ||
options?: T[] | ||
type: 'add' | 'remove' | 'removeAll' | ||
} | ||
open: { event: Event } | ||
close: { event: Event } | ||
} | ||
|
||
export type MultiSelectEvents = { | ||
[key in keyof DispatchEvents]: CustomEvent<DispatchEvents[key]> | ||
} & { | ||
blur: FocusEvent | ||
click: MouseEvent | ||
focus: FocusEvent | ||
keydown: KeyboardEvent | ||
keyup: KeyboardEvent | ||
mouseenter: MouseEvent | ||
mouseleave: MouseEvent | ||
touchcancel: TouchEvent | ||
touchend: TouchEvent | ||
touchmove: TouchEvent | ||
touchstart: TouchEvent | ||
} |