@thecb/components 10.8.3-beta.2 → 10.8.3
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 +76 -89
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +76 -89
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/search/Search.js +3 -1
- package/src/components/molecules/address-form/AddressForm.js +1 -0
- package/src/components/molecules/payment-details/PaymentDetails.js +1 -2
- package/src/components/molecules/payment-details/PaymentDetails.stories.js +0 -1
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);
|
|
@@ -26799,7 +26768,6 @@ var inject = function inject(baseString) {
|
|
|
26799
26768
|
};
|
|
26800
26769
|
var formattedToUnformattedIndex = function formattedToUnformattedIndex(formattedIndex, rawValue, formatter) {
|
|
26801
26770
|
var maxFormatExceeded = rawValue.length >= formatter.formats.length;
|
|
26802
|
-
|
|
26803
26771
|
if (maxFormatExceeded) {
|
|
26804
26772
|
return formattedIndex;
|
|
26805
26773
|
} else {
|
|
@@ -26824,7 +26792,6 @@ var unformattedToFormattedIndex = function unformattedToFormattedIndex(rawIndex,
|
|
|
26824
26792
|
}, 0) + rawIndex;
|
|
26825
26793
|
}
|
|
26826
26794
|
};
|
|
26827
|
-
|
|
26828
26795
|
var createFormat = function createFormat(formats, formatChar) {
|
|
26829
26796
|
return {
|
|
26830
26797
|
uniqueDelimiters: getUniqueFormatDelimiters(formats, formatChar),
|
|
@@ -26832,33 +26799,70 @@ var createFormat = function createFormat(formats, formatChar) {
|
|
|
26832
26799
|
formatChar: formatChar
|
|
26833
26800
|
};
|
|
26834
26801
|
};
|
|
26835
|
-
|
|
26836
26802
|
var FormattedInput = function FormattedInput(_ref) {
|
|
26837
|
-
var
|
|
26838
|
-
|
|
26839
|
-
|
|
26840
|
-
|
|
26841
|
-
|
|
26803
|
+
var _ref$isMobile = _ref.isMobile,
|
|
26804
|
+
isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile,
|
|
26805
|
+
value = _ref.value,
|
|
26806
|
+
formatter = _ref.formatter,
|
|
26807
|
+
_onChange = _ref.onChange,
|
|
26808
|
+
props = _objectWithoutProperties$1(_ref, ["isMobile", "value", "formatter", "onChange"]);
|
|
26809
|
+
console.log("🚀 ~ FormattedInput ~ props:", props);
|
|
26810
|
+
console.log('isMobile line', isMobile);
|
|
26842
26811
|
var inputEl = React.useRef(null);
|
|
26843
|
-
|
|
26844
26812
|
var _useState = React.useState({
|
|
26845
|
-
|
|
26846
|
-
|
|
26847
|
-
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
|
|
26851
|
-
|
|
26852
|
-
|
|
26853
|
-
|
|
26854
|
-
|
|
26813
|
+
selectionStart: 0,
|
|
26814
|
+
selectionEnd: 0,
|
|
26815
|
+
rawValue: value,
|
|
26816
|
+
"delete": false,
|
|
26817
|
+
formattedValue: format$1(formatter)(value)
|
|
26818
|
+
}),
|
|
26819
|
+
_useState2 = _slicedToArray$1(_useState, 2),
|
|
26820
|
+
state = _useState2[0],
|
|
26821
|
+
setState = _useState2[1];
|
|
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
|
-
|
|
26828
|
+
var handleFormat = function handleFormat(event) {
|
|
26829
|
+
debugger;
|
|
26830
|
+
console.log('in handle format 2');
|
|
26831
|
+
/* At the beginning of onChange, event.target.value is a concat of the previous formatted value
|
|
26832
|
+
* and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
|
|
26833
|
+
* the unformatted value for the user's onChange, the formatted string and unformatted injection need
|
|
26834
|
+
* to be separated, then unformat the formatted string, then insert (or delete) the injection from the
|
|
26835
|
+
* old unformatted value.
|
|
26836
|
+
*/
|
|
26837
|
+
|
|
26838
|
+
var injectionLength = event.target.value.length - state.formattedValue.length;
|
|
26839
|
+
var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
|
|
26840
|
+
var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
|
|
26841
|
+
// Need to find where to put it
|
|
26842
|
+
|
|
26843
|
+
var rawInjectionPointStart = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter);
|
|
26844
|
+
var rawInjectionPointEnd = formattedToUnformattedIndex(state.selectionEnd, state.rawValue, formatter); // Unformat the previous formatted value for injection
|
|
26845
|
+
// Using the relevant format string, strips away chars not marked with the formatChar
|
|
26846
|
+
|
|
26847
|
+
var unformattedOldValue = unformat(formatter)(state.formattedValue, state.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
|
|
26848
|
+
|
|
26849
|
+
var injectIntoOldValue = inject(unformattedOldValue);
|
|
26850
|
+
var unformattedNewValue = state["delete"] ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
|
|
26851
|
+
var lengthDifference = unformattedNewValue.length - state.rawValue.length;
|
|
26852
|
+
var rawIndex = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
|
|
26853
|
+
// Applied by useLayoutEffect
|
|
26854
|
+
|
|
26855
|
+
var newFormattedCursorPosition = state.selectionStart == state.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, state["delete"]) : state["delete"] ? state.selectionStart : state.selectionEnd;
|
|
26856
|
+
setState({
|
|
26857
|
+
selectionStart: newFormattedCursorPosition,
|
|
26858
|
+
selectionEnd: newFormattedCursorPosition,
|
|
26859
|
+
rawValue: state.rawValue,
|
|
26860
|
+
"delete": false,
|
|
26861
|
+
formattedValue: state.formattedValue
|
|
26862
|
+
});
|
|
26863
|
+
return unformattedNewValue;
|
|
26864
|
+
};
|
|
26865
|
+
return /*#__PURE__*/React__default.createElement("input", _extends$2({}, props, {
|
|
26862
26866
|
ref: inputEl,
|
|
26863
26867
|
value: format$1(formatter)(value),
|
|
26864
26868
|
onKeyDown: function onKeyDown(event) {
|
|
@@ -26871,42 +26875,26 @@ var FormattedInput = function FormattedInput(_ref) {
|
|
|
26871
26875
|
formattedValue: event.target.value
|
|
26872
26876
|
});
|
|
26873
26877
|
},
|
|
26874
|
-
onChange: function onChange(
|
|
26875
|
-
|
|
26876
|
-
|
|
26877
|
-
|
|
26878
|
-
|
|
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
|
|
26878
|
+
onChange: function onChange(e) {
|
|
26879
|
+
console.log('in onChange');
|
|
26880
|
+
if (!isMobile) {
|
|
26881
|
+
handleFormat(e);
|
|
26882
|
+
} // Apply the external onChange function to the raw underlying string
|
|
26906
26883
|
// This is where the user generally updates the input value
|
|
26907
26884
|
|
|
26908
26885
|
if (_onChange) {
|
|
26909
|
-
_onChange(
|
|
26886
|
+
_onChange(e.target.value);
|
|
26887
|
+
}
|
|
26888
|
+
},
|
|
26889
|
+
onBlur: function onBlur(e) {
|
|
26890
|
+
console.log('in onBlur');
|
|
26891
|
+
if (isMobile) {
|
|
26892
|
+
handleFormat(e);
|
|
26893
|
+
} // Apply the external onChange function to the raw underlying string
|
|
26894
|
+
// This is where the user generally updates the input value
|
|
26895
|
+
|
|
26896
|
+
if (_onChange) {
|
|
26897
|
+
_onChange(e.target.value);
|
|
26910
26898
|
}
|
|
26911
26899
|
}
|
|
26912
26900
|
}));
|
|
@@ -28602,7 +28590,7 @@ var Search = function Search(_ref) {
|
|
|
28602
28590
|
id: "searchInput",
|
|
28603
28591
|
role: "search",
|
|
28604
28592
|
"aria-controls": ariaControlsId,
|
|
28605
|
-
extraStyles: "border-radius: 4px 0 0 4px
|
|
28593
|
+
extraStyles: "border-radius: 4px 0 0 4px; border: none; box-shadow: 0px 1px 2px 0px ".concat(CHARADE_GREY, "1A; font-size: 0.875rem;"),
|
|
28606
28594
|
onKeyDown: function onKeyDown(e) {
|
|
28607
28595
|
return searchOnKeypress || e.key === "Enter" ? handleSubmit() : noop;
|
|
28608
28596
|
},
|
|
@@ -28630,7 +28618,7 @@ var Search = function Search(_ref) {
|
|
|
28630
28618
|
minWidth: "0",
|
|
28631
28619
|
width: "3rem",
|
|
28632
28620
|
padding: ".5rem",
|
|
28633
|
-
extraStyles: "\n height: 48px; \n margin: 4px 0 0;\n border-radius: 0 4px 4px 0;\n background: ".concat(themeValues.searchIconBackgroundColor, ";\n "),
|
|
28621
|
+
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
28622
|
variant: "primary",
|
|
28635
28623
|
contentOverride: true,
|
|
28636
28624
|
action: handleSubmit
|
|
@@ -40880,6 +40868,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40880
40868
|
dataQa: "State or Province",
|
|
40881
40869
|
isRequired: true
|
|
40882
40870
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
40871
|
+
isMobile: true,
|
|
40883
40872
|
isNum: isUS,
|
|
40884
40873
|
formatter: isUS ? zipFormat : null,
|
|
40885
40874
|
labelTextWhenNoError: "Zip code",
|
|
@@ -48024,8 +48013,6 @@ var PaymentDetails = function PaymentDetails(_ref4) {
|
|
|
48024
48013
|
isLoading = _ref4$isLoading === void 0 ? false : _ref4$isLoading,
|
|
48025
48014
|
_ref4$isError = _ref4.isError,
|
|
48026
48015
|
isError = _ref4$isError === void 0 ? false : _ref4$isError,
|
|
48027
|
-
_ref4$multiCartEnable = _ref4.multiCartEnabled,
|
|
48028
|
-
multiCartEnabled = _ref4$multiCartEnable === void 0 ? false : _ref4$multiCartEnable,
|
|
48029
48016
|
agencyDisplayName = _ref4.agencyDisplayName;
|
|
48030
48017
|
var _useState = React.useState(initiallyOpen),
|
|
48031
48018
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -48066,7 +48053,7 @@ var PaymentDetails = function PaymentDetails(_ref4) {
|
|
|
48066
48053
|
variant: themeValues.labeledAmountSubtotal
|
|
48067
48054
|
}, fee)));
|
|
48068
48055
|
});
|
|
48069
|
-
var agencySubheading = /*#__PURE__*/React__default.createElement(React__default.Fragment, null,
|
|
48056
|
+
var agencySubheading = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, agencyDisplayName && /*#__PURE__*/React__default.createElement(Cluster, {
|
|
48070
48057
|
justify: "space-between",
|
|
48071
48058
|
align: "center",
|
|
48072
48059
|
style: {
|