@thecb/components 10.9.0-beta.6 → 10.9.0-beta.8

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
@@ -26638,45 +26638,34 @@ function _extends$2() {
26638
26638
  _extends$2 = Object.assign || function (target) {
26639
26639
  for (var i = 1; i < arguments.length; i++) {
26640
26640
  var source = arguments[i];
26641
-
26642
26641
  for (var key in source) {
26643
26642
  if (Object.prototype.hasOwnProperty.call(source, key)) {
26644
26643
  target[key] = source[key];
26645
26644
  }
26646
26645
  }
26647
26646
  }
26648
-
26649
26647
  return target;
26650
26648
  };
26651
-
26652
26649
  return _extends$2.apply(this, arguments);
26653
26650
  }
26654
-
26655
26651
  function _objectWithoutPropertiesLoose$1(source, excluded) {
26656
26652
  if (source == null) return {};
26657
26653
  var target = {};
26658
26654
  var sourceKeys = Object.keys(source);
26659
26655
  var key, i;
26660
-
26661
26656
  for (i = 0; i < sourceKeys.length; i++) {
26662
26657
  key = sourceKeys[i];
26663
26658
  if (excluded.indexOf(key) >= 0) continue;
26664
26659
  target[key] = source[key];
26665
26660
  }
26666
-
26667
26661
  return target;
26668
26662
  }
26669
-
26670
26663
  function _objectWithoutProperties$1(source, excluded) {
26671
26664
  if (source == null) return {};
26672
-
26673
26665
  var target = _objectWithoutPropertiesLoose$1(source, excluded);
26674
-
26675
26666
  var key, i;
26676
-
26677
26667
  if (Object.getOwnPropertySymbols) {
26678
26668
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
26679
-
26680
26669
  for (i = 0; i < sourceSymbolKeys.length; i++) {
26681
26670
  key = sourceSymbolKeys[i];
26682
26671
  if (excluded.indexOf(key) >= 0) continue;
@@ -26684,48 +26673,37 @@ function _objectWithoutProperties$1(source, excluded) {
26684
26673
  target[key] = source[key];
26685
26674
  }
26686
26675
  }
26687
-
26688
26676
  return target;
26689
26677
  }
26690
-
26691
26678
  function _slicedToArray$1(arr, i) {
26692
26679
  return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _nonIterableRest$1();
26693
26680
  }
26694
-
26695
26681
  function _toConsumableArray$1(arr) {
26696
26682
  return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _nonIterableSpread$1();
26697
26683
  }
26698
-
26699
26684
  function _arrayWithoutHoles$1(arr) {
26700
26685
  if (Array.isArray(arr)) {
26701
26686
  for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
26702
-
26703
26687
  return arr2;
26704
26688
  }
26705
26689
  }
26706
-
26707
26690
  function _arrayWithHoles$1(arr) {
26708
26691
  if (Array.isArray(arr)) return arr;
26709
26692
  }
26710
-
26711
26693
  function _iterableToArray$1(iter) {
26712
26694
  if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
26713
26695
  }
26714
-
26715
26696
  function _iterableToArrayLimit$1(arr, i) {
26716
26697
  if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
26717
26698
  return;
26718
26699
  }
26719
-
26720
26700
  var _arr = [];
26721
26701
  var _n = true;
26722
26702
  var _d = false;
26723
26703
  var _e = undefined;
26724
-
26725
26704
  try {
26726
26705
  for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
26727
26706
  _arr.push(_s.value);
26728
-
26729
26707
  if (i && _arr.length === i) break;
26730
26708
  }
26731
26709
  } catch (err) {
@@ -26738,29 +26716,23 @@ function _iterableToArrayLimit$1(arr, i) {
26738
26716
  if (_d) throw _e;
26739
26717
  }
26740
26718
  }
26741
-
26742
26719
  return _arr;
26743
26720
  }
26744
-
26745
26721
  function _nonIterableSpread$1() {
26746
26722
  throw new TypeError("Invalid attempt to spread non-iterable instance");
26747
26723
  }
26748
-
26749
26724
  function _nonIterableRest$1() {
26750
26725
  throw new TypeError("Invalid attempt to destructure non-iterable instance");
26751
26726
  }
26752
-
26753
26727
  var getUniqueFormatDelimiters = function getUniqueFormatDelimiters(formats, formatChar) {
26754
26728
  return _toConsumableArray$1(new Set(formats.join("").split(formatChar).join("").split("")));
26755
26729
  };
26756
26730
  var format$1 = function format(formatter) {
26757
26731
  return function (value) {
26758
26732
  var usedFormat = formatter.formats[value.length];
26759
-
26760
26733
  if (!usedFormat) {
26761
26734
  return value;
26762
26735
  }
26763
-
26764
26736
  var formatPieces = usedFormat.split(formatter.formatChar);
26765
26737
  var valuePieces = value.split("");
26766
26738
  var zipped = formatPieces.map(function (v, i) {
@@ -26769,7 +26741,6 @@ var format$1 = function format(formatter) {
26769
26741
  return zipped.join("");
26770
26742
  };
26771
26743
  };
26772
-
26773
26744
  var countDelims = function countDelims(formatter, index) {
26774
26745
  var count = 0;
26775
26746
  var format = formatter.formats[index];
@@ -26779,13 +26750,11 @@ var countDelims = function countDelims(formatter, index) {
26779
26750
  });
26780
26751
  return count;
26781
26752
  };
26782
-
26783
26753
  var unformat = function unformat(formatter) {
26784
26754
  return function (formattedValue, formatIndex) {
26785
26755
  if (formatIndex >= formatter.formats.length) {
26786
26756
  return formattedValue;
26787
26757
  }
26788
-
26789
26758
  var format = formatter.formats[formatIndex];
26790
26759
  return formattedValue.split("").filter(function (_, i) {
26791
26760
  return !(format[i] != formatter.formatChar);
@@ -26798,8 +26767,9 @@ var inject = function inject(baseString) {
26798
26767
  };
26799
26768
  };
26800
26769
  var formattedToUnformattedIndex = function formattedToUnformattedIndex(formattedIndex, rawValue, formatter) {
26770
+ // TODO: fix this
26801
26771
  var maxFormatExceeded = rawValue.length >= formatter.formats.length;
26802
-
26772
+ console.log("🚀 ~ maxFormatExceeded:", maxFormatExceeded);
26803
26773
  if (maxFormatExceeded) {
26804
26774
  return formattedIndex;
26805
26775
  } else {
@@ -26811,7 +26781,9 @@ var formattedToUnformattedIndex = function formattedToUnformattedIndex(formatted
26811
26781
  }
26812
26782
  };
26813
26783
  var unformattedToFormattedIndex = function unformattedToFormattedIndex(rawIndex, rawValue, formatter, del) {
26814
- var maxFormatExceeded = rawValue.length >= formatter.formats.length; // If forced to stay formatted, offset by delims - 1
26784
+ // TODO: fix this
26785
+ var maxFormatExceeded = rawValue.length >= formatter.formats.length;
26786
+ console.log("🚀 ~ unformattedToFormattedIndex ~ maxFormatExceeded:", maxFormatExceeded); // If forced to stay formatted, offset by delims - 1
26815
26787
  // This is done so the component doesn't assume that any added chars will be kept
26816
26788
  // (i.e. if an external constraint is applied)
26817
26789
 
@@ -26824,7 +26796,6 @@ var unformattedToFormattedIndex = function unformattedToFormattedIndex(rawIndex,
26824
26796
  }, 0) + rawIndex;
26825
26797
  }
26826
26798
  };
26827
-
26828
26799
  var createFormat = function createFormat(formats, formatChar) {
26829
26800
  return {
26830
26801
  uniqueDelimiters: getUniqueFormatDelimiters(formats, formatChar),
@@ -26832,83 +26803,77 @@ var createFormat = function createFormat(formats, formatChar) {
26832
26803
  formatChar: formatChar
26833
26804
  };
26834
26805
  };
26835
-
26836
26806
  var FormattedInput = function FormattedInput(_ref) {
26837
26807
  var value = _ref.value,
26838
- formatter = _ref.formatter,
26839
- _onChange = _ref.onChange,
26840
- props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
26841
-
26808
+ formatter = _ref.formatter,
26809
+ onChange = _ref.onChange,
26810
+ props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
26842
26811
  var inputEl = React.useRef(null);
26843
-
26844
26812
  var _useState = React.useState({
26845
- selectionStart: 0,
26846
- selectionEnd: 0,
26847
- rawValue: value,
26848
- "delete": false,
26849
- formattedValue: format$1(formatter)(value)
26850
- }),
26851
- _useState2 = _slicedToArray$1(_useState, 2),
26852
- state = _useState2[0],
26853
- setState = _useState2[1];
26854
-
26813
+ selectionStart: 0,
26814
+ selectionEnd: 0,
26815
+ rawValue: value,
26816
+ formattedValue: format$1(formatter)(value)
26817
+ }),
26818
+ _useState2 = _slicedToArray$1(_useState, 2),
26819
+ state = _useState2[0],
26820
+ setState = _useState2[1];
26821
+ var isDeleteRef = React.useRef(false);
26855
26822
  React.useLayoutEffect(function () {
26856
26823
  // A lot of the work here is cursor manipulation
26857
26824
  if (inputEl.current && inputEl.current === document.activeElement) {
26858
26825
  inputEl.current.setSelectionRange(state.selectionStart, state.selectionEnd);
26859
26826
  }
26860
26827
  });
26861
- return React__default.createElement("input", _extends$2({}, props, {
26828
+ var handleChange = function handleChange(event) {
26829
+ // Detect the key event before the value change
26830
+ // const deleteKeyPressed = isDeleteRef.current;
26831
+ debugger;
26832
+ var deleteKeyPressed = event.key === "Backspace" || event.key === "Delete";
26833
+ /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
26834
+ * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
26835
+ * the unformatted value for the user's onChange, the formatted string and unformatted injection need
26836
+ * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
26837
+ * old unformatted value.
26838
+ */
26839
+
26840
+ var injectionLength = event.target.value.length - state.formattedValue.length;
26841
+ var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
26842
+ var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
26843
+ // Need to find where to put it
26844
+
26845
+ var rawInjectionPointStart = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter);
26846
+ var rawInjectionPointEnd = formattedToUnformattedIndex(state.selectionEnd, state.rawValue, formatter); // Unformat the previous formatted value for injection
26847
+ // Using the relevant format string, strips away chars not marked with the formatChar
26848
+
26849
+ var unformattedOldValue = unformat(formatter)(state.formattedValue, state.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
26850
+
26851
+ var injectIntoOldValue = inject(unformattedOldValue);
26852
+ var unformattedNewValue = deleteKeyPressed ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
26853
+ var lengthDifference = unformattedNewValue.length - state.rawValue.length;
26854
+ var rawIndex = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
26855
+ // Applied by useLayoutEffect
26856
+
26857
+ var newFormattedCursorPosition = state.selectionStart == state.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, deleteKeyPressed) : deleteKeyPressed ? state.selectionStart : state.selectionEnd;
26858
+ setState({
26859
+ selectionStart: newFormattedCursorPosition,
26860
+ selectionEnd: newFormattedCursorPosition,
26861
+ rawValue: unformattedNewValue,
26862
+ formattedValue: format$1(formatter)(unformattedNewValue)
26863
+ });
26864
+ if (onChange) {
26865
+ onChange(unformattedNewValue);
26866
+ } // Reset delete flag
26867
+
26868
+ isDeleteRef.current = false;
26869
+ };
26870
+ return /*#__PURE__*/React__default.createElement("input", _extends$2({}, props, {
26862
26871
  ref: inputEl,
26863
- value: format$1(formatter)(value),
26872
+ value: state.formattedValue,
26864
26873
  onKeyDown: function onKeyDown(event) {
26865
- // Keep track of the state of the input before onChange, including if user is hitting delete
26866
- setState({
26867
- rawValue: value,
26868
- selectionStart: event.target.selectionStart,
26869
- selectionEnd: event.target.selectionEnd,
26870
- "delete": event.key === "Backspace" || event.key === "Delete",
26871
- formattedValue: event.target.value
26872
- });
26874
+ isDeleteRef.current = event.key === "Backspace" || event.key === "Delete";
26873
26875
  },
26874
- onChange: function onChange(event) {
26875
- /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
26876
- * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
26877
- * the unformatted value for the user's onChange, the formatted string and unformatted injection need
26878
- * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
26879
- * old unformatted value.
26880
- */
26881
- var injectionLength = event.target.value.length - state.formattedValue.length;
26882
- var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
26883
- var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
26884
- // Need to find where to put it
26885
-
26886
- var rawInjectionPointStart = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter);
26887
- var rawInjectionPointEnd = formattedToUnformattedIndex(state.selectionEnd, state.rawValue, formatter); // Unformat the previous formatted value for injection
26888
- // Using the relevant format string, strips away chars not marked with the formatChar
26889
-
26890
- var unformattedOldValue = unformat(formatter)(state.formattedValue, state.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
26891
-
26892
- var injectIntoOldValue = inject(unformattedOldValue);
26893
- var unformattedNewValue = state["delete"] ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
26894
- var lengthDifference = unformattedNewValue.length - state.rawValue.length;
26895
- var rawIndex = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
26896
- // Applied by useLayoutEffect
26897
-
26898
- var newFormattedCursorPosition = state.selectionStart == state.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, state["delete"]) : state["delete"] ? state.selectionStart : state.selectionEnd;
26899
- setState({
26900
- selectionStart: newFormattedCursorPosition,
26901
- selectionEnd: newFormattedCursorPosition,
26902
- rawValue: state.rawValue,
26903
- "delete": false,
26904
- formattedValue: state.formattedValue
26905
- }); // Apply the external onChange function to the raw underlying string
26906
- // This is where the user generally updates the input value
26907
-
26908
- if (_onChange) {
26909
- _onChange(unformattedNewValue);
26910
- }
26911
- }
26876
+ onChange: handleChange
26912
26877
  }));
26913
26878
  };
26914
26879
 
@@ -27159,14 +27124,14 @@ var FormInput = function FormInput(_ref15) {
27159
27124
  autoComplete: autocompleteValue,
27160
27125
  required: isRequired
27161
27126
  // Additional handler to detect autofilled values
27162
- // {...(autocompleteValue && {
27163
- // onFocus: e => {
27164
- // if (!isFocused) {
27165
- // setValue(e.target?.value);
27166
- // setIsFocused(true);
27167
- // }
27168
- // }
27169
- // })}
27127
+ }, autocompleteValue && {
27128
+ onFocus: function onFocus(e) {
27129
+ if (!isFocused) {
27130
+ var _e$target;
27131
+ setValue((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
27132
+ setIsFocused(true);
27133
+ }
27134
+ }
27170
27135
  }, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
27171
27136
  "aria-labelledby": createIdFromString(labelTextWhenNoError),
27172
27137
  "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
@@ -28602,7 +28567,7 @@ var Search = function Search(_ref) {
28602
28567
  id: "searchInput",
28603
28568
  role: "search",
28604
28569
  "aria-controls": ariaControlsId,
28605
- extraStyles: "border-radius: 2px 0 0 2px;",
28570
+ extraStyles: "border-radius: 4px 0 0 4px; border: none; box-shadow: 0px 1px 2px 0px ".concat(CHARADE_GREY, "1A; font-size: 0.875rem;"),
28606
28571
  onKeyDown: function onKeyDown(e) {
28607
28572
  return searchOnKeypress || e.key === "Enter" ? handleSubmit() : noop;
28608
28573
  },
@@ -28630,7 +28595,7 @@ var Search = function Search(_ref) {
28630
28595
  minWidth: "0",
28631
28596
  width: "3rem",
28632
28597
  padding: ".5rem",
28633
- extraStyles: "\n height: 48px; \n margin: 4px 0 0;\n border-radius: 0 2px 2px 0;\n background: ".concat(themeValues.searchIconBackgroundColor, ";\n "),
28598
+ 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 "),
28634
28599
  variant: "primary",
28635
28600
  contentOverride: true,
28636
28601
  action: handleSubmit
@@ -48024,8 +47989,6 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48024
47989
  isLoading = _ref4$isLoading === void 0 ? false : _ref4$isLoading,
48025
47990
  _ref4$isError = _ref4.isError,
48026
47991
  isError = _ref4$isError === void 0 ? false : _ref4$isError,
48027
- _ref4$multiCartEnable = _ref4.multiCartEnabled,
48028
- multiCartEnabled = _ref4$multiCartEnable === void 0 ? false : _ref4$multiCartEnable,
48029
47992
  agencyDisplayName = _ref4.agencyDisplayName;
48030
47993
  var _useState = React.useState(initiallyOpen),
48031
47994
  _useState2 = _slicedToArray(_useState, 2),
@@ -48066,7 +48029,7 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48066
48029
  variant: themeValues.labeledAmountSubtotal
48067
48030
  }, fee)));
48068
48031
  });
48069
- var agencySubheading = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, multiCartEnabled && agencyDisplayName && /*#__PURE__*/React__default.createElement(Cluster, {
48032
+ var agencySubheading = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, agencyDisplayName && /*#__PURE__*/React__default.createElement(Cluster, {
48070
48033
  justify: "space-between",
48071
48034
  align: "center",
48072
48035
  style: {