diefra_ecm_ui 1.2.2 → 1.2.4
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/components/Input/index.d.ts +2 -2
- package/dist/index.cjs +12 -12
- package/dist/index.js +571 -586
- package/package.json +1 -1
|
@@ -8,8 +8,8 @@ export interface InputProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
forceReadOnly?: boolean;
|
|
10
10
|
forceHidden?: boolean;
|
|
11
|
-
prefix?: string
|
|
12
|
-
suffix?: string
|
|
11
|
+
prefix?: string;
|
|
12
|
+
suffix?: string;
|
|
13
13
|
helpText?: React.ReactNode;
|
|
14
14
|
helpTitle?: string;
|
|
15
15
|
helpWidth?: string;
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),L=require("react-hook-form"),ne=require("react-imask"),B=require("@fluig-kit/ecm"),H=require("date-fns");function ee({title:t,isOpen:n,onOpen:f,onClose:m,content:c,footer:a,width:h}){const d=o.useCallback(j=>{j.key==="Escape"&&m()},[m]);return o.useEffect(()=>(n&&(document.addEventListener("keydown",d),f==null||f(),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="auto"}),[n,d,f]),n?e.jsx("div",{className:"modal-overlay",onClick:m,"aria-modal":"true",role:"dialog",children:e.jsxs("div",{style:{maxWidth:h},className:"modal-container",onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:t}),e.jsx("div",{className:"btn-close-modal",onClick:m,role:"button","aria-label":"Fechar modal",children:e.jsx("i",{className:"flaticon flaticon-close icon-sm","aria-hidden":"true"})})]}),e.jsx("div",{className:"modal-content",children:c}),a&&e.jsx("div",{className:"modal-footer",children:a})]})}):null}function re({text:t,title:n="Ajuda & Informações",width:f="500px",className:m=""}){const[c,a]=o.useState(!1),h=d=>{d.preventDefault(),d.stopPropagation(),a(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`dfe-help-indicator ${m}`,onClick:h,role:"button",tabIndex:0,"aria-label":"Botão de ajuda",title:"Clique para obter ajuda",children:e.jsx("span",{children:"?"})}),e.jsx(ee,{title:n,isOpen:c,onClose:()=>a(!1),width:f,content:e.jsx("div",{className:"dfe-help-modal-body",children:t}),footer:e.jsx("div",{className:"dfe-help-modal-footer",children:e.jsx("button",{type:"button",className:"btn btn-info dfe-help-btn",onClick:()=>a(!1),children:"Entendido"})})})]})}const W=o.memo(re),le={cpf:"000.000.000-00",cnpj:"00.000.000/0000-00",telefone:"(00) 00000-0000",cep:"00000-000"};function ie({name:t,label:n="",placeholder:f="",type:m="text",mask:c,className:a="",forceReadOnly:h=!1,forceHidden:d=!1,prefix:j,suffix:r,helpText:x,helpTitle:_,helpWidth:$,valueManual:V,onChangeManual:y,errorManual:S}){var J,G;const O=V!==void 0&&!!y,{isReadOnly:R,isHidden:g}=B.useSection(),s=h||!!R(t),l=d||!!g(t),{isView:i}=B.useFluigRuntime();let u=null;try{u=L.useFormContext()}catch{}const p=!O&&u?L.useController({name:t,control:u.control}):null,E=!O&&u?L.useFormState({name:t}):null,I=O?V:p==null?void 0:p.field.value,A=O?S:(G=(J=E==null?void 0:E.errors)==null?void 0:J[t])==null?void 0:G.message,k=o.useMemo(()=>c?le[c]??c:null,[c]),N=o.useCallback(D=>{if(!D)return"";const q=D.replace(/\D/g,"");return(Number(q)/100).toFixed(2)},[]),b=o.useCallback(D=>{if(D===""||D===null||D===void 0)return"";const q=Number(D);return isNaN(q)?"":q.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),F=D=>{let q=D;m==="monetary"&&(q=N(D)),O?y==null||y(q):p==null||p.field.onChange(q)},v=()=>{O||p==null||p.field.onBlur()},C=o.useMemo(()=>m==="monetary"?b(I):String(I??""),[I,m,b]);if(l)return null;const T=`form-control ${s?"readOnly":""} ${A?"border-red":""} ${a}`,z={paddingLeft:j?"36px":void 0,paddingRight:r?"36px":void 0,width:"100%"},Y=()=>k?e.jsx(ne.IMaskInput,{mask:k,value:C,unmask:!0,onAccept:D=>F(D),placeholder:f,readOnly:s,className:T,style:z,inputRef:O||p==null?void 0:p.field.ref,onBlur:v}):e.jsx("input",{type:m==="number"?"number":"text",value:C,onChange:D=>F(D.target.value),onBlur:v,placeholder:f,readOnly:s,className:T,style:z}),U=({children:D})=>e.jsxs("div",{style:{position:"relative",flex:1,display:"flex",alignItems:"center"},children:[j&&e.jsx("span",{style:{position:"absolute",left:"12px",color:"var(--dfe-muted-fg)",zIndex:3,fontWeight:500,fontSize:"13px",pointerEvents:"none"},children:j}),D,r&&e.jsx("span",{style:{position:"absolute",right:"12px",color:"var(--dfe-muted-fg)",zIndex:3,fontWeight:500,fontSize:"13px",pointerEvents:"none"},children:r})]});return i?e.jsxs("div",{className:"form-group",children:[n&&e.jsx("label",{children:n}),e.jsxs("div",{className:x?"dfe-flex-input-wrapper":"",children:[e.jsx(U,{children:e.jsx("span",{className:T,style:z,children:C||"-"})}),x&&e.jsx(W,{text:x,title:_,width:$})]})]}):e.jsxs("div",{className:`form-group ${l?"hidden":""}`,children:[n&&e.jsx("label",{children:n}),e.jsxs("div",{className:x?"dfe-flex-input-wrapper":"",children:[e.jsx(U,{children:Y()}),x&&e.jsx(W,{text:x,title:_,width:$})]}),!O&&e.jsx("input",{type:"hidden",name:t,value:I||""}),A&&e.jsx("p",{className:"text-danger",children:String(A)})]})}const ce=o.memo(ie);function oe({name:t,label:n="",options:f=[],placeholder:m="",labelKey:c="label",valueKey:a="value",enableSearch:h=!1,searchPlaceholder:d="Buscar...",loading:j=!1,onSearchChange:r,debounceTime:x=300,onSelect:_,forceReadOnly:$=!1,forceHidden:V=!1,helpText:y,helpTitle:S,helpWidth:O,valueManual:R,onChangeManual:g,errorManual:s}){var q;const l=R!==void 0&&!!g,{isReadOnly:i,isHidden:u}=B.useSection(),p=$||!!i(t),E=V||!!u(t),{isView:I}=B.useFluigRuntime();let A="",k=()=>{},N,b=null,F=()=>{};if(l)A=R;else try{const w=L.useFormContext(),P=L.useController({name:t,control:w.control});A=P.field.value,k=P.field.onChange,N=P.field.ref,b=(q=P.fieldState)==null?void 0:q.error,F=w.clearErrors}catch{}const[v,C]=o.useState(!1),[T,z]=o.useState(""),Y=o.useRef(null),U=o.useRef(r);o.useEffect(()=>{U.current=r},[r]),o.useEffect(()=>{const w=P=>{Y.current&&!Y.current.contains(P.target)&&C(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),o.useEffect(()=>{v||z("")},[v]),o.useEffect(()=>{if(!h)return;const w=setTimeout(()=>{var P;(P=U.current)==null||P.call(U,T)},x);return()=>clearTimeout(w)},[T,h,x]);const J=o.useMemo(()=>h&&!r&&T.trim()?f.filter(w=>String((w==null?void 0:w[c])??"").toLowerCase().includes(T.toLowerCase())):f??[],[f,h,r,T,c]),G=o.useMemo(()=>{if(A==null)return"";if(typeof A=="object")return String(A[a]??"");const w=(f||[]).find(P=>String(P==null?void 0:P[a])===String(A));return String(w?(w==null?void 0:w[c])??"":A)},[A,f,a,c]),D=w=>{p||(l?g==null||g(w[a]):(k(w[a]),F==null||F(t)),_==null||_(w),C(!1))};return E?null:e.jsxs("div",{className:`select-wrapper form-group ${E?"hidden":""}`,ref:Y,children:[e.jsx("label",{className:"control-label",children:n}),I?e.jsxs("div",{className:y?"dfe-flex-input-wrapper":"",children:[e.jsx("span",{className:"form-control",style:y?{flex:1}:void 0,children:G||"-"}),y&&e.jsx(W,{text:y,title:S,width:O})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:y?"dfe-flex-input-wrapper":"",children:[e.jsxs("div",{className:`select-control ${b?"border-red":""} ${p?"readOnly":""}`,onClick:()=>!p&&C(w=>!w),ref:N,style:y?{flex:1}:void 0,children:[e.jsx("span",{className:`select-display ${p?"readOnly":""}`,children:G||m}),e.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),y&&e.jsx(W,{text:y,title:S,width:O})]}),v&&!p&&e.jsxs("div",{className:"select-dropdown",children:[h&&e.jsx("div",{className:"select-search",children:e.jsx("input",{type:"text",className:"select-search-input",value:T,onChange:w=>z(w.target.value),placeholder:j?"Carregando...":d,autoFocus:!0,onClick:w=>w.stopPropagation()})}),e.jsx("ul",{className:"select-options",children:j?e.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):J.length>0?J.map(w=>e.jsx("li",{onClick:()=>D(w),className:"select-option handleHover",children:w[c]},w[a])):e.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),!l&&e.jsx("input",{type:"hidden",name:t,value:A||""}),(b||s)&&e.jsx("p",{className:"text-danger",children:String((b==null?void 0:b.message)??s)})]})}const Q=o.memo(oe);function de({name:t,options:n=[],label:f="",valueKey:m="value",labelKey:c="label",forceReadOnly:a=!1,forceHidden:h=!1,valueManual:d,onChangeManual:j}){var I,A;let r=null;try{r=L.useFormContext()}catch{}const x=d!==void 0&&!!j,{isView:_,isReadOnly:$}=B.useFluigRuntime(),{isReadOnly:V,isHidden:y}=B.useSection(),S=V?V(t):!1,O=y?y(t):!1,R=a||S,g=h||O,s=R||$||_,l=()=>n?n.reduce((k,N)=>{const b=String(N[m]);if(x)k[b]=!!(d!=null&&d[b]);else if(r){const F=r.getValues(b);k[b]=F==="on"}else k[b]=!1;return k},{}):{},i=!x&&r?r.watch(t):void 0,u=o.useMemo(()=>x&&d?d:i&&typeof i=="object"?i:l(),[i,d,n]);o.useEffect(()=>{if(x||!r)return;const k=r.getValues(t);(!k||typeof k!="object")&&r.setValue(t,u,{shouldDirty:!1,shouldValidate:!1})},[u,t,r,x]);const p=(k,N)=>{if(s)return;const b={...u,[k]:N};if(x){j&&j(b);return}r&&(r.setValue(t,b,{shouldDirty:!0,shouldValidate:!0}),r.setValue(k,N?"on":"",{shouldValidate:!1}))},E=x?null:(A=(I=r==null?void 0:r.formState)==null?void 0:I.errors)==null?void 0:A[t];return e.jsxs("div",{className:`form-group ${g?"hidden":""}`,children:[f&&e.jsx("label",{children:f}),e.jsx("div",{className:`checkbox-group-custom ${s?"readOnly":""}`,children:n.map(k=>{const N=String(k[m]),b=u[N]===!0;return e.jsxs("div",{children:[!x&&r&&e.jsx("input",{type:"hidden",...r.register(N)}),e.jsxs("label",{className:`custom-checkbox ${b?"checked":""} ${s?"readOnly":""}`,children:[e.jsx("input",{type:"checkbox",checked:b,disabled:s,onChange:F=>p(N,F.target.checked)}),e.jsx("span",{className:"checkmark"}),e.jsx("span",{children:k[c]})]})]},N)})}),E&&e.jsx("p",{className:"text-danger",children:String(E.message)})]})}function ae({name:t,label:n="",options:f=[],valueKey:m="value",labelKey:c="label",iconKey:a="icon",forceReadOnly:h=!1,forceHidden:d=!1,valueManual:j,onChangeManual:r,errorManual:x}){var I,A;const _=j!==void 0&&!!r,{isReadOnly:$,isHidden:V}=B.useSection(),y=h||!!$(t),S=d||!!V(t),{isView:O,isReadOnly:R}=B.useFluigRuntime();let g=null;try{g=L.useFormContext()}catch{}const s=!_&&g?L.useController({name:t,control:g.control,defaultValue:""}):null,l=!_&&g?L.useFormState({name:t}):null,i=_?x:(A=(I=l==null?void 0:l.errors)==null?void 0:I[t])==null?void 0:A.message,u=y||R||O,p=_?j:(s==null?void 0:s.field.value)??"",E=o.useCallback(k=>{u||(_?r==null||r(k):(s==null||s.field.onChange(k),s==null||s.field.onBlur()))},[u,_,r,s]);return e.jsxs("div",{className:`form-group column ${S?"hidden":""}`,children:[n&&e.jsx("label",{className:"control-label",children:n}),e.jsx("div",{className:`btn-group ${u?"view-mode":""}`,"data-field-name":t,children:f.map(k=>{const N=k[m],b=p===N,F=k.color?{"--customColor":k.color}:void 0;return e.jsxs("div",{style:F,className:`btn fs-ellipsis ${b?"active":""}`,onClick:()=>E(N),children:[k[a]&&e.jsx("i",{className:`${k[a]} icon-sm`})," ",k[c]]},N)})}),!_&&e.jsx("input",{type:"hidden",name:t,value:p||"",ref:s==null?void 0:s.field.ref}),(i||x)&&e.jsx("p",{className:"text-danger",children:String(i??x)})]})}const ue=o.memo(ae),fe=({name:t,label:n="",placeholder:f="",className:m="",rows:c=4,maxLength:a,forceReadOnly:h=!1,forceHidden:d=!1,valueManual:j,onChangeManual:r,errorManual:x})=>{var u;const _=j!==void 0&&!!r,{isReadOnly:$,isHidden:V}=B.useSection(),y=h||!!$(t),S=d||!!V(t),{isView:O}=B.useFluigRuntime(),R=o.useRef(null);let g={value:j??"",onChange:p=>r==null?void 0:r(p)},s=null;if(!_)try{const{control:p}=L.useFormContext(),E=L.useController({name:t,control:p});g=E.field,s=(u=E.fieldState)==null?void 0:u.error}catch{}const l=()=>{R.current&&(R.current.style.height="auto",R.current.style.height=`${R.current.scrollHeight}px`)};if(o.useEffect(()=>{l()},[g.value]),O)return e.jsxs("div",{className:`form-group ${S?"hidden":""}`,children:[e.jsx("label",{children:n}),e.jsx("span",{className:"form-control",children:g.value||"-"})]});const i=`form-control ${y?"readOnly":""} ${s||x?"border-red":""} ${m}`;return e.jsxs("div",{className:`form-group ${S?"hidden":""}`,children:[n&&e.jsx("label",{children:n}),e.jsx("textarea",{ref:R,rows:c,maxLength:a,value:g.value||"",placeholder:f,readOnly:y,className:i,style:{resize:"none",maxHeight:"400px",overflowY:"auto"},onChange:p=>{_?r==null||r(p.target.value):g.onChange(p)},onInput:l}),(s||x)&&e.jsx("p",{className:"text-danger",children:String((s==null?void 0:s.message)??x)})]})},me=o.memo(fe);/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),T=require("react-hook-form"),ne=require("react-imask"),P=require("@fluig-kit/ecm"),L=require("date-fns");function ee({title:t,isOpen:r,onOpen:m,onClose:u,content:c,footer:a,width:x}){const d=o.useCallback(v=>{v.key==="Escape"&&u()},[u]);return o.useEffect(()=>(r&&(document.addEventListener("keydown",d),m==null||m(),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="auto"}),[r,d,m]),r?e.jsx("div",{className:"modal-overlay",onClick:u,"aria-modal":"true",role:"dialog",children:e.jsxs("div",{style:{maxWidth:x},className:"modal-container",onClick:v=>v.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:t}),e.jsx("div",{className:"btn-close-modal",onClick:u,role:"button","aria-label":"Fechar modal",children:e.jsx("i",{className:"flaticon flaticon-close icon-sm","aria-hidden":"true"})})]}),e.jsx("div",{className:"modal-content",children:c}),a&&e.jsx("div",{className:"modal-footer",children:a})]})}):null}function re({text:t,title:r="Ajuda & Informações",width:m="500px",className:u=""}){const[c,a]=o.useState(!1),x=d=>{d.preventDefault(),d.stopPropagation(),a(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`dfe-help-indicator ${u}`,onClick:x,role:"button",tabIndex:0,"aria-label":"Botão de ajuda",title:"Clique para obter ajuda",children:e.jsx("span",{children:"?"})}),e.jsx(ee,{title:r,isOpen:c,onClose:()=>a(!1),width:m,content:e.jsx("div",{className:"dfe-help-modal-body",children:t}),footer:e.jsx("div",{className:"dfe-help-modal-footer",children:e.jsx("button",{type:"button",className:"btn btn-info dfe-help-btn",onClick:()=>a(!1),children:"Entendido"})})})]})}const z=o.memo(re),le={cpf:"000.000.000-00",cnpj:"00.000.000/0000-00",telefone:"(00) 00000-0000",cep:"00000-000"};function ie({name:t,label:r="",placeholder:m="",type:u="text",mask:c,className:a="",forceReadOnly:x=!1,forceHidden:d=!1,prefix:v,suffix:s,helpText:p,helpTitle:_,helpWidth:O,valueManual:B,onChangeManual:j,errorManual:R}){var Y,J;const S=B!==void 0&&!!j,{isReadOnly:$,isHidden:b}=P.useSection(),n=x||!!$(t),l=d||!!b(t),{isView:i}=P.useFluigRuntime();let f=null;try{f=T.useFormContext()}catch{}const h=!S&&f?T.useController({name:t,control:f.control}):null,I=!S&&f?T.useFormState({name:t}):null,E=S?B:h==null?void 0:h.field.value,C=S?R:(J=(Y=I==null?void 0:I.errors)==null?void 0:Y[t])==null?void 0:J.message,w=o.useMemo(()=>c?le[c]??c:null,[c]),k=o.useCallback(q=>{if(q===""||q===null||q===void 0)return"";let A=String(q);if(u==="monetary"){const H=Number(q);return isNaN(H)?"":H.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})}if(u==="number"){A=A.replace(".",",");const H=A.split(",");H[0]=H[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),A=H.join(",")}return v&&(A=`${v}${A}`),s&&(A=`${A}${s}`),A},[v,s,u]),y=o.useMemo(()=>k(E),[E,k]),V=q=>{let A=q.target.value;const H=y,G=`${v||""}${s||""}`;if(!A||A===v||A===s||A===G){S?j==null||j(""):h==null||h.field.onChange("");return}if(s&&A.length>H.length&&H&&A.startsWith(H)){const N=A.slice(H.length);A=String(E||"")+N}v&&A.length>H.length&&H&&A.endsWith(H)&&(A=A.slice(0,A.length-H.length)+String(E||""));let D=A;if(s&&D.endsWith(s)&&(D=D.slice(0,-s.length)),v&&D.startsWith(v)&&(D=D.slice(v.length)),u==="monetary"){const N=D.replace(/\D/g,"");D=N?(Number(N)/100).toFixed(2):""}else u==="number"&&(D=D.replace(/[^\d.,-]/g,""),D=D.replace(/\./g,"").replace(",","."));A.length<H.length&&D===String(E||"")&&D.length>0&&(D=D.slice(0,-1)),S?j==null||j(D):h==null||h.field.onChange(D)},g=()=>{S||h==null||h.field.onBlur()};if(l)return null;const F=`form-control ${n?"readOnly":""} ${C?"border-red":""} ${a}`,W=()=>w?e.jsx(ne.IMaskInput,{mask:w,value:y,unmask:!0,onAccept:q=>{S?j==null||j(q):h==null||h.field.onChange(q)},placeholder:m,readOnly:n,className:F,inputRef:S||h==null?void 0:h.field.ref,onBlur:g}):e.jsx("input",{type:"text",inputMode:u==="number"||u==="monetary"?"numeric":void 0,value:y,onChange:V,onBlur:g,placeholder:m,readOnly:n,className:F});return i?e.jsxs("div",{className:"form-group",children:[r&&e.jsx("label",{children:r}),e.jsxs("div",{className:p?"dfe-flex-input-wrapper":"",children:[e.jsx("span",{className:F,children:y||"-"}),p&&e.jsx(z,{text:p,title:_,width:O})]})]}):e.jsxs("div",{className:`form-group ${l?"hidden":""}`,children:[r&&e.jsx("label",{children:r}),e.jsxs("div",{className:p?"dfe-flex-input-wrapper":"",children:[W(),p&&e.jsx(z,{text:p,title:_,width:O})]}),!S&&e.jsx("input",{type:"hidden",name:t,value:E||""}),C&&e.jsx("p",{className:"text-danger",children:String(C)})]})}const ce=o.memo(ie);function oe({name:t,label:r="",options:m=[],placeholder:u="",labelKey:c="label",valueKey:a="value",enableSearch:x=!1,searchPlaceholder:d="Buscar...",loading:v=!1,onSearchChange:s,debounceTime:p=300,onSelect:_,forceReadOnly:O=!1,forceHidden:B=!1,helpText:j,helpTitle:R,helpWidth:S,valueManual:$,onChangeManual:b,errorManual:n}){var D;const l=$!==void 0&&!!b,{isReadOnly:i,isHidden:f}=P.useSection(),h=O||!!i(t),I=B||!!f(t),{isView:E}=P.useFluigRuntime();let C="",w=()=>{},k,y=null,V=()=>{};if(l)C=$;else try{const N=T.useFormContext(),U=T.useController({name:t,control:N.control});C=U.field.value,w=U.field.onChange,k=U.field.ref,y=(D=U.fieldState)==null?void 0:D.error,V=N.clearErrors}catch{}const[g,F]=o.useState(!1),[W,Y]=o.useState(""),J=o.useRef(null),q=o.useRef(s);o.useEffect(()=>{q.current=s},[s]),o.useEffect(()=>{const N=U=>{J.current&&!J.current.contains(U.target)&&F(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),o.useEffect(()=>{g||Y("")},[g]),o.useEffect(()=>{if(!x)return;const N=setTimeout(()=>{var U;(U=q.current)==null||U.call(q,W)},p);return()=>clearTimeout(N)},[W,x,p]);const A=o.useMemo(()=>x&&!s&&W.trim()?m.filter(N=>String((N==null?void 0:N[c])??"").toLowerCase().includes(W.toLowerCase())):m??[],[m,x,s,W,c]),H=o.useMemo(()=>{if(C==null)return"";if(typeof C=="object")return String(C[a]??"");const N=(m||[]).find(U=>String(U==null?void 0:U[a])===String(C));return String(N?(N==null?void 0:N[c])??"":C)},[C,m,a,c]),G=N=>{h||(l?b==null||b(N[a]):(w(N[a]),V==null||V(t)),_==null||_(N),F(!1))};return I?null:e.jsxs("div",{className:`select-wrapper form-group ${I?"hidden":""}`,ref:J,children:[e.jsx("label",{className:"control-label",children:r}),E?e.jsxs("div",{className:j?"dfe-flex-input-wrapper":"",children:[e.jsx("span",{className:"form-control",style:j?{flex:1}:void 0,children:H||"-"}),j&&e.jsx(z,{text:j,title:R,width:S})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:j?"dfe-flex-input-wrapper":"",children:[e.jsxs("div",{className:`select-control ${y?"border-red":""} ${h?"readOnly":""}`,onClick:()=>!h&&F(N=>!N),ref:k,style:j?{flex:1}:void 0,children:[e.jsx("span",{className:`select-display ${h?"readOnly":""}`,children:H||u}),e.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),j&&e.jsx(z,{text:j,title:R,width:S})]}),g&&!h&&e.jsxs("div",{className:"select-dropdown",children:[x&&e.jsx("div",{className:"select-search",children:e.jsx("input",{type:"text",className:"select-search-input",value:W,onChange:N=>Y(N.target.value),placeholder:v?"Carregando...":d,autoFocus:!0,onClick:N=>N.stopPropagation()})}),e.jsx("ul",{className:"select-options",children:v?e.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):A.length>0?A.map(N=>e.jsx("li",{onClick:()=>G(N),className:"select-option handleHover",children:N[c]},N[a])):e.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),!l&&e.jsx("input",{type:"hidden",name:t,value:C||""}),(y||n)&&e.jsx("p",{className:"text-danger",children:String((y==null?void 0:y.message)??n)})]})}const Q=o.memo(oe);function de({name:t,options:r=[],label:m="",valueKey:u="value",labelKey:c="label",forceReadOnly:a=!1,forceHidden:x=!1,valueManual:d,onChangeManual:v}){var E,C;let s=null;try{s=T.useFormContext()}catch{}const p=d!==void 0&&!!v,{isView:_,isReadOnly:O}=P.useFluigRuntime(),{isReadOnly:B,isHidden:j}=P.useSection(),R=B?B(t):!1,S=j?j(t):!1,$=a||R,b=x||S,n=$||O||_,l=()=>r?r.reduce((w,k)=>{const y=String(k[u]);if(p)w[y]=!!(d!=null&&d[y]);else if(s){const V=s.getValues(y);w[y]=V==="on"}else w[y]=!1;return w},{}):{},i=!p&&s?s.watch(t):void 0,f=o.useMemo(()=>p&&d?d:i&&typeof i=="object"?i:l(),[i,d,r]);o.useEffect(()=>{if(p||!s)return;const w=s.getValues(t);(!w||typeof w!="object")&&s.setValue(t,f,{shouldDirty:!1,shouldValidate:!1})},[f,t,s,p]);const h=(w,k)=>{if(n)return;const y={...f,[w]:k};if(p){v&&v(y);return}s&&(s.setValue(t,y,{shouldDirty:!0,shouldValidate:!0}),s.setValue(w,k?"on":"",{shouldValidate:!1}))},I=p?null:(C=(E=s==null?void 0:s.formState)==null?void 0:E.errors)==null?void 0:C[t];return e.jsxs("div",{className:`form-group ${b?"hidden":""}`,children:[m&&e.jsx("label",{children:m}),e.jsx("div",{className:`checkbox-group-custom ${n?"readOnly":""}`,children:r.map(w=>{const k=String(w[u]),y=f[k]===!0;return e.jsxs("div",{children:[!p&&s&&e.jsx("input",{type:"hidden",...s.register(k)}),e.jsxs("label",{className:`custom-checkbox ${y?"checked":""} ${n?"readOnly":""}`,children:[e.jsx("input",{type:"checkbox",checked:y,disabled:n,onChange:V=>h(k,V.target.checked)}),e.jsx("span",{className:"checkmark"}),e.jsx("span",{children:w[c]})]})]},k)})}),I&&e.jsx("p",{className:"text-danger",children:String(I.message)})]})}function ae({name:t,label:r="",options:m=[],valueKey:u="value",labelKey:c="label",iconKey:a="icon",forceReadOnly:x=!1,forceHidden:d=!1,valueManual:v,onChangeManual:s,errorManual:p}){var E,C;const _=v!==void 0&&!!s,{isReadOnly:O,isHidden:B}=P.useSection(),j=x||!!O(t),R=d||!!B(t),{isView:S,isReadOnly:$}=P.useFluigRuntime();let b=null;try{b=T.useFormContext()}catch{}const n=!_&&b?T.useController({name:t,control:b.control,defaultValue:""}):null,l=!_&&b?T.useFormState({name:t}):null,i=_?p:(C=(E=l==null?void 0:l.errors)==null?void 0:E[t])==null?void 0:C.message,f=j||$||S,h=_?v:(n==null?void 0:n.field.value)??"",I=o.useCallback(w=>{f||(_?s==null||s(w):(n==null||n.field.onChange(w),n==null||n.field.onBlur()))},[f,_,s,n]);return e.jsxs("div",{className:`form-group column ${R?"hidden":""}`,children:[r&&e.jsx("label",{className:"control-label",children:r}),e.jsx("div",{className:`btn-group ${f?"view-mode":""}`,"data-field-name":t,children:m.map(w=>{const k=w[u],y=h===k,V=w.color?{"--customColor":w.color}:void 0;return e.jsxs("div",{style:V,className:`btn fs-ellipsis ${y?"active":""}`,onClick:()=>I(k),children:[w[a]&&e.jsx("i",{className:`${w[a]} icon-sm`})," ",w[c]]},k)})}),!_&&e.jsx("input",{type:"hidden",name:t,value:h||"",ref:n==null?void 0:n.field.ref}),(i||p)&&e.jsx("p",{className:"text-danger",children:String(i??p)})]})}const ue=o.memo(ae),fe=({name:t,label:r="",placeholder:m="",className:u="",rows:c=4,maxLength:a,forceReadOnly:x=!1,forceHidden:d=!1,valueManual:v,onChangeManual:s,errorManual:p})=>{var f;const _=v!==void 0&&!!s,{isReadOnly:O,isHidden:B}=P.useSection(),j=x||!!O(t),R=d||!!B(t),{isView:S}=P.useFluigRuntime(),$=o.useRef(null);let b={value:v??"",onChange:h=>s==null?void 0:s(h)},n=null;if(!_)try{const{control:h}=T.useFormContext(),I=T.useController({name:t,control:h});b=I.field,n=(f=I.fieldState)==null?void 0:f.error}catch{}const l=()=>{$.current&&($.current.style.height="auto",$.current.style.height=`${$.current.scrollHeight}px`)};if(o.useEffect(()=>{l()},[b.value]),S)return e.jsxs("div",{className:`form-group ${R?"hidden":""}`,children:[e.jsx("label",{children:r}),e.jsx("span",{className:"form-control",children:b.value||"-"})]});const i=`form-control ${j?"readOnly":""} ${n||p?"border-red":""} ${u}`;return e.jsxs("div",{className:`form-group ${R?"hidden":""}`,children:[r&&e.jsx("label",{children:r}),e.jsx("textarea",{ref:$,rows:c,maxLength:a,value:b.value||"",placeholder:m,readOnly:j,className:i,style:{resize:"none",maxHeight:"400px",overflowY:"auto"},onChange:h=>{_?s==null||s(h.target.value):b.onChange(h)},onInput:l}),(n||p)&&e.jsx("p",{className:"text-danger",children:String((n==null?void 0:n.message)??p)})]})},me=o.memo(fe);/**
|
|
2
2
|
* @license lucide-react v0.575.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const te=(...t)=>t.filter((
|
|
6
|
+
*/const te=(...t)=>t.filter((r,m,u)=>!!r&&r.trim()!==""&&u.indexOf(r)===m).join(" ").trim();/**
|
|
7
7
|
* @license lucide-react v0.575.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const xe=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(
|
|
16
|
+
*/const xe=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,m,u)=>u?u.toUpperCase():m.toLowerCase());/**
|
|
17
17
|
* @license lucide-react v0.575.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const X=t=>{const
|
|
21
|
+
*/const X=t=>{const r=xe(t);return r.charAt(0).toUpperCase()+r.slice(1)};/**
|
|
22
22
|
* @license lucide-react v0.575.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
@@ -28,22 +28,22 @@
|
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const ve=t=>{for(const
|
|
31
|
+
*/const ve=t=>{for(const r in t)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1};/**
|
|
32
32
|
* @license lucide-react v0.575.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const je=o.forwardRef(({color:t="currentColor",size:
|
|
36
|
+
*/const je=o.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:m=2,absoluteStrokeWidth:u,className:c="",children:a,iconNode:x,...d},v)=>o.createElement("svg",{ref:v,...pe,width:r,height:r,stroke:t,strokeWidth:u?Number(m)*24/Number(r):m,className:te("lucide",c),...!a&&!ve(d)&&{"aria-hidden":"true"},...d},[...x.map(([s,p])=>o.createElement(s,p)),...Array.isArray(a)?a:[a]]));/**
|
|
37
37
|
* @license lucide-react v0.575.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const Z=(t,
|
|
41
|
+
*/const Z=(t,r)=>{const m=o.forwardRef(({className:u,...c},a)=>o.createElement(je,{ref:a,iconNode:r,className:te(`lucide-${he(X(t))}`,`lucide-${t}`,u),...c}));return m.displayName=X(t),m};/**
|
|
42
42
|
* @license lucide-react v0.575.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const ge=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],ye=Z("calendar",ge);/**
|
|
47
47
|
* @license lucide-react v0.575.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const ke=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],we=Z("chevron-right",ke),se="dd/MM/yyyy",K=t=>{if(!t)return null;const
|
|
57
|
-
${
|
|
58
|
-
${
|
|
59
|
-
${
|
|
56
|
+
*/const ke=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],we=Z("chevron-right",ke),se="dd/MM/yyyy",K=t=>{if(!t)return null;const r=L.parse(t,se,new Date);return L.isValid(r)?r:null},Se=t=>t?L.format(t,se):"",Re=[{value:0,label:"Janeiro"},{value:1,label:"Fevereiro"},{value:2,label:"Março"},{value:3,label:"Abril"},{value:4,label:"Maio"},{value:5,label:"Junho"},{value:6,label:"Julho"},{value:7,label:"Agosto"},{value:8,label:"Setembro"},{value:9,label:"Outubro"},{value:10,label:"Novembro"},{value:11,label:"Dezembro"}],M=1940,$e=2100,_e=Array.from({length:$e-M+1},(t,r)=>{const m=M+r;return{value:m,label:String(m)}});function Oe({name:t,label:r="",placeholder:m="dd/mm/aaaa",className:u="",forceReadOnly:c=!1,forceHidden:a=!1,valueManual:x,onChangeManual:d,errorManual:v}){var V;const s=x!==void 0&&!!d,{isReadOnly:p,isHidden:_}=P.useSection(),O=c||!!p(t),B=a||!!_(t),{isView:j}=P.useFluigRuntime();let R="",S=()=>{},$,b=null,n=()=>{};if(s)R=x;else try{const g=T.useFormContext(),F=T.useController({name:t,control:g.control});R=F.field.value,S=F.field.onChange,$=F.field.ref,b=(V=F.fieldState)==null?void 0:V.error,n=g.clearErrors}catch{}const[l,i]=o.useState(!1),[f,h]=o.useState(new Date),I=o.useRef(null);o.useEffect(()=>{if(l){const g=K(R);h(g&&L.isValid(g)?g:new Date)}},[l,R]),o.useEffect(()=>{const g=F=>{I.current&&!I.current.contains(F.target)&&i(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const E=o.useMemo(()=>K(R),[R]),C=g=>{if(O)return;const F=Se(g);s?d==null||d(F):(S(F),n==null||n(t)),i(!1)},w=o.useMemo(()=>L.eachDayOfInterval({start:L.startOfWeek(L.startOfMonth(f)),end:L.endOfWeek(L.endOfMonth(f))}),[f]),k=f.getMonth(),y=L.getYear(f);return e.jsxs("div",{className:`dfe-datepicker-wrapper form-group ${B?"hidden":""} ${u}`,ref:I,children:[e.jsx("label",{className:"control-label",children:r}),j?e.jsx("span",{className:"form-control",children:R||"-"}):e.jsxs("div",{className:"dfe-datepicker-inner-container",children:[e.jsxs("div",{className:`dfe-datepicker-control ${b?"border-red":""} ${O?"readOnly":""}`,onClick:()=>!O&&i(g=>!g),ref:$,children:[e.jsx("span",{className:`dfe-datepicker-display ${O?"readOnly":""}`,children:R||m}),e.jsx(ye,{size:16,className:"dfe-datepicker-icon"})]}),l&&!O&&e.jsxs("div",{className:"dfe-datepicker-dropdown",onClick:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"dfe-datepicker-header",children:[e.jsx("button",{type:"button",onClick:()=>h(L.subMonths(f,1)),className:"dfe-datepicker-nav-btn",children:e.jsx(Ne,{size:16})}),e.jsxs("div",{className:"dfe-datepicker-selectors",children:[e.jsx(Q,{name:"datepicker_internal_month",valueManual:k,onChangeManual:g=>h(L.setMonth(f,Number(g))),options:Re,placeholder:"Mês"}),e.jsx(Q,{name:"datepicker_internal_year",valueManual:y,onChangeManual:g=>h(L.setYear(f,Number(g))),options:_e,enableSearch:!0,searchPlaceholder:"Buscar ano...",placeholder:"Ano"})]}),e.jsx("button",{type:"button",onClick:()=>h(L.addMonths(f,1)),className:"dfe-datepicker-nav-btn",children:e.jsx(we,{size:16})})]}),e.jsx("div",{className:"dfe-datepicker-grid-header",children:["D","S","T","Q","Q","S","S"].map((g,F)=>e.jsx("span",{children:g},F))}),e.jsx("div",{className:"dfe-datepicker-grid",children:w.map((g,F)=>{const W=!L.isSameMonth(g,f),Y=E&&L.isSameDay(g,E);return e.jsx("div",{onClick:()=>!W&&C(g),className:`dfe-datepicker-day
|
|
57
|
+
${Y?"selected":"handleHover"}
|
|
58
|
+
${W?"outside":""}
|
|
59
|
+
${L.isToday(g)?"today":""}`,children:L.format(g,"d")},F)})})]})]}),!s&&e.jsx("input",{type:"hidden",name:t,value:R||""}),(b||v)&&e.jsx("p",{className:"text-danger",children:String((b==null?void 0:b.message)??v)})]})}const Ae=o.memo(Oe);function Ee({mapping:t={},defaultLabel:r="Não reconhecido",className:m="",hidden:u=!1,label:c}){const{activityId:a}=P.useFluigRuntime(),x=o.useMemo(()=>!t||a===null||a===void 0?null:t[a],[a,t]);if(!x)return e.jsxs("div",{className:`form-group ${u?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsx("div",{className:`status-badge default ${m}`,children:r})]});const d={"--customColor":x.color};return e.jsxs("div",{className:`form-group ${u?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsxs("div",{className:`status-badge ${m}`,style:d,children:[x.icon&&e.jsx("i",{className:x.icon}),e.jsx("span",{children:x.label})]})]})}const Ce=o.memo(Ee);function Fe({name:t,control:r,defaultRowValue:m,isView:u,isReadOnly:c,filters:a=[]}){const{field:x}=T.useController({name:t,control:r}),[d,v]=o.useState([]),[s,p]=o.useState([]),_=()=>Date.now()+Math.random(),O=l=>{try{const i=JSON.parse(l);return Array.isArray(i)?i.map(f=>({...f,_uid:f._uid||_()})):[]}catch(i){return console.error(`Erro ao ler dados da tabela "${t}":`,i),[]}};o.useEffect(()=>{if(!(d.length>0&&!u)&&x.value&&typeof x.value=="string"){const l=JSON.stringify(d);if(x.value===l)return;const i=O(x.value);v(i)}},[x.value,u]),o.useEffect(()=>{if(c)return;const l=JSON.stringify(d);x.value!==l&&x.onChange(l)},[d,x,c]);const B=o.useCallback(()=>{const l={_uid:_(),...m};v(i=>[...i,l])},[m]),j=o.useCallback(()=>{v(l=>l.filter(i=>!s.includes(i._uid))),p([])},[s]),R=o.useCallback((l,i,f)=>{v(h=>h.map(I=>I._uid===l?{...I,[i]:f}:I))},[]),S=o.useCallback(l=>{p(i=>i.includes(l)?i.filter(f=>f!==l):[...i,l])},[]),$=o.useCallback(l=>{p(l?d.map(i=>i._uid):[])},[d]),b=d.length>0&&s.length===d.length,n=o.useMemo(()=>!a||a.length===0?d:d.filter(l=>a.every(i=>{if("custom"in i)return i.custom(l);const f=l[i.field];switch(i.operator){case"===":return f===i.value;case"!==":return f!==i.value;case">":return f>i.value;case"<":return f<i.value;case">=":return f>=i.value;case"<=":return f<=i.value;default:return!0}})),[d,a]);return{field:x,tableRows:d,visibleRows:n,selectedRowIds:s,isAllSelected:b,handle:{addRow:B,removeRows:j,updateCellValue:R,toggleSelection:S,toggleSelectAll:$}}}const Ie=({name:t,title:r="Tabela Dinâmica",columns:m,defaultRowValue:u={},forceReadOnly:c=!1,layout:a="fluid",actions:x=!0,filters:d=[]})=>{const{control:v}=T.useFormContext(),{isView:s,isReadOnly:p}=P.useFluigRuntime(),{isReadOnly:_}=P.useSection(),O=c||s||p||_&&_(t),{field:B,visibleRows:j,selectedRowIds:R,isAllSelected:S,handle:$}=Fe({name:t,control:v,defaultRowValue:u,isView:s,isReadOnly:!!O,filters:d}),b=a==="fixed";return e.jsxs("div",{className:`table-wrapper ${b?"table-fixed":"table-fluid"}`,children:[e.jsx("input",{type:"hidden",...B}),e.jsxs("div",{className:"header-handle",children:[e.jsx("h3",{children:r}),!O&&x&&e.jsxs("div",{className:"handle-actions",children:[e.jsxs("button",{type:"button",className:`btn ${R.length>0?"btn-danger":"btn-primary"}`,disabled:R.length===0,onClick:$.removeRows,children:["Remover (",R.length,")"]}),e.jsx("button",{type:"button",className:"btn-add",onClick:$.addRow,children:"Adicionar"})]})]}),e.jsx("div",{className:"table-scroll",children:e.jsxs("table",{className:"table-custom",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[!O&&e.jsx("th",{style:{width:"50px"},children:e.jsx("input",{type:"checkbox",checked:S,onChange:n=>$.toggleSelectAll(n.target.checked)})}),m.map(n=>e.jsx("th",{style:n.width?{minWidth:b?n.width:"100%"}:{width:"max-content"},children:n.label},String(n.key)))]})}),e.jsxs("tbody",{children:[j.map((n,l)=>e.jsxs("tr",{children:[!O&&e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:R.includes(n._uid),onChange:()=>$.toggleSelection(n._uid)})}),m.map(i=>e.jsx("td",{children:i.render?i.render.length<=1?i.render({row:n,index:l,updateRow:(f,h)=>$.updateCellValue(n._uid,String(f),h),isLocked:!!O,isView:!!s}):i.render(n,l,(f,h)=>$.updateCellValue(n._uid,f,h),!!O,!!s):n[i.key]},`${n._uid}-${String(i.key)}`))]},n._uid)),j.length===0&&e.jsx("tr",{className:"empty-row",children:e.jsx("td",{colSpan:100,className:"text-center",children:O?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},Ve=(t,r)=>{const[m,u]=o.useState(null);let c=null;try{c=T.useFormContext().watch}catch{}const a=r!==void 0?r:c?c(t):void 0,x=o.useCallback(()=>{try{const v=window.top.__REACT_ATTACHMENT_BRIDGE__;if(v){const s=v.getAttachment(t,a);u(s||(a?{name:a,documentId:0}:null))}else u(a?{name:a,documentId:0}:null)}catch{u(a?{name:a,documentId:0}:null)}},[t,a,r]);return o.useEffect(()=>{x();const d=setInterval(x,2e3);return()=>clearInterval(d)},[x]),{attachment:m,sync:x}},De=({name:t,label:r,help:m,valueManual:u,onChangeManual:c,forceReadOnly:a=!1,forceHidden:x=!1,helpText:d,helpTitle:v,helpWidth:s})=>{const p=!!c,{isReadOnly:_,isHidden:O}=P.useSection(),{isView:B}=P.useFluigRuntime(),j=a||B||!!_(t),R=x||!!O(t),[S,$]=o.useState(!1);let b=null;try{b=T.useFormContext().control}catch{}const n=b&&!p?T.useController({name:t,control:b}).field:{value:u,onChange:k=>c==null?void 0:c(k)},{attachment:l,sync:i}=Ve(t,u),f=()=>{var k;try{const y=window.top;return{bridge:y.__REACT_ATTACHMENT_BRIDGE__,toast:(k=y.FLUIGC)==null?void 0:k.toast}}catch{return{bridge:null,toast:null}}},h=o.useCallback(()=>{if(j)return;const k=document.createElement("input");k.type="file",k.onchange=y=>{const V=y.target.files[0];if(!V)return;const{bridge:g,toast:F}=f();$(!0),g?g.upload(V,t,W=>{p?c==null||c(W.name):n.onChange(W.name),setTimeout(()=>{$(!1),i()},1e3),F&&F({title:"Sucesso",message:"Arquivo enviado",type:"success"})}):(p?c==null||c(V.name):n.onChange(V.name),$(!1))},k.click()},[t,n,i,c,j,p]),I=k=>{if(k.stopPropagation(),j)return;const y=(l==null?void 0:l.name)||u||n.value;if(!y)return;const{bridge:V,toast:g}=f();V?V.removeByFileName(y)?(p?c==null||c(""):n.onChange(""),i()):g&&g({title:"Erro",message:"Erro ao remover anexo",type:"danger"}):(p?c==null||c(""):n.onChange(""),i())},E=!!l&&!S,C=(l==null?void 0:l.name)||u||n.value,w=["fluig-attachment__box",E?"fluig-attachment__box--has-file":"",S?"fluig-attachment__box--uploading":"",j&&!E?"readOnly":"",j&&E?"fluig-attachment__box--readonly-view":""].join(" ");return R?null:e.jsxs("div",{className:"form-group fluig-attachment",children:[r&&e.jsx("label",{className:"fluig-attachment__label",children:r}),e.jsxs("div",{className:d?"dfe-flex-input-wrapper":"",children:[e.jsxs("div",{className:w,style:d?{flex:1}:void 0,onClick:()=>{if(E){const k=f(),y=(l==null?void 0:l.physicalFileName)||(l==null?void 0:l.description)||(l==null?void 0:l.name)||C;k.bridge&&y&&k.bridge.view(y)}else h()},children:[e.jsxs("span",{className:"fluig-attachment__content",children:[e.jsx("i",{className:`flaticon icon-sm ${S?"flaticon-loading":E?"flaticon-file":"flaticon-paperclip"} fluig-attachment__icon`}),e.jsx("span",{className:"fluig-attachment__filename",children:S?" Enviando...":E?C:j?"Nenhum arquivo":m||"Anexar"})]}),E&&!j&&e.jsx("button",{type:"button",className:"fluig-attachment__btn-remove btn btn-link text-danger",onClick:I,children:e.jsx("i",{className:"flaticon flaticon-trash icon-sm"})})]}),d&&e.jsx(z,{text:d,title:v,width:s})]}),!p&&b&&e.jsx("input",{type:"hidden",name:t,value:n.value||""})]})},Be=o.memo(De);exports.Attachment=Be;exports.Checkbox=de;exports.DatePicker=Ae;exports.Help=z;exports.Input=ce;exports.Modal=ee;exports.RadioBtn=ue;exports.Select=Q;exports.SimpleTable=Ie;exports.StatusBadge=Ce;exports.TextArea=me;
|