@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.esm.js CHANGED
@@ -26630,45 +26630,34 @@ function _extends$2() {
26630
26630
  _extends$2 = Object.assign || function (target) {
26631
26631
  for (var i = 1; i < arguments.length; i++) {
26632
26632
  var source = arguments[i];
26633
-
26634
26633
  for (var key in source) {
26635
26634
  if (Object.prototype.hasOwnProperty.call(source, key)) {
26636
26635
  target[key] = source[key];
26637
26636
  }
26638
26637
  }
26639
26638
  }
26640
-
26641
26639
  return target;
26642
26640
  };
26643
-
26644
26641
  return _extends$2.apply(this, arguments);
26645
26642
  }
26646
-
26647
26643
  function _objectWithoutPropertiesLoose$1(source, excluded) {
26648
26644
  if (source == null) return {};
26649
26645
  var target = {};
26650
26646
  var sourceKeys = Object.keys(source);
26651
26647
  var key, i;
26652
-
26653
26648
  for (i = 0; i < sourceKeys.length; i++) {
26654
26649
  key = sourceKeys[i];
26655
26650
  if (excluded.indexOf(key) >= 0) continue;
26656
26651
  target[key] = source[key];
26657
26652
  }
26658
-
26659
26653
  return target;
26660
26654
  }
26661
-
26662
26655
  function _objectWithoutProperties$1(source, excluded) {
26663
26656
  if (source == null) return {};
26664
-
26665
26657
  var target = _objectWithoutPropertiesLoose$1(source, excluded);
26666
-
26667
26658
  var key, i;
26668
-
26669
26659
  if (Object.getOwnPropertySymbols) {
26670
26660
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
26671
-
26672
26661
  for (i = 0; i < sourceSymbolKeys.length; i++) {
26673
26662
  key = sourceSymbolKeys[i];
26674
26663
  if (excluded.indexOf(key) >= 0) continue;
@@ -26676,48 +26665,37 @@ function _objectWithoutProperties$1(source, excluded) {
26676
26665
  target[key] = source[key];
26677
26666
  }
26678
26667
  }
26679
-
26680
26668
  return target;
26681
26669
  }
26682
-
26683
26670
  function _slicedToArray$1(arr, i) {
26684
26671
  return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _nonIterableRest$1();
26685
26672
  }
26686
-
26687
26673
  function _toConsumableArray$1(arr) {
26688
26674
  return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _nonIterableSpread$1();
26689
26675
  }
26690
-
26691
26676
  function _arrayWithoutHoles$1(arr) {
26692
26677
  if (Array.isArray(arr)) {
26693
26678
  for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
26694
-
26695
26679
  return arr2;
26696
26680
  }
26697
26681
  }
26698
-
26699
26682
  function _arrayWithHoles$1(arr) {
26700
26683
  if (Array.isArray(arr)) return arr;
26701
26684
  }
26702
-
26703
26685
  function _iterableToArray$1(iter) {
26704
26686
  if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
26705
26687
  }
26706
-
26707
26688
  function _iterableToArrayLimit$1(arr, i) {
26708
26689
  if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
26709
26690
  return;
26710
26691
  }
26711
-
26712
26692
  var _arr = [];
26713
26693
  var _n = true;
26714
26694
  var _d = false;
26715
26695
  var _e = undefined;
26716
-
26717
26696
  try {
26718
26697
  for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
26719
26698
  _arr.push(_s.value);
26720
-
26721
26699
  if (i && _arr.length === i) break;
26722
26700
  }
26723
26701
  } catch (err) {
@@ -26730,29 +26708,23 @@ function _iterableToArrayLimit$1(arr, i) {
26730
26708
  if (_d) throw _e;
26731
26709
  }
26732
26710
  }
26733
-
26734
26711
  return _arr;
26735
26712
  }
26736
-
26737
26713
  function _nonIterableSpread$1() {
26738
26714
  throw new TypeError("Invalid attempt to spread non-iterable instance");
26739
26715
  }
26740
-
26741
26716
  function _nonIterableRest$1() {
26742
26717
  throw new TypeError("Invalid attempt to destructure non-iterable instance");
26743
26718
  }
26744
-
26745
26719
  var getUniqueFormatDelimiters = function getUniqueFormatDelimiters(formats, formatChar) {
26746
26720
  return _toConsumableArray$1(new Set(formats.join("").split(formatChar).join("").split("")));
26747
26721
  };
26748
26722
  var format$1 = function format(formatter) {
26749
26723
  return function (value) {
26750
26724
  var usedFormat = formatter.formats[value.length];
26751
-
26752
26725
  if (!usedFormat) {
26753
26726
  return value;
26754
26727
  }
26755
-
26756
26728
  var formatPieces = usedFormat.split(formatter.formatChar);
26757
26729
  var valuePieces = value.split("");
26758
26730
  var zipped = formatPieces.map(function (v, i) {
@@ -26761,7 +26733,6 @@ var format$1 = function format(formatter) {
26761
26733
  return zipped.join("");
26762
26734
  };
26763
26735
  };
26764
-
26765
26736
  var countDelims = function countDelims(formatter, index) {
26766
26737
  var count = 0;
26767
26738
  var format = formatter.formats[index];
@@ -26771,13 +26742,11 @@ var countDelims = function countDelims(formatter, index) {
26771
26742
  });
26772
26743
  return count;
26773
26744
  };
26774
-
26775
26745
  var unformat = function unformat(formatter) {
26776
26746
  return function (formattedValue, formatIndex) {
26777
26747
  if (formatIndex >= formatter.formats.length) {
26778
26748
  return formattedValue;
26779
26749
  }
26780
-
26781
26750
  var format = formatter.formats[formatIndex];
26782
26751
  return formattedValue.split("").filter(function (_, i) {
26783
26752
  return !(format[i] != formatter.formatChar);
@@ -26790,8 +26759,9 @@ var inject = function inject(baseString) {
26790
26759
  };
26791
26760
  };
26792
26761
  var formattedToUnformattedIndex = function formattedToUnformattedIndex(formattedIndex, rawValue, formatter) {
26762
+ // TODO: fix this
26793
26763
  var maxFormatExceeded = rawValue.length >= formatter.formats.length;
26794
-
26764
+ console.log("🚀 ~ maxFormatExceeded:", maxFormatExceeded);
26795
26765
  if (maxFormatExceeded) {
26796
26766
  return formattedIndex;
26797
26767
  } else {
@@ -26803,7 +26773,9 @@ var formattedToUnformattedIndex = function formattedToUnformattedIndex(formatted
26803
26773
  }
26804
26774
  };
26805
26775
  var unformattedToFormattedIndex = function unformattedToFormattedIndex(rawIndex, rawValue, formatter, del) {
26806
- var maxFormatExceeded = rawValue.length >= formatter.formats.length; // If forced to stay formatted, offset by delims - 1
26776
+ // TODO: fix this
26777
+ var maxFormatExceeded = rawValue.length >= formatter.formats.length;
26778
+ console.log("🚀 ~ unformattedToFormattedIndex ~ maxFormatExceeded:", maxFormatExceeded); // If forced to stay formatted, offset by delims - 1
26807
26779
  // This is done so the component doesn't assume that any added chars will be kept
26808
26780
  // (i.e. if an external constraint is applied)
26809
26781
 
@@ -26816,7 +26788,6 @@ var unformattedToFormattedIndex = function unformattedToFormattedIndex(rawIndex,
26816
26788
  }, 0) + rawIndex;
26817
26789
  }
26818
26790
  };
26819
-
26820
26791
  var createFormat = function createFormat(formats, formatChar) {
26821
26792
  return {
26822
26793
  uniqueDelimiters: getUniqueFormatDelimiters(formats, formatChar),
@@ -26824,100 +26795,77 @@ var createFormat = function createFormat(formats, formatChar) {
26824
26795
  formatChar: formatChar
26825
26796
  };
26826
26797
  };
26827
-
26828
26798
  var FormattedInput = function FormattedInput(_ref) {
26829
26799
  var value = _ref.value,
26830
- formatter = _ref.formatter,
26831
- _onChange = _ref.onChange,
26832
- props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
26833
-
26834
- console.log("🚀 ~ FormattedInput ~ props:", props);
26800
+ formatter = _ref.formatter,
26801
+ onChange = _ref.onChange,
26802
+ props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
26835
26803
  var inputEl = useRef(null);
26836
-
26837
26804
  var _useState = useState({
26838
- selectionStart: 0,
26839
- selectionEnd: 0,
26840
- rawValue: value,
26841
- "delete": false,
26842
- formattedValue: format$1(formatter)(value)
26843
- }),
26844
- _useState2 = _slicedToArray$1(_useState, 2),
26845
- state = _useState2[0],
26846
- setState = _useState2[1];
26847
-
26805
+ selectionStart: 0,
26806
+ selectionEnd: 0,
26807
+ rawValue: value,
26808
+ formattedValue: format$1(formatter)(value)
26809
+ }),
26810
+ _useState2 = _slicedToArray$1(_useState, 2),
26811
+ state = _useState2[0],
26812
+ setState = _useState2[1];
26813
+ var isDeleteRef = useRef(false);
26848
26814
  useLayoutEffect(function () {
26849
26815
  // A lot of the work here is cursor manipulation
26850
26816
  if (inputEl.current && inputEl.current === document.activeElement) {
26851
26817
  inputEl.current.setSelectionRange(state.selectionStart, state.selectionEnd);
26852
26818
  }
26853
26819
  });
26854
- return React.createElement("input", _extends$2({}, props, {
26820
+ var handleChange = function handleChange(event) {
26821
+ // Detect the key event before the value change
26822
+ // const deleteKeyPressed = isDeleteRef.current;
26823
+ debugger;
26824
+ var deleteKeyPressed = event.key === "Backspace" || event.key === "Delete";
26825
+ /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
26826
+ * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
26827
+ * the unformatted value for the user's onChange, the formatted string and unformatted injection need
26828
+ * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
26829
+ * old unformatted value.
26830
+ */
26831
+
26832
+ var injectionLength = event.target.value.length - state.formattedValue.length;
26833
+ var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
26834
+ var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
26835
+ // Need to find where to put it
26836
+
26837
+ var rawInjectionPointStart = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter);
26838
+ var rawInjectionPointEnd = formattedToUnformattedIndex(state.selectionEnd, state.rawValue, formatter); // Unformat the previous formatted value for injection
26839
+ // Using the relevant format string, strips away chars not marked with the formatChar
26840
+
26841
+ var unformattedOldValue = unformat(formatter)(state.formattedValue, state.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
26842
+
26843
+ var injectIntoOldValue = inject(unformattedOldValue);
26844
+ var unformattedNewValue = deleteKeyPressed ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
26845
+ var lengthDifference = unformattedNewValue.length - state.rawValue.length;
26846
+ var rawIndex = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
26847
+ // Applied by useLayoutEffect
26848
+
26849
+ var newFormattedCursorPosition = state.selectionStart == state.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, deleteKeyPressed) : deleteKeyPressed ? state.selectionStart : state.selectionEnd;
26850
+ setState({
26851
+ selectionStart: newFormattedCursorPosition,
26852
+ selectionEnd: newFormattedCursorPosition,
26853
+ rawValue: unformattedNewValue,
26854
+ formattedValue: format$1(formatter)(unformattedNewValue)
26855
+ });
26856
+ if (onChange) {
26857
+ onChange(unformattedNewValue);
26858
+ } // Reset delete flag
26859
+
26860
+ isDeleteRef.current = false;
26861
+ };
26862
+ return /*#__PURE__*/React.createElement("input", _extends$2({}, props, {
26855
26863
  ref: inputEl,
26856
- value: format$1(formatter)(value) // onKeyDown={event => {
26857
- // if (event.isTrusted && event.key === 'Unidentified') {
26858
- // // Possibly an autofill event
26859
- // console.log('autofill event')
26860
- // } else {
26861
- // console.log('regular user input')
26862
- // // Regular user input
26863
- // // Keep track of the state of the input before onChange, including if user is hitting delete
26864
- // setState({
26865
- // rawValue: value,
26866
- // selectionStart: event.target.selectionStart,
26867
- // selectionEnd: event.target.selectionEnd,
26868
- // delete: event.key === "Backspace" || event.key === "Delete",
26869
- // formattedValue: event.target.value
26870
- // });
26871
- // }
26872
- // console.log('on key down fired')
26873
- // }}
26874
- ,
26875
- onChange: function onChange(event) {
26876
- setState({
26877
- rawValue: value,
26878
- selectionStart: event.target.selectionStart,
26879
- selectionEnd: event.target.selectionEnd,
26880
- "delete": event.key === "Backspace" || event.key === "Delete",
26881
- formattedValue: event.target.value
26882
- });
26883
- /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
26884
- * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
26885
- * the unformatted value for the user's onChange, the formatted string and unformatted injection need
26886
- * to be separated, then unformat the formatted string, then in sert (or delete) the injection from the
26887
- * old unformatted value.
26888
- */
26889
-
26890
- var injectionLength = event.target.value.length - state.formattedValue.length;
26891
- var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
26892
- var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
26893
- // Need to find where to put it
26894
-
26895
- var rawInjectionPointStart = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter);
26896
- var rawInjectionPointEnd = formattedToUnformattedIndex(state.selectionEnd, state.rawValue, formatter); // Unformat the previous formatted value for injection
26897
- // Using the relevant format string, strips away chars not marked with the formatChar
26898
-
26899
- var unformattedOldValue = unformat(formatter)(state.formattedValue, state.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
26900
-
26901
- var injectIntoOldValue = inject(unformattedOldValue);
26902
- var unformattedNewValue = state["delete"] ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
26903
- var lengthDifference = unformattedNewValue.length - state.rawValue.length;
26904
- var rawIndex = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
26905
- // Applied by useLayoutEffect
26906
-
26907
- var newFormattedCursorPosition = state.selectionStart == state.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, state["delete"]) : state["delete"] ? state.selectionStart : state.selectionEnd;
26908
- setState({
26909
- selectionStart: newFormattedCursorPosition,
26910
- selectionEnd: newFormattedCursorPosition,
26911
- rawValue: state.rawValue,
26912
- "delete": false,
26913
- formattedValue: state.formattedValue
26914
- }); // Apply the external onChange function to the raw underlying string
26915
- // This is where the user generally updates the input value
26916
-
26917
- if (_onChange) {
26918
- _onChange(unformattedNewValue);
26919
- }
26920
- }
26864
+ value: state.formattedValue,
26865
+ onKeyDown: function onKeyDown(event) {
26866
+ isDeleteRef.current = event.key === "Backspace" || event.key === "Delete";
26867
+ },
26868
+ onChange: handleChange
26921
26869
  }));
26922
26870
  };
26923
26871
 
@@ -28611,7 +28559,7 @@ var Search = function Search(_ref) {
28611
28559
  id: "searchInput",
28612
28560
  role: "search",
28613
28561
  "aria-controls": ariaControlsId,
28614
- extraStyles: "border-radius: 2px 0 0 2px;",
28562
+ extraStyles: "border-radius: 4px 0 0 4px; border: none; box-shadow: 0px 1px 2px 0px ".concat(CHARADE_GREY, "1A; font-size: 0.875rem;"),
28615
28563
  onKeyDown: function onKeyDown(e) {
28616
28564
  return searchOnKeypress || e.key === "Enter" ? handleSubmit() : noop;
28617
28565
  },
@@ -28639,7 +28587,7 @@ var Search = function Search(_ref) {
28639
28587
  minWidth: "0",
28640
28588
  width: "3rem",
28641
28589
  padding: ".5rem",
28642
- extraStyles: "\n height: 48px; \n margin: 4px 0 0;\n border-radius: 0 2px 2px 0;\n background: ".concat(themeValues.searchIconBackgroundColor, ";\n "),
28590
+ 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 "),
28643
28591
  variant: "primary",
28644
28592
  contentOverride: true,
28645
28593
  action: handleSubmit
@@ -48033,8 +47981,6 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48033
47981
  isLoading = _ref4$isLoading === void 0 ? false : _ref4$isLoading,
48034
47982
  _ref4$isError = _ref4.isError,
48035
47983
  isError = _ref4$isError === void 0 ? false : _ref4$isError,
48036
- _ref4$multiCartEnable = _ref4.multiCartEnabled,
48037
- multiCartEnabled = _ref4$multiCartEnable === void 0 ? false : _ref4$multiCartEnable,
48038
47984
  agencyDisplayName = _ref4.agencyDisplayName;
48039
47985
  var _useState = useState(initiallyOpen),
48040
47986
  _useState2 = _slicedToArray(_useState, 2),
@@ -48075,7 +48021,7 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48075
48021
  variant: themeValues.labeledAmountSubtotal
48076
48022
  }, fee)));
48077
48023
  });
48078
- var agencySubheading = /*#__PURE__*/React.createElement(React.Fragment, null, multiCartEnabled && agencyDisplayName && /*#__PURE__*/React.createElement(Cluster, {
48024
+ var agencySubheading = /*#__PURE__*/React.createElement(React.Fragment, null, agencyDisplayName && /*#__PURE__*/React.createElement(Cluster, {
48079
48025
  justify: "space-between",
48080
48026
  align: "center",
48081
48027
  style: {