@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.esm.js CHANGED
@@ -26831,6 +26831,7 @@ var FormattedInput = function FormattedInput(_ref) {
26831
26831
  _onChange = _ref.onChange,
26832
26832
  props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
26833
26833
 
26834
+ console.log("🚀 ~ FormattedInput ~ props:", props);
26834
26835
  var inputEl = useRef(null);
26835
26836
 
26836
26837
  var _useState = useState({
@@ -26852,9 +26853,26 @@ var FormattedInput = function FormattedInput(_ref) {
26852
26853
  });
26853
26854
  return React.createElement("input", _extends$2({}, props, {
26854
26855
  ref: inputEl,
26855
- value: format$1(formatter)(value),
26856
- onKeyDown: function onKeyDown(event) {
26857
- // Keep track of the state of the input before onChange, including if user is hitting delete
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) {
26858
26876
  setState({
26859
26877
  rawValue: value,
26860
26878
  selectionStart: event.target.selectionStart,
@@ -26862,14 +26880,13 @@ var FormattedInput = function FormattedInput(_ref) {
26862
26880
  "delete": event.key === "Backspace" || event.key === "Delete",
26863
26881
  formattedValue: event.target.value
26864
26882
  });
26865
- },
26866
- onChange: function onChange(event) {
26867
26883
  /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
26868
26884
  * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
26869
26885
  * the unformatted value for the user's onChange, the formatted string and unformatted injection need
26870
- * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
26886
+ * to be separated, then unformat the formatted string, then in sert (or delete) the injection from the
26871
26887
  * old unformatted value.
26872
26888
  */
26889
+
26873
26890
  var injectionLength = event.target.value.length - state.formattedValue.length;
26874
26891
  var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
26875
26892
  var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
@@ -27151,14 +27168,14 @@ var FormInput = function FormInput(_ref15) {
27151
27168
  autoComplete: autocompleteValue,
27152
27169
  required: isRequired
27153
27170
  // Additional handler to detect autofilled values
27154
- // {...(autocompleteValue && {
27155
- // onFocus: e => {
27156
- // if (!isFocused) {
27157
- // setValue(e.target?.value);
27158
- // setIsFocused(true);
27159
- // }
27160
- // }
27161
- // })}
27171
+ }, autocompleteValue && {
27172
+ onFocus: function onFocus(e) {
27173
+ if (!isFocused) {
27174
+ var _e$target;
27175
+ setValue((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value);
27176
+ setIsFocused(true);
27177
+ }
27178
+ }
27162
27179
  }, props)) : /*#__PURE__*/React.createElement(InputField, _extends({
27163
27180
  "aria-labelledby": createIdFromString(labelTextWhenNoError),
27164
27181
  "aria-describedby": createIdFromString(labelTextWhenNoError, "error message"),