Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-input/core

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-input/core - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

dist/hooks/useInput.js

@@ -1,1 +0,1 @@

import{useRef as e,useEffect as t}from"react";import n from"../utils/setInputAttributes.js";import r from"../errors/SyntheticChangeError.js";import u from"./useDispatchCustomInputEvent.js";import"react-dom";var l=function(e){return null!==e&&"text"===e.type};function i(i){var c=i.init,o=i.tracking,a=i.customInputEventType,d=i.customInputEventHandler,s=e(null),v=e({requestID:-1,fallbackRequestID:-1,cachedRequestID:-1,start:0,end:0}),f=u(s,a,d),p=f[0],h=f[1];return t((function(){"production"!==process.env.NODE_ENV&&(null===s.current&&console.error(new Error("Input element does not exist.")),null!==s.current&&"text"!==s.current.type&&console.error(new Error('The type of the input element does not match the type "text".')))}),[]),t((function(){var e;if(null!==s.current&&l(s.current)){var t=null!==(e=s.current._wrapperState)&&void 0!==e?e:{},r=t.controlled,u=void 0!==r&&r,i=t.initialValue,o=c({controlled:u,initialValue:void 0===i?"":i});n(s.current,{value:o.value})}}),[]),t((function(){var e=function(e){var t,u,i,c,a,d,f,p,m,E,w,I,_,b,q,D;if(l(s.current))try{if(null===s.current)throw new r("Reference to input element is not initialized.");if(v.current.cachedRequestID===v.current.requestID)throw new r("The input selection has not been updated.");v.current.cachedRequestID=v.current.requestID;var g=s.current,S=g.value,k=g.selectionStart,y=g.selectionEnd;if(null===k||null===y)throw new r("The selection attributes have not been initialized.");var R=null!==(i=null===(u=null===(t=s.current._valueTracker)||void 0===t?void 0:t.getValue)||void 0===u?void 0:u.call(t))&&void 0!==i?i:"",T="initial";if(k>v.current.start?T="insert":k<=v.current.start&&k<v.current.end?T="deleteBackward":k===v.current.end&&S.length<R.length&&(T="deleteForward"),("deleteBackward"===T||"deleteForward"===T)&&S.length>R.length)throw new r("Input type detection error.");var V="",F="",A=v.current.start,L=v.current.end;switch(T){case"insert":V=S.slice(v.current.start,k);break;case"deleteBackward":case"deleteForward":var x=R.length-S.length;A=k,L=k+x,F=R.slice(A,L);break;default:throw new r("The input type is undefined.")}var j=o({inputType:T,value:S,addedValue:V,deletedValue:F,previousValue:R,changeStart:A,changeEnd:L,selectionStart:k,selectionEnd:y});n(s.current,{value:j.value,selectionStart:j.selectionStart,selectionEnd:j.selectionEnd}),h(j.__detail),null===(a=null===(c=s.current._valueTracker)||void 0===c?void 0:c.setValue)||void 0===a||a.call(c,R),v.current.start=j.selectionStart,v.current.end=j.selectionEnd}catch(t){var B=t,C=B.name,z=B.cause;if(null!==s.current&&n(s.current,{value:null!==(E=null!==(f=null===(d=null==z?void 0:z.__attributes)||void 0===d?void 0:d.value)&&void 0!==f?f:null===(m=null===(p=s.current._valueTracker)||void 0===p?void 0:p.getValue)||void 0===m?void 0:m.call(p))&&void 0!==E?E:"",selectionStart:null!==(I=null===(w=null==z?void 0:z.__attributes)||void 0===w?void 0:w.selectionStart)&&void 0!==I?I:v.current.start,selectionEnd:null!==(b=null===(_=null==z?void 0:z.__attributes)||void 0===_?void 0:_.selectionEnd)&&void 0!==b?b:v.current.end}),void 0!==(null===(q=null==z?void 0:z.__attributes)||void 0===q?void 0:q.selectionStart)&&(v.current.start=z.__attributes.selectionStart),void 0!==(null===(D=null==z?void 0:z.__attributes)||void 0===D?void 0:D.selectionEnd)&&(v.current.end=z.__attributes.selectionEnd),e.preventDefault(),e.stopPropagation(),"SyntheticChangeError"!==C)throw t}},t=s.current;return null==t||t.addEventListener("input",e),function(){null==t||t.removeEventListener("input",e)}}),[o,h]),t((function(){var e=function(){if(l(s.current)){var e=function(){var t,n,r,u;p.current?(v.current.start=null!==(n=null===(t=s.current)||void 0===t?void 0:t.selectionStart)&&void 0!==n?n:0,v.current.end=null!==(u=null===(r=s.current)||void 0===r?void 0:r.selectionEnd)&&void 0!==u?u:0,v.current.requestID=requestAnimationFrame(e)):v.current.fallbackRequestID=requestAnimationFrame(e)};v.current.requestID=requestAnimationFrame(e)}};null!==s.current&&document.activeElement===s.current&&e();var t=s.current;return null==t||t.addEventListener("focus",e),function(){null==t||t.removeEventListener("focus",e)}}),[]),t((function(){var e=function(){l(s.current)&&(cancelAnimationFrame(v.current.requestID),cancelAnimationFrame(v.current.fallbackRequestID),v.current.requestID=-1,v.current.fallbackRequestID=-1,v.current.cachedRequestID=-1)},t=s.current;return null==t||t.addEventListener("blur",e),function(){null==t||t.removeEventListener("blur",e)}}),[]),s}export{i as default};
import{useRef as e,useEffect as t}from"react";import n from"../utils/setInputAttributes.js";import r from"../errors/SyntheticChangeError.js";import u from"./useDispatchCustomInputEvent.js";import"react-dom";var l=function(e){return null!==e&&"text"===e.type};function i(i){var c=i.init,o=i.tracking,a=i.customInputEventType,d=i.customInputEventHandler,s=e(null),v=e({requestID:-1,fallbackRequestID:-1,cachedRequestID:-1,start:0,end:0}),f=u(s,a,d),p=f[0],h=f[1];return t((function(){"production"!==process.env.NODE_ENV&&(null===s.current&&console.error(new Error("Input element does not exist.")),null!==s.current&&"text"!==s.current.type&&console.error(new Error('The type of the input element does not match the type "text".')))}),[]),t((function(){var e;if(null!==s.current&&l(s.current)){var t=null!==(e=s.current._wrapperState)&&void 0!==e?e:{},r=t.controlled,u=void 0!==r&&r,i=t.initialValue,o=void 0===i?"":i,a=c({controlled:u,initialValue:s.current.value||o});n(s.current,{value:a.value})}}),[]),t((function(){var e=function(e){var t,u,i,c,a,d,f,p,m,E,w,I,_,b,q,D;if(l(s.current))try{if(null===s.current)throw new r("Reference to input element is not initialized.");if(v.current.cachedRequestID===v.current.requestID)throw new r("The input selection has not been updated.");v.current.cachedRequestID=v.current.requestID;var g=s.current,S=g.value,k=g.selectionStart,y=g.selectionEnd;if(null===k||null===y)throw new r("The selection attributes have not been initialized.");var R=null!==(i=null===(u=null===(t=s.current._valueTracker)||void 0===t?void 0:t.getValue)||void 0===u?void 0:u.call(t))&&void 0!==i?i:"",T="initial";if(k>v.current.start?T="insert":k<=v.current.start&&k<v.current.end?T="deleteBackward":k===v.current.end&&S.length<R.length&&(T="deleteForward"),("deleteBackward"===T||"deleteForward"===T)&&S.length>R.length)throw new r("Input type detection error.");var V="",F="",A=v.current.start,L=v.current.end;switch(T){case"insert":V=S.slice(v.current.start,k);break;case"deleteBackward":case"deleteForward":var x=R.length-S.length;A=k,L=k+x,F=R.slice(A,L);break;default:throw new r("The input type is undefined.")}var j=o({inputType:T,value:S,addedValue:V,deletedValue:F,previousValue:R,changeStart:A,changeEnd:L,selectionStart:k,selectionEnd:y});n(s.current,{value:j.value,selectionStart:j.selectionStart,selectionEnd:j.selectionEnd}),h(j.__detail),null===(a=null===(c=s.current._valueTracker)||void 0===c?void 0:c.setValue)||void 0===a||a.call(c,R),v.current.start=j.selectionStart,v.current.end=j.selectionEnd}catch(t){var B=t,C=B.name,z=B.cause;if(null!==s.current&&n(s.current,{value:null!==(E=null!==(f=null===(d=null==z?void 0:z.__attributes)||void 0===d?void 0:d.value)&&void 0!==f?f:null===(m=null===(p=s.current._valueTracker)||void 0===p?void 0:p.getValue)||void 0===m?void 0:m.call(p))&&void 0!==E?E:"",selectionStart:null!==(I=null===(w=null==z?void 0:z.__attributes)||void 0===w?void 0:w.selectionStart)&&void 0!==I?I:v.current.start,selectionEnd:null!==(b=null===(_=null==z?void 0:z.__attributes)||void 0===_?void 0:_.selectionEnd)&&void 0!==b?b:v.current.end}),void 0!==(null===(q=null==z?void 0:z.__attributes)||void 0===q?void 0:q.selectionStart)&&(v.current.start=z.__attributes.selectionStart),void 0!==(null===(D=null==z?void 0:z.__attributes)||void 0===D?void 0:D.selectionEnd)&&(v.current.end=z.__attributes.selectionEnd),e.preventDefault(),e.stopPropagation(),"SyntheticChangeError"!==C)throw t}},t=s.current;return null==t||t.addEventListener("input",e),function(){null==t||t.removeEventListener("input",e)}}),[o,h]),t((function(){var e=function(){if(l(s.current)){var e=function(){var t,n,r,u;p.current?(v.current.start=null!==(n=null===(t=s.current)||void 0===t?void 0:t.selectionStart)&&void 0!==n?n:0,v.current.end=null!==(u=null===(r=s.current)||void 0===r?void 0:r.selectionEnd)&&void 0!==u?u:0,v.current.requestID=requestAnimationFrame(e)):v.current.fallbackRequestID=requestAnimationFrame(e)};v.current.requestID=requestAnimationFrame(e)}};null!==s.current&&document.activeElement===s.current&&e();var t=s.current;return null==t||t.addEventListener("focus",e),function(){null==t||t.removeEventListener("focus",e)}}),[]),t((function(){var e=function(){l(s.current)&&(cancelAnimationFrame(v.current.requestID),cancelAnimationFrame(v.current.fallbackRequestID),v.current.requestID=-1,v.current.fallbackRequestID=-1,v.current.cachedRequestID=-1)},t=s.current;return null==t||t.addEventListener("blur",e),function(){null==t||t.removeEventListener("blur",e)}}),[]),s}export{i as default};
{
"name": "@react-input/core",
"version": "1.0.0",
"version": "1.0.1",
"author": "Nikolay Goncharuk <goncharuk.bro@gmail.com>",

@@ -5,0 +5,0 @@ "description": "The core of the packages included in the `@react-input` scope.",

@@ -0,0 +0,0 @@ # @react-input/core

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc