pcm-shared-components 0.0.177 → 0.0.180

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,
@@ -36,18 +37,13 @@ export const CurrencyTextInput = props => {
36
37
  useThousandSeparator,
37
38
  fontSize,
38
39
  textPadding,
40
+ error,
41
+ helperText,
42
+ disabled,
39
43
  theme
40
44
  } = props;
41
45
  const compTheme = theme ? theme : useTheme();
42
- const defaultTheme = createTheme(compTheme); //Hooks
43
-
44
- const [localValue, setLocalValue] = useState(value);
45
- useEffect(() => {
46
- clearTimeout(debounce);
47
- debounce = setTimeout(() => {
48
- onChangeDebounce(localValue);
49
- }, 700);
50
- }, [localValue]); //---------------------------------------------------
46
+ const defaultTheme = createTheme(compTheme); //---------------------------------------------------
51
47
  // Functions used to sanitize the number
52
48
  //---------------------------------------------------
53
49
 
@@ -157,14 +153,19 @@ export const CurrencyTextInput = props => {
157
153
  };
158
154
 
159
155
  const handleOnChange = event => {
160
- setLocalValue(event.target.value);
156
+ //Sanitize the output same as the input
157
+ event.target.value = handleCurrencyFormatting(event.target.value);
161
158
  onChange(event);
162
159
  };
163
160
 
164
161
  return /*#__PURE__*/React.createElement(ThemeProvider, {
165
162
  theme: defaultTheme
166
163
  }, /*#__PURE__*/React.createElement(TextField, {
167
- id: "input-with-icon-textfield",
164
+ id: id,
165
+ name: name,
166
+ error: error,
167
+ helperText: helperText,
168
+ disabled: disabled,
168
169
  className: ` ${className}`,
169
170
  fullWidth: fullWidth,
170
171
  label: label,
@@ -190,12 +191,13 @@ export const CurrencyTextInput = props => {
190
191
  };
191
192
  export default CurrencyTextInput;
192
193
  CurrencyTextInput.defaultProps = {
194
+ id: '',
195
+ name: '',
193
196
  value: 0,
194
197
  label: 'Some Label',
195
198
  variant: 'outlined',
196
199
  fullWidth: true,
197
200
  onChange: () => {},
198
- onChangeDebounce: () => {},
199
201
  currencySymbol: '$',
200
202
  useThousandSeparator: true,
201
203
  className: '',
@@ -205,9 +207,18 @@ CurrencyTextInput.defaultProps = {
205
207
  textAlign: 'right',
206
208
  fontSize: 16,
207
209
  textPadding: 4,
210
+ error: false,
211
+ disabled: false,
212
+ helperText: '',
208
213
  theme: undefined
209
214
  };
210
215
  CurrencyTextInput.propTypes = {
216
+ /** Unique id of the component */
217
+ id: PropTypes.string,
218
+
219
+ /** Name of the target often used to update state*/
220
+ name: PropTypes.string,
221
+
211
222
  /** Value to be enter and display in input */
212
223
  value: PropTypes.string,
213
224
 
@@ -217,6 +228,15 @@ CurrencyTextInput.propTypes = {
217
228
  /** Controls the look of the text field*/
218
229
  variant: PropTypes.oneOf(['filled', 'outlined', 'standard']),
219
230
 
231
+ /** Determines if the text field will be in an error state*/
232
+ error: PropTypes.bool,
233
+
234
+ /** Determines if the text field is disabled of not*/
235
+ disabled: PropTypes.bool,
236
+
237
+ /** Helper text to display below the field*/
238
+ helperText: PropTypes.string,
239
+
220
240
  /** Determines if the text field will be full width or fit content*/
221
241
  fullWidth: PropTypes.bool,
222
242
 
@@ -226,9 +246,6 @@ CurrencyTextInput.propTypes = {
226
246
  /** Callback fired when the value is changed*/
227
247
  onChange: PropTypes.func,
228
248
 
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
249
  /** Defines the currency symbol string.*/
233
250
  currencySymbol: PropTypes.string,
234
251
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcm-shared-components",
3
- "version": "0.0.177",
3
+ "version": "0.0.180",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "babel": {