@internxt/ui 0.1.14 → 0.1.15
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 +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -35,7 +35,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
35
35
|
transition-all duration-200
|
|
36
36
|
${H()}
|
|
37
37
|
${S}
|
|
38
|
-
`,children:o}),ne(),B(),A&&w&&g!=="cancel"&&a.jsx("div",{className:"absolute bottom-full mb-2 left-0",children:w})]})},Du=({children:o,title:g,subtitle:s,popsFrom:x,className:v,delayInMs:S,arrow:w=!0})=>{const[C,A]=R.useState(!1),$=R.useRef(null);function D(){A(!0)}function E(){A(!1)}function M(){$.current!==null&&clearTimeout($.current),D()}function H(){S?$.current=setTimeout(()=>{$.current=null,E()},S):E()}let B="",ne="",N="";switch(x){case"right":B="left-full top-1/2 -translate-y-1/2 ml-1.5",ne="flex-row-reverse",N="polygon(100% 0%, 100% 100%, 0% 50%)";break;case"left":B="right-full top-1/2 -translate-y-1/2 mr-1.5",ne="flex-row",N="polygon(0% 0%, 0% 100%, 100% 50%)";break;case"top":B="bottom-full left-1/2 -translate-x-1/2 mb-1.5 origin-bottom",ne="flex-col",N="polygon(0% 0%, 100% 0%, 50% 100%)";break;case"bottom":B="top-full left-1/2 -translate-x-1/2 mt-1.5",ne="flex-col-reverse",N="polygon(50% 0%, 0% 100%, 100% 100%)";break}return a.jsxs("div",{className:`relative w-max ${v}`,onMouseEnter:M,onMouseLeave:H,style:{lineHeight:0},children:[a.jsxs("div",{className:`pointer-events-none absolute ${B} flex items-center ${ne} drop-shadow-tooltip transition-all duration-150 ${C?"scale-100 opacity-100":"scale-50 opacity-0"}`,children:[a.jsxs("div",{className:"w-max rounded-lg bg-gray-90 px-4 py-1.5 text-center dark:bg-gray-5",children:[a.jsx("p",{className:"text-base text-white",children:g}),s&&a.jsx("p",{className:"-mt-1 text-sm text-gray-40",children:s})]}),w&&a.jsx("div",{className:`bg-gray-90 dark:bg-gray-5 ${x==="bottom"||x==="top"?"h-1.5 w-4":"h-4 w-1.5"}`,style:{clipPath:N,marginTop:x==="top"?"-1px":void 0},"data-testid":"tooltip-arrow"})]}),o]})},ex=({className:o="",classText:g="select-text text-gray-80",text:s,copiedText:x="Copied!",copyToClipboardText:v="Copy to clipboard"})=>{const[S,w]=R.useState(!1);async function C(){await navigator.clipboard.writeText(s),w(!0),setTimeout(()=>w(!1),1e3)}return a.jsxs("div",{className:`${o} flex h-11 items-center justify-between rounded-md border border-gray-10 bg-gray-5 px-4`,children:[a.jsx("p",{className:`${g}`,children:s}),a.jsx(Du,{className:"ml-6",popsFrom:"
|
|
38
|
+
`,children:o}),ne(),B(),A&&w&&g!=="cancel"&&a.jsx("div",{className:"absolute bottom-full mb-2 left-0",children:w})]})},Du=({children:o,title:g,subtitle:s,popsFrom:x,className:v,delayInMs:S,arrow:w=!0})=>{const[C,A]=R.useState(!1),$=R.useRef(null);function D(){A(!0)}function E(){A(!1)}function M(){$.current!==null&&clearTimeout($.current),D()}function H(){S?$.current=setTimeout(()=>{$.current=null,E()},S):E()}let B="",ne="",N="";switch(x){case"right":B="left-full top-1/2 -translate-y-1/2 ml-1.5",ne="flex-row-reverse",N="polygon(100% 0%, 100% 100%, 0% 50%)";break;case"left":B="right-full top-1/2 -translate-y-1/2 mr-1.5",ne="flex-row",N="polygon(0% 0%, 0% 100%, 100% 50%)";break;case"top":B="bottom-full left-1/2 -translate-x-1/2 mb-1.5 origin-bottom",ne="flex-col",N="polygon(0% 0%, 100% 0%, 50% 100%)";break;case"bottom":B="top-full left-1/2 -translate-x-1/2 mt-1.5",ne="flex-col-reverse",N="polygon(50% 0%, 0% 100%, 100% 100%)";break}return a.jsxs("div",{className:`relative w-max ${v}`,onMouseEnter:M,onMouseLeave:H,style:{lineHeight:0},children:[a.jsxs("div",{className:`pointer-events-none absolute ${B} flex items-center ${ne} drop-shadow-tooltip transition-all duration-150 ${C?"scale-100 opacity-100":"scale-50 opacity-0"}`,children:[a.jsxs("div",{className:"w-max rounded-lg bg-gray-90 px-4 py-1.5 text-center dark:bg-gray-5",children:[a.jsx("p",{className:"text-base text-white",children:g}),s&&a.jsx("p",{className:"-mt-1 text-sm text-gray-40",children:s})]}),w&&a.jsx("div",{className:`bg-gray-90 dark:bg-gray-5 ${x==="bottom"||x==="top"?"h-1.5 w-4":"h-4 w-1.5"}`,style:{clipPath:N,marginTop:x==="top"?"-1px":void 0},"data-testid":"tooltip-arrow"})]}),o]})},ex=({className:o="",classText:g="select-text text-gray-80",text:s,copiedText:x="Copied!",copyToClipboardText:v="Copy to clipboard"})=>{const[S,w]=R.useState(!1);async function C(){await navigator.clipboard.writeText(s),w(!0),setTimeout(()=>w(!1),1e3)}return a.jsxs("div",{className:`${o} flex h-11 items-center justify-between rounded-md border border-gray-10 bg-gray-5 px-4`,children:[a.jsx("p",{className:`${g}`,children:s}),a.jsx(Du,{className:"ml-6",popsFrom:"top",title:S?x:v,delayInMs:S?500:void 0,children:a.jsx("button",{disabled:S,onClick:C,children:a.jsx(ve.Copy,{className:"shrink-0 text-gray-50 hover:text-gray-60",size:24})})})]})},nx=({className:o="",label:g,variant:s="default",accent:x,disabled:v,placeholder:S,value:w,maxLength:C,onChange:A,onClear:$,message:D,onFocus:E,onBlur:M,autofocus:H=!1,autoComplete:B="on",dataTest:ne,name:N,required:T=!1,labelDataCy:V,inputDataCy:Q,onKeyDown:ie,inputClassName:ae="",borderRadius:oe="rounded-md",fontClasses:he="text-lg font-normal"})=>{const we=R.useRef(null),Ve=()=>{we&&we.current&&(s!=="email"&&(we.current.selectionStart=we.current.value.length,we.current.selectionEnd=we.current.value.length),we.current.focus())};R.useEffect(()=>{(D||H)&&Ve()},[D,H,v]);let Ie;switch(x){case"error":Ie="border-red focus:border-red ring-red";break;case"warning":Ie="focus:border-orange ring-orange";break;case"success":Ie="focus:border-green ring-green";break;default:Ie="focus:border-primary ring-primary";break}const en=s==="search"?"border-transparent":"border-gray-20 disabled:border-gray-10 hover:border-gray-30",gn=s==="search"?"placeholder-gray-40":"placeholder-gray-30",kn=s==="search"?"pr-4 pl-10":"px-4",[nn,Pn]=R.useState(!1),[ze,$e]=R.useState(!1),_e=a.jsxs("div",{className:"relative",children:[a.jsx("input",{ref:we,disabled:v,className:`inxt-input h-10 w-full border bg-transparent ${he} text-gray-80 outline-none ring-opacity-10 focus:ring-3 disabled:text-gray-40 disabled:placeholder-gray-20 dark:ring-opacity-20
|
|
39
39
|
${en} ${Ie} ${gn} ${kn} ${oe} ${ae}`,type:s==="password"&&!nn?"password":s==="email"?"email":"text",placeholder:S,onChange:se=>A&&A(se.target.value),onFocus:()=>{E&&E(),$e(!0)},onBlur:()=>{M&&M(),$e(!1)},autoComplete:B,value:w,maxLength:C,"data-test":ne,"data-cy":Q,name:N,required:T,onKeyDown:ie??void 0}),s==="password"&&ze&&a.jsx("div",{role:"button",tabIndex:0,onMouseDown:se=>{se.preventDefault(),Pn(!nn)},className:"absolute right-4 top-1/2 -translate-y-1/2 cursor-pointer bg-transparent py-2 pl-2 text-gray-80",children:nn?a.jsx(ve.Eye,{size:24}):a.jsx(ve.EyeSlash,{size:24})}),s==="search"&&a.jsx(ve.MagnifyingGlass,{className:`absolute left-4 top-1/2 -translate-y-1/2 ${v?"text-gray-20":"text-gray-40"}`,size:20}),s==="search"&&w&&!v&&a.jsx("div",{role:"button",tabIndex:0,onMouseDown:se=>{se.preventDefault(),$&&$()},className:`absolute right-4 top-1/2 -translate-y-1/2 cursor-pointer py-2 pl-2 text-gray-40
|
|
40
40
|
${ze?"bg-white":"bg-gray-5"}`,children:a.jsx(ve.X,{size:20})})]});let an,Y;switch(x){case"success":an="text-green",Y=ve.CheckCircle;break;case"warning":an="text-orange",Y=ve.Warning;break;case"error":an="text-red",Y=ve.WarningOctagon;break;default:an="text-gray-80"}return a.jsxs("div",{className:`${o}`,children:[g?a.jsxs("label",{children:[a.jsx("span",{"data-cy":V,className:`text-sm ${v?"text-gray-40":"text-gray-80"}`,children:g}),_e]}):_e,C&&a.jsx("p",{className:"font-regular mt-1 text-right text-sm text-gray-50",children:`${w?.length??0}/${C}`}),D&&a.jsxs("div",{className:`mt-0.5 flex items-center ${an}`,children:[Y&&a.jsx(Y,{size:16,weight:"fill"}),a.jsx("p",{className:"ml-1 text-sm",children:D})]})]})},tx=({checked:o,id:g,disabled:s=!1,onClick:x})=>{const v=s?"border-gray-10":"border-gray-40",S=s&&o?"border-0 bg-gray-20":o&&"border-0 bg-primary active:bg-primary-dark";return a.jsxs("div",{id:g,className:"flex cursor-pointer",children:[a.jsx("button",{disabled:s,onClick:x,className:`flex h-5 w-5 items-center justify-center rounded-full border ${S} ${v}`,children:a.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${o||s?"bg-white":"hover:bg-gray-10"}`})}),a.jsx("input",{type:"radio",className:"h-0 w-0 appearance-none opacity-0",checked:!0,readOnly:!0})]})},rx=({value:o,min:g=0,max:s,step:x,className:v,disabled:S=!1,ariaLabel:w="Range slider",onChange:C})=>{const A=(o-g)/(s-g)*100,$=`linear-gradient(to right, #3264fe ${A}%, #d5d5d5 ${A}%)`;return a.jsx("div",{className:v,children:a.jsx("input",{id:"my-slider",type:"range",min:g,max:s,value:o,step:x,onInput:D=>C(Number(D.target.value)),disabled:S,"aria-label":w,style:{background:$}})})},ix=({disabled:o=!1,id:g,dataTestId:s="switch",size:x="md",onClick:v,onCheckedChange:S})=>{const[w,C]=R.useState(!1),A=H=>{const B=H.target.checked;C(B),S&&S(B)},$=o?"bg-gray-5":w?"bg-green":"bg-gray-10",D={md:"w-8 h-5",lg:"w-12 h-7",xl:"w-14 h-8"},E={md:"w-4 h-4",lg:"w-6 h-6",xl:"w-7 h-7"},M={md:"translate-x-[13px]",lg:"translate-x-[21px]",xl:"translate-x-[25px]"};return a.jsxs("label",{htmlFor:g,className:`relative inline-flex items-center cursor-pointer ${D[x]}`,"data-testid":s,children:[a.jsx("input",{type:"checkbox",id:g,disabled:o,checked:w,onChange:A,onClick:v,className:"sr-only"}),a.jsx("div",{className:`absolute inset-0 rounded-full transition-colors duration-200 ${$} ${o?"data-[state=checked]:bg-green/50":""}`}),a.jsx("span",{className:`block bg-white rounded-full transition-transform duration-200 transform ${w?M[x]:"translate-x-[3px]"} ${E[x]} ${o?"pointer-events-none":""}`})]})},sx=({disabled:o=!1,accentColor:g,placeholder:s="",value:x="",onChange:v,name:S})=>a.jsx("textarea",{disabled:o,placeholder:s,className:`
|
|
41
41
|
w-full h-full py-4 px-3.5 bg-transparent border rounded-md outline-none text-lg font-regular resize-none
|