react-hook-core 0.1.24 → 0.1.25
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.
- package/lib/index.js +15 -28
- package/package.json +1 -1
- package/src/index.ts +15 -26
package/lib/index.js
CHANGED
|
@@ -53,8 +53,7 @@ exports.Loading = function (props) {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
exports.CurrencyInput = function (props) {
|
|
56
|
-
var _a;
|
|
57
|
-
var _b = react_1.useState(undefined), state = _b[0], setState = _b[1];
|
|
56
|
+
var _a = react_1.useState(undefined), state = _a[0], setState = _a[1];
|
|
58
57
|
react_1.useEffect(function () {
|
|
59
58
|
setState(props.value);
|
|
60
59
|
}, [props.value]);
|
|
@@ -68,32 +67,20 @@ exports.CurrencyInput = function (props) {
|
|
|
68
67
|
props.onChangeNumber(parseFloat(v1));
|
|
69
68
|
}
|
|
70
69
|
};
|
|
71
|
-
var
|
|
72
|
-
value
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (props.locale && props.currencyOnBlur) {
|
|
88
|
-
props.currencyOnBlur(e, props.locale, props.currencyCode, props.symbol);
|
|
89
|
-
}
|
|
90
|
-
setTimeout(function () {
|
|
91
|
-
var v2 = e.target.value;
|
|
92
|
-
setState(v2);
|
|
93
|
-
}, 50);
|
|
94
|
-
},
|
|
95
|
-
_a);
|
|
96
|
-
return React.createElement("input", { className: ip.className, onBlur: ip.onBlur, type: ip.type, name: ip.name, onChange: ip.onChange, disabled: ip.disabled, "data-field": ip['data-field'], min: ip.min, max: ip.max, value: state });
|
|
70
|
+
var onBlur = function (e) {
|
|
71
|
+
if (props.allowZero && e.target.value === '0') {
|
|
72
|
+
setState('0');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (props.locale && props.currencyOnBlur) {
|
|
76
|
+
props.currencyOnBlur(e, props.locale, props.currencyCode, props.symbol);
|
|
77
|
+
}
|
|
78
|
+
setTimeout(function () {
|
|
79
|
+
var v2 = e.target.value;
|
|
80
|
+
setState(v2);
|
|
81
|
+
}, 50);
|
|
82
|
+
};
|
|
83
|
+
return React.createElement("input", { className: props.className, onBlur: onBlur, type: props.type, name: props.name, onChange: props.onChange ? props.onChange : onChange, disabled: props.disabled, "data-field": props['data-field'], min: props.min, max: props.max, value: state });
|
|
97
84
|
};
|
|
98
85
|
function formatDate(date, format) {
|
|
99
86
|
if (!date) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -120,32 +120,21 @@ export const CurrencyInput = (props: InputProps) => {
|
|
|
120
120
|
props.onChangeNumber(parseFloat(v1));
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
const
|
|
124
|
-
value
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (props.locale && props.currencyOnBlur) {
|
|
139
|
-
props.currencyOnBlur(e, props.locale, props.currencyCode, props.symbol);
|
|
140
|
-
}
|
|
141
|
-
setTimeout(() => {
|
|
142
|
-
const v2 = e.target.value;
|
|
143
|
-
setState(v2);
|
|
144
|
-
}, 50);
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
// return <input className={ip.className} type={ip.type} name={ip.name} onChange={ip.onChange} disabled={ip.disabled} data-field={ip['data-field']} min={ip.min} max={ip.max} value={state} />;
|
|
148
|
-
return React.createElement("input", { className: ip.className, onBlur: ip.onBlur, type: ip.type, name: ip.name, onChange: ip.onChange, disabled: ip.disabled, "data-field": ip['data-field'], min: ip.min, max: ip.max, value: state });
|
|
123
|
+
const onBlur = (e: FocusEvent<HTMLInputElement>) => {
|
|
124
|
+
if (props.allowZero && e.target.value === '0') {
|
|
125
|
+
setState('0');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (props.locale && props.currencyOnBlur) {
|
|
129
|
+
props.currencyOnBlur(e, props.locale, props.currencyCode, props.symbol);
|
|
130
|
+
}
|
|
131
|
+
setTimeout(() => {
|
|
132
|
+
const v2 = e.target.value;
|
|
133
|
+
setState(v2);
|
|
134
|
+
}, 50);
|
|
135
|
+
}
|
|
136
|
+
// return <input className={props.className} onBlur={onBlur} type={props.type} name={props.name} onChange={props.onChange ? props.onChange : onChange} disabled={props.disabled} data-field={props['data-field']} min={props.min} max={props.max} value={state} />;
|
|
137
|
+
return React.createElement("input", { className: props.className, onBlur: onBlur, type: props.type, name: props.name, onChange: props.onChange ? props.onChange : onChange , disabled: props.disabled, "data-field": props['data-field'], min: props.min, max: props.max, value: state });
|
|
149
138
|
};
|
|
150
139
|
export type OnClick = React.MouseEvent<HTMLElement, MouseEvent>;
|
|
151
140
|
export function formatDate(date: Date | null | undefined, format: string): string {
|