mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-29 22:11:22 +00:00

- internal API has been moved to a constructor variable. - added reconnect with exponential backoff - initial tests of SSE features are working - added many JSDoc comments in the process. - added link to "sse triggers" test
64 lines
2.6 KiB
TypeScript
64 lines
2.6 KiB
TypeScript
export interface HtmxApi {
|
|
config?: HtmxConfig
|
|
logger?: (a: HTMLElement, b: Event, c: any) => void | null
|
|
on: (event:string, listener:EventListener) => void
|
|
}
|
|
|
|
export interface HtmxConfig {
|
|
historyEnabled?: boolean;
|
|
historyCacheSize?: number;
|
|
refreshOnHistoryMiss?: boolean;
|
|
defaultSwapStyle?: 'innerHTML' | string;
|
|
defaultSwapDelay?: number;
|
|
defaultSettleDelay?: number;
|
|
includeIndicatorStyles?: boolean;
|
|
indicatorClass?: 'htmx-indicator' | string;
|
|
requestClass?: 'htmx-request' | string;
|
|
settlingClass?: 'htmx-settling' | string;
|
|
swappingClass?: 'htmx-swapping' | string;
|
|
addedClass?: string;
|
|
allowEval?: boolean;
|
|
timeout: number;
|
|
attributesToSettle?: ["class", "style", "width", "height"] | string[];
|
|
withCredentials?: boolean;
|
|
wsReconnectDelay?: 'full-jitter' | string;
|
|
disableSelector?: "[hx-disable], [data-hx-disable]" | string;
|
|
useTemplateFragments?: boolean;
|
|
scrollBehavior: string;
|
|
}
|
|
|
|
export declare var htmx: HtmxApi
|
|
|
|
export interface HtmxExtension {
|
|
init: (api: HtmxInternalApi) => void;
|
|
onEvent: (name: string, event: Event) => boolean;
|
|
transformResponse: (text: string, xhr: XMLHttpRequest, elt: HTMLElement) => string;
|
|
isInlineSwap: (swapStyle: string) => boolean;
|
|
handleSwap: (swapStyle: string, target: HTMLElement, fragment: string, settleInfo: Object) => boolean;
|
|
encodeParameters: (xhr: XMLHttpRequest, parameters: Object, elt: HTMLElement) => void;
|
|
}
|
|
|
|
export interface HtmxInternalApi {
|
|
bodyContains: (element: HTMLElement) => boolean
|
|
hasAttribute: (element: HTMLElement, qualifiedName: string) => boolean
|
|
getAttributeValue: (element: HTMLElement, qualifiedName: string) => string | null
|
|
getInternalData: (element: HTMLElement) => Object
|
|
getSwapSpecification: (element: HTMLElement) => HtmxSwapSpecification
|
|
getTarget: (element: HTMLElement) => object
|
|
makeSettleInfo: () => Object
|
|
selectAndSwap: (swapStyle: any, target: any, elt: any, responseText: any, settleInfo: any) => void // TODO: improve parameter definitions
|
|
settleImmediately: (tasks: any) => void // TODO: improve parameter definitions
|
|
triggerEvent: (element: HTMLElement, eventName: string, detail: any) => void
|
|
triggerErrorEvent: (element: HTMLElement, eventName: string, detail: any) => void
|
|
withExtensions: (element: HTMLElement, toDo:(ext:HtmxExtension) => void) => void
|
|
}
|
|
|
|
export interface HtmxSwapSpecification {
|
|
swapStyle: string
|
|
swapDelay: number
|
|
settleDelay: number
|
|
show?: string
|
|
showTarget?: string
|
|
scroll?: string
|
|
scrollTarget?: string
|
|
} |