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.
@@ -8,8 +8,8 @@ export interface InputProps {
8
8
  className?: string;
9
9
  forceReadOnly?: boolean;
10
10
  forceHidden?: boolean;
11
- prefix?: string | React.ReactNode;
12
- suffix?: string | React.ReactNode;
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((n,f,m)=>!!n&&n.trim()!==""&&m.indexOf(n)===f).join(" ").trim();/**
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,(n,f,m)=>m?m.toUpperCase():f.toLowerCase());/**
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 n=xe(t);return n.charAt(0).toUpperCase()+n.slice(1)};/**
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 n in t)if(n.startsWith("aria-")||n==="role"||n==="title")return!0;return!1};/**
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:n=24,strokeWidth:f=2,absoluteStrokeWidth:m,className:c="",children:a,iconNode:h,...d},j)=>o.createElement("svg",{ref:j,...pe,width:n,height:n,stroke:t,strokeWidth:m?Number(f)*24/Number(n):f,className:te("lucide",c),...!a&&!ve(d)&&{"aria-hidden":"true"},...d},[...h.map(([r,x])=>o.createElement(r,x)),...Array.isArray(a)?a:[a]]));/**
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,n)=>{const f=o.forwardRef(({className:m,...c},a)=>o.createElement(je,{ref:a,iconNode:n,className:te(`lucide-${he(X(t))}`,`lucide-${t}`,m),...c}));return f.displayName=X(t),f};/**
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 ye=[["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=Z("calendar",ye);/**
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 n=H.parse(t,se,new Date);return H.isValid(n)?n:null},Se=t=>t?H.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,Oe=Array.from({length:_e-M+1},(t,n)=>{const f=M+n;return{value:f,label:String(f)}});function $e({name:t,label:n="",placeholder:f="dd/mm/aaaa",className:m="",forceReadOnly:c=!1,forceHidden:a=!1,valueManual:h,onChangeManual:d,errorManual:j}){var F;const r=h!==void 0&&!!d,{isReadOnly:x,isHidden:_}=B.useSection(),$=c||!!x(t),V=a||!!_(t),{isView:y}=B.useFluigRuntime();let S="",O=()=>{},R,g=null,s=()=>{};if(r)S=h;else try{const v=L.useFormContext(),C=L.useController({name:t,control:v.control});S=C.field.value,O=C.field.onChange,R=C.field.ref,g=(F=C.fieldState)==null?void 0:F.error,s=v.clearErrors}catch{}const[l,i]=o.useState(!1),[u,p]=o.useState(new Date),E=o.useRef(null);o.useEffect(()=>{if(l){const v=K(S);p(v&&H.isValid(v)?v:new Date)}},[l,S]),o.useEffect(()=>{const v=C=>{E.current&&!E.current.contains(C.target)&&i(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const I=o.useMemo(()=>K(S),[S]),A=v=>{if($)return;const C=Se(v);r?d==null||d(C):(O(C),s==null||s(t)),i(!1)},k=o.useMemo(()=>H.eachDayOfInterval({start:H.startOfWeek(H.startOfMonth(u)),end:H.endOfWeek(H.endOfMonth(u))}),[u]),N=u.getMonth(),b=H.getYear(u);return e.jsxs("div",{className:`dfe-datepicker-wrapper form-group ${V?"hidden":""} ${m}`,ref:E,children:[e.jsx("label",{className:"control-label",children:n}),y?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":""} ${$?"readOnly":""}`,onClick:()=>!$&&i(v=>!v),ref:R,children:[e.jsx("span",{className:`dfe-datepicker-display ${$?"readOnly":""}`,children:S||f}),e.jsx(ge,{size:16,className:"dfe-datepicker-icon"})]}),l&&!$&&e.jsxs("div",{className:"dfe-datepicker-dropdown",onClick:v=>v.stopPropagation(),children:[e.jsxs("div",{className:"dfe-datepicker-header",children:[e.jsx("button",{type:"button",onClick:()=>p(H.subMonths(u,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:N,onChangeManual:v=>p(H.setMonth(u,Number(v))),options:Re,placeholder:"Mês"}),e.jsx(Q,{name:"datepicker_internal_year",valueManual:b,onChangeManual:v=>p(H.setYear(u,Number(v))),options:Oe,enableSearch:!0,searchPlaceholder:"Buscar ano...",placeholder:"Ano"})]}),e.jsx("button",{type:"button",onClick:()=>p(H.addMonths(u,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((v,C)=>e.jsx("span",{children:v},C))}),e.jsx("div",{className:"dfe-datepicker-grid",children:k.map((v,C)=>{const T=!H.isSameMonth(v,u),z=I&&H.isSameDay(v,I);return e.jsx("div",{onClick:()=>!T&&A(v),className:`dfe-datepicker-day
57
- ${z?"selected":"handleHover"}
58
- ${T?"outside":""}
59
- ${H.isToday(v)?"today":""}`,children:H.format(v,"d")},C)})})]})]}),!r&&e.jsx("input",{type:"hidden",name:t,value:S||""}),(g||j)&&e.jsx("p",{className:"text-danger",children:String((g==null?void 0:g.message)??j)})]})}const Ae=o.memo($e);function Ce({mapping:t={},defaultLabel:n="Não reconhecido",className:f="",hidden:m=!1,label:c}){const{activityId:a}=B.useFluigRuntime(),h=o.useMemo(()=>!t||a===null||a===void 0?null:t[a],[a,t]);if(!h)return e.jsxs("div",{className:`form-group ${m?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsx("div",{className:`status-badge default ${f}`,children:n})]});const d={"--customColor":h.color};return e.jsxs("div",{className:`form-group ${m?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsxs("div",{className:`status-badge ${f}`,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:n,defaultRowValue:f,isView:m,isReadOnly:c,filters:a=[]}){const{field:h}=L.useController({name:t,control:n}),[d,j]=o.useState([]),[r,x]=o.useState([]),_=()=>Date.now()+Math.random(),$=l=>{try{const i=JSON.parse(l);return Array.isArray(i)?i.map(u=>({...u,_uid:u._uid||_()})):[]}catch(i){return console.error(`Erro ao ler dados da tabela "${t}":`,i),[]}};o.useEffect(()=>{if(!(d.length>0&&!m)&&h.value&&typeof h.value=="string"){const l=JSON.stringify(d);if(h.value===l)return;const i=$(h.value);j(i)}},[h.value,m]),o.useEffect(()=>{if(c)return;const l=JSON.stringify(d);h.value!==l&&h.onChange(l)},[d,h,c]);const V=o.useCallback(()=>{const l={_uid:_(),...f};j(i=>[...i,l])},[f]),y=o.useCallback(()=>{j(l=>l.filter(i=>!r.includes(i._uid))),x([])},[r]),S=o.useCallback((l,i,u)=>{j(p=>p.map(E=>E._uid===l?{...E,[i]:u}:E))},[]),O=o.useCallback(l=>{x(i=>i.includes(l)?i.filter(u=>u!==l):[...i,l])},[]),R=o.useCallback(l=>{x(l?d.map(i=>i._uid):[])},[d]),g=d.length>0&&r.length===d.length,s=o.useMemo(()=>!a||a.length===0?d:d.filter(l=>a.every(i=>{if("custom"in i)return i.custom(l);const u=l[i.field];switch(i.operator){case"===":return u===i.value;case"!==":return u!==i.value;case">":return u>i.value;case"<":return u<i.value;case">=":return u>=i.value;case"<=":return u<=i.value;default:return!0}})),[d,a]);return{field:h,tableRows:d,visibleRows:s,selectedRowIds:r,isAllSelected:g,handle:{addRow:V,removeRows:y,updateCellValue:S,toggleSelection:O,toggleSelectAll:R}}}const Ie=({name:t,title:n="Tabela Dinâmica",columns:f,defaultRowValue:m={},forceReadOnly:c=!1,layout:a="fluid",actions:h=!0,filters:d=[]})=>{const{control:j}=L.useFormContext(),{isView:r,isReadOnly:x}=B.useFluigRuntime(),{isReadOnly:_}=B.useSection(),$=c||r||x||_&&_(t),{field:V,visibleRows:y,selectedRowIds:S,isAllSelected:O,handle:R}=Fe({name:t,control:j,defaultRowValue:m,isView:r,isReadOnly:!!$,filters:d}),g=a==="fixed";return e.jsxs("div",{className:`table-wrapper ${g?"table-fixed":"table-fluid"}`,children:[e.jsx("input",{type:"hidden",...V}),e.jsxs("div",{className:"header-handle",children:[e.jsx("h3",{children:n}),!$&&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:R.removeRows,children:["Remover (",S.length,")"]}),e.jsx("button",{type:"button",className:"btn-add",onClick:R.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:[!$&&e.jsx("th",{style:{width:"50px"},children:e.jsx("input",{type:"checkbox",checked:O,onChange:s=>R.toggleSelectAll(s.target.checked)})}),f.map(s=>e.jsx("th",{style:s.width?{minWidth:g?s.width:"100%"}:{width:"max-content"},children:s.label},String(s.key)))]})}),e.jsxs("tbody",{children:[y.map((s,l)=>e.jsxs("tr",{children:[!$&&e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:S.includes(s._uid),onChange:()=>R.toggleSelection(s._uid)})}),f.map(i=>e.jsx("td",{children:i.render?i.render.length<=1?i.render({row:s,index:l,updateRow:(u,p)=>R.updateCellValue(s._uid,String(u),p),isLocked:!!$,isView:!!r}):i.render(s,l,(u,p)=>R.updateCellValue(s._uid,u,p),!!$,!!r):s[i.key]},`${s._uid}-${String(i.key)}`))]},s._uid)),y.length===0&&e.jsx("tr",{className:"empty-row",children:e.jsx("td",{colSpan:100,className:"text-center",children:$?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},Ve=(t,n)=>{const[f,m]=o.useState(null);let c=null;try{c=L.useFormContext().watch}catch{}const a=n!==void 0?n:c?c(t):void 0,h=o.useCallback(()=>{try{const j=window.top.__REACT_ATTACHMENT_BRIDGE__;if(j){const r=j.getAttachment(t,a);m(r||(a?{name:a,documentId:0}:null))}else m(a?{name:a,documentId:0}:null)}catch{m(a?{name:a,documentId:0}:null)}},[t,a,n]);return o.useEffect(()=>{h();const d=setInterval(h,2e3);return()=>clearInterval(d)},[h]),{attachment:f,sync:h}},De=({name:t,label:n,help:f,valueManual:m,onChangeManual:c,forceReadOnly:a=!1,forceHidden:h=!1,helpText:d,helpTitle:j,helpWidth:r})=>{const x=!!c,{isReadOnly:_,isHidden:$}=B.useSection(),{isView:V}=B.useFluigRuntime(),y=a||V||!!_(t),S=h||!!$(t),[O,R]=o.useState(!1);let g=null;try{g=L.useFormContext().control}catch{}const s=g&&!x?L.useController({name:t,control:g}).field:{value:m,onChange:N=>c==null?void 0:c(N)},{attachment:l,sync:i}=Ve(t,m),u=()=>{var N;try{const b=window.top;return{bridge:b.__REACT_ATTACHMENT_BRIDGE__,toast:(N=b.FLUIGC)==null?void 0:N.toast}}catch{return{bridge:null,toast:null}}},p=o.useCallback(()=>{if(y)return;const N=document.createElement("input");N.type="file",N.onchange=b=>{const F=b.target.files[0];if(!F)return;const{bridge:v,toast:C}=u();R(!0),v?v.upload(F,t,T=>{x?c==null||c(T.name):s.onChange(T.name),setTimeout(()=>{R(!1),i()},1e3),C&&C({title:"Sucesso",message:"Arquivo enviado",type:"success"})}):(x?c==null||c(F.name):s.onChange(F.name),R(!1))},N.click()},[t,s,i,c,y,x]),E=N=>{if(N.stopPropagation(),y)return;const b=(l==null?void 0:l.name)||m||s.value;if(!b)return;const{bridge:F,toast:v}=u();F?F.removeByFileName(b)?(x?c==null||c(""):s.onChange(""),i()):v&&v({title:"Erro",message:"Erro ao remover anexo",type:"danger"}):(x?c==null||c(""):s.onChange(""),i())},I=!!l&&!O,A=(l==null?void 0:l.name)||m||s.value,k=["fluig-attachment__box",I?"fluig-attachment__box--has-file":"",O?"fluig-attachment__box--uploading":"",y&&!I?"readOnly":"",y&&I?"fluig-attachment__box--readonly-view":""].join(" ");return S?null:e.jsxs("div",{className:"form-group fluig-attachment",children:[n&&e.jsx("label",{className:"fluig-attachment__label",children:n}),e.jsxs("div",{className:d?"dfe-flex-input-wrapper":"",children:[e.jsxs("div",{className:k,style:d?{flex:1}:void 0,onClick:()=>{if(I){const N=u(),b=(l==null?void 0:l.physicalFileName)||(l==null?void 0:l.description)||(l==null?void 0:l.name)||A;N.bridge&&b&&N.bridge.view(b)}else p()},children:[e.jsxs("span",{className:"fluig-attachment__content",children:[e.jsx("i",{className:`flaticon icon-sm ${O?"flaticon-loading":I?"flaticon-file":"flaticon-paperclip"} fluig-attachment__icon`}),e.jsx("span",{className:"fluig-attachment__filename",children:O?" Enviando...":I?A:y?"Nenhum arquivo":f||"Anexar"})]}),I&&!y&&e.jsx("button",{type:"button",className:"fluig-attachment__btn-remove btn btn-link text-danger",onClick:E,children:e.jsx("i",{className:"flaticon flaticon-trash icon-sm"})})]}),d&&e.jsx(W,{text:d,title:j,width:r})]}),!x&&g&&e.jsx("input",{type:"hidden",name:t,value:s.value||""})]})},He=o.memo(De);exports.Attachment=He;exports.Checkbox=de;exports.DatePicker=Ae;exports.Help=W;exports.Input=ce;exports.Modal=ee;exports.RadioBtn=ue;exports.Select=Q;exports.SimpleTable=Ie;exports.StatusBadge=Ee;exports.TextArea=me;
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;