dsql-admin/dsql-app/.local_dist/server/chunks/3737.js
Benjamin Toby 7a06e83a46 Updates
2024-12-08 20:56:57 +01:00

1 line
5.7 KiB
JavaScript

"use strict";exports.id=3737,exports.ids=[3737],exports.modules={13737:(e,t,r)=>{let n,a;r.d(t,{A:()=>d});var o=r(8732),l=r(82015),i=r.n(l);function s({value:e,format:t}){let r;if(!e)return 0;try{r="string"===t?e.toString().replace(/\D/g,"").replace(/\B(?=(\d{3})+(?!\d))/g,","):parseInt(e.toString().replace(/\D/g,""))}catch(e){r=0,console.log(e)}return r}function u({value:e,format:t,decimals:r}){let n;let a=e?.toString()?.match(/^\-/)?"-":"";try{if("string"===t){let t=e.toString().split(".");n=a+t[0].toString().replace(/[^0-9\.]/g,"").replace(/\B(?=(\d{3})+(?!\d))/g,",")+(t[1]?r?`.${t[1].substring(0,r)}`:`.${t[1].substring(0,2)}`:"")}else n=parseFloat(a+e.toString().replace(/[^0-9\.]/g,""))}catch(e){n=0,console.log(e)}return n}function d(e){try{let{title:c,name:p,defaultValue:m,placeholder:g,autoComplete:v,onInputHandler:h,required:w,inputType:f,setAlert:x,prefix:b,minValue:S,maxValue:y,encrypted:j,numberText:I,appendCurrency:T,elementRef:F,onChangeHandler:L,value:N,step:D,decimal:M,pattern:W,info:E,fontSize:k,maxWidth:R,setValue:q,id:B}=e;function t(e){e.target.value.match(/./)?(e.target.classList.remove("warning"),x&&x(null)):e.target.required&&e.target.classList.add("warning"),I&&(e.target.value=e.target.value.toString().match(/^0+$/)?"0":e.target.value.toString().replace(M?/[^0-9\.]/g:/\D/g,"").replace(/^0*/,"").replace(/\B(?=(\d{3})+(?!\d))/g,",")),h&&h(e),L&&L(e)}function r(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let t=e.target.closest(".info-wrapper"),r=t.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!r.classList.contains("hidden")){r.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&r.classList.contains("hidden"))){if(!t){r.classList.add("hidden");return}if(r.classList.contains("hidden")){r.classList.remove("hidden");return}r.classList.add("hidden")}}let C=F||i().useRef();function l(e){let t=M?parseFloat(u({value:C.current?.value||0}).toString())-(D?parseFloat(D.toString()):20):parseInt(s({value:C.current.value}).toString())-(D||20),r=M?u({value:t,format:"raw"}):s({value:t,format:"raw"});S&&"number"==typeof r&&r<S||(C.current.value=M?parseFloat(u({value:t,format:"raw"}).toString()).toFixed("number"==typeof M?M:2):s({value:t,format:"string"}).toString(),q&&q(C.current.value))}function d(e){let t=M?parseFloat(u({value:C.current.value}).toString())+(D?parseFloat(D.toString()):20):parseInt(s({value:C.current.value}).toString())+(D||20),r=M?parseFloat(u({value:t,format:"raw"}).toString()).toFixed("number"==typeof M?M:2):s({value:t,format:"string"}),n=M?parseFloat(u({value:r,format:"raw"}).toString()):parseInt(s({value:r,format:"raw"}).toString());y&&n>y||(C.current.value=r.toString(),q&&q(C.current.value))}return(0,o.jsxs)("div",{className:"form-input-wrapper flex flex-col items-start gap-0.5 w-full relative",style:{...R?{maxWidth:R}:{}},children:[c&&(0,o.jsx)("label",{htmlFor:p,children:c}),(0,o.jsxs)("div",{className:"flex items-center w-full relative",children:[b&&(0,o.jsx)("div",{className:"absolute left-4 bottom-2 text-lg",children:b}),(0,o.jsx)("input",{type:f||"text",name:p,id:B||p,ref:C,placeholder:g||c||"",autoComplete:v,onInput:e=>{t(e)},onChange:e=>{t(e)},value:N||void 0,defaultValue:N?void 0:m||void 0,pattern:W?W.toString():void 0,required:!!w&&w,style:{...k?{fontSize:k}:{},...b?{paddingLeft:"35px"}:{}},min:S,max:y,"data-encrypted":j||null,"data-appendcurrency":T||null,className:"bg-white"+(E?" pr-16":"")}),I&&(0,o.jsxs)("div",{className:"absolute gap-1"+(E?" right-12":" right-4"),style:{top:"50%",transform:"translate(0,-50%)"},children:[(0,o.jsx)("span",{className:"number-text-button w-10 md:w-8 h-10 md:h-8 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center cursor-pointer hover:bg-slate-200 text-2xl font-semibold touch-none",onMouseDown:e=>{e.preventDefault(),window.innerWidth<1200||(l(e),n=setTimeout(()=>{a=setInterval(()=>{l(e)},50)},200))},onTouchStart:e=>{e.preventDefault(),window.innerWidth>=1200||(l(e),n=setTimeout(()=>{a=setInterval(()=>{l(e)},50)},200))},onMouseUp:e=>{window.clearTimeout(n),window.clearInterval(a)},onTouchEnd:e=>{window.clearTimeout(n),window.clearInterval(a)},onMouseLeave:e=>{window.clearTimeout(n),window.clearInterval(a)},onTouchMove:e=>{e.preventDefault()},children:(0,o.jsx)("span",{className:"pointer-events-none",children:"-"})}),(0,o.jsx)("span",{className:"number-text-button w-10 md:w-8 h-10 md:h-8 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center cursor-pointer hover:bg-slate-200 text-2xl font-semibold touch-none",onMouseDown:e=>{e.preventDefault(),window.innerWidth<1200||(d(e),n=setTimeout(()=>{a=setInterval(()=>{d(e)},50)},200))},onTouchStart:e=>{e.preventDefault(),window.innerWidth>=1200||(d(e),n=setTimeout(()=>{a=setInterval(()=>{d(e)},50)},200))},onMouseUp:e=>{window.clearTimeout(n),window.clearInterval(a)},onTouchEnd:e=>{window.clearTimeout(n),window.clearInterval(a)},onMouseLeave:e=>{window.clearTimeout(n),window.clearInterval(a)},children:(0,o.jsx)("span",{className:"pointer-events-none",children:"+"})})]}),E&&(0,o.jsxs)("div",{className:"info-wrapper absolute right-2 w-8 h-8 rounded-full bg-white flex items-center justify-center z-10",style:{top:"50%",transform:"translate(0,-50%)"},onMouseEnter:r,onMouseLeave:r,onClick:r,children:[(0,o.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,o.jsx)("div",{className:"info-dropdown absolute top-9 right-0 bg-white w-52 md:w-96 p-2 sm:p-6 shadow-xl rounded hidden text-center border border-slate-300 border-solid",children:(0,o.jsx)("span",{children:E})}),(0,o.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormInput =>",e),(0,o.jsx)("div",{children:"Form Input Error"})}}}};