@thecb/components 6.1.4-beta.4 → 6.1.4-beta.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "6.1.4-beta.4",
3
+ "version": "6.1.4-beta.5",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -114,11 +114,17 @@ const FormInput = ({
114
114
  customHeight,
115
115
  autocomplete,
116
116
  extraStyles,
117
- removeFromValue,
117
+ removeFromValue, // regex of characters to remove before setting value
118
118
  ...props
119
119
  }) => {
120
120
  const [showPassword, setShowPassword] = useState(false);
121
121
  const { isMobile } = useContext(ThemeContext);
122
+ const setValue = value => {
123
+ if (removeFromValue !== undefined) {
124
+ return fieldActions.set(value.replace(removeFromValue, ""));
125
+ }
126
+ return fieldActions.set(value);
127
+ };
122
128
 
123
129
  return (
124
130
  <Stack childGap="0.25rem">
@@ -200,7 +206,7 @@ const FormInput = ({
200
206
  (field.dirty && field.hasErrors) ||
201
207
  (field.hasErrors && showErrors)
202
208
  }
203
- onChange={e => console.log("e is", e) || fieldActions.set(e)}
209
+ onChange={value => setValue(value)}
204
210
  type={type}
205
211
  value={field.rawValue}
206
212
  pattern={isNum ? "[0-9]*" : ""}
@@ -226,7 +232,7 @@ const FormInput = ({
226
232
  (field.dirty && field.hasErrors) ||
227
233
  (field.hasErrors && showErrors)
228
234
  }
229
- onChange={e => fieldActions.set(e.target.value)}
235
+ onChange={e => setValue(e.target.value)}
230
236
  type={type === "password" && showPassword ? "text" : type}
231
237
  value={field.rawValue}
232
238
  pattern={isNum ? "[0-9]*" : ""}
@@ -140,6 +140,7 @@ const PaymentFormCard = ({
140
140
  formatter={expirationDateFormat}
141
141
  onKeyDown={e => e.key === "Enter" && handleSubmit(e)}
142
142
  isNum
143
+ removeFromValue={/\//} // removes "/" from browser autofill
143
144
  autocomplete="cc-exp"
144
145
  />
145
146
  <FormInput
@@ -31,7 +31,7 @@ const formConfig = {
31
31
  isValidMonth(0),
32
32
  dateAfterToday("MMYY", "month", true)
33
33
  ],
34
- constraints: [onlyExpirationDate(), hasLength(0, 5)]
34
+ constraints: [onlyExpirationDate(), hasLength(0, 4)]
35
35
  },
36
36
  cvv: {
37
37
  validators: [required(), hasLength(3, 4)],