@thecb/components 6.1.4 → 6.1.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/dist/index.cjs.js CHANGED
@@ -22550,7 +22550,7 @@ var fallbackValues$i = {
22550
22550
  };
22551
22551
 
22552
22552
  var _excluded$p = ["showErrors", "themeValues"],
22553
- _excluded2 = ["type", "labelTextWhenNoError", "errorMessages", "isNum", "isEmail", "helperModal", "field", "fieldActions", "showErrors", "formatter", "decorator", "themeValues", "background", "customHeight", "autocomplete", "extraStyles"];
22553
+ _excluded2 = ["type", "labelTextWhenNoError", "errorMessages", "isNum", "isEmail", "helperModal", "field", "fieldActions", "showErrors", "formatter", "decorator", "themeValues", "background", "customHeight", "autocomplete", "extraStyles", "removeFromValue"];
22554
22554
  var InputField = styled__default.input.withConfig({
22555
22555
  displayName: "FormInput__InputField",
22556
22556
  componentId: "sc-l094r1-0"
@@ -22634,6 +22634,7 @@ var FormInput = function FormInput(_ref15) {
22634
22634
  customHeight = _ref15.customHeight,
22635
22635
  autocomplete = _ref15.autocomplete,
22636
22636
  extraStyles = _ref15.extraStyles,
22637
+ removeFromValue = _ref15.removeFromValue,
22637
22638
  props = _objectWithoutProperties(_ref15, _excluded2);
22638
22639
 
22639
22640
  var _useState = React.useState(false),
@@ -22644,6 +22645,14 @@ var FormInput = function FormInput(_ref15) {
22644
22645
  var _useContext = React.useContext(styled.ThemeContext),
22645
22646
  isMobile = _useContext.isMobile;
22646
22647
 
22648
+ var setValue = function setValue(value) {
22649
+ if (removeFromValue !== undefined) {
22650
+ return fieldActions.set(value.replace(removeFromValue, ""));
22651
+ }
22652
+
22653
+ return fieldActions.set(value);
22654
+ };
22655
+
22647
22656
  return /*#__PURE__*/React__default.createElement(Stack, {
22648
22657
  childGap: "0.25rem"
22649
22658
  }, /*#__PURE__*/React__default.createElement(Box, {
@@ -22697,8 +22706,8 @@ var FormInput = function FormInput(_ref15) {
22697
22706
  "aria-labelledby": createIdFromString(labelTextWhenNoError),
22698
22707
  "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
22699
22708
  "aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
22700
- onChange: function onChange(e) {
22701
- return fieldActions.set(e);
22709
+ onChange: function onChange(value) {
22710
+ return setValue(value);
22702
22711
  },
22703
22712
  type: type,
22704
22713
  value: field.rawValue,
@@ -22717,7 +22726,7 @@ var FormInput = function FormInput(_ref15) {
22717
22726
  "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
22718
22727
  "aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
22719
22728
  onChange: function onChange(e) {
22720
- return fieldActions.set(e.target.value);
22729
+ return setValue(e.target.value);
22721
22730
  },
22722
22731
  type: type === "password" && showPassword ? "text" : type,
22723
22732
  value: field.rawValue,
@@ -34730,6 +34739,24 @@ const ONLY_NATURALS_ERROR = "error/ONLY_NATURALS";
34730
34739
  const onlyNaturals = createValidator(ONLY_NATURALS, ONLY_NATURALS_ERROR);
34731
34740
  validatorFns[ONLY_NATURALS] = (value, args, form) => /^(\d+)?$/.test(value);
34732
34741
 
34742
+ /*
34743
+ 07/22: experimental expiration date constraint
34744
+ should allow entry of expiration date using "/" character
34745
+ to accommodate browser autofill
34746
+
34747
+ not tested as validation function
34748
+ to validate exp date instead use combo of:
34749
+ required(), hasLength(), isValidMonth(), dateAfterToday()
34750
+ */
34751
+ const ONLY_EXPIRATION_DATE = "validator/ONLY_EXPIRATION_DATE";
34752
+ const ONLY_EXPIRATION_DATE_ERROR = "error/ONLY_EXPIRATION_DATE";
34753
+ const onlyExpirationDate = createValidator(
34754
+ ONLY_EXPIRATION_DATE,
34755
+ ONLY_EXPIRATION_DATE_ERROR
34756
+ );
34757
+ validatorFns[ONLY_EXPIRATION_DATE] = (value, args, form) =>
34758
+ /^(\d?\d?\/?\d?\d?)?$/.test(value);
34759
+
34733
34760
  const NUMBER_LESS_THAN = "validator/NUMBER_LESS_THAN";
34734
34761
  const NUMBER_LESS_THAN_ERROR = "error/NUMBER_LESS_THAN";
34735
34762
  const numberLessThan = createValidator(
@@ -42247,6 +42274,8 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
42247
42274
  return e.key === "Enter" && handleSubmit(e);
42248
42275
  },
42249
42276
  isNum: true,
42277
+ removeFromValue: /\// // removes "/" from browser autofill
42278
+ ,
42250
42279
  autocomplete: "cc-exp"
42251
42280
  }), /*#__PURE__*/React__default.createElement(FormInput$1, {
42252
42281
  labelTextWhenNoError: "CVV",
@@ -42299,7 +42328,7 @@ var formConfig$8 = {
42299
42328
  },
42300
42329
  expirationDate: {
42301
42330
  validators: [required(), hasLength(4, 4), isValidMonth(0), dateAfterToday("MMYY", "month", true)],
42302
- constraints: [onlyIntegers(), hasLength(0, 4)]
42331
+ constraints: [onlyExpirationDate(), hasLength(0, 4)]
42303
42332
  },
42304
42333
  cvv: {
42305
42334
  validators: [required(), hasLength(3, 4)],
@@ -43343,9 +43372,7 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
43343
43372
  periscopeDataSuccess = _ref.periscopeDataSuccess,
43344
43373
  periscopeDataFailure = _ref.periscopeDataFailure,
43345
43374
  periscopeDataRequestSuccess = _ref.periscopeDataRequestSuccess,
43346
- periscopeDataRequestFailure = _ref.periscopeDataRequestFailure,
43347
- _ref$timerMS = _ref.timerMS,
43348
- timerMS = _ref$timerMS === void 0 ? 20000 : _ref$timerMS;
43375
+ periscopeDataRequestFailure = _ref.periscopeDataRequestFailure;
43349
43376
 
43350
43377
  var _useState = React.useState(0),
43351
43378
  _useState2 = _slicedToArray(_useState, 2),
@@ -43360,7 +43387,7 @@ var PeriscopeDashboardIframe = function PeriscopeDashboardIframe(_ref) {
43360
43387
  if (!periscopeDataSuccess) {
43361
43388
  periscopeDataRequestFailure();
43362
43389
  }
43363
- }, timerMS);
43390
+ }, 10000);
43364
43391
  return function () {
43365
43392
  return clearTimeout(time.timer);
43366
43393
  };