@thecb/components 10.9.0-beta.6 → 10.9.0-beta.7
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
|
@@ -26839,6 +26839,7 @@ var FormattedInput = function FormattedInput(_ref) {
|
|
|
26839
26839
|
_onChange = _ref.onChange,
|
|
26840
26840
|
props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
|
|
26841
26841
|
|
|
26842
|
+
console.log("🚀 ~ FormattedInput ~ props:", props);
|
|
26842
26843
|
var inputEl = React.useRef(null);
|
|
26843
26844
|
|
|
26844
26845
|
var _useState = React.useState({
|
|
@@ -26860,9 +26861,26 @@ var FormattedInput = function FormattedInput(_ref) {
|
|
|
26860
26861
|
});
|
|
26861
26862
|
return React__default.createElement("input", _extends$2({}, props, {
|
|
26862
26863
|
ref: inputEl,
|
|
26863
|
-
value: format$1(formatter)(value)
|
|
26864
|
-
|
|
26865
|
-
|
|
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) {
|
|
26866
26884
|
setState({
|
|
26867
26885
|
rawValue: value,
|
|
26868
26886
|
selectionStart: event.target.selectionStart,
|
|
@@ -26870,14 +26888,13 @@ var FormattedInput = function FormattedInput(_ref) {
|
|
|
26870
26888
|
"delete": event.key === "Backspace" || event.key === "Delete",
|
|
26871
26889
|
formattedValue: event.target.value
|
|
26872
26890
|
});
|
|
26873
|
-
},
|
|
26874
|
-
onChange: function onChange(event) {
|
|
26875
26891
|
/* At the beginning of onChange, event.target.value is a concat of the previous formatted value
|
|
26876
26892
|
* and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
|
|
26877
26893
|
* 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
|
|
26894
|
+
* to be separated, then unformat the formatted string, then in sert (or delete) the injection from the
|
|
26879
26895
|
* old unformatted value.
|
|
26880
26896
|
*/
|
|
26897
|
+
|
|
26881
26898
|
var injectionLength = event.target.value.length - state.formattedValue.length;
|
|
26882
26899
|
var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
|
|
26883
26900
|
var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
|
|
@@ -27159,14 +27176,14 @@ var FormInput = function FormInput(_ref15) {
|
|
|
27159
27176
|
autoComplete: autocompleteValue,
|
|
27160
27177
|
required: isRequired
|
|
27161
27178
|
// Additional handler to detect autofilled values
|
|
27162
|
-
|
|
27163
|
-
|
|
27164
|
-
|
|
27165
|
-
|
|
27166
|
-
|
|
27167
|
-
|
|
27168
|
-
|
|
27169
|
-
|
|
27179
|
+
}, autocompleteValue && {
|
|
27180
|
+
onFocus: function onFocus(e) {
|
|
27181
|
+
if (!isFocused) {
|
|
27182
|
+
var _e$target;
|
|
27183
|
+
setValue((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
|
|
27184
|
+
setIsFocused(true);
|
|
27185
|
+
}
|
|
27186
|
+
}
|
|
27170
27187
|
}, props)) : /*#__PURE__*/React__default.createElement(InputField, _extends({
|
|
27171
27188
|
"aria-labelledby": createIdFromString(labelTextWhenNoError),
|
|
27172
27189
|
"aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),
|