electerious / basicLightbox

The lightest lightbox ever made.

Home Page:https://basiclightbox.electerious.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add types to work with typescript (index.d.ts)

jhm-ciberman opened this issue · comments

Hi!
I have writted the index.d.ts file for basiclightbox. Please add it to the project so all typescript users can use basiclightbox with typescript 😄

(you can google how to add typings to your npm package, if you have troubles I can create the PR for you, it's just that atm I have no free time)

// Type definitions for basiclightbox 4.0.3
// Project: BasicLightBox
// Definitions by: Javier "Ciberman" Mora <https://github.com/jhm-ciberman>

declare module "basiclightbox" {


	export interface Options {
		/*
		 * Prevents the lightbox from closing when clicking its background.
		 */
		closable?: boolean;
		/*
		 * One or more space separated classes to be added to the basicLightbox element.
		 * Must be a string or a function which returns a string.
		 */
		className?: null | string | (() => string);
		/*
		 * Callback functions.
		 * Returning false will stop the caller function and prevent the lightbox from showing or closing.
		 */
		beforeShow?: ((instance: Instance) => (boolean | void));
		/*
		 * Callback functions.
		 * Returning false will stop the caller function and prevent the lightbox from showing or closing.
		 */
		afterShow?: ((instance: Instance) => (boolean | void));
		/*
		 * Callback functions.
		 * Returning false will stop the caller function and prevent the lightbox from showing or closing.
		 */
		beforeClose?: ((instance: Instance) => (boolean | void));
		/*
		 * Callback functions.
		 * Returning false will stop the caller function and prevent the lightbox from showing or closing.
		 */
		afterClose?: ((instance: Instance) => (boolean | void));
		/*
		 * String containing HTML or function which returns a string of HTML.
		 * Will be added before or after the content placeholder of the lightbox.
		 */
		beforePlaceholder?: string | (() => string);
		afterPlaceholder?: string | (() => string);
	}

	export interface Instance {
		/**
		 * Shows a lightbox instance.
		 * @param callback A function that gets executed as soon as the lightbox starts to fade in.
		 */
		show(callback?: () => void): void;
		/**
		 * Closes a lightbox instance.
		 * @param callback A function that gets executed as soon as the lightbox has been faded out.
		 */
		close(callback?: () => void): void;
		/**
		 * Returns true when the lightbox instance is visible. Also returns true when the lightbox is currently in the process of showing/hiding and not fully visible/hidden, yet.
		 */
		visible(): boolean;
		/**
		 * Returns the Node object associated with the instance.
		 */
		element(): Node;
	}

	/**
	 * Creates a new basicLightbox instance.
	 *
	 * Be sure to assign your instance to a variable. Using your instance, you can…
	 *
	 * …show and hide the lightbox.
	 * …check if the the lightbox is visible.
	 * …modify the content of the lightbox.
	 *
	 * @param html Content of the lightbox.
	 * @param opts An object of options.
	 */
	export function create(html: string, opts?: Options): Instance;

	/**
	 * Returns true when a lightbox is visible. Also returns true when a lightbox is currently in the process of showing/hiding and not fully visible/hidden, yet.
	 */
	export function visible(): boolean;
}

Hi @jhm-ciberman! Thanks for your work, but I'm not planning to add TypeScript to basicLightbox. This package should stay simple and clean + I'm not a TypeScript user and therefore can't and won't maintain it.