dsql-admin/dsql-app/.local_dist/server/chunks/3737.js

1 line
5.7 KiB
JavaScript
Raw Normal View History

2024-12-08 19:56:57 +00:00
"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=