From 09bc77ae3daea033a2e0802443e586e94d7da7ba Mon Sep 17 00:00:00 2001 From: Rudolph Gottesheim Date: Fri, 19 Jan 2018 19:12:29 +0100 Subject: [PATCH] Fix cleave.js (Cleave is a class, not a function) (#23046) * Fix cleave.js (Cleave is a class, not a function) See examples at https://github.com/nosir/cleave.js * Add whitespace --- types/cleave.js/cleave.js-tests.tsx | 7 ++++++- types/cleave.js/index.d.ts | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/types/cleave.js/cleave.js-tests.tsx b/types/cleave.js/cleave.js-tests.tsx index 3bbc6570a3..825b44a2ad 100644 --- a/types/cleave.js/cleave.js-tests.tsx +++ b/types/cleave.js/cleave.js-tests.tsx @@ -3,7 +3,12 @@ import Cleave = require("cleave.js"); import CleaveReact = require("cleave.js/react"); const Example1 = () => { - Cleave("#my-input", { phone: true }); + const cleave = new Cleave("#my-input", { phone: true }); + cleave.setPhoneRegionCode("AT"); + cleave.setRawValue("foo"); + const foo: string = cleave.getFormattedValue(); + const bar: string = cleave.getRawValue(); + cleave.destroy(); }; const ExampleReact1 = (props: any) => { diff --git a/types/cleave.js/index.d.ts b/types/cleave.js/index.d.ts index 17e8c1c512..27fe7d8c41 100644 --- a/types/cleave.js/index.d.ts +++ b/types/cleave.js/index.d.ts @@ -6,5 +6,18 @@ import { CleaveOptions } from './options'; -declare function Cleave(selector: string, options: CleaveOptions): void; +declare class Cleave { + constructor(selector: string, options: CleaveOptions); + + getRawValue(): string; + + setRawValue(value: string): void; + + getFormattedValue(): string; + + destroy(): void; + + setPhoneRegionCode(regionCode: string): void; +} + export = Cleave;