diff --git a/types/js-captcha/dist/js/jCaptcha.d.ts b/types/js-captcha/dist/js/jCaptcha.d.ts new file mode 100644 index 0000000000..64aed8df30 --- /dev/null +++ b/types/js-captcha/dist/js/jCaptcha.d.ts @@ -0,0 +1,32 @@ +declare namespace jCaptcha { + /** + * Options for the base jCaptcha class. Derived from https://github.com/robiveli/js-captcha#options + */ + interface Options { + el?: string; + + requiredValue?: string; + + resetOnError?: boolean; + focusOnError?: boolean; + clearOnSubmit?: boolean; + + canvasWidth?: number; + canvasHeight?: number; + canvasFontSize?: string; + canvasFontFamily?: string; + canvasFillStyle?: string; + + callback?: (response: "success" | "error", input: NodeListOf) => void; + } +} + +declare class jCaptcha { + constructor(options?: jCaptcha.Options); + + validate(): void; + reset(): void; +} + +export = jCaptcha; +export as namespace jCaptcha; diff --git a/types/js-captcha/index.d.ts b/types/js-captcha/index.d.ts new file mode 100644 index 0000000000..2e0b2b5c8b --- /dev/null +++ b/types/js-captcha/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for js-captcha 1.1 +// Project: https://github.com/robiveli/js-captcha +// Definitions by: PikachuEXE +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as jCaptcha from "./dist/js/jCaptcha"; diff --git a/types/js-captcha/js-captcha-tests.ts b/types/js-captcha/js-captcha-tests.ts new file mode 100644 index 0000000000..b56eef1a75 --- /dev/null +++ b/types/js-captcha/js-captcha-tests.ts @@ -0,0 +1,31 @@ +import jCaptcha from "js-captcha/dist/js/jCaptcha"; + +const myCaptcha1 = new jCaptcha({ + el: "jCaptcha1", + + requiredValue: "*", + + resetOnError: true, + focusOnError: true, + clearOnSubmit: true, + + canvasWidth: 50, + canvasHeight: 15, + canvasFontSize: "15px", + canvasFontFamily: "Arial", + canvasFillStyle: "#ddd", + + callback: (response: "success" | "error", input: NodeListOf) => { + if (response === "success") { + // Do something + } + + if (response === "error") { + // Do something + } + }, +}); + +const myCaptcha2 = new jCaptcha({}); + +const myCaptcha3 = new jCaptcha(); diff --git a/types/js-captcha/tsconfig.json b/types/js-captcha/tsconfig.json new file mode 100644 index 0000000000..362549c090 --- /dev/null +++ b/types/js-captcha/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "dist/js/jCaptcha.d.ts", + "js-captcha-tests.ts" + ] +} diff --git a/types/js-captcha/tslint.json b/types/js-captcha/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/js-captcha/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}