@thecb/components 10.9.0-beta.7 → 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,100 +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
-
26842
- console.log("🚀 ~ FormattedInput ~ props:", props);
26808
+ formatter = _ref.formatter,
26809
+ onChange = _ref.onChange,
26810
+ props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
26843
26811
  var inputEl = React.useRef(null);
26844
-
26845
26812
  var _useState = React.useState({
26846
- selectionStart: 0,
26847
- selectionEnd: 0,
26848
- rawValue: value,
26849
- "delete": false,
26850
- formattedValue: format$1(formatter)(value)
26851
- }),
26852
- _useState2 = _slicedToArray$1(_useState, 2),
26853
- state = _useState2[0],
26854
- setState = _useState2[1];
26855
-
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);
26856
26822
  React.useLayoutEffect(function () {
26857
26823
  // A lot of the work here is cursor manipulation
26858
26824
  if (inputEl.current && inputEl.current === document.activeElement) {
26859
26825
  inputEl.current.setSelectionRange(state.selectionStart, state.selectionEnd);
26860
26826
  }
26861
26827
  });
26862
- 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, {
26863
26871
  ref: inputEl,
26864
- value: format$1(formatter)(value) // onKeyDown={event => {
26865
- // if (event.isTrusted && event.key === 'Unidentified') {
26866
- // // Possibly an autofill event
26867
- // console.log('autofill event')
26868
- // } else {
26869
- // console.log('regular user input')
26870
- // // Regular user input
26871
- // // Keep track of the state of the input before onChange, including if user is hitting delete
26872
- // setState({
26873
- // rawValue: value,
26874
- // selectionStart: event.target.selectionStart,
26875
- // selectionEnd: event.target.selectionEnd,
26876
- // delete: event.key === "Backspace" || event.key === "Delete",
26877
- // formattedValue: event.target.value
26878
- // });
26879
- // }
26880
- // console.log('on key down fired')
26881
- // }}
26882
- ,
26883
- onChange: function onChange(event) {
26884
- setState({
26885
- rawValue: value,
26886
- selectionStart: event.target.selectionStart,
26887
- selectionEnd: event.target.selectionEnd,
26888
- "delete": event.key === "Backspace" || event.key === "Delete",
26889
- formattedValue: event.target.value
26890
- });
26891
- /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
26892
- * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
26893
- * the unformatted value for the user's onChange, the formatted string and unformatted injection need
26894
- * to be separated, then unformat the formatted string, then in sert (or delete) the injection from the
26895
- * old unformatted value.
26896
- */
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
- }
26872
+ value: state.formattedValue,
26873
+ onKeyDown: function onKeyDown(event) {
26874
+ isDeleteRef.current = event.key === "Backspace" || event.key === "Delete";
26875
+ },
26876
+ onChange: handleChange
26929
26877
  }));
26930
26878
  };
26931
26879
 
@@ -28619,7 +28567,7 @@ var Search = function Search(_ref) {
28619
28567
  id: "searchInput",
28620
28568
  role: "search",
28621
28569
  "aria-controls": ariaControlsId,
28622
- 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;"),
28623
28571
  onKeyDown: function onKeyDown(e) {
28624
28572
  return searchOnKeypress || e.key === "Enter" ? handleSubmit() : noop;
28625
28573
  },
@@ -28647,7 +28595,7 @@ var Search = function Search(_ref) {
28647
28595
  minWidth: "0",
28648
28596
  width: "3rem",
28649
28597
  padding: ".5rem",
28650
- 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 "),
28651
28599
  variant: "primary",
28652
28600
  contentOverride: true,
28653
28601
  action: handleSubmit
@@ -48041,8 +47989,6 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48041
47989
  isLoading = _ref4$isLoading === void 0 ? false : _ref4$isLoading,
48042
47990
  _ref4$isError = _ref4.isError,
48043
47991
  isError = _ref4$isError === void 0 ? false : _ref4$isError,
48044
- _ref4$multiCartEnable = _ref4.multiCartEnabled,
48045
- multiCartEnabled = _ref4$multiCartEnable === void 0 ? false : _ref4$multiCartEnable,
48046
47992
  agencyDisplayName = _ref4.agencyDisplayName;
48047
47993
  var _useState = React.useState(initiallyOpen),
48048
47994
  _useState2 = _slicedToArray(_useState, 2),
@@ -48083,7 +48029,7 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48083
48029
  variant: themeValues.labeledAmountSubtotal
48084
48030
  }, fee)));
48085
48031
  });
48086
- 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, {
48087
48033
  justify: "space-between",
48088
48034
  align: "center",
48089
48035
  style: {