@jamsr-ui/input
Advanced tools
Comparing version 0.0.16 to 0.0.17
export { Input, InputProps } from './input.js'; | ||
export { inputVariants } from './style.js'; | ||
import '@jamsr-ui/utils'; | ||
import './use-input.js'; | ||
import 'react'; | ||
import './use-input.js'; | ||
import '@jamsr-ui/utils'; | ||
import 'tailwind-variants'; | ||
import 'tailwind-variants/dist/config.js'; |
"use client" | ||
"use strict";var M=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var ue=(p,o)=>{for(var c in o)M(p,c,{get:o[c],enumerable:!0})},de=(p,o,c,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of le(o))!ie.call(p,i)&&i!==c&&M(p,i,{get:()=>o[i],enumerable:!(m=se(o,i))||m.enumerable});return p};var ce=p=>de(M({},"__esModule",{value:!0}),p);var Pe={};ue(Pe,{Input:()=>X,inputVariants:()=>y});module.exports=ce(Pe);var K=require("@jamsr-ui/button"),T=require("@jamsr-ui/shared-icons"),Q=require("@jamsr-ui/utils"),f=require("react");var U=require("@jamsr-ui/hooks"),d=require("@jamsr-ui/utils"),a=require("react");var q=require("@jamsr-ui/utils"),y=(0,q.tv)({slots:{base:"flex flex-col gap-1",input:"block w-full grow bg-transparent text-sm placeholder:text-sm placeholder:text-foreground-400 read-only:cursor-not-allowed focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",labelWrapper:"flex items-center gap-2",label:"shrink-0 select-none text-sm font-normal text-foreground-400",mainWrapper:"flex gap-1",inputWrapper:"w-full focus-within:border-primary focus-within:ring-primary",innerWrapper:"flex items-center",helper:""},variants:{variant:{outline:{inputWrapper:"rounded-lg border-2 border-divider",input:"rounded-lg"},transparent:{inputWrapper:"border-none bg-transparent outline-none",input:"p-0"},search:{inputWrapper:"rounded-2xl border-2 border-divider bg-background-paper"}},size:{false:{},sm:{input:"p-1.5"},md:{input:"p-3"},lg:{input:"p-5"}},isInvalid:{true:{inputWrapper:"border-error focus-within:border-error focus-within:shadow-error focus-within:ring-error"}},labelPlacement:{top:{mainWrapper:"flex-col"},start:{mainWrapper:"items-center"}}},defaultVariants:{variant:"outline",size:"md",labelPlacement:"top"}});var J=p=>{let{as:o,label:c,labelPlacement:m,labelHelperContent:i,className:h,classNames:t,size:I,mask:l,defaultValue:x,value:v,onValueChange:W,isInvalid:C,type:w,isSecuredText:P,showPassword:N,setShowPassword:V,startContent:R,endContent:S,onChange:b,multiline:k,fullWidth:E,variant:H,helperText:G,precision:u=2,ref:$,...B}=p,Y=o??"div",Z=k?"textarea":"input",r=y({variant:H,size:I,isInvalid:C,labelPlacement:m}),[g,z]=(0,U.useControlledState)({prop:v,defaultProp:x,onChange:W}),[L,F]=(0,U.useControlledState)({prop:N,onChange:V}),A=(0,a.useCallback)(e=>{let{value:s}=e.target;if(s=String(s),u<1)s=s.replace(/\D/g,"");else if(l==="number"||l==="currency"||l==="percent"){let O=`^\\$?\\d*\\.?\\d{0,${u}}$`;new RegExp(O).test(s)?s=s.replace(/^\$/,""):s=g}b?.(e),z(s)},[l,b,u,z,g]),_=(0,a.useCallback)(()=>F(e=>!e),[F]),j=(0,a.useCallback)(e=>({"data-slot":"base",className:r.base({class:(0,d.cn)(t?.base,e?.className)}),...e}),[r,t?.base]),ee=(0,a.useCallback)(e=>({...e,"data-slot":"label-wrapper",className:r.labelWrapper({class:(0,d.cn)(t?.labelWrapper,e?.className)})}),[r,t?.labelWrapper]),te=(0,a.useCallback)(e=>({...e,"data-slot":"label",className:r.label({class:(0,d.cn)(t?.label,e?.className)})}),[r,t?.label]),re=(0,a.useCallback)(e=>({...e,"data-slot":"inner-wrapper",className:r.innerWrapper({class:(0,d.cn)(t?.innerWrapper,e?.className)})}),[r,t?.innerWrapper]),ne=(0,a.useCallback)(e=>({...e,"data-slot":"helper",className:r.helper({class:(0,d.cn)(t?.helper,e?.className)})}),[r,t?.helper]),oe=(0,a.useCallback)(e=>({...e,"data-slot":"main-wrapper",className:r.mainWrapper({class:(0,d.cn)(t?.mainWrapper,e?.className)})}),[r,t?.mainWrapper]),ae=(0,a.useCallback)(e=>({...e,ref:$,"data-slot":"input-wrapper",className:r.inputWrapper({class:(0,d.cn)(t?.inputWrapper,e?.className)})}),[$,r,t?.inputWrapper]),D=(0,a.useMemo)(()=>P?L?"text":"password":w,[P,L,w]),pe=(0,a.useCallback)(e=>{let s=l==="currency"?`$${g}`:g;return{"data-slot":"input",className:r.input({class:(0,d.cn)(t?.input,e?.className,h)}),value:s,onChange:A,type:D,...B,...e}},[l,g,r,t?.input,h,A,D,B]);return{Component:Y,InputComponent:Z,classNames:t,label:c,helperText:G,startContent:R,endContent:S,labelPlacement:m,isInvalid:C,isSecuredText:P,showPassword:L,mask:l,getBaseProps:j,labelHelper:i,getLabelWrapperProps:ee,getLabelProps:te,getInputProps:pe,getInputWrapperProps:ae,getHelperProps:ne,getInnerWrapperProps:re,handleChangeInputType:_,getMainWrapperProps:oe}};var n=require("react/jsx-runtime"),me=(p,o)=>{let{Component:c,InputComponent:m,label:i,helperText:h,startContent:t,endContent:I,isSecuredText:l,showPassword:x,mask:v,getBaseProps:W,getLabelWrapperProps:C,getLabelProps:w,labelHelper:P,getInputProps:N,getInputWrapperProps:V,getHelperProps:R,getInnerWrapperProps:S,handleChangeInputType:b,getMainWrapperProps:k}=J(p),E=(0,f.useId)(),H=(0,f.useMemo)(()=>{let u=t;return u?(0,n.jsx)("div",{className:"pl-2 text-foreground-muted empty:hidden",children:u}):null},[t]),G=(0,f.useMemo)(()=>{let u=l===!0&&(0,n.jsx)(K.Button,{isIconOnly:!0,onClick:b,variant:"link",rounded:!0,children:x?(0,n.jsx)(T.EyeClosed,{}):(0,n.jsx)(T.EyeOpen,{})})||v==="percent"&&"%"||I;return u?(0,n.jsx)("div",{className:"pr-2 text-foreground-muted",children:u}):null},[I,b,l,v,x]);return(0,n.jsxs)(c,{ref:o,...W(),children:[(0,n.jsxs)("div",{...k(),children:[(0,n.jsxs)("div",{...C(),children:[(0,n.jsx)("label",{htmlFor:E,...w(),children:i}),P]}),(0,n.jsx)("div",{...V(),children:(0,n.jsxs)("div",{...S(),children:[H,(0,n.jsx)(m,{id:E,...N()}),G]})})]}),(0,n.jsx)("div",{...R(),children:h})]})},X=(0,Q.forwardRefUI)(me);0&&(module.exports={Input,inputVariants}); | ||
"use strict";var U=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.prototype.hasOwnProperty;var ie=(p,o)=>{for(var c in o)U(p,c,{get:o[c],enumerable:!0})},ue=(p,o,c,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of se(o))!le.call(p,i)&&i!==c&&U(p,i,{get:()=>o[i],enumerable:!(m=pe(o,i))||m.enumerable});return p};var ce=p=>ue(U({},"__esModule",{value:!0}),p);var de={};ie(de,{Input:()=>Q,inputVariants:()=>N});module.exports=ce(de);var J=require("@jamsr-ui/button"),V=require("@jamsr-ui/shared-icons"),K=require("@jamsr-ui/utils"),h=require("react");var L=require("@jamsr-ui/hooks"),u=require("@jamsr-ui/utils"),a=require("react");var F=require("@jamsr-ui/utils"),N=(0,F.tv)({slots:{base:"flex flex-col gap-1",input:"block w-full grow bg-transparent text-sm placeholder:text-sm placeholder:text-foreground-400 read-only:cursor-not-allowed focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",labelWrapper:"flex items-center gap-2",label:"shrink-0 select-none text-sm font-normal text-foreground-400",mainWrapper:"flex gap-1",inputWrapper:"w-full focus-within:border-primary focus-within:ring-primary",innerWrapper:"flex items-center",helper:""},variants:{variant:{outline:{inputWrapper:"rounded-lg border-2 border-divider",input:"rounded-lg"},transparent:{inputWrapper:"border-none bg-transparent outline-none",input:"p-0"},search:{inputWrapper:"rounded-2xl border-2 border-divider bg-background-paper"}},size:{false:{},sm:{input:"p-1.5"},md:{input:"p-3"},lg:{input:"p-5"}},isInvalid:{true:{inputWrapper:"border-error focus-within:border-error focus-within:shadow-error focus-within:ring-error"}},labelPlacement:{top:{mainWrapper:"flex-col"},start:{mainWrapper:"items-center"}}},defaultVariants:{variant:"outline",size:"md",labelPlacement:"top"}});var q=p=>{let{as:o,label:c,labelPlacement:m,labelHelperContent:i,className:v,classNames:t,size:C,mask:l,defaultValue:I,value:w,onValueChange:S,isInvalid:y,type:x,isSecuredText:P,showPassword:R,setShowPassword:T,startContent:k,endContent:G,onChange:g,fullWidth:M,variant:W,helperText:H,precision:b=2,ref:d,...$}=p,X=o??"div",Y="input",r=N({variant:W,size:C,isInvalid:y,labelPlacement:m}),[f,B]=(0,L.useControlledState)({prop:w,defaultProp:I,onChange:S}),[E,z]=(0,L.useControlledState)({prop:R,onChange:T}),D=(0,a.useCallback)(e=>{let{value:s}=e.target;if(s=String(s),b<1)s=s.replace(/\D/g,"");else if(l==="number"||l==="currency"||l==="percent"){let A=`^\\$?\\d*\\.?\\d{0,${b}}$`;new RegExp(A).test(s)?s=s.replace(/^\$/,""):s=f}g?.(e),B(s)},[l,g,b,B,f]),Z=(0,a.useCallback)(()=>z(e=>!e),[z]),_=(0,a.useCallback)(e=>({"data-slot":"base",className:r.base({class:(0,u.cn)(t?.base,e?.className)}),...e}),[r,t?.base]),j=(0,a.useCallback)(e=>({...e,"data-slot":"label-wrapper",className:r.labelWrapper({class:(0,u.cn)(t?.labelWrapper,e?.className)})}),[r,t?.labelWrapper]),ee=(0,a.useCallback)(e=>({...e,"data-slot":"label",className:r.label({class:(0,u.cn)(t?.label,e?.className)})}),[r,t?.label]),te=(0,a.useCallback)(e=>({...e,"data-slot":"inner-wrapper",className:r.innerWrapper({class:(0,u.cn)(t?.innerWrapper,e?.className)})}),[r,t?.innerWrapper]),re=(0,a.useCallback)(e=>({...e,"data-slot":"helper",className:r.helper({class:(0,u.cn)(t?.helper,e?.className)})}),[r,t?.helper]),ne=(0,a.useCallback)(e=>({...e,"data-slot":"main-wrapper",className:r.mainWrapper({class:(0,u.cn)(t?.mainWrapper,e?.className)})}),[r,t?.mainWrapper]),oe=(0,a.useCallback)(e=>({...e,ref:d,"data-slot":"input-wrapper",className:r.inputWrapper({class:(0,u.cn)(t?.inputWrapper,e?.className)})}),[d,r,t?.inputWrapper]),O=(0,a.useMemo)(()=>P?E?"text":"password":x,[P,E,x]),ae=(0,a.useCallback)(e=>{let s=l==="currency"?`$${f}`:f;return{"data-slot":"input",className:r.input({class:(0,u.cn)(t?.input,e?.className,v)}),value:s,onChange:D,type:O,...$,...e}},[l,f,r,t?.input,v,D,O,$]);return{Component:X,InputComponent:Y,classNames:t,label:c,helperText:H,startContent:k,endContent:G,labelPlacement:m,isInvalid:y,isSecuredText:P,showPassword:E,mask:l,getBaseProps:_,labelHelper:i,getLabelWrapperProps:j,getLabelProps:ee,getInputProps:ae,getInputWrapperProps:oe,getHelperProps:re,getInnerWrapperProps:te,handleChangeInputType:Z,getMainWrapperProps:ne}};var n=require("react/jsx-runtime"),Q=(0,K.forwardRefUI)((p,o)=>{let{Component:c,InputComponent:m,label:i,helperText:v,startContent:t,endContent:C,isSecuredText:l,showPassword:I,mask:w,getBaseProps:S,getLabelWrapperProps:y,getLabelProps:x,labelHelper:P,getInputProps:R,getInputWrapperProps:T,getHelperProps:k,getInnerWrapperProps:G,handleChangeInputType:g,getMainWrapperProps:M}=q(p),W=(0,h.useId)(),H=(0,h.useMemo)(()=>{let d=t;return d?(0,n.jsx)("div",{className:"text-foreground-muted pl-2 empty:hidden",children:d}):null},[t]),b=(0,h.useMemo)(()=>{let d=l===!0&&(0,n.jsx)(J.Button,{isIconOnly:!0,onClick:g,variant:"link",rounded:!0,children:I?(0,n.jsx)(V.EyeClosed,{}):(0,n.jsx)(V.EyeOpen,{})})||w==="percent"&&"%"||C;return d?(0,n.jsx)("div",{className:"text-foreground-muted pr-2",children:d}):null},[C,g,l,w,I]);return(0,n.jsxs)(c,{"data-component":"input",ref:o,...S(),children:[(0,n.jsxs)("div",{...M(),children:[(0,n.jsxs)("div",{...y(),children:[(0,n.jsx)("label",{htmlFor:W,...x(),children:i}),P]}),(0,n.jsx)("div",{...T(),children:(0,n.jsxs)("div",{...G(),children:[H,(0,n.jsx)(m,{id:W,...R()}),b]})})]}),(0,n.jsx)("div",{...k(),children:v})]})});0&&(module.exports={Input,inputVariants}); |
@@ -1,11 +0,11 @@ | ||
import react__default from 'react'; | ||
import * as _jamsr_ui_utils from '@jamsr-ui/utils'; | ||
import { UseInputProps } from './use-input.js'; | ||
import './style.js'; | ||
import '@jamsr-ui/utils'; | ||
import 'react'; | ||
import 'tailwind-variants'; | ||
import 'tailwind-variants/dist/config.js'; | ||
type InputProps<T extends boolean> = UseInputProps<T>; | ||
declare const Input: <T extends boolean>(props: InputProps<T>) => react__default.ReactNode; | ||
type InputProps = UseInputProps; | ||
declare const Input: _jamsr_ui_utils.InternalForwardRefRenderFunction<"input", UseInputProps, never>; | ||
export { Input, type InputProps }; |
"use client" | ||
"use strict";var L=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.prototype.hasOwnProperty;var ie=(p,a)=>{for(var c in a)L(p,c,{get:a[c],enumerable:!0})},ue=(p,a,c,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of se(a))!le.call(p,i)&&i!==c&&L(p,i,{get:()=>a[i],enumerable:!(m=pe(a,i))||m.enumerable});return p};var de=p=>ue(L({},"__esModule",{value:!0}),p);var Pe={};ie(Pe,{Input:()=>me});module.exports=de(Pe);var K=require("@jamsr-ui/button"),y=require("@jamsr-ui/shared-icons"),Q=require("@jamsr-ui/utils"),f=require("react");var M=require("@jamsr-ui/hooks"),d=require("@jamsr-ui/utils"),o=require("react");var O=require("@jamsr-ui/utils"),q=(0,O.tv)({slots:{base:"flex flex-col gap-1",input:"block w-full grow bg-transparent text-sm placeholder:text-sm placeholder:text-foreground-400 read-only:cursor-not-allowed focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",labelWrapper:"flex items-center gap-2",label:"shrink-0 select-none text-sm font-normal text-foreground-400",mainWrapper:"flex gap-1",inputWrapper:"w-full focus-within:border-primary focus-within:ring-primary",innerWrapper:"flex items-center",helper:""},variants:{variant:{outline:{inputWrapper:"rounded-lg border-2 border-divider",input:"rounded-lg"},transparent:{inputWrapper:"border-none bg-transparent outline-none",input:"p-0"},search:{inputWrapper:"rounded-2xl border-2 border-divider bg-background-paper"}},size:{false:{},sm:{input:"p-1.5"},md:{input:"p-3"},lg:{input:"p-5"}},isInvalid:{true:{inputWrapper:"border-error focus-within:border-error focus-within:shadow-error focus-within:ring-error"}},labelPlacement:{top:{mainWrapper:"flex-col"},start:{mainWrapper:"items-center"}}},defaultVariants:{variant:"outline",size:"md",labelPlacement:"top"}});var J=p=>{let{as:a,label:c,labelPlacement:m,labelHelperContent:i,className:h,classNames:t,size:I,mask:l,defaultValue:v,value:x,onValueChange:T,isInvalid:C,type:w,isSecuredText:P,showPassword:W,setShowPassword:N,startContent:R,endContent:S,onChange:b,multiline:V,fullWidth:k,variant:E,helperText:H,precision:u=2,ref:U,...$}=p,X=a??"div",Y=V?"textarea":"input",r=q({variant:E,size:I,isInvalid:C,labelPlacement:m}),[g,B]=(0,M.useControlledState)({prop:x,defaultProp:v,onChange:T}),[G,z]=(0,M.useControlledState)({prop:W,onChange:N}),F=(0,o.useCallback)(e=>{let{value:s}=e.target;if(s=String(s),u<1)s=s.replace(/\D/g,"");else if(l==="number"||l==="currency"||l==="percent"){let D=`^\\$?\\d*\\.?\\d{0,${u}}$`;new RegExp(D).test(s)?s=s.replace(/^\$/,""):s=g}b?.(e),B(s)},[l,b,u,B,g]),Z=(0,o.useCallback)(()=>z(e=>!e),[z]),_=(0,o.useCallback)(e=>({"data-slot":"base",className:r.base({class:(0,d.cn)(t?.base,e?.className)}),...e}),[r,t?.base]),j=(0,o.useCallback)(e=>({...e,"data-slot":"label-wrapper",className:r.labelWrapper({class:(0,d.cn)(t?.labelWrapper,e?.className)})}),[r,t?.labelWrapper]),ee=(0,o.useCallback)(e=>({...e,"data-slot":"label",className:r.label({class:(0,d.cn)(t?.label,e?.className)})}),[r,t?.label]),te=(0,o.useCallback)(e=>({...e,"data-slot":"inner-wrapper",className:r.innerWrapper({class:(0,d.cn)(t?.innerWrapper,e?.className)})}),[r,t?.innerWrapper]),re=(0,o.useCallback)(e=>({...e,"data-slot":"helper",className:r.helper({class:(0,d.cn)(t?.helper,e?.className)})}),[r,t?.helper]),ne=(0,o.useCallback)(e=>({...e,"data-slot":"main-wrapper",className:r.mainWrapper({class:(0,d.cn)(t?.mainWrapper,e?.className)})}),[r,t?.mainWrapper]),ae=(0,o.useCallback)(e=>({...e,ref:U,"data-slot":"input-wrapper",className:r.inputWrapper({class:(0,d.cn)(t?.inputWrapper,e?.className)})}),[U,r,t?.inputWrapper]),A=(0,o.useMemo)(()=>P?G?"text":"password":w,[P,G,w]),oe=(0,o.useCallback)(e=>{let s=l==="currency"?`$${g}`:g;return{"data-slot":"input",className:r.input({class:(0,d.cn)(t?.input,e?.className,h)}),value:s,onChange:F,type:A,...$,...e}},[l,g,r,t?.input,h,F,A,$]);return{Component:X,InputComponent:Y,classNames:t,label:c,helperText:H,startContent:R,endContent:S,labelPlacement:m,isInvalid:C,isSecuredText:P,showPassword:G,mask:l,getBaseProps:_,labelHelper:i,getLabelWrapperProps:j,getLabelProps:ee,getInputProps:oe,getInputWrapperProps:ae,getHelperProps:re,getInnerWrapperProps:te,handleChangeInputType:Z,getMainWrapperProps:ne}};var n=require("react/jsx-runtime"),ce=(p,a)=>{let{Component:c,InputComponent:m,label:i,helperText:h,startContent:t,endContent:I,isSecuredText:l,showPassword:v,mask:x,getBaseProps:T,getLabelWrapperProps:C,getLabelProps:w,labelHelper:P,getInputProps:W,getInputWrapperProps:N,getHelperProps:R,getInnerWrapperProps:S,handleChangeInputType:b,getMainWrapperProps:V}=J(p),k=(0,f.useId)(),E=(0,f.useMemo)(()=>{let u=t;return u?(0,n.jsx)("div",{className:"pl-2 text-foreground-muted empty:hidden",children:u}):null},[t]),H=(0,f.useMemo)(()=>{let u=l===!0&&(0,n.jsx)(K.Button,{isIconOnly:!0,onClick:b,variant:"link",rounded:!0,children:v?(0,n.jsx)(y.EyeClosed,{}):(0,n.jsx)(y.EyeOpen,{})})||x==="percent"&&"%"||I;return u?(0,n.jsx)("div",{className:"pr-2 text-foreground-muted",children:u}):null},[I,b,l,x,v]);return(0,n.jsxs)(c,{ref:a,...T(),children:[(0,n.jsxs)("div",{...V(),children:[(0,n.jsxs)("div",{...C(),children:[(0,n.jsx)("label",{htmlFor:k,...w(),children:i}),P]}),(0,n.jsx)("div",{...N(),children:(0,n.jsxs)("div",{...S(),children:[E,(0,n.jsx)(m,{id:k,...W()}),H]})})]}),(0,n.jsx)("div",{...R(),children:h})]})},me=(0,Q.forwardRefUI)(ce);0&&(module.exports={Input}); | ||
"use strict";var E=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var le=(p,a)=>{for(var c in a)E(p,c,{get:a[c],enumerable:!0})},ie=(p,a,c,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of pe(a))!se.call(p,i)&&i!==c&&E(p,i,{get:()=>a[i],enumerable:!(m=oe(a,i))||m.enumerable});return p};var ue=p=>ie(E({},"__esModule",{value:!0}),p);var de={};le(de,{Input:()=>ce});module.exports=ue(de);var J=require("@jamsr-ui/button"),N=require("@jamsr-ui/shared-icons"),K=require("@jamsr-ui/utils"),h=require("react");var U=require("@jamsr-ui/hooks"),u=require("@jamsr-ui/utils"),o=require("react");var A=require("@jamsr-ui/utils"),F=(0,A.tv)({slots:{base:"flex flex-col gap-1",input:"block w-full grow bg-transparent text-sm placeholder:text-sm placeholder:text-foreground-400 read-only:cursor-not-allowed focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",labelWrapper:"flex items-center gap-2",label:"shrink-0 select-none text-sm font-normal text-foreground-400",mainWrapper:"flex gap-1",inputWrapper:"w-full focus-within:border-primary focus-within:ring-primary",innerWrapper:"flex items-center",helper:""},variants:{variant:{outline:{inputWrapper:"rounded-lg border-2 border-divider",input:"rounded-lg"},transparent:{inputWrapper:"border-none bg-transparent outline-none",input:"p-0"},search:{inputWrapper:"rounded-2xl border-2 border-divider bg-background-paper"}},size:{false:{},sm:{input:"p-1.5"},md:{input:"p-3"},lg:{input:"p-5"}},isInvalid:{true:{inputWrapper:"border-error focus-within:border-error focus-within:shadow-error focus-within:ring-error"}},labelPlacement:{top:{mainWrapper:"flex-col"},start:{mainWrapper:"items-center"}}},defaultVariants:{variant:"outline",size:"md",labelPlacement:"top"}});var q=p=>{let{as:a,label:c,labelPlacement:m,labelHelperContent:i,className:v,classNames:t,size:C,mask:l,defaultValue:w,value:I,onValueChange:S,isInvalid:y,type:W,isSecuredText:P,showPassword:V,setShowPassword:R,startContent:T,endContent:k,onChange:g,fullWidth:L,variant:x,helperText:G,precision:b=2,ref:d,...M}=p,Q=a??"div",X="input",r=F({variant:x,size:C,isInvalid:y,labelPlacement:m}),[f,$]=(0,U.useControlledState)({prop:I,defaultProp:w,onChange:S}),[H,B]=(0,U.useControlledState)({prop:V,onChange:R}),z=(0,o.useCallback)(e=>{let{value:s}=e.target;if(s=String(s),b<1)s=s.replace(/\D/g,"");else if(l==="number"||l==="currency"||l==="percent"){let O=`^\\$?\\d*\\.?\\d{0,${b}}$`;new RegExp(O).test(s)?s=s.replace(/^\$/,""):s=f}g?.(e),$(s)},[l,g,b,$,f]),Y=(0,o.useCallback)(()=>B(e=>!e),[B]),Z=(0,o.useCallback)(e=>({"data-slot":"base",className:r.base({class:(0,u.cn)(t?.base,e?.className)}),...e}),[r,t?.base]),_=(0,o.useCallback)(e=>({...e,"data-slot":"label-wrapper",className:r.labelWrapper({class:(0,u.cn)(t?.labelWrapper,e?.className)})}),[r,t?.labelWrapper]),j=(0,o.useCallback)(e=>({...e,"data-slot":"label",className:r.label({class:(0,u.cn)(t?.label,e?.className)})}),[r,t?.label]),ee=(0,o.useCallback)(e=>({...e,"data-slot":"inner-wrapper",className:r.innerWrapper({class:(0,u.cn)(t?.innerWrapper,e?.className)})}),[r,t?.innerWrapper]),te=(0,o.useCallback)(e=>({...e,"data-slot":"helper",className:r.helper({class:(0,u.cn)(t?.helper,e?.className)})}),[r,t?.helper]),re=(0,o.useCallback)(e=>({...e,"data-slot":"main-wrapper",className:r.mainWrapper({class:(0,u.cn)(t?.mainWrapper,e?.className)})}),[r,t?.mainWrapper]),ne=(0,o.useCallback)(e=>({...e,ref:d,"data-slot":"input-wrapper",className:r.inputWrapper({class:(0,u.cn)(t?.inputWrapper,e?.className)})}),[d,r,t?.inputWrapper]),D=(0,o.useMemo)(()=>P?H?"text":"password":W,[P,H,W]),ae=(0,o.useCallback)(e=>{let s=l==="currency"?`$${f}`:f;return{"data-slot":"input",className:r.input({class:(0,u.cn)(t?.input,e?.className,v)}),value:s,onChange:z,type:D,...M,...e}},[l,f,r,t?.input,v,z,D,M]);return{Component:Q,InputComponent:X,classNames:t,label:c,helperText:G,startContent:T,endContent:k,labelPlacement:m,isInvalid:y,isSecuredText:P,showPassword:H,mask:l,getBaseProps:Z,labelHelper:i,getLabelWrapperProps:_,getLabelProps:j,getInputProps:ae,getInputWrapperProps:ne,getHelperProps:te,getInnerWrapperProps:ee,handleChangeInputType:Y,getMainWrapperProps:re}};var n=require("react/jsx-runtime"),ce=(0,K.forwardRefUI)((p,a)=>{let{Component:c,InputComponent:m,label:i,helperText:v,startContent:t,endContent:C,isSecuredText:l,showPassword:w,mask:I,getBaseProps:S,getLabelWrapperProps:y,getLabelProps:W,labelHelper:P,getInputProps:V,getInputWrapperProps:R,getHelperProps:T,getInnerWrapperProps:k,handleChangeInputType:g,getMainWrapperProps:L}=q(p),x=(0,h.useId)(),G=(0,h.useMemo)(()=>{let d=t;return d?(0,n.jsx)("div",{className:"text-foreground-muted pl-2 empty:hidden",children:d}):null},[t]),b=(0,h.useMemo)(()=>{let d=l===!0&&(0,n.jsx)(J.Button,{isIconOnly:!0,onClick:g,variant:"link",rounded:!0,children:w?(0,n.jsx)(N.EyeClosed,{}):(0,n.jsx)(N.EyeOpen,{})})||I==="percent"&&"%"||C;return d?(0,n.jsx)("div",{className:"text-foreground-muted pr-2",children:d}):null},[C,g,l,I,w]);return(0,n.jsxs)(c,{"data-component":"input",ref:a,...S(),children:[(0,n.jsxs)("div",{...L(),children:[(0,n.jsxs)("div",{...y(),children:[(0,n.jsx)("label",{htmlFor:x,...W(),children:i}),P]}),(0,n.jsx)("div",{...R(),children:(0,n.jsxs)("div",{...k(),children:[G,(0,n.jsx)(m,{id:x,...V()}),b]})})]}),(0,n.jsx)("div",{...T(),children:v})]})});0&&(module.exports={Input}); |
@@ -8,3 +8,3 @@ import * as react from 'react'; | ||
type Props<T extends boolean> = { | ||
type Props = { | ||
startContent?: React.ReactNode; | ||
@@ -20,3 +20,2 @@ endContent?: React.ReactNode; | ||
onValueChange?: (value: string) => void; | ||
multiline?: T; | ||
fullWidth?: boolean; | ||
@@ -30,7 +29,5 @@ showPassword?: boolean; | ||
}; | ||
type InputProps<T> = T extends true ? UIProps<"textarea"> & { | ||
type?: undefined; | ||
} : UIProps<"input">; | ||
type UseInputProps<T extends boolean> = InputProps<T> & Props<T> & InputVariantProps; | ||
declare const useInput: <T extends boolean>(props: UseInputProps<T>) => { | ||
type InputProps = UIProps<"input">; | ||
type UseInputProps = InputProps & Props & InputVariantProps; | ||
declare const useInput: (props: UseInputProps) => { | ||
Component: _jamsr_ui_utils.As<any>; | ||
@@ -37,0 +34,0 @@ InputComponent: string; |
"use client" | ||
"use strict";var g=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var re=(s,n)=>{for(var u in n)g(s,u,{get:n[u],enumerable:!0})},ae=(s,n,u,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of ee(n))!te.call(s,l)&&l!==u&&g(s,l,{get:()=>n[l],enumerable:!(c=_(n,l))||c.enumerable});return s};var ne=s=>ae(g({},"__esModule",{value:!0}),s);var se={};re(se,{useInput:()=>oe});module.exports=ne(se);var f=require("@jamsr-ui/hooks"),p=require("@jamsr-ui/utils"),a=require("react");var S=require("@jamsr-ui/utils"),R=(0,S.tv)({slots:{base:"flex flex-col gap-1",input:"block w-full grow bg-transparent text-sm placeholder:text-sm placeholder:text-foreground-400 read-only:cursor-not-allowed focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",labelWrapper:"flex items-center gap-2",label:"shrink-0 select-none text-sm font-normal text-foreground-400",mainWrapper:"flex gap-1",inputWrapper:"w-full focus-within:border-primary focus-within:ring-primary",innerWrapper:"flex items-center",helper:""},variants:{variant:{outline:{inputWrapper:"rounded-lg border-2 border-divider",input:"rounded-lg"},transparent:{inputWrapper:"border-none bg-transparent outline-none",input:"p-0"},search:{inputWrapper:"rounded-2xl border-2 border-divider bg-background-paper"}},size:{false:{},sm:{input:"p-1.5"},md:{input:"p-3"},lg:{input:"p-5"}},isInvalid:{true:{inputWrapper:"border-error focus-within:border-error focus-within:shadow-error focus-within:ring-error"}},labelPlacement:{top:{mainWrapper:"flex-col"},start:{mainWrapper:"items-center"}}},defaultVariants:{variant:"outline",size:"md",labelPlacement:"top"}});var oe=s=>{let{as:n,label:u,labelPlacement:c,labelHelperContent:l,className:h,classNames:t,size:G,mask:i,defaultValue:k,value:H,onValueChange:E,isInvalid:w,type:x,isSecuredText:m,showPassword:$,setShowPassword:L,startContent:M,endContent:U,onChange:C,multiline:z,fullWidth:pe,variant:A,helperText:D,precision:P=2,ref:y,...W}=s,B=n??"div",j=z?"textarea":"input",r=R({variant:A,size:G,isInvalid:w,labelPlacement:c}),[d,v]=(0,f.useControlledState)({prop:H,defaultProp:k,onChange:E}),[b,I]=(0,f.useControlledState)({prop:$,onChange:L}),N=(0,a.useCallback)(e=>{let{value:o}=e.target;if(o=String(o),P<1)o=o.replace(/\D/g,"");else if(i==="number"||i==="currency"||i==="percent"){let V=`^\\$?\\d*\\.?\\d{0,${P}}$`;new RegExp(V).test(o)?o=o.replace(/^\$/,""):o=d}C?.(e),v(o)},[i,C,P,v,d]),q=(0,a.useCallback)(()=>I(e=>!e),[I]),F=(0,a.useCallback)(e=>({"data-slot":"base",className:r.base({class:(0,p.cn)(t?.base,e?.className)}),...e}),[r,t?.base]),J=(0,a.useCallback)(e=>({...e,"data-slot":"label-wrapper",className:r.labelWrapper({class:(0,p.cn)(t?.labelWrapper,e?.className)})}),[r,t?.labelWrapper]),K=(0,a.useCallback)(e=>({...e,"data-slot":"label",className:r.label({class:(0,p.cn)(t?.label,e?.className)})}),[r,t?.label]),O=(0,a.useCallback)(e=>({...e,"data-slot":"inner-wrapper",className:r.innerWrapper({class:(0,p.cn)(t?.innerWrapper,e?.className)})}),[r,t?.innerWrapper]),Q=(0,a.useCallback)(e=>({...e,"data-slot":"helper",className:r.helper({class:(0,p.cn)(t?.helper,e?.className)})}),[r,t?.helper]),X=(0,a.useCallback)(e=>({...e,"data-slot":"main-wrapper",className:r.mainWrapper({class:(0,p.cn)(t?.mainWrapper,e?.className)})}),[r,t?.mainWrapper]),Y=(0,a.useCallback)(e=>({...e,ref:y,"data-slot":"input-wrapper",className:r.inputWrapper({class:(0,p.cn)(t?.inputWrapper,e?.className)})}),[y,r,t?.inputWrapper]),T=(0,a.useMemo)(()=>m?b?"text":"password":x,[m,b,x]),Z=(0,a.useCallback)(e=>{let o=i==="currency"?`$${d}`:d;return{"data-slot":"input",className:r.input({class:(0,p.cn)(t?.input,e?.className,h)}),value:o,onChange:N,type:T,...W,...e}},[i,d,r,t?.input,h,N,T,W]);return{Component:B,InputComponent:j,classNames:t,label:u,helperText:D,startContent:M,endContent:U,labelPlacement:c,isInvalid:w,isSecuredText:m,showPassword:b,mask:i,getBaseProps:F,labelHelper:l,getLabelWrapperProps:J,getLabelProps:K,getInputProps:Z,getInputWrapperProps:Y,getHelperProps:Q,getInnerWrapperProps:O,handleChangeInputType:q,getMainWrapperProps:X}};0&&(module.exports={useInput}); | ||
"use strict";var g=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(p,n)=>{for(var u in n)g(p,u,{get:n[u],enumerable:!0})},re=(p,n,u,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of _(n))!ee.call(p,l)&&l!==u&&g(p,l,{get:()=>n[l],enumerable:!(c=Z(n,l))||c.enumerable});return p};var ae=p=>re(g({},"__esModule",{value:!0}),p);var oe={};te(oe,{useInput:()=>ne});module.exports=ae(oe);var f=require("@jamsr-ui/hooks"),s=require("@jamsr-ui/utils"),a=require("react");var R=require("@jamsr-ui/utils"),T=(0,R.tv)({slots:{base:"flex flex-col gap-1",input:"block w-full grow bg-transparent text-sm placeholder:text-sm placeholder:text-foreground-400 read-only:cursor-not-allowed focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",labelWrapper:"flex items-center gap-2",label:"shrink-0 select-none text-sm font-normal text-foreground-400",mainWrapper:"flex gap-1",inputWrapper:"w-full focus-within:border-primary focus-within:ring-primary",innerWrapper:"flex items-center",helper:""},variants:{variant:{outline:{inputWrapper:"rounded-lg border-2 border-divider",input:"rounded-lg"},transparent:{inputWrapper:"border-none bg-transparent outline-none",input:"p-0"},search:{inputWrapper:"rounded-2xl border-2 border-divider bg-background-paper"}},size:{false:{},sm:{input:"p-1.5"},md:{input:"p-3"},lg:{input:"p-5"}},isInvalid:{true:{inputWrapper:"border-error focus-within:border-error focus-within:shadow-error focus-within:ring-error"}},labelPlacement:{top:{mainWrapper:"flex-col"},start:{mainWrapper:"items-center"}}},defaultVariants:{variant:"outline",size:"md",labelPlacement:"top"}});var ne=p=>{let{as:n,label:u,labelPlacement:c,labelHelperContent:l,className:h,classNames:t,size:G,mask:i,defaultValue:k,value:H,onValueChange:$,isInvalid:w,type:C,isSecuredText:m,showPassword:E,setShowPassword:L,startContent:M,endContent:U,onChange:W,fullWidth:pe,variant:z,helperText:D,precision:P=2,ref:y,...v}=p,A=n??"div",B="input",r=T({variant:z,size:G,isInvalid:w,labelPlacement:c}),[d,x]=(0,f.useControlledState)({prop:H,defaultProp:k,onChange:$}),[b,I]=(0,f.useControlledState)({prop:E,onChange:L}),N=(0,a.useCallback)(e=>{let{value:o}=e.target;if(o=String(o),P<1)o=o.replace(/\D/g,"");else if(i==="number"||i==="currency"||i==="percent"){let S=`^\\$?\\d*\\.?\\d{0,${P}}$`;new RegExp(S).test(o)?o=o.replace(/^\$/,""):o=d}W?.(e),x(o)},[i,W,P,x,d]),j=(0,a.useCallback)(()=>I(e=>!e),[I]),q=(0,a.useCallback)(e=>({"data-slot":"base",className:r.base({class:(0,s.cn)(t?.base,e?.className)}),...e}),[r,t?.base]),F=(0,a.useCallback)(e=>({...e,"data-slot":"label-wrapper",className:r.labelWrapper({class:(0,s.cn)(t?.labelWrapper,e?.className)})}),[r,t?.labelWrapper]),J=(0,a.useCallback)(e=>({...e,"data-slot":"label",className:r.label({class:(0,s.cn)(t?.label,e?.className)})}),[r,t?.label]),K=(0,a.useCallback)(e=>({...e,"data-slot":"inner-wrapper",className:r.innerWrapper({class:(0,s.cn)(t?.innerWrapper,e?.className)})}),[r,t?.innerWrapper]),O=(0,a.useCallback)(e=>({...e,"data-slot":"helper",className:r.helper({class:(0,s.cn)(t?.helper,e?.className)})}),[r,t?.helper]),Q=(0,a.useCallback)(e=>({...e,"data-slot":"main-wrapper",className:r.mainWrapper({class:(0,s.cn)(t?.mainWrapper,e?.className)})}),[r,t?.mainWrapper]),X=(0,a.useCallback)(e=>({...e,ref:y,"data-slot":"input-wrapper",className:r.inputWrapper({class:(0,s.cn)(t?.inputWrapper,e?.className)})}),[y,r,t?.inputWrapper]),V=(0,a.useMemo)(()=>m?b?"text":"password":C,[m,b,C]),Y=(0,a.useCallback)(e=>{let o=i==="currency"?`$${d}`:d;return{"data-slot":"input",className:r.input({class:(0,s.cn)(t?.input,e?.className,h)}),value:o,onChange:N,type:V,...v,...e}},[i,d,r,t?.input,h,N,V,v]);return{Component:A,InputComponent:B,classNames:t,label:u,helperText:D,startContent:M,endContent:U,labelPlacement:c,isInvalid:w,isSecuredText:m,showPassword:b,mask:i,getBaseProps:q,labelHelper:l,getLabelWrapperProps:F,getLabelProps:J,getInputProps:Y,getInputWrapperProps:X,getHelperProps:O,getInnerWrapperProps:K,handleChangeInputType:j,getMainWrapperProps:Q}};0&&(module.exports={useInput}); |
{ | ||
"name": "@jamsr-ui/input", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "", | ||
@@ -24,6 +24,6 @@ "main": "./dist/index.mjs", | ||
"dependencies": { | ||
"@jamsr-ui/button": "^0.0.16", | ||
"@jamsr-ui/shared-icons": "^0.0.15", | ||
"@jamsr-ui/hooks": "^0.0.9", | ||
"@jamsr-ui/utils": "^0.0.14" | ||
"@jamsr-ui/button": "^0.0.17", | ||
"@jamsr-ui/hooks": "^0.0.10", | ||
"@jamsr-ui/shared-icons": "^0.0.16", | ||
"@jamsr-ui/utils": "^0.0.15" | ||
}, | ||
@@ -30,0 +30,0 @@ "module": "dist/index.mjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41401
476
+ Added@jamsr-ui/button@0.0.17(transitive)
+ Added@jamsr-ui/hooks@0.0.10(transitive)
+ Added@jamsr-ui/progress@0.0.17(transitive)
+ Added@jamsr-ui/ripple@0.0.17(transitive)
+ Added@jamsr-ui/shared-icons@0.0.16(transitive)
+ Added@jamsr-ui/utils@0.0.15(transitive)
- Removed@jamsr-ui/button@0.0.16(transitive)
- Removed@jamsr-ui/hooks@0.0.9(transitive)
- Removed@jamsr-ui/progress@0.0.16(transitive)
- Removed@jamsr-ui/ripple@0.0.16(transitive)
- Removed@jamsr-ui/shared-icons@0.0.15(transitive)
- Removed@jamsr-ui/utils@0.0.14(transitive)
Updated@jamsr-ui/button@^0.0.17
Updated@jamsr-ui/hooks@^0.0.10
Updated@jamsr-ui/utils@^0.0.15