@eliseubatista99/react-scaffold-core 1.2.0 → 1.2.1

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.
@@ -14,6 +14,7 @@ export interface InputFieldProps {
14
14
  initialValue?: string;
15
15
  pattern?: string;
16
16
  maxLength?: number;
17
+ disabled?: boolean;
17
18
  type?: HTMLInputTypeAttribute;
18
19
  onInput?: (e: React.FormEvent<HTMLInputElement>) => void;
19
20
  onChange?: (value: string) => void;
package/dist/index.cjs.js CHANGED
@@ -156,7 +156,7 @@ Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}
156
156
  input:-webkit-autofill {
157
157
  background-color: #00000000;
158
158
  }
159
- `,On=e=>{const{onValueChanged:t,handleOnBlur:r,handleOnFocus:i,handleOnClick:a}=Qo(e),{ref:s,name:c,label:u,leftIcon:l,rightIcon:d,bottomMessage:g,placeHolder:y,autoComplete:E="off",value:M,initialValue:C,type:p="text",maxLength:R,inputStyles:S,containerStyles:A,styles:W,step:F,pattern:m,onInput:w}=e;return X.jsxs(es,{style:{width:"100%",maxWidth:"357px",gap:"8px",...W},children:[u,X.jsxs("div",{onClick:()=>a(),style:{display:"flex",flexDirection:"row",width:"100%",height:"47px",margin:"8px auto 0 auto",border:"2px solid #000000",borderRadius:"5px",padding:"5px 15px",color:"#000000",fontFamily:"inherit",fontStyle:"normal",fontWeight:400,fontSize:"16px",lineHeight:"24px",outline:"none",alignItems:"center",gap:"10px",...A},children:[l,X.jsx("input",{ref:s,name:c,type:p,autoComplete:E,step:F,maxLength:R,placeholder:y,value:M,defaultValue:C,onChange:t,onFocus:i,onBlur:r,onInput:w,pattern:m,style:{flex:1,border:"none",color:"inherit",fontFamily:"inherit",fontStyle:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",outline:"inherit",background:"none",...S}}),d]}),g]})},ts=({id:e,styles:t,children:r})=>{const{isItemVisible:i}=et();return X.jsx(X.Fragment,{children:i(e)&&X.jsx("div",{style:{width:"100%",minHeight:"100%",left:0,top:0,position:"fixed",zIndex:1e3,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...t},children:r})})},rs=({id:e,children:t,backgroundStyles:r,contentStyles:i,onClickOutsideModal:a})=>{const{isItemVisible:s}=et();return X.jsx(X.Fragment,{children:s(e)&&X.jsx("div",{style:{width:"100%",height:"100%",minHeight:"100vh",background:"#00000068",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e3,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...r},onClick:()=>{a?.()},children:X.jsx("div",{style:{width:"90%",maxWidth:"375px",height:"fit-content",minHeight:"80px",maxHeight:"50%",background:"#ffffff",borderRadius:"16px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:1001,position:"relative",padding:"24px",...i},onClick:c=>{c.stopPropagation()},children:t})})})},ns=e=>{const t=V.useRef(""),r=V.useCallback(u=>(e.allowNegatives?(u=u.replace(/-/g,(l,d)=>d===0?"-":""),u.indexOf("-")>0&&(u=u.replace(/-/g,""),u="-"+u)):u=u.replace(/-/g,""),u),[e]),i=V.useCallback(u=>{if(e.allowDecimals){u.startsWith(".")&&(u="0"+u),u.length===2&&u[0]==="-"&&u[1]==="."&&(u="-");const l=u.indexOf(".");l!==-1&&(u=u.slice(0,l+1)+u.slice(l+1).replace(/\./g,""));const[d,...g]=u.split("."),[y,...E]=t.current.split(".");let M=g.join(""),C=E.join("");e.decimalScale!==void 0&&(M.length>e.decimalScale?M=C:M=M.slice(0,e.decimalScale)),u=M||u.endsWith(".")?`${d}.${M}`:d}else u=u.replace(/\./g,"");return u},[e]),a=V.useCallback(u=>{const l=Number(u);var d=e.max;return d===void 0&&(d=e.maxLength?Number("9".repeat(e.maxLength)):void 0),!isNaN(l)&&(e.min!==void 0&&l<e.min||d!==void 0&&l>d)?t.current??u:u},[e]),s=V.useCallback(u=>{const l=u.target,d=l.selectionStart??0,g=l.selectionEnd??0;let y=l.value;y=y.replace(/[^0-9\.\-]/g,""),y=r(y),y=i(y),y=a(y);const E=y.length-l.value.length;l.value=y,l.setSelectionRange(d+E,g+E),t.current=y},[r,i,a]);return{props:V.useCallback(()=>({...e,type:"text",pattern:"^-?[0-9]*.?[0-9]*$",onInput:s}),[e,s])()}},is=({allowNegatives:e=!0,allowDecimals:t=!0,decimalScale:r=2,...i})=>{const{props:a}=ns({allowNegatives:e,allowDecimals:t,decimalScale:r,...i});return X.jsx(On,{type:"text",...a})},as=e=>{const t=V.useRef(null),r=V.useRef(null),i=V.useRef(null),[a,s]=V.useState(24),[c,u]=V.useState(24),[l,d]=V.useState(300),g=V.useCallback(()=>{t.current&&s(t.current.clientHeight)},[t,t.current]),y=V.useCallback(()=>{r.current&&u(r.current.clientHeight)},[r,r.current]),E=V.useCallback(()=>{i.current&&d(i.current.clientWidth)},[i,i.current]),M=V.useCallback(()=>{let C=0;return e.header?.visibility==="always"&&(C=C+(a||0)),e.footer?.visibility==="always"&&(C=C+(c||0)),C},[r,r.current]);return V.useEffect(()=>{g()},[g,t,t.current]),V.useEffect(()=>{y()},[y,r,r.current]),V.useEffect(()=>{E()},[E,i,i.current]),{header:{...e.header,visible:e.header!==void 0,height:!e.header||e.header?.visibility==="fixed"?0:a,ref:t},footer:{...e.footer,visible:e.footer!==void 0,height:!e.footer||e.footer?.visibility==="fixed"?0:c,ref:r},sidebar:{...e.sidebar,width:l,visible:e.sidebar!==void 0,ref:i},page:{extraHeight:M()}}},os=Pe.div`
159
+ `,On=e=>{const{onValueChanged:t,handleOnBlur:r,handleOnFocus:i,handleOnClick:a}=Qo(e),{ref:s,name:c,label:u,leftIcon:l,rightIcon:d,bottomMessage:g,placeHolder:y,autoComplete:E="off",value:M,initialValue:C,type:p="text",maxLength:R,inputStyles:S,containerStyles:A,styles:W,step:F,pattern:m,disabled:w,onInput:x}=e;return X.jsxs(es,{style:{width:"100%",maxWidth:"357px",gap:"8px",...W},children:[u,X.jsxs("div",{onClick:()=>a(),style:{display:"flex",flexDirection:"row",width:"100%",height:"47px",margin:"8px auto 0 auto",border:"2px solid #000000",borderRadius:"5px",padding:"5px 15px",color:"#000000",fontFamily:"inherit",fontStyle:"normal",fontWeight:400,fontSize:"16px",lineHeight:"24px",outline:"none",alignItems:"center",gap:"10px",...A},children:[l,X.jsx("input",{ref:s,name:c,type:p,autoComplete:E,step:F,maxLength:R,placeholder:y,value:M,defaultValue:C,onChange:t,onFocus:i,onBlur:r,onInput:x,pattern:m,disabled:w,style:{flex:1,border:"none",color:"inherit",fontFamily:"inherit",fontStyle:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",outline:"inherit",background:"none",...S}}),d]}),g]})},ts=({id:e,styles:t,children:r})=>{const{isItemVisible:i}=et();return X.jsx(X.Fragment,{children:i(e)&&X.jsx("div",{style:{width:"100%",minHeight:"100%",left:0,top:0,position:"fixed",zIndex:1e3,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...t},children:r})})},rs=({id:e,children:t,backgroundStyles:r,contentStyles:i,onClickOutsideModal:a})=>{const{isItemVisible:s}=et();return X.jsx(X.Fragment,{children:s(e)&&X.jsx("div",{style:{width:"100%",height:"100%",minHeight:"100vh",background:"#00000068",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e3,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...r},onClick:()=>{a?.()},children:X.jsx("div",{style:{width:"90%",maxWidth:"375px",height:"fit-content",minHeight:"80px",maxHeight:"50%",background:"#ffffff",borderRadius:"16px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:1001,position:"relative",padding:"24px",...i},onClick:c=>{c.stopPropagation()},children:t})})})},ns=e=>{const t=V.useRef(""),r=V.useCallback(u=>(e.allowNegatives?(u=u.replace(/-/g,(l,d)=>d===0?"-":""),u.indexOf("-")>0&&(u=u.replace(/-/g,""),u="-"+u)):u=u.replace(/-/g,""),u),[e]),i=V.useCallback(u=>{if(e.allowDecimals){u.startsWith(".")&&(u="0"+u),u.length===2&&u[0]==="-"&&u[1]==="."&&(u="-");const l=u.indexOf(".");l!==-1&&(u=u.slice(0,l+1)+u.slice(l+1).replace(/\./g,""));const[d,...g]=u.split("."),[y,...E]=t.current.split(".");let M=g.join(""),C=E.join("");e.decimalScale!==void 0&&(M.length>e.decimalScale?M=C:M=M.slice(0,e.decimalScale)),u=M||u.endsWith(".")?`${d}.${M}`:d}else u=u.replace(/\./g,"");return u},[e]),a=V.useCallback(u=>{const l=Number(u);var d=e.max;return d===void 0&&(d=e.maxLength?Number("9".repeat(e.maxLength)):void 0),!isNaN(l)&&(e.min!==void 0&&l<e.min||d!==void 0&&l>d)?t.current??u:u},[e]),s=V.useCallback(u=>{const l=u.target,d=l.selectionStart??0,g=l.selectionEnd??0;let y=l.value;y=y.replace(/[^0-9\.\-]/g,""),y=r(y),y=i(y),y=a(y);const E=y.length-l.value.length;l.value=y,l.setSelectionRange(d+E,g+E),t.current=y},[r,i,a]);return{props:V.useCallback(()=>({...e,type:"text",pattern:"^-?[0-9]*.?[0-9]*$",onInput:s}),[e,s])()}},is=({allowNegatives:e=!0,allowDecimals:t=!0,decimalScale:r=2,...i})=>{const{props:a}=ns({allowNegatives:e,allowDecimals:t,decimalScale:r,...i});return X.jsx(On,{type:"text",...a})},as=e=>{const t=V.useRef(null),r=V.useRef(null),i=V.useRef(null),[a,s]=V.useState(24),[c,u]=V.useState(24),[l,d]=V.useState(300),g=V.useCallback(()=>{t.current&&s(t.current.clientHeight)},[t,t.current]),y=V.useCallback(()=>{r.current&&u(r.current.clientHeight)},[r,r.current]),E=V.useCallback(()=>{i.current&&d(i.current.clientWidth)},[i,i.current]),M=V.useCallback(()=>{let C=0;return e.header?.visibility==="always"&&(C=C+(a||0)),e.footer?.visibility==="always"&&(C=C+(c||0)),C},[r,r.current]);return V.useEffect(()=>{g()},[g,t,t.current]),V.useEffect(()=>{y()},[y,r,r.current]),V.useEffect(()=>{E()},[E,i,i.current]),{header:{...e.header,visible:e.header!==void 0,height:!e.header||e.header?.visibility==="fixed"?0:a,ref:t},footer:{...e.footer,visible:e.footer!==void 0,height:!e.footer||e.footer?.visibility==="fixed"?0:c,ref:r},sidebar:{...e.sidebar,width:l,visible:e.sidebar!==void 0,ref:i},page:{extraHeight:M()}}},os=Pe.div`
160
160
  min-height: 100%;
161
161
  max-height: 100%;
162
162
  width: 100%;
package/dist/index.es.js CHANGED
@@ -6433,7 +6433,8 @@ const xn = B.createContext({
6433
6433
  styles: W,
6434
6434
  step: F,
6435
6435
  pattern: m,
6436
- onInput: w
6436
+ disabled: w,
6437
+ onInput: x
6437
6438
  } = e;
6438
6439
  return /* @__PURE__ */ X.jsxs(
6439
6440
  Yo,
@@ -6487,8 +6488,9 @@ const xn = B.createContext({
6487
6488
  onChange: t,
6488
6489
  onFocus: i,
6489
6490
  onBlur: r,
6490
- onInput: w,
6491
+ onInput: x,
6491
6492
  pattern: m,
6493
+ disabled: w,
6492
6494
  style: {
6493
6495
  flex: 1,
6494
6496
  border: "none",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliseubatista99/react-scaffold-core",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "private": false,
5
5
  "description": "A library which provides basic components, hooks, helpers and providers to easily build a React application and avoid repeating the usual code.",
6
6
  "main": "dist/index.cjs.js",