-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86118e6
commit afc9298
Showing
4 changed files
with
92 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './prompt.css'; | ||
export * from './prompt'; |
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,79 @@ | ||
import { CachedDataset } from './util'; | ||
type Command = | ||
/** | ||
* HTML selector | ||
*/ | ||
string | ||
/** | ||
* HTML element | ||
*/ | ||
| HTMLElement; | ||
type MaybeHTMLElement = HTMLElement | null; | ||
type PromptElements = { | ||
prompt: TPrompt; | ||
content: HTMLElement; | ||
root: HTMLElement; | ||
isDetails: boolean; | ||
isModal: boolean; | ||
isEscapable?: boolean; | ||
isFocusFirst?: boolean; | ||
focusFirstSelector?: string; | ||
touchLayer?: MaybeHTMLElement; | ||
toggle?: MaybeHTMLElement; | ||
escapeListener: (e: KeyboardEvent) => void; | ||
clickTouchLayerListener: (e: MouseEvent) => void; | ||
clickToggleListener: (e: Event) => void; | ||
firstFocusable?: HTMLElement; | ||
}; | ||
export type PromptStatus = { | ||
isOpen: boolean; | ||
willShow: boolean; | ||
didShow: boolean; | ||
willHide: boolean; | ||
didHide: boolean; | ||
}; | ||
export type Options = { | ||
willShow?: (elements?: PromptElements) => void; | ||
didShow?: (elements?: PromptElements) => void; | ||
willHide?: (elements?: PromptElements) => void; | ||
didHide?: (elements?: PromptElements) => void; | ||
getStatus?: (status: PromptStatus) => void; | ||
isIgnoreLockDuration?: boolean; | ||
}; | ||
export type TPrompt = { | ||
el?: MaybeHTMLElement; | ||
init: (command: Command) => void; | ||
toggle: (command: Command, options?: Options) => void; | ||
show: (command: Command, options?: Options) => void; | ||
hide: (command: Command, options?: Options) => void; | ||
options?: Options; | ||
/** | ||
* Phoenix LiveView callback. | ||
*/ | ||
mounted: () => void; | ||
/** | ||
* Phoenix LiveView callback. | ||
*/ | ||
beforeUpdate: () => void; | ||
/** | ||
* Phoenix LiveView callback. | ||
*/ | ||
updated: () => void; | ||
/** | ||
* Phoenix LiveView callback. | ||
*/ | ||
destroyed: () => void; | ||
status: PromptStatus; | ||
/** | ||
* Phoenix LiveView specific. | ||
* Cached values of the dataset values of the root element, so that the state can be restored after an update. | ||
*/ | ||
_cache: CachedDataset; | ||
}; | ||
export declare const Prompt: TPrompt; | ||
declare global { | ||
interface Window { | ||
Prompt?: TPrompt; | ||
} | ||
} | ||
export {}; |
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,10 @@ | ||
export declare const wait: (m: number) => Promise<unknown>; | ||
export declare const getDuration: (domElement: HTMLElement) => number; | ||
export declare const repaint: (element: HTMLElement) => number; | ||
export declare const isVisible: (element: HTMLElement) => boolean; | ||
export declare const getFirstFocusable: (content: HTMLElement) => HTMLElement; | ||
export type CachedDataset = Record<string, string>; | ||
export declare const storeDataset: (cache: CachedDataset, id?: string, dataset?: DOMStringMap) => void; | ||
export declare const readDataset: (cache: CachedDataset, id?: string) => any; | ||
export declare const clearDataset: (cache: CachedDataset, id?: string) => void; | ||
export declare const applyDataset: (dataset: DOMStringMap, el?: HTMLElement | null) => void; |
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