UNPKG

bona

Version:

Super lightweight microframework focused on static websites and landing pages.

187 lines 5.67 kB
/** * @typedef {Object} BonaAjaxProps * @property {boolean} [bindLinks] Handle all links on the page. * @property {boolean} [bindHistory] Handle history changes. * @property {RegExp} [checkLinkUrlRegExp] RegExp to check link URL eligibility. * @property {boolean} [restoreScrollHistory] Restore the window scroll after the history change. * @property {string} [scrollRestoration] Scroll restoration behavior on history navigation. * * @typedef {Object} BonaReqOptions * @property {boolean} [checkResponseStatus] Check the response status and redirect if an error occurs. * @property {string|boolean} [history] Push or replace history. * @property {object} [historyState] Pass history state object. * @property {boolean} [preventSame] Prevent goTo to the same URLs. * @property {boolean} [preventHash] Prevent goTo to hashes. * @property {boolean} [preventRunning] Prevent goTo when a transition is already running. * @property {DOMParserSupportedType} [parserType] Specifies the parser type used to parse the DOM. * @property {string[]} [updateSelectors] Selectors to update. * @property {boolean} [extendNodes] Extend or replace new nodes. * @property {boolean} [removeNodes] Remove non-existent nodes. * @property {boolean} [detachNodes] Detach non-existent nodes from store. * @property {boolean} [resetScroll] Reset the window scroll after an update. * @property {boolean} [restoreScroll] Restore the window scroll after an update. * @property {boolean} [scrollToHash] Scroll to hashes after an update. * @property {boolean} [fireLeave] Fire leave hook. * @property {boolean} [fireLoaded] Fire loaded hook. * @property {boolean} [fireRefresh] Fire refresh ho.ok. * @property {boolean} [fireEnter] Fire enter hook. * @property {boolean} [fireComplete] Fire complete hook. * @property {boolean} [fireDestroy] Fire destroy hook. * @property {object} [fetch] Fetch options. * * @typedef {BonaAjaxProps & BonaReqOptions} BonaAjaxOptions */ export default class Ajax extends Component { constructor(...args: any[]); /** @type {BonaAjaxOptions} **/ options: BonaAjaxOptions; event: {}; scroll: {}; parser: DOMParser; running: boolean; url: URL; prevUrl: URL; /** * Handle all links on the page. */ bindLinks(): void; /** * Handle history change. */ bindHistory(): void; /** * Push or replace url in history. * * @param {string} url Url. * @param {string} [method] Push or replace. * @param {object} [state] History state object. */ pushHistory(url: string, method?: string, state?: object): void; /** * Go to a new location. * * @param {string} url URL. * @param {BonaReqOptions} [options] Request options. * @return {Promise} */ goTo(url: string, options?: BonaReqOptions): Promise<any>; /** * Execute prepared request. * * @param {string} url Url. * @param {BonaReqOptions} [options] Request options. * @return {Promise} */ executeRequest(url: string, options?: BonaReqOptions): Promise<any>; } export type BonaAjaxProps = { /** * Handle all links on the page. */ bindLinks?: boolean; /** * Handle history changes. */ bindHistory?: boolean; /** * RegExp to check link URL eligibility. */ checkLinkUrlRegExp?: RegExp; /** * Restore the window scroll after the history change. */ restoreScrollHistory?: boolean; /** * Scroll restoration behavior on history navigation. */ scrollRestoration?: string; }; export type BonaReqOptions = { /** * Check the response status and redirect if an error occurs. */ checkResponseStatus?: boolean; /** * Push or replace history. */ history?: string | boolean; /** * Pass history state object. */ historyState?: object; /** * Prevent goTo to the same URLs. */ preventSame?: boolean; /** * Prevent goTo to hashes. */ preventHash?: boolean; /** * Prevent goTo when a transition is already running. */ preventRunning?: boolean; /** * Specifies the parser type used to parse the DOM. */ parserType?: DOMParserSupportedType; /** * Selectors to update. */ updateSelectors?: string[]; /** * Extend or replace new nodes. */ extendNodes?: boolean; /** * Remove non-existent nodes. */ removeNodes?: boolean; /** * Detach non-existent nodes from store. */ detachNodes?: boolean; /** * Reset the window scroll after an update. */ resetScroll?: boolean; /** * Restore the window scroll after an update. */ restoreScroll?: boolean; /** * Scroll to hashes after an update. */ scrollToHash?: boolean; /** * Fire leave hook. */ fireLeave?: boolean; /** * Fire loaded hook. */ fireLoaded?: boolean; /** * Fire refresh ho.ok. */ fireRefresh?: boolean; /** * Fire enter hook. */ fireEnter?: boolean; /** * Fire complete hook. */ fireComplete?: boolean; /** * Fire destroy hook. */ fireDestroy?: boolean; /** * Fetch options. */ fetch?: object; }; export type BonaAjaxOptions = BonaAjaxProps & BonaReqOptions; import Component from "../component"; //# sourceMappingURL=index.d.ts.map