pcm-shared-components 0.0.175 → 0.0.179
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.
|
@@ -21,12 +21,13 @@ let debounce;
|
|
|
21
21
|
|
|
22
22
|
export const CurrencyTextInput = props => {
|
|
23
23
|
const {
|
|
24
|
+
id,
|
|
25
|
+
name,
|
|
24
26
|
value,
|
|
25
27
|
label,
|
|
26
28
|
variant,
|
|
27
29
|
fullWidth,
|
|
28
30
|
onChange,
|
|
29
|
-
onChangeDebounce,
|
|
30
31
|
currencySymbol,
|
|
31
32
|
className,
|
|
32
33
|
decimalPlaces,
|
|
@@ -39,15 +40,7 @@ export const CurrencyTextInput = props => {
|
|
|
39
40
|
theme
|
|
40
41
|
} = props;
|
|
41
42
|
const compTheme = theme ? theme : useTheme();
|
|
42
|
-
const defaultTheme = createTheme(compTheme);
|
|
43
|
-
|
|
44
|
-
const [localValue, setLocalValue] = useState(value);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
clearTimeout(debounce);
|
|
47
|
-
debounce = setTimeout(() => {
|
|
48
|
-
onChangeDebounce(localValue);
|
|
49
|
-
}, 700);
|
|
50
|
-
}, [localValue]); //---------------------------------------------------
|
|
43
|
+
const defaultTheme = createTheme(compTheme); //---------------------------------------------------
|
|
51
44
|
// Functions used to sanitize the number
|
|
52
45
|
//---------------------------------------------------
|
|
53
46
|
|
|
@@ -157,14 +150,16 @@ export const CurrencyTextInput = props => {
|
|
|
157
150
|
};
|
|
158
151
|
|
|
159
152
|
const handleOnChange = event => {
|
|
160
|
-
|
|
161
|
-
|
|
153
|
+
//Sanitize the output same as the input
|
|
154
|
+
event.target.value = handleCurrencyFormatting(event.target.value);
|
|
155
|
+
onChange(event);
|
|
162
156
|
};
|
|
163
157
|
|
|
164
158
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
165
159
|
theme: defaultTheme
|
|
166
160
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
167
|
-
id:
|
|
161
|
+
id: id,
|
|
162
|
+
name: name,
|
|
168
163
|
className: ` ${className}`,
|
|
169
164
|
fullWidth: fullWidth,
|
|
170
165
|
label: label,
|
|
@@ -190,12 +185,13 @@ export const CurrencyTextInput = props => {
|
|
|
190
185
|
};
|
|
191
186
|
export default CurrencyTextInput;
|
|
192
187
|
CurrencyTextInput.defaultProps = {
|
|
188
|
+
id: '',
|
|
189
|
+
name: '',
|
|
193
190
|
value: 0,
|
|
194
191
|
label: 'Some Label',
|
|
195
192
|
variant: 'outlined',
|
|
196
193
|
fullWidth: true,
|
|
197
194
|
onChange: () => {},
|
|
198
|
-
onChangeDebounce: () => {},
|
|
199
195
|
currencySymbol: '$',
|
|
200
196
|
useThousandSeparator: true,
|
|
201
197
|
className: '',
|
|
@@ -208,6 +204,12 @@ CurrencyTextInput.defaultProps = {
|
|
|
208
204
|
theme: undefined
|
|
209
205
|
};
|
|
210
206
|
CurrencyTextInput.propTypes = {
|
|
207
|
+
/** Unique id of the component */
|
|
208
|
+
id: PropTypes.string,
|
|
209
|
+
|
|
210
|
+
/** Name of the target often used to update state*/
|
|
211
|
+
name: PropTypes.string,
|
|
212
|
+
|
|
211
213
|
/** Value to be enter and display in input */
|
|
212
214
|
value: PropTypes.string,
|
|
213
215
|
|
|
@@ -226,9 +228,6 @@ CurrencyTextInput.propTypes = {
|
|
|
226
228
|
/** Callback fired when the value is changed*/
|
|
227
229
|
onChange: PropTypes.func,
|
|
228
230
|
|
|
229
|
-
/** Same as onChange except only fires 700ms after the users has completed typing to prevent performance issues. Returns the new value */
|
|
230
|
-
onChangeDebounce: PropTypes.func,
|
|
231
|
-
|
|
232
231
|
/** Defines the currency symbol string.*/
|
|
233
232
|
currencySymbol: PropTypes.string,
|
|
234
233
|
|