@thecb/components 10.9.0-beta.1 → 10.9.0-beta.11

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
@@ -6548,7 +6548,7 @@ var BoxWrapper = styled__default(function (_ref) {
6548
6548
  });
6549
6549
  /* eslint-enable no-unused-vars */
6550
6550
 
6551
- var _excluded$3 = ["autocompleteValue", "padding", "borderSize", "borderColor", "borderRadius", "boxShadow", "background", "color", "minHeight", "width", "minWidth", "maxWidth", "borderWidthOverride", "border", "textAlign", "hoverStyles", "activeStyles", "disabledStyles", "focusStyles", "variant", "as", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onFocus", "onBlur", "onTouchEnd", "theme", "hiddenStyles", "extraStyles", "srOnly", "dataQa", "id", "children"];
6551
+ var _excluded$3 = ["autocompleteValue", "padding", "borderSize", "borderColor", "borderRadius", "boxShadow", "background", "color", "minHeight", "width", "minWidth", "maxWidth", "borderWidthOverride", "border", "textAlign", "hoverStyles", "activeStyles", "disabledStyles", "focusStyles", "variant", "as", "onClick", "onKeyDown", "onMouseEnter", "onMouseLeave", "onFocus", "onBlur", "onTouchEnd", "theme", "hiddenStyles", "extraStyles", "srOnly", "dataQa", "children"];
6552
6552
 
6553
6553
  /*
6554
6554
  Box component to create generic boxes
@@ -6597,7 +6597,6 @@ var Box = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
6597
6597
  _ref$srOnly = _ref.srOnly,
6598
6598
  srOnly = _ref$srOnly === void 0 ? false : _ref$srOnly,
6599
6599
  dataQa = _ref.dataQa,
6600
- id = _ref.id,
6601
6600
  children = _ref.children,
6602
6601
  rest = _objectWithoutProperties(_ref, _excluded$3);
6603
6602
  return /*#__PURE__*/React__default.createElement(BoxWrapper, _extends({
@@ -6633,8 +6632,7 @@ var Box = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
6633
6632
  onFocus: onFocus,
6634
6633
  onBlur: onBlur,
6635
6634
  onTouchEnd: onTouchEnd,
6636
- ref: ref,
6637
- id: id
6635
+ ref: ref
6638
6636
  }, rest), children && safeChildren(children, /*#__PURE__*/React__default.createElement(React.Fragment, null)));
6639
6637
  });
6640
6638
 
@@ -24898,9 +24896,7 @@ var Dropdown = function Dropdown(_ref13) {
24898
24896
  _ref13$ariaInvalid = _ref13.ariaInvalid,
24899
24897
  ariaInvalid = _ref13$ariaInvalid === void 0 ? false : _ref13$ariaInvalid,
24900
24898
  _ref13$isRequired = _ref13.isRequired,
24901
- isRequired = _ref13$isRequired === void 0 ? false : _ref13$isRequired,
24902
- _ref13$inputId = _ref13.inputId,
24903
- inputId = _ref13$inputId === void 0 ? false : _ref13$inputId;
24899
+ isRequired = _ref13$isRequired === void 0 ? false : _ref13$isRequired;
24904
24900
  var _useState = React.useState(""),
24905
24901
  _useState2 = _slicedToArray(_useState, 2),
24906
24902
  inputValue = _useState2[0],
@@ -25109,7 +25105,6 @@ var Dropdown = function Dropdown(_ref13) {
25109
25105
  width: "100%",
25110
25106
  dataQa: "".concat(ariaLabelledby, "-dropdown")
25111
25107
  }, /*#__PURE__*/React__default.createElement(Box, {
25112
- id: inputId,
25113
25108
  as: "input",
25114
25109
  autoComplete: autocompleteValue,
25115
25110
  "aria-controls": "".concat(ariaLabelledby, "_listbox"),
@@ -25312,11 +25307,7 @@ var FormSelect = function FormSelect(_ref) {
25312
25307
  _ref$widthFitOptions = _ref.widthFitOptions,
25313
25308
  widthFitOptions = _ref$widthFitOptions === void 0 ? false : _ref$widthFitOptions,
25314
25309
  _ref$isRequired = _ref.isRequired,
25315
- isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired,
25316
- _ref$htmlFor = _ref.htmlFor,
25317
- htmlFor = _ref$htmlFor === void 0 ? null : _ref$htmlFor,
25318
- _ref$inputId = _ref.inputId,
25319
- inputId = _ref$inputId === void 0 ? null : _ref$inputId;
25310
+ isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired;
25320
25311
  var _useState = React.useState(false),
25321
25312
  _useState2 = _slicedToArray(_useState, 2),
25322
25313
  open = _useState2[0],
@@ -25350,10 +25341,8 @@ var FormSelect = function FormSelect(_ref) {
25350
25341
  color: themeValues.labelColor,
25351
25342
  weight: themeValues.fontWeight,
25352
25343
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
25353
- id: createIdFromString(labelTextWhenNoError),
25354
- htmlFor: htmlFor
25344
+ id: createIdFromString(labelTextWhenNoError)
25355
25345
  }, labelTextWhenNoError))), /*#__PURE__*/React__default.createElement(Dropdown$1, {
25356
- inputId: inputId,
25357
25346
  ariaLabelledby: createIdFromString(labelTextWhenNoError),
25358
25347
  ariaDescribedby: createIdFromString(labelTextWhenNoError, "error message"),
25359
25348
  maxHeight: dropdownMaxHeight,
@@ -26150,11 +26139,7 @@ var CountryDropdown = function CountryDropdown(_ref) {
26150
26139
  _ref$isRequired = _ref.isRequired,
26151
26140
  isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired,
26152
26141
  _ref$dataQa = _ref.dataQa,
26153
- dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa,
26154
- _ref$htmlFor = _ref.htmlFor,
26155
- htmlFor = _ref$htmlFor === void 0 ? null : _ref$htmlFor,
26156
- _ref$inputId = _ref.inputId,
26157
- inputId = _ref$inputId === void 0 ? null : _ref$inputId;
26142
+ dataQa = _ref$dataQa === void 0 ? null : _ref$dataQa;
26158
26143
  return /*#__PURE__*/React__default.createElement(FormSelect$1, {
26159
26144
  options: options,
26160
26145
  field: field,
@@ -26165,8 +26150,6 @@ var CountryDropdown = function CountryDropdown(_ref) {
26165
26150
  showErrors: showErrors,
26166
26151
  onChange: onChange,
26167
26152
  autocompleteValue: "country-name",
26168
- htmlFor: htmlFor,
26169
- inputId: inputId,
26170
26153
  isRequired: isRequired
26171
26154
  });
26172
26155
  };
@@ -26655,45 +26638,34 @@ function _extends$2() {
26655
26638
  _extends$2 = Object.assign || function (target) {
26656
26639
  for (var i = 1; i < arguments.length; i++) {
26657
26640
  var source = arguments[i];
26658
-
26659
26641
  for (var key in source) {
26660
26642
  if (Object.prototype.hasOwnProperty.call(source, key)) {
26661
26643
  target[key] = source[key];
26662
26644
  }
26663
26645
  }
26664
26646
  }
26665
-
26666
26647
  return target;
26667
26648
  };
26668
-
26669
26649
  return _extends$2.apply(this, arguments);
26670
26650
  }
26671
-
26672
26651
  function _objectWithoutPropertiesLoose$1(source, excluded) {
26673
26652
  if (source == null) return {};
26674
26653
  var target = {};
26675
26654
  var sourceKeys = Object.keys(source);
26676
26655
  var key, i;
26677
-
26678
26656
  for (i = 0; i < sourceKeys.length; i++) {
26679
26657
  key = sourceKeys[i];
26680
26658
  if (excluded.indexOf(key) >= 0) continue;
26681
26659
  target[key] = source[key];
26682
26660
  }
26683
-
26684
26661
  return target;
26685
26662
  }
26686
-
26687
26663
  function _objectWithoutProperties$1(source, excluded) {
26688
26664
  if (source == null) return {};
26689
-
26690
26665
  var target = _objectWithoutPropertiesLoose$1(source, excluded);
26691
-
26692
26666
  var key, i;
26693
-
26694
26667
  if (Object.getOwnPropertySymbols) {
26695
26668
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
26696
-
26697
26669
  for (i = 0; i < sourceSymbolKeys.length; i++) {
26698
26670
  key = sourceSymbolKeys[i];
26699
26671
  if (excluded.indexOf(key) >= 0) continue;
@@ -26701,48 +26673,37 @@ function _objectWithoutProperties$1(source, excluded) {
26701
26673
  target[key] = source[key];
26702
26674
  }
26703
26675
  }
26704
-
26705
26676
  return target;
26706
26677
  }
26707
-
26708
26678
  function _slicedToArray$1(arr, i) {
26709
26679
  return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _nonIterableRest$1();
26710
26680
  }
26711
-
26712
26681
  function _toConsumableArray$1(arr) {
26713
26682
  return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _nonIterableSpread$1();
26714
26683
  }
26715
-
26716
26684
  function _arrayWithoutHoles$1(arr) {
26717
26685
  if (Array.isArray(arr)) {
26718
26686
  for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
26719
-
26720
26687
  return arr2;
26721
26688
  }
26722
26689
  }
26723
-
26724
26690
  function _arrayWithHoles$1(arr) {
26725
26691
  if (Array.isArray(arr)) return arr;
26726
26692
  }
26727
-
26728
26693
  function _iterableToArray$1(iter) {
26729
26694
  if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
26730
26695
  }
26731
-
26732
26696
  function _iterableToArrayLimit$1(arr, i) {
26733
26697
  if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
26734
26698
  return;
26735
26699
  }
26736
-
26737
26700
  var _arr = [];
26738
26701
  var _n = true;
26739
26702
  var _d = false;
26740
26703
  var _e = undefined;
26741
-
26742
26704
  try {
26743
26705
  for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
26744
26706
  _arr.push(_s.value);
26745
-
26746
26707
  if (i && _arr.length === i) break;
26747
26708
  }
26748
26709
  } catch (err) {
@@ -26755,29 +26716,23 @@ function _iterableToArrayLimit$1(arr, i) {
26755
26716
  if (_d) throw _e;
26756
26717
  }
26757
26718
  }
26758
-
26759
26719
  return _arr;
26760
26720
  }
26761
-
26762
26721
  function _nonIterableSpread$1() {
26763
26722
  throw new TypeError("Invalid attempt to spread non-iterable instance");
26764
26723
  }
26765
-
26766
26724
  function _nonIterableRest$1() {
26767
26725
  throw new TypeError("Invalid attempt to destructure non-iterable instance");
26768
26726
  }
26769
-
26770
26727
  var getUniqueFormatDelimiters = function getUniqueFormatDelimiters(formats, formatChar) {
26771
26728
  return _toConsumableArray$1(new Set(formats.join("").split(formatChar).join("").split("")));
26772
26729
  };
26773
26730
  var format$1 = function format(formatter) {
26774
26731
  return function (value) {
26775
26732
  var usedFormat = formatter.formats[value.length];
26776
-
26777
26733
  if (!usedFormat) {
26778
26734
  return value;
26779
26735
  }
26780
-
26781
26736
  var formatPieces = usedFormat.split(formatter.formatChar);
26782
26737
  var valuePieces = value.split("");
26783
26738
  var zipped = formatPieces.map(function (v, i) {
@@ -26786,7 +26741,6 @@ var format$1 = function format(formatter) {
26786
26741
  return zipped.join("");
26787
26742
  };
26788
26743
  };
26789
-
26790
26744
  var countDelims = function countDelims(formatter, index) {
26791
26745
  var count = 0;
26792
26746
  var format = formatter.formats[index];
@@ -26796,13 +26750,11 @@ var countDelims = function countDelims(formatter, index) {
26796
26750
  });
26797
26751
  return count;
26798
26752
  };
26799
-
26800
26753
  var unformat = function unformat(formatter) {
26801
26754
  return function (formattedValue, formatIndex) {
26802
26755
  if (formatIndex >= formatter.formats.length) {
26803
26756
  return formattedValue;
26804
26757
  }
26805
-
26806
26758
  var format = formatter.formats[formatIndex];
26807
26759
  return formattedValue.split("").filter(function (_, i) {
26808
26760
  return !(format[i] != formatter.formatChar);
@@ -26816,7 +26768,6 @@ var inject = function inject(baseString) {
26816
26768
  };
26817
26769
  var formattedToUnformattedIndex = function formattedToUnformattedIndex(formattedIndex, rawValue, formatter) {
26818
26770
  var maxFormatExceeded = rawValue.length >= formatter.formats.length;
26819
-
26820
26771
  if (maxFormatExceeded) {
26821
26772
  return formattedIndex;
26822
26773
  } else {
@@ -26841,7 +26792,6 @@ var unformattedToFormattedIndex = function unformattedToFormattedIndex(rawIndex,
26841
26792
  }, 0) + rawIndex;
26842
26793
  }
26843
26794
  };
26844
-
26845
26795
  var createFormat = function createFormat(formats, formatChar) {
26846
26796
  return {
26847
26797
  uniqueDelimiters: getUniqueFormatDelimiters(formats, formatChar),
@@ -26849,83 +26799,80 @@ var createFormat = function createFormat(formats, formatChar) {
26849
26799
  formatChar: formatChar
26850
26800
  };
26851
26801
  };
26852
-
26853
26802
  var FormattedInput = function FormattedInput(_ref) {
26854
26803
  var value = _ref.value,
26855
- formatter = _ref.formatter,
26856
- _onChange = _ref.onChange,
26857
- props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
26858
-
26804
+ formatter = _ref.formatter,
26805
+ onChange = _ref.onChange,
26806
+ props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
26807
+ var _useState = React.useState(format$1(formatter)(value)),
26808
+ _useState2 = _slicedToArray$1(_useState, 2),
26809
+ formattedValue = _useState2[0],
26810
+ setFormattedValue = _useState2[1];
26859
26811
  var inputEl = React.useRef(null);
26860
-
26861
- var _useState = React.useState({
26812
+ var stateRefs = React.useRef({
26862
26813
  selectionStart: 0,
26863
26814
  selectionEnd: 0,
26864
- rawValue: value,
26865
- "delete": false,
26866
- formattedValue: format$1(formatter)(value)
26867
- }),
26868
- _useState2 = _slicedToArray$1(_useState, 2),
26869
- state = _useState2[0],
26870
- setState = _useState2[1];
26871
-
26815
+ isDelete: false,
26816
+ rawValue: ''
26817
+ });
26872
26818
  React.useLayoutEffect(function () {
26873
26819
  // A lot of the work here is cursor manipulation
26874
26820
  if (inputEl.current && inputEl.current === document.activeElement) {
26875
- inputEl.current.setSelectionRange(state.selectionStart, state.selectionEnd);
26821
+ inputEl.current.setSelectionRange(stateRefs.current.selectionStart, stateRefs.current.selectionEnd);
26876
26822
  }
26877
- });
26878
- return React__default.createElement("input", _extends$2({}, props, {
26823
+ }, [stateRefs]);
26824
+ var handleChange = function handleChange(event) {
26825
+ var deleteKeyPressed = stateRefs.current.isDelete;
26826
+ var maxFormatExceeded = stateRefs.current.rawValue.length >= formatter.formats.length - 1;
26827
+ if (maxFormatExceeded && !deleteKeyPressed) {
26828
+ return;
26829
+ }
26830
+ /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
26831
+ * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
26832
+ * the unformatted value for the user's onChange, the formatted string and unformatted injection need
26833
+ * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
26834
+ * old unformatted value.
26835
+ */
26836
+
26837
+ var injectionLength = event.target.value.length - formattedValue.length;
26838
+ var end = stateRefs.current.selectionStart === stateRefs.current.selectionEnd ? stateRefs.current.selectionStart + injectionLength : stateRefs.current.selectionEnd - 1;
26839
+ var injection = event.target.value.substring(stateRefs.current.selectionStart, end); // Injection is the new unformatted piece of the input
26840
+ // Need to find where to put it
26841
+
26842
+ var rawInjectionPointStart = formattedToUnformattedIndex(stateRefs.current.selectionStart, stateRefs.current.rawValue, formatter);
26843
+ var rawInjectionPointEnd = formattedToUnformattedIndex(stateRefs.current.selectionEnd, stateRefs.current.rawValue, formatter); // Unformat the previous formatted value for injection
26844
+ // Using the relevant format string, strips away chars not marked with the formatChar
26845
+
26846
+ var unformattedOldValue = unformat(formatter)(formattedValue, stateRefs.current.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
26847
+
26848
+ var injectIntoOldValue = inject(unformattedOldValue);
26849
+ var unformattedNewValue = deleteKeyPressed ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
26850
+ var lengthDifference = unformattedNewValue.length - stateRefs.current.rawValue.length;
26851
+ var rawIndex = formattedToUnformattedIndex(stateRefs.current.selectionStart, stateRefs.current.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
26852
+ // Applied by useLayoutEffect
26853
+
26854
+ var newFormattedCursorPosition = stateRefs.current.selectionStart === stateRefs.current.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, deleteKeyPressed) : deleteKeyPressed ? stateRefs.current.selectionStart : stateRefs.current.selectionEnd;
26855
+ var formattedNewValue = format$1(formatter)(unformattedNewValue);
26856
+ setFormattedValue(formattedNewValue); // Apply the external onChange function to the raw underlying string
26857
+ // This is where the user generally updates the input value
26858
+
26859
+ if (onChange) {
26860
+ onChange(unformattedNewValue);
26861
+ }
26862
+ };
26863
+ return /*#__PURE__*/React__default.createElement("input", _extends$2({}, props, {
26879
26864
  ref: inputEl,
26880
26865
  value: format$1(formatter)(value),
26881
26866
  onKeyDown: function onKeyDown(event) {
26882
- // Keep track of the state of the input before onChange, including if user is hitting delete
26883
- setState({
26884
- rawValue: value,
26867
+ // Keep track of the state of the input before onChange
26868
+ stateRefs.current = {
26869
+ isDelete: event.key === "Backspace" || event.key === "Delete",
26885
26870
  selectionStart: event.target.selectionStart,
26886
26871
  selectionEnd: event.target.selectionEnd,
26887
- "delete": event.key === "Backspace" || event.key === "Delete",
26888
- formattedValue: event.target.value
26889
- });
26872
+ rawValue: value
26873
+ };
26890
26874
  },
26891
- onChange: function onChange(event) {
26892
- /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
26893
- * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
26894
- * the unformatted value for the user's onChange, the formatted string and unformatted injection need
26895
- * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
26896
- * old unformatted value.
26897
- */
26898
- var injectionLength = event.target.value.length - state.formattedValue.length;
26899
- var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
26900
- var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
26901
- // Need to find where to put it
26902
-
26903
- var rawInjectionPointStart = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter);
26904
- var rawInjectionPointEnd = formattedToUnformattedIndex(state.selectionEnd, state.rawValue, formatter); // Unformat the previous formatted value for injection
26905
- // Using the relevant format string, strips away chars not marked with the formatChar
26906
-
26907
- var unformattedOldValue = unformat(formatter)(state.formattedValue, state.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
26908
-
26909
- var injectIntoOldValue = inject(unformattedOldValue);
26910
- var unformattedNewValue = state["delete"] ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
26911
- var lengthDifference = unformattedNewValue.length - state.rawValue.length;
26912
- var rawIndex = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
26913
- // Applied by useLayoutEffect
26914
-
26915
- var newFormattedCursorPosition = state.selectionStart == state.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, state["delete"]) : state["delete"] ? state.selectionStart : state.selectionEnd;
26916
- setState({
26917
- selectionStart: newFormattedCursorPosition,
26918
- selectionEnd: newFormattedCursorPosition,
26919
- rawValue: state.rawValue,
26920
- "delete": false,
26921
- formattedValue: state.formattedValue
26922
- }); // Apply the external onChange function to the raw underlying string
26923
- // This is where the user generally updates the input value
26924
-
26925
- if (_onChange) {
26926
- _onChange(unformattedNewValue);
26927
- }
26928
- }
26875
+ onChange: handleChange
26929
26876
  }));
26930
26877
  };
26931
26878
 
@@ -26994,7 +26941,7 @@ var fallbackValues$k = {
26994
26941
  };
26995
26942
 
26996
26943
  var _excluded$s = ["showErrors", "themeValues"],
26997
- _excluded2 = ["type", "labelTextWhenNoError", "errorMessages", "isNum", "isEmail", "helperModal", "field", "fieldActions", "showErrors", "formatter", "decorator", "themeValues", "background", "customHeight", "autocompleteValue", "extraStyles", "removeFromValue", "dataQa", "isRequired", "htmlFor", "inputId"];
26944
+ _excluded2 = ["type", "labelTextWhenNoError", "errorMessages", "isNum", "isEmail", "helperModal", "field", "fieldActions", "showErrors", "formatter", "decorator", "themeValues", "background", "customHeight", "autocompleteValue", "extraStyles", "removeFromValue", "dataQa", "isRequired"];
26998
26945
  var InputField = styled__default.input.withConfig({
26999
26946
  displayName: "FormInput__InputField",
27000
26947
  componentId: "sc-l094r1-0"
@@ -27082,10 +27029,6 @@ var FormInput = function FormInput(_ref15) {
27082
27029
  dataQa = _ref15$dataQa === void 0 ? null : _ref15$dataQa,
27083
27030
  _ref15$isRequired = _ref15.isRequired,
27084
27031
  isRequired = _ref15$isRequired === void 0 ? false : _ref15$isRequired,
27085
- _ref15$htmlFor = _ref15.htmlFor,
27086
- htmlFor = _ref15$htmlFor === void 0 ? null : _ref15$htmlFor,
27087
- _ref15$inputId = _ref15.inputId,
27088
- inputId = _ref15$inputId === void 0 ? null : _ref15$inputId,
27089
27032
  props = _objectWithoutProperties(_ref15, _excluded2);
27090
27033
  var _useState = React.useState(false),
27091
27034
  _useState2 = _slicedToArray(_useState, 2),
@@ -27123,8 +27066,7 @@ var FormInput = function FormInput(_ref15) {
27123
27066
  variant: "pS",
27124
27067
  weight: themeValues.fontWeight,
27125
27068
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
27126
- id: createIdFromString(labelTextWhenNoError),
27127
- htmlFor: htmlFor
27069
+ id: createIdFromString(labelTextWhenNoError)
27128
27070
  }, labelTextWhenNoError), helperModal()) : /*#__PURE__*/React__default.createElement(Box, {
27129
27071
  padding: "0",
27130
27072
  minWidth: "100%"
@@ -27137,8 +27079,7 @@ var FormInput = function FormInput(_ref15) {
27137
27079
  variant: "pS",
27138
27080
  fontWeight: themeValues.fontWeight,
27139
27081
  extraStyles: "word-break: break-word;\n font-family: Public Sans;\n &::first-letter {\n text-transform: uppercase;\n }",
27140
- id: createIdFromString(labelTextWhenNoError),
27141
- htmlFor: htmlFor
27082
+ id: createIdFromString(labelTextWhenNoError)
27142
27083
  }, labelTextWhenNoError), type === "password" && /*#__PURE__*/React__default.createElement(Text$1, {
27143
27084
  variant: "pS",
27144
27085
  color: themeValues.linkColor,
@@ -27159,7 +27100,6 @@ var FormInput = function FormInput(_ref15) {
27159
27100
  }, decorator)))), /*#__PURE__*/React__default.createElement(Box, {
27160
27101
  padding: "0"
27161
27102
  }, formatter ? /*#__PURE__*/React__default.createElement(FormattedInputField, _extends({
27162
- id: inputId || (props === null || props === void 0 ? void 0 : props.id),
27163
27103
  "aria-labelledby": createIdFromString(labelTextWhenNoError),
27164
27104
  "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
27165
27105
  "aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
@@ -27192,7 +27132,6 @@ var FormInput = function FormInput(_ref15) {
27192
27132
  }
27193
27133
  }
27194
27134
  }, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
27195
- id: inputId || (props === null || props === void 0 ? void 0 : props.id),
27196
27135
  "aria-labelledby": createIdFromString(labelTextWhenNoError),
27197
27136
  "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
27198
27137
  "aria-invalid": field.dirty && field.hasErrors || field.hasErrors && showErrors,
@@ -28627,7 +28566,7 @@ var Search = function Search(_ref) {
28627
28566
  id: "searchInput",
28628
28567
  role: "search",
28629
28568
  "aria-controls": ariaControlsId,
28630
- extraStyles: "border-radius: 2px 0 0 2px;",
28569
+ extraStyles: "border-radius: 4px 0 0 4px; border: none; box-shadow: 0px 1px 2px 0px ".concat(CHARADE_GREY, "1A; font-size: 0.875rem;"),
28631
28570
  onKeyDown: function onKeyDown(e) {
28632
28571
  return searchOnKeypress || e.key === "Enter" ? handleSubmit() : noop;
28633
28572
  },
@@ -28655,7 +28594,7 @@ var Search = function Search(_ref) {
28655
28594
  minWidth: "0",
28656
28595
  width: "3rem",
28657
28596
  padding: ".5rem",
28658
- extraStyles: "\n height: 48px; \n margin: 4px 0 0;\n border-radius: 0 2px 2px 0;\n background: ".concat(themeValues.searchIconBackgroundColor, ";\n "),
28597
+ extraStyles: "\n height: 48px; \n margin: 4px 0 0;\n border-radius: 0 4px 4px 0;\n background: ".concat(themeValues.searchIconBackgroundColor, ";\n border: none;\n box-shadow: 0px 1px 2px 0px ").concat(CHARADE_GREY, "1A;\n "),
28659
28598
  variant: "primary",
28660
28599
  contentOverride: true,
28661
28600
  action: handleSubmit
@@ -39332,11 +39271,7 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
39332
39271
  showErrors = _ref.showErrors,
39333
39272
  countryCode = _ref.countryCode,
39334
39273
  _ref$isRequired = _ref.isRequired,
39335
- isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired,
39336
- _ref$htmlFor = _ref.htmlFor,
39337
- htmlFor = _ref$htmlFor === void 0 ? null : _ref$htmlFor,
39338
- _ref$inputId = _ref.inputId,
39339
- inputId = _ref$inputId === void 0 ? null : _ref$inputId;
39274
+ isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired;
39340
39275
  var placeholder = countryCode === "US" ? placeHolderOptionUS : placeHolderOption;
39341
39276
  var options = [placeholder].concat(_toConsumableArray(getOptions(countryCode)));
39342
39277
  return /*#__PURE__*/React__default.createElement(FormSelect$1, {
@@ -39347,8 +39282,6 @@ var FormStateDropdown = function FormStateDropdown(_ref) {
39347
39282
  errorMessages: errorMessages,
39348
39283
  showErrors: showErrors,
39349
39284
  autocompleteValue: "address-level1",
39350
- htmlFor: htmlFor,
39351
- inputId: inputId,
39352
39285
  isRequired: isRequired
39353
39286
  });
39354
39287
  };
@@ -40862,8 +40795,6 @@ var AddressForm = function AddressForm(_ref) {
40862
40795
  }
40863
40796
  },
40864
40797
  showErrors: showErrors,
40865
- htmlFor: "country-name",
40866
- inputId: "country-name",
40867
40798
  dataQa: "Country",
40868
40799
  isRequired: true
40869
40800
  }), /*#__PURE__*/React__default.createElement(FormInput$1, {
@@ -40876,8 +40807,6 @@ var AddressForm = function AddressForm(_ref) {
40876
40807
  return e.key === "Enter" && handleSubmit(e);
40877
40808
  },
40878
40809
  autocompleteValue: "address-line1",
40879
- htmlFor: "address-line1",
40880
- inputId: "address-line1",
40881
40810
  dataQa: "Address",
40882
40811
  isRequired: true
40883
40812
  }), /*#__PURE__*/React__default.createElement(FormInput$1, {
@@ -40889,8 +40818,6 @@ var AddressForm = function AddressForm(_ref) {
40889
40818
  return e.key === "Enter" && handleSubmit(e);
40890
40819
  },
40891
40820
  autocompleteValue: "address-line2",
40892
- htmlFor: "address-line2",
40893
- inputId: "address-line2",
40894
40821
  dataQa: "Address Line 2"
40895
40822
  }), /*#__PURE__*/React__default.createElement(FormInput$1, {
40896
40823
  labelTextWhenNoError: "City",
@@ -40902,8 +40829,6 @@ var AddressForm = function AddressForm(_ref) {
40902
40829
  return e.key === "Enter" && handleSubmit(e);
40903
40830
  },
40904
40831
  autocompleteValue: "address-level2",
40905
- htmlFor: "city",
40906
- inputId: "city",
40907
40832
  dataQa: "City",
40908
40833
  isRequired: true
40909
40834
  }), /*#__PURE__*/React__default.createElement(FormStateDropdown, {
@@ -40916,9 +40841,6 @@ var AddressForm = function AddressForm(_ref) {
40916
40841
  onKeyDown: function onKeyDown(e) {
40917
40842
  return e.key === "Enter" && handleSubmit(e);
40918
40843
  },
40919
- autocompleteValue: "address-level1",
40920
- htmlFor: "stateOrProvince",
40921
- inputId: "stateOrProvince",
40922
40844
  dataQa: "State or Province",
40923
40845
  isRequired: true
40924
40846
  }), /*#__PURE__*/React__default.createElement(FormInput$1, {
@@ -40933,8 +40855,6 @@ var AddressForm = function AddressForm(_ref) {
40933
40855
  return e.key === "Enter" && handleSubmit(e);
40934
40856
  },
40935
40857
  autocompleteValue: "postal-code",
40936
- htmlFor: "postal-code",
40937
- inputId: "postal-code",
40938
40858
  dataQa: "Zip code",
40939
40859
  isRequired: true
40940
40860
  }), showWalletCheckbox && /*#__PURE__*/React__default.createElement(Checkbox$1, {
@@ -41822,6 +41742,13 @@ var EmailForm = function EmailForm(_ref) {
41822
41742
  }, []);
41823
41743
  }
41824
41744
  var emailFieldErrorMessages = _defineProperty(_defineProperty({}, required.error, "Email address is required"), isProbablyEmail.error, "Invalid email address");
41745
+ React.useEffect(function () {
41746
+ if (isRequired) {
41747
+ actions.fields.email.addValidator(required());
41748
+ } else {
41749
+ actions.fields.email.removeValidator(required());
41750
+ }
41751
+ }, [isRequired]);
41825
41752
  return /*#__PURE__*/React__default.createElement(FormContainer$1, {
41826
41753
  variant: variant,
41827
41754
  role: "form",
@@ -41852,7 +41779,7 @@ var EmailForm = function EmailForm(_ref) {
41852
41779
 
41853
41780
  var formConfig$3 = {
41854
41781
  email: {
41855
- validators: [required(), isProbablyEmail()]
41782
+ validators: [isProbablyEmail()] // 'required' validator is conditionally added based on `isRequired` prop
41856
41783
  }
41857
41784
  };
41858
41785
  var _createFormState$3 = createFormState(formConfig$3),
@@ -48068,8 +47995,6 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48068
47995
  isLoading = _ref4$isLoading === void 0 ? false : _ref4$isLoading,
48069
47996
  _ref4$isError = _ref4.isError,
48070
47997
  isError = _ref4$isError === void 0 ? false : _ref4$isError,
48071
- _ref4$multiCartEnable = _ref4.multiCartEnabled,
48072
- multiCartEnabled = _ref4$multiCartEnable === void 0 ? false : _ref4$multiCartEnable,
48073
47998
  agencyDisplayName = _ref4.agencyDisplayName;
48074
47999
  var _useState = React.useState(initiallyOpen),
48075
48000
  _useState2 = _slicedToArray(_useState, 2),
@@ -48110,7 +48035,7 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48110
48035
  variant: themeValues.labeledAmountSubtotal
48111
48036
  }, fee)));
48112
48037
  });
48113
- var agencySubheading = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, multiCartEnabled && agencyDisplayName && /*#__PURE__*/React__default.createElement(Cluster, {
48038
+ var agencySubheading = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, agencyDisplayName && /*#__PURE__*/React__default.createElement(Cluster, {
48114
48039
  justify: "space-between",
48115
48040
  align: "center",
48116
48041
  style: {
@@ -49059,6 +48984,13 @@ var PhoneForm = function PhoneForm(_ref) {
49059
48984
  }, []);
49060
48985
  }
49061
48986
  var phoneErrorMessage = _defineProperty(_defineProperty({}, required.error, "Phone number is required"), hasLength.error, "Phone number must be 10 digits");
48987
+ React.useEffect(function () {
48988
+ if (isRequired) {
48989
+ actions.fields.phone.addValidator(required());
48990
+ } else {
48991
+ actions.fields.phone.removeValidator(required());
48992
+ }
48993
+ }, [isRequired]);
49062
48994
  return /*#__PURE__*/React__default.createElement(FormContainer$1, {
49063
48995
  variant: variant,
49064
48996
  role: "form",
@@ -49087,7 +49019,8 @@ var PhoneForm = function PhoneForm(_ref) {
49087
49019
 
49088
49020
  var formConfig$8 = {
49089
49021
  phone: {
49090
- validators: [required(), hasLength(10, 10)],
49022
+ validators: [hasLength(10, 10)],
49023
+ // 'required' validator is conditionally added based on `isRequired` prop
49091
49024
  constraints: [onlyIntegers(), hasLength(0, 10)]
49092
49025
  }
49093
49026
  };