diefra_ecm_ui 1.2.2 → 1.2.3
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 +13 -13
- package/dist/index.js +541 -543
- 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:a,content:c,footer:u,width:h}){const d=o.useCallback(p=>{p.key==="Escape"&&a()},[a]);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:a,"aria-modal":"true",role:"dialog",children:e.jsxs("div",{style:{maxWidth:h},className:"modal-container",onClick:p=>p.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:t}),e.jsx("div",{className:"btn-close-modal",onClick:a,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}),u&&e.jsx("div",{className:"modal-footer",children:u})]})}):null}function re({text:t,title:r="Ajuda & Informações",width:m="500px",className:a=""}){const[c,u]=o.useState(!1),h=d=>{d.preventDefault(),d.stopPropagation(),u(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`dfe-help-indicator ${a}`,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:r,isOpen:c,onClose:()=>u(!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:()=>u(!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:a="text",mask:c,className:u="",forceReadOnly:h=!1,forceHidden:d=!1,prefix:p,suffix:s,helpText:v,helpTitle:_,helpWidth:A,valueManual:H,onChangeManual:b,errorManual:S}){var W,Y;const R=H!==void 0&&!!b,{isReadOnly:O,isHidden:g}=P.useSection(),n=h||!!O(t),l=d||!!g(t),{isView:i}=P.useFluigRuntime();let f=null;try{f=T.useFormContext()}catch{}const x=!R&&f?T.useController({name:t,control:f.control}):null,F=!R&&f?T.useFormState({name:t}):null,V=R?H:x==null?void 0:x.field.value,C=R?S:(Y=(W=F==null?void 0:F.errors)==null?void 0:W[t])==null?void 0:Y.message,w=o.useMemo(()=>c?le[c]??c:null,[c]),k=o.useCallback(B=>{if(!B)return"";let N=B;if(s)if(N.endsWith(s))N=N.slice(0,-s.length);else{const D=N.lastIndexOf(s);D!==-1&&(N=N.substring(0,D)+N.substring(D+s.length))}if(p)if(N.startsWith(p))N=N.slice(p.length);else{const D=N.indexOf(p);D!==-1&&(N=N.substring(0,D)+N.substring(D+p.length))}if(a==="monetary"){const D=N.replace(/\D/g,"");return D?(Number(D)/100).toFixed(2):""}return a==="number"&&(N=N.replace(/[^\d.,-]/g,""),N=N.replace(/\./g,"").replace(",",".")),N},[p,s,a]),y=o.useCallback(B=>{if(B===""||B===null||B===void 0)return"";let N=String(B);if(a==="monetary"){const D=Number(B);return isNaN(D)?"":D.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})}if(a==="number"){N=N.replace(".",",");const D=N.split(",");D[0]=D[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),N=D.join(",")}return p&&(N=`${p}${N}`),s&&(N=`${N}${s}`),N},[p,s,a]),I=B=>{const N=`${p||""}${s||""}`;if(!B||B===p||B===s||B===N){R?b==null||b(""):x==null||x.field.onChange("");return}const D=k(B);R?b==null||b(D):x==null||x.field.onChange(D)},j=()=>{R||x==null||x.field.onBlur()},E=o.useMemo(()=>y(V),[V,y]);if(l)return null;const q=`form-control ${n?"readOnly":""} ${C?"border-red":""} ${u}`,J=()=>w?e.jsx(ne.IMaskInput,{mask:w,value:E,unmask:!0,onAccept:B=>I(B),placeholder:m,readOnly:n,className:q,inputRef:R||x==null?void 0:x.field.ref,onBlur:j}):e.jsx("input",{type:"text",inputMode:a==="number"||a==="monetary"?"numeric":void 0,value:E,onChange:B=>I(B.target.value),onBlur:j,placeholder:m,readOnly:n,className:q});return i?e.jsxs("div",{className:"form-group",children:[r&&e.jsx("label",{children:r}),e.jsxs("div",{className:v?"dfe-flex-input-wrapper":"",children:[e.jsx("span",{className:q,children:E||"-"}),v&&e.jsx(z,{text:v,title:_,width:A})]})]}):e.jsxs("div",{className:`form-group ${l?"hidden":""}`,children:[r&&e.jsx("label",{children:r}),e.jsxs("div",{className:v?"dfe-flex-input-wrapper":"",children:[J(),v&&e.jsx(z,{text:v,title:_,width:A})]}),!R&&e.jsx("input",{type:"hidden",name:t,value:V||""}),C&&e.jsx("p",{className:"text-danger",children:String(C)})]})}const ce=o.memo(ie);function oe({name:t,label:r="",options:m=[],placeholder:a="",labelKey:c="label",valueKey:u="value",enableSearch:h=!1,searchPlaceholder:d="Buscar...",loading:p=!1,onSearchChange:s,debounceTime:v=300,onSelect:_,forceReadOnly:A=!1,forceHidden:H=!1,helpText:b,helpTitle:S,helpWidth:R,valueManual:O,onChangeManual:g,errorManual:n}){var Z;const l=O!==void 0&&!!g,{isReadOnly:i,isHidden:f}=P.useSection(),x=A||!!i(t),F=H||!!f(t),{isView:V}=P.useFluigRuntime();let C="",w=()=>{},k,y=null,I=()=>{};if(l)C=O;else try{const $=T.useFormContext(),U=T.useController({name:t,control:$.control});C=U.field.value,w=U.field.onChange,k=U.field.ref,y=(Z=U.fieldState)==null?void 0:Z.error,I=$.clearErrors}catch{}const[j,E]=o.useState(!1),[q,J]=o.useState(""),W=o.useRef(null),Y=o.useRef(s);o.useEffect(()=>{Y.current=s},[s]),o.useEffect(()=>{const $=U=>{W.current&&!W.current.contains(U.target)&&E(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]),o.useEffect(()=>{j||J("")},[j]),o.useEffect(()=>{if(!h)return;const $=setTimeout(()=>{var U;(U=Y.current)==null||U.call(Y,q)},v);return()=>clearTimeout($)},[q,h,v]);const B=o.useMemo(()=>h&&!s&&q.trim()?m.filter($=>String(($==null?void 0:$[c])??"").toLowerCase().includes(q.toLowerCase())):m??[],[m,h,s,q,c]),N=o.useMemo(()=>{if(C==null)return"";if(typeof C=="object")return String(C[u]??"");const $=(m||[]).find(U=>String(U==null?void 0:U[u])===String(C));return String($?($==null?void 0:$[c])??"":C)},[C,m,u,c]),D=$=>{x||(l?g==null||g($[u]):(w($[u]),I==null||I(t)),_==null||_($),E(!1))};return F?null:e.jsxs("div",{className:`select-wrapper form-group ${F?"hidden":""}`,ref:W,children:[e.jsx("label",{className:"control-label",children:r}),V?e.jsxs("div",{className:b?"dfe-flex-input-wrapper":"",children:[e.jsx("span",{className:"form-control",style:b?{flex:1}:void 0,children:N||"-"}),b&&e.jsx(z,{text:b,title:S,width:R})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:b?"dfe-flex-input-wrapper":"",children:[e.jsxs("div",{className:`select-control ${y?"border-red":""} ${x?"readOnly":""}`,onClick:()=>!x&&E($=>!$),ref:k,style:b?{flex:1}:void 0,children:[e.jsx("span",{className:`select-display ${x?"readOnly":""}`,children:N||a}),e.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),b&&e.jsx(z,{text:b,title:S,width:R})]}),j&&!x&&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:q,onChange:$=>J($.target.value),placeholder:p?"Carregando...":d,autoFocus:!0,onClick:$=>$.stopPropagation()})}),e.jsx("ul",{className:"select-options",children:p?e.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):B.length>0?B.map($=>e.jsx("li",{onClick:()=>D($),className:"select-option handleHover",children:$[c]},$[u])):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 G=o.memo(oe);function de({name:t,options:r=[],label:m="",valueKey:a="value",labelKey:c="label",forceReadOnly:u=!1,forceHidden:h=!1,valueManual:d,onChangeManual:p}){var V,C;let s=null;try{s=T.useFormContext()}catch{}const v=d!==void 0&&!!p,{isView:_,isReadOnly:A}=P.useFluigRuntime(),{isReadOnly:H,isHidden:b}=P.useSection(),S=H?H(t):!1,R=b?b(t):!1,O=u||S,g=h||R,n=O||A||_,l=()=>r?r.reduce((w,k)=>{const y=String(k[a]);if(v)w[y]=!!(d!=null&&d[y]);else if(s){const I=s.getValues(y);w[y]=I==="on"}else w[y]=!1;return w},{}):{},i=!v&&s?s.watch(t):void 0,f=o.useMemo(()=>v&&d?d:i&&typeof i=="object"?i:l(),[i,d,r]);o.useEffect(()=>{if(v||!s)return;const w=s.getValues(t);(!w||typeof w!="object")&&s.setValue(t,f,{shouldDirty:!1,shouldValidate:!1})},[f,t,s,v]);const x=(w,k)=>{if(n)return;const y={...f,[w]:k};if(v){p&&p(y);return}s&&(s.setValue(t,y,{shouldDirty:!0,shouldValidate:!0}),s.setValue(w,k?"on":"",{shouldValidate:!1}))},F=v?null:(C=(V=s==null?void 0:s.formState)==null?void 0:V.errors)==null?void 0:C[t];return e.jsxs("div",{className:`form-group ${g?"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[a]),y=f[k]===!0;return e.jsxs("div",{children:[!v&&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:I=>x(k,I.target.checked)}),e.jsx("span",{className:"checkmark"}),e.jsx("span",{children:w[c]})]})]},k)})}),F&&e.jsx("p",{className:"text-danger",children:String(F.message)})]})}function ae({name:t,label:r="",options:m=[],valueKey:a="value",labelKey:c="label",iconKey:u="icon",forceReadOnly:h=!1,forceHidden:d=!1,valueManual:p,onChangeManual:s,errorManual:v}){var V,C;const _=p!==void 0&&!!s,{isReadOnly:A,isHidden:H}=P.useSection(),b=h||!!A(t),S=d||!!H(t),{isView:R,isReadOnly:O}=P.useFluigRuntime();let g=null;try{g=T.useFormContext()}catch{}const n=!_&&g?T.useController({name:t,control:g.control,defaultValue:""}):null,l=!_&&g?T.useFormState({name:t}):null,i=_?v:(C=(V=l==null?void 0:l.errors)==null?void 0:V[t])==null?void 0:C.message,f=b||O||R,x=_?p:(n==null?void 0:n.field.value)??"",F=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 ${S?"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[a],y=x===k,I=w.color?{"--customColor":w.color}:void 0;return e.jsxs("div",{style:I,className:`btn fs-ellipsis ${y?"active":""}`,onClick:()=>F(k),children:[w[u]&&e.jsx("i",{className:`${w[u]} icon-sm`})," ",w[c]]},k)})}),!_&&e.jsx("input",{type:"hidden",name:t,value:x||"",ref:n==null?void 0:n.field.ref}),(i||v)&&e.jsx("p",{className:"text-danger",children:String(i??v)})]})}const ue=o.memo(ae),fe=({name:t,label:r="",placeholder:m="",className:a="",rows:c=4,maxLength:u,forceReadOnly:h=!1,forceHidden:d=!1,valueManual:p,onChangeManual:s,errorManual:v})=>{var f;const _=p!==void 0&&!!s,{isReadOnly:A,isHidden:H}=P.useSection(),b=h||!!A(t),S=d||!!H(t),{isView:R}=P.useFluigRuntime(),O=o.useRef(null);let g={value:p??"",onChange:x=>s==null?void 0:s(x)},n=null;if(!_)try{const{control:x}=T.useFormContext(),F=T.useController({name:t,control:x});g=F.field,n=(f=F.fieldState)==null?void 0:f.error}catch{}const l=()=>{O.current&&(O.current.style.height="auto",O.current.style.height=`${O.current.scrollHeight}px`)};if(o.useEffect(()=>{l()},[g.value]),R)return e.jsxs("div",{className:`form-group ${S?"hidden":""}`,children:[e.jsx("label",{children:r}),e.jsx("span",{className:"form-control",children:g.value||"-"})]});const i=`form-control ${b?"readOnly":""} ${n||v?"border-red":""} ${a}`;return e.jsxs("div",{className:`form-group ${S?"hidden":""}`,children:[r&&e.jsx("label",{children:r}),e.jsx("textarea",{ref:O,rows:c,maxLength:u,value:g.value||"",placeholder:m,readOnly:b,className:i,style:{resize:"none",maxHeight:"400px",overflowY:"auto"},onChange:x=>{_?s==null||s(x.target.value):g.onChange(x)},onInput:l}),(n||v)&&e.jsx("p",{className:"text-danger",children:String((n==null?void 0:n.message)??v)})]})},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,a)=>!!r&&r.trim()!==""&&a.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,a)=>a?a.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,32 +28,32 @@
|
|
|
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:a,className:c="",children:u,iconNode:h,...d},p)=>o.createElement("svg",{ref:p,...pe,width:r,height:r,stroke:t,strokeWidth:a?Number(m)*24/Number(r):m,className:te("lucide",c),...!u&&!ve(d)&&{"aria-hidden":"true"},...d},[...h.map(([s,v])=>o.createElement(s,v)),...Array.isArray(u)?u:[u]]));/**
|
|
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
|
|
41
|
+
*/const Q=(t,r)=>{const m=o.forwardRef(({className:a,...c},u)=>o.createElement(je,{ref:u,iconNode:r,className:te(`lucide-${he(X(t))}`,`lucide-${t}`,a),...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 be=[["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"}]],ge=Q("calendar",be);/**
|
|
47
47
|
* @license lucide-react v0.575.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const ye=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ne=Q("chevron-left",ye);/**
|
|
52
52
|
* @license lucide-react v0.575.0 - ISC
|
|
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=
|
|
57
|
-
${
|
|
58
|
-
${
|
|
59
|
-
${
|
|
56
|
+
*/const ke=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],we=Q("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,Oe=2100,$e=Array.from({length:Oe-M+1},(t,r)=>{const m=M+r;return{value:m,label:String(m)}});function _e({name:t,label:r="",placeholder:m="dd/mm/aaaa",className:a="",forceReadOnly:c=!1,forceHidden:u=!1,valueManual:h,onChangeManual:d,errorManual:p}){var I;const s=h!==void 0&&!!d,{isReadOnly:v,isHidden:_}=P.useSection(),A=c||!!v(t),H=u||!!_(t),{isView:b}=P.useFluigRuntime();let S="",R=()=>{},O,g=null,n=()=>{};if(s)S=h;else try{const j=T.useFormContext(),E=T.useController({name:t,control:j.control});S=E.field.value,R=E.field.onChange,O=E.field.ref,g=(I=E.fieldState)==null?void 0:I.error,n=j.clearErrors}catch{}const[l,i]=o.useState(!1),[f,x]=o.useState(new Date),F=o.useRef(null);o.useEffect(()=>{if(l){const j=K(S);x(j&&L.isValid(j)?j:new Date)}},[l,S]),o.useEffect(()=>{const j=E=>{F.current&&!F.current.contains(E.target)&&i(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const V=o.useMemo(()=>K(S),[S]),C=j=>{if(A)return;const E=Se(j);s?d==null||d(E):(R(E),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 ${H?"hidden":""} ${a}`,ref:F,children:[e.jsx("label",{className:"control-label",children:r}),b?e.jsx("span",{className:"form-control",children:S||"-"}):e.jsxs("div",{className:"dfe-datepicker-inner-container",children:[e.jsxs("div",{className:`dfe-datepicker-control ${g?"border-red":""} ${A?"readOnly":""}`,onClick:()=>!A&&i(j=>!j),ref:O,children:[e.jsx("span",{className:`dfe-datepicker-display ${A?"readOnly":""}`,children:S||m}),e.jsx(ge,{size:16,className:"dfe-datepicker-icon"})]}),l&&!A&&e.jsxs("div",{className:"dfe-datepicker-dropdown",onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:"dfe-datepicker-header",children:[e.jsx("button",{type:"button",onClick:()=>x(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(G,{name:"datepicker_internal_month",valueManual:k,onChangeManual:j=>x(L.setMonth(f,Number(j))),options:Re,placeholder:"Mês"}),e.jsx(G,{name:"datepicker_internal_year",valueManual:y,onChangeManual:j=>x(L.setYear(f,Number(j))),options:$e,enableSearch:!0,searchPlaceholder:"Buscar ano...",placeholder:"Ano"})]}),e.jsx("button",{type:"button",onClick:()=>x(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((j,E)=>e.jsx("span",{children:j},E))}),e.jsx("div",{className:"dfe-datepicker-grid",children:w.map((j,E)=>{const q=!L.isSameMonth(j,f),J=V&&L.isSameDay(j,V);return e.jsx("div",{onClick:()=>!q&&C(j),className:`dfe-datepicker-day
|
|
57
|
+
${J?"selected":"handleHover"}
|
|
58
|
+
${q?"outside":""}
|
|
59
|
+
${L.isToday(j)?"today":""}`,children:L.format(j,"d")},E)})})]})]}),!s&&e.jsx("input",{type:"hidden",name:t,value:S||""}),(g||p)&&e.jsx("p",{className:"text-danger",children:String((g==null?void 0:g.message)??p)})]})}const Ae=o.memo(_e);function Ce({mapping:t={},defaultLabel:r="Não reconhecido",className:m="",hidden:a=!1,label:c}){const{activityId:u}=P.useFluigRuntime(),h=o.useMemo(()=>!t||u===null||u===void 0?null:t[u],[u,t]);if(!h)return e.jsxs("div",{className:`form-group ${a?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsx("div",{className:`status-badge default ${m}`,children:r})]});const d={"--customColor":h.color};return e.jsxs("div",{className:`form-group ${a?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsxs("div",{className:`status-badge ${m}`,style:d,children:[h.icon&&e.jsx("i",{className:h.icon}),e.jsx("span",{children:h.label})]})]})}const Ee=o.memo(Ce);function Fe({name:t,control:r,defaultRowValue:m,isView:a,isReadOnly:c,filters:u=[]}){const{field:h}=T.useController({name:t,control:r}),[d,p]=o.useState([]),[s,v]=o.useState([]),_=()=>Date.now()+Math.random(),A=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&&!a)&&h.value&&typeof h.value=="string"){const l=JSON.stringify(d);if(h.value===l)return;const i=A(h.value);p(i)}},[h.value,a]),o.useEffect(()=>{if(c)return;const l=JSON.stringify(d);h.value!==l&&h.onChange(l)},[d,h,c]);const H=o.useCallback(()=>{const l={_uid:_(),...m};p(i=>[...i,l])},[m]),b=o.useCallback(()=>{p(l=>l.filter(i=>!s.includes(i._uid))),v([])},[s]),S=o.useCallback((l,i,f)=>{p(x=>x.map(F=>F._uid===l?{...F,[i]:f}:F))},[]),R=o.useCallback(l=>{v(i=>i.includes(l)?i.filter(f=>f!==l):[...i,l])},[]),O=o.useCallback(l=>{v(l?d.map(i=>i._uid):[])},[d]),g=d.length>0&&s.length===d.length,n=o.useMemo(()=>!u||u.length===0?d:d.filter(l=>u.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,u]);return{field:h,tableRows:d,visibleRows:n,selectedRowIds:s,isAllSelected:g,handle:{addRow:H,removeRows:b,updateCellValue:S,toggleSelection:R,toggleSelectAll:O}}}const Ie=({name:t,title:r="Tabela Dinâmica",columns:m,defaultRowValue:a={},forceReadOnly:c=!1,layout:u="fluid",actions:h=!0,filters:d=[]})=>{const{control:p}=T.useFormContext(),{isView:s,isReadOnly:v}=P.useFluigRuntime(),{isReadOnly:_}=P.useSection(),A=c||s||v||_&&_(t),{field:H,visibleRows:b,selectedRowIds:S,isAllSelected:R,handle:O}=Fe({name:t,control:p,defaultRowValue:a,isView:s,isReadOnly:!!A,filters:d}),g=u==="fixed";return e.jsxs("div",{className:`table-wrapper ${g?"table-fixed":"table-fluid"}`,children:[e.jsx("input",{type:"hidden",...H}),e.jsxs("div",{className:"header-handle",children:[e.jsx("h3",{children:r}),!A&&h&&e.jsxs("div",{className:"handle-actions",children:[e.jsxs("button",{type:"button",className:`btn ${S.length>0?"btn-danger":"btn-primary"}`,disabled:S.length===0,onClick:O.removeRows,children:["Remover (",S.length,")"]}),e.jsx("button",{type:"button",className:"btn-add",onClick:O.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:[!A&&e.jsx("th",{style:{width:"50px"},children:e.jsx("input",{type:"checkbox",checked:R,onChange:n=>O.toggleSelectAll(n.target.checked)})}),m.map(n=>e.jsx("th",{style:n.width?{minWidth:g?n.width:"100%"}:{width:"max-content"},children:n.label},String(n.key)))]})}),e.jsxs("tbody",{children:[b.map((n,l)=>e.jsxs("tr",{children:[!A&&e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:S.includes(n._uid),onChange:()=>O.toggleSelection(n._uid)})}),m.map(i=>e.jsx("td",{children:i.render?i.render.length<=1?i.render({row:n,index:l,updateRow:(f,x)=>O.updateCellValue(n._uid,String(f),x),isLocked:!!A,isView:!!s}):i.render(n,l,(f,x)=>O.updateCellValue(n._uid,f,x),!!A,!!s):n[i.key]},`${n._uid}-${String(i.key)}`))]},n._uid)),b.length===0&&e.jsx("tr",{className:"empty-row",children:e.jsx("td",{colSpan:100,className:"text-center",children:A?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},Ve=(t,r)=>{const[m,a]=o.useState(null);let c=null;try{c=T.useFormContext().watch}catch{}const u=r!==void 0?r:c?c(t):void 0,h=o.useCallback(()=>{try{const p=window.top.__REACT_ATTACHMENT_BRIDGE__;if(p){const s=p.getAttachment(t,u);a(s||(u?{name:u,documentId:0}:null))}else a(u?{name:u,documentId:0}:null)}catch{a(u?{name:u,documentId:0}:null)}},[t,u,r]);return o.useEffect(()=>{h();const d=setInterval(h,2e3);return()=>clearInterval(d)},[h]),{attachment:m,sync:h}},De=({name:t,label:r,help:m,valueManual:a,onChangeManual:c,forceReadOnly:u=!1,forceHidden:h=!1,helpText:d,helpTitle:p,helpWidth:s})=>{const v=!!c,{isReadOnly:_,isHidden:A}=P.useSection(),{isView:H}=P.useFluigRuntime(),b=u||H||!!_(t),S=h||!!A(t),[R,O]=o.useState(!1);let g=null;try{g=T.useFormContext().control}catch{}const n=g&&!v?T.useController({name:t,control:g}).field:{value:a,onChange:k=>c==null?void 0:c(k)},{attachment:l,sync:i}=Ve(t,a),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}}},x=o.useCallback(()=>{if(b)return;const k=document.createElement("input");k.type="file",k.onchange=y=>{const I=y.target.files[0];if(!I)return;const{bridge:j,toast:E}=f();O(!0),j?j.upload(I,t,q=>{v?c==null||c(q.name):n.onChange(q.name),setTimeout(()=>{O(!1),i()},1e3),E&&E({title:"Sucesso",message:"Arquivo enviado",type:"success"})}):(v?c==null||c(I.name):n.onChange(I.name),O(!1))},k.click()},[t,n,i,c,b,v]),F=k=>{if(k.stopPropagation(),b)return;const y=(l==null?void 0:l.name)||a||n.value;if(!y)return;const{bridge:I,toast:j}=f();I?I.removeByFileName(y)?(v?c==null||c(""):n.onChange(""),i()):j&&j({title:"Erro",message:"Erro ao remover anexo",type:"danger"}):(v?c==null||c(""):n.onChange(""),i())},V=!!l&&!R,C=(l==null?void 0:l.name)||a||n.value,w=["fluig-attachment__box",V?"fluig-attachment__box--has-file":"",R?"fluig-attachment__box--uploading":"",b&&!V?"readOnly":"",b&&V?"fluig-attachment__box--readonly-view":""].join(" ");return S?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(V){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 x()},children:[e.jsxs("span",{className:"fluig-attachment__content",children:[e.jsx("i",{className:`flaticon icon-sm ${R?"flaticon-loading":V?"flaticon-file":"flaticon-paperclip"} fluig-attachment__icon`}),e.jsx("span",{className:"fluig-attachment__filename",children:R?" Enviando...":V?C:b?"Nenhum arquivo":m||"Anexar"})]}),V&&!b&&e.jsx("button",{type:"button",className:"fluig-attachment__btn-remove btn btn-link text-danger",onClick:F,children:e.jsx("i",{className:"flaticon flaticon-trash icon-sm"})})]}),d&&e.jsx(z,{text:d,title:p,width:s})]}),!v&&g&&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=G;exports.SimpleTable=Ie;exports.StatusBadge=Ee;exports.TextArea=me;
|