@thecb/components 10.8.3-beta.3 → 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
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,39 +26799,35 @@ var createFormat = function createFormat(formats, formatChar) {
|
|
|
26832
26799
|
formatChar: formatChar
|
|
26833
26800
|
};
|
|
26834
26801
|
};
|
|
26835
|
-
|
|
26836
26802
|
var FormattedInput = function FormattedInput(_ref) {
|
|
26837
26803
|
var _ref$isMobile = _ref.isMobile,
|
|
26838
|
-
|
|
26839
|
-
|
|
26840
|
-
|
|
26841
|
-
|
|
26842
|
-
|
|
26843
|
-
|
|
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"]);
|
|
26844
26809
|
console.log("🚀 ~ FormattedInput ~ props:", props);
|
|
26845
26810
|
console.log('isMobile line', isMobile);
|
|
26846
26811
|
var inputEl = React.useRef(null);
|
|
26847
|
-
|
|
26848
26812
|
var _useState = React.useState({
|
|
26849
|
-
|
|
26850
|
-
|
|
26851
|
-
|
|
26852
|
-
|
|
26853
|
-
|
|
26854
|
-
|
|
26855
|
-
|
|
26856
|
-
|
|
26857
|
-
|
|
26858
|
-
|
|
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];
|
|
26859
26822
|
React.useLayoutEffect(function () {
|
|
26860
26823
|
// A lot of the work here is cursor manipulation
|
|
26861
26824
|
if (inputEl.current && inputEl.current === document.activeElement) {
|
|
26862
26825
|
inputEl.current.setSelectionRange(state.selectionStart, state.selectionEnd);
|
|
26863
26826
|
}
|
|
26864
26827
|
});
|
|
26865
|
-
|
|
26866
26828
|
var handleFormat = function handleFormat(event) {
|
|
26867
|
-
|
|
26829
|
+
debugger;
|
|
26830
|
+
console.log('in handle format 2');
|
|
26868
26831
|
/* At the beginning of onChange, event.target.value is a concat of the previous formatted value
|
|
26869
26832
|
* and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
|
|
26870
26833
|
* the unformatted value for the user's onChange, the formatted string and unformatted injection need
|
|
@@ -26896,15 +26859,10 @@ var FormattedInput = function FormattedInput(_ref) {
|
|
|
26896
26859
|
rawValue: state.rawValue,
|
|
26897
26860
|
"delete": false,
|
|
26898
26861
|
formattedValue: state.formattedValue
|
|
26899
|
-
});
|
|
26900
|
-
|
|
26901
|
-
|
|
26902
|
-
if (onChange) {
|
|
26903
|
-
onChange(unformattedNewValue);
|
|
26904
|
-
}
|
|
26862
|
+
});
|
|
26863
|
+
return unformattedNewValue;
|
|
26905
26864
|
};
|
|
26906
|
-
|
|
26907
|
-
return React__default.createElement("input", _extends$2({}, props, {
|
|
26865
|
+
return /*#__PURE__*/React__default.createElement("input", _extends$2({}, props, {
|
|
26908
26866
|
ref: inputEl,
|
|
26909
26867
|
value: format$1(formatter)(value),
|
|
26910
26868
|
onKeyDown: function onKeyDown(event) {
|
|
@@ -26916,16 +26874,28 @@ var FormattedInput = function FormattedInput(_ref) {
|
|
|
26916
26874
|
"delete": event.key === "Backspace" || event.key === "Delete",
|
|
26917
26875
|
formattedValue: event.target.value
|
|
26918
26876
|
});
|
|
26919
|
-
}
|
|
26920
|
-
}, isMobile ? {
|
|
26921
|
-
onBlur: function onBlur(e) {
|
|
26922
|
-
debugger;
|
|
26923
|
-
handleFormat(e);
|
|
26924
|
-
}
|
|
26925
|
-
} : {
|
|
26877
|
+
},
|
|
26926
26878
|
onChange: function onChange(e) {
|
|
26927
|
-
|
|
26928
|
-
|
|
26879
|
+
console.log('in onChange');
|
|
26880
|
+
if (!isMobile) {
|
|
26881
|
+
handleFormat(e);
|
|
26882
|
+
} // Apply the external onChange function to the raw underlying string
|
|
26883
|
+
// This is where the user generally updates the input value
|
|
26884
|
+
|
|
26885
|
+
if (_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);
|
|
26898
|
+
}
|
|
26929
26899
|
}
|
|
26930
26900
|
}));
|
|
26931
26901
|
};
|
|
@@ -40898,6 +40868,7 @@ var AddressForm = function AddressForm(_ref) {
|
|
|
40898
40868
|
dataQa: "State or Province",
|
|
40899
40869
|
isRequired: true
|
|
40900
40870
|
}), /*#__PURE__*/React__default.createElement(FormInput$1, {
|
|
40871
|
+
isMobile: true,
|
|
40901
40872
|
isNum: isUS,
|
|
40902
40873
|
formatter: isUS ? zipFormat : null,
|
|
40903
40874
|
labelTextWhenNoError: "Zip code",
|