Skip to content

Commit

Permalink
Restore types
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurClemens committed Aug 14, 2024
1 parent 86118e6 commit afc9298
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './prompt.css';
export * from './prompt';
79 changes: 79 additions & 0 deletions dist/prompt.d.ts
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 {};
10 changes: 10 additions & 0 deletions dist/util.d.ts
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;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dialogic-js",
"version": "0.5.3",
"version": "0.5.4",
"description": "Control the opening and closing of dialogs and menus using HTML and (optionally) vanilla JavaScript.",
"types": "dist",
"files": [
Expand Down

0 comments on commit afc9298

Please sign in to comment.