currency-fomatter 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,107 @@
1
+ import React, { Component } from "react";
2
+ type MyProps = {
3
+ value?: any;
4
+ format: any;
5
+ decimalScale: number;
6
+ decimalSeparator: string;
7
+ thousandSpacing: "2" | "2s" | "3" | "4";
8
+ thousandSeparator: string | boolean;
9
+ mask: string | string[];
10
+ allowNegative: boolean;
11
+ prefix: string;
12
+ suffix: string;
13
+ removeFormatting: any;
14
+ fixedDecimalScale: boolean;
15
+ isNumericString: boolean;
16
+ isAllowed: any;
17
+ onValueChange: any;
18
+ onChange: any;
19
+ onKeyDown: any;
20
+ onMouseUp: any;
21
+ onFocus: any;
22
+ onBlur: any;
23
+ type: "text" | "tel";
24
+ displayType: "input" | "text";
25
+ customInput: any;
26
+ renderText: any;
27
+ };
28
+ type MyState = {
29
+ value?: string;
30
+ numAsString?: any;
31
+ };
32
+ declare class CurrencyFormat extends Component<MyProps, MyState> {
33
+ state: {
34
+ value?: string;
35
+ numAsString?: any;
36
+ };
37
+ static defaultProps: Object;
38
+ constructor(props: MyProps);
39
+ componentDidUpdate(prevProps: Object): void;
40
+ updateValueIfRequired(prevProps: Object): void;
41
+ /** Misc methods **/
42
+ getFloatString(num?: string): string;
43
+ getNumberRegex(g: boolean, ignoreDecimalSeparator?: boolean): RegExp;
44
+ getSeparators(): {
45
+ decimalSeparator: string;
46
+ thousandSeparator: string | false;
47
+ thousandSpacing: "2" | "2s" | "3" | "4";
48
+ };
49
+ getMaskAtIndex(index: number): string;
50
+ validateProps(): void;
51
+ splitDecimal(numStr: string): {
52
+ beforeDecimal: string;
53
+ afterDecimal: string;
54
+ hasNagation: boolean;
55
+ addNegation: boolean;
56
+ };
57
+ /** Misc methods end **/
58
+ /** caret specific methods **/
59
+ setPatchedCaretPosition(el: any, caretPos: number, currentValue: string): void;
60
+ correctCaretPosition(value: string, caretPos: number, direction?: string): any;
61
+ getCaretPosition(inputValue: string, formattedValue: string, caretPos: number): any;
62
+ /** caret specific methods ends **/
63
+ /** methods to remove formattting **/
64
+ removePrefixAndSuffix(val: string): string;
65
+ removePatternFormatting(val: string): string;
66
+ removeFormatting(val: string): string;
67
+ /** methods to remove formattting end **/
68
+ /*** format specific methods start ***/
69
+ /**
70
+ * Format when # based string is provided
71
+ * @param {string} numStr Numeric String
72
+ * @return {string} formatted Value
73
+ */
74
+ formatWithPattern(numStr: string): any;
75
+ /**
76
+ * Format the given string according to thousand separator and thousand spacing
77
+ * @param {*} beforeDecimal
78
+ * @param {*} thousandSeparator
79
+ * @param {*} thousandSpacing
80
+ */
81
+ formatThousand(beforeDecimal: any, thousandSeparator: string | boolean, thousandSpacing: "2" | "2s" | "3" | "4"): any;
82
+ /**
83
+ * @param {string} numStr Numeric string/floatString] It always have decimalSeparator as .
84
+ * @return {string} formatted Value
85
+ */
86
+ formatAsNumber(numStr: string): string;
87
+ formatNumString(value?: string): string;
88
+ formatValueProp(): string;
89
+ formatNegation(value?: string): string;
90
+ formatInput(value?: string): string;
91
+ /*** format specific methods end ***/
92
+ isCharacterAFormat(caretPos: number, value: string): boolean;
93
+ checkIfFormatGotDeleted(start: number, end: number, value: string): boolean;
94
+ /**
95
+ * This will check if any formatting got removed by the delete or backspace and reset the value
96
+ * It will also work as fallback if android chome keyDown handler does not work
97
+ **/
98
+ correctInputValue(caretPos: number, lastValue: string, value: string): string;
99
+ onChange(e: React.FormEvent<HTMLInputElement>): void;
100
+ onBlur(e: React.FormEvent<HTMLInputElement>): void;
101
+ onKeyDown(e: any): void;
102
+ /** required to handle the caret position when click anywhere within the input **/
103
+ onMouseUp(e: React.FormEvent<HTMLInputElement>): void;
104
+ onFocus(e: React.FormEvent<HTMLInputElement>): void;
105
+ render(): any;
106
+ }
107
+ export default CurrencyFormat;