diefra_ecm_ui 1.2.1 → 1.2.2

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,6 +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
13
  helpText?: React.ReactNode;
12
14
  helpTitle?: string;
13
15
  helpWidth?: string;
@@ -15,6 +17,6 @@ export interface InputProps {
15
17
  onChangeManual?: (value: string) => void;
16
18
  errorManual?: string;
17
19
  }
18
- declare function InputCustom({ name, label, placeholder, type, mask, className, forceReadOnly, forceHidden, helpText, helpTitle, helpWidth, valueManual, onChangeManual, errorManual, }: InputProps): import("react/jsx-runtime").JSX.Element | null;
20
+ declare function InputCustom({ name, label, placeholder, type, mask, className, forceReadOnly, forceHidden, prefix, suffix, helpText, helpTitle, helpWidth, valueManual, onChangeManual, errorManual, }: InputProps): import("react/jsx-runtime").JSX.Element | null;
19
21
  declare const _default: import('../../../node_modules/react').MemoExoticComponent<typeof InputCustom>;
20
22
  export default _default;
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"),B=require("react-hook-form"),ne=require("react-imask"),L=require("@fluig-kit/ecm"),H=require("date-fns");function M({title:t,isOpen:l,onOpen:u,onClose:f,content:c,footer:a,width:h}){const d=o.useCallback(p=>{p.key==="Escape"&&f()},[f]);return o.useEffect(()=>(l&&(document.addEventListener("keydown",d),u==null||u(),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",d),document.body.style.overflow="auto"}),[l,d,u]),l?e.jsx("div",{className:"modal-overlay",onClick:f,"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:f,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:l="Ajuda & Informações",width:u="500px",className:f=""}){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 ${f}`,onClick:h,role:"button",tabIndex:0,"aria-label":"Botão de ajuda",title:"Clique para obter ajuda",children:e.jsx("span",{children:"?"})}),e.jsx(M,{title:l,isOpen:c,onClose:()=>a(!1),width:u,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 Y=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:l="",placeholder:u="",type:f="text",mask:c,className:a="",forceReadOnly:h=!1,forceHidden:d=!1,helpText:p,helpTitle:i,helpWidth:v,valueManual:O,onChangeManual:S,errorManual:V}){var T,U;const j=O!==void 0&&!!S,{isReadOnly:R,isHidden:F}=L.useSection(),w=h||!!R(t),y=d||!!F(t),{isView:n}=L.useFluigRuntime();let r=null;try{r=B.useFormContext()}catch{}const s=!j&&r?B.useController({name:t,control:r.control}):null,m=!j&&r?B.useFormState({name:t}):null,b=j?O:s==null?void 0:s.field.value,A=j?V:(U=(T=m==null?void 0:m.errors)==null?void 0:T[t])==null?void 0:U.message,I=o.useMemo(()=>c?le[c]??c:null,[c]),C=o.useCallback(D=>{if(!D)return"";const P=D.replace(/\D/g,"");return(Number(P)/100).toFixed(2)},[]),k=o.useCallback(D=>{if(D===""||D===null||D===void 0)return"";const P=Number(D);return isNaN(P)?"":P.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),N=D=>{let P=D;f==="monetary"&&(P=C(D)),j?S==null||S(P):s==null||s.field.onChange(P)},g=()=>{j||s==null||s.field.onBlur()},$=o.useMemo(()=>f==="monetary"?k(b):String(b??""),[b,f,k]);if(y)return null;const x=`form-control ${w?"readOnly":""} ${A?"border-red":""} ${a}`,E=()=>I?e.jsx(ne.IMaskInput,{mask:I,value:$,unmask:!0,onAccept:D=>N(D),placeholder:u,readOnly:w,className:x,inputRef:j||s==null?void 0:s.field.ref,onBlur:g}):e.jsx("input",{type:f==="number"?"number":"text",value:$,onChange:D=>N(D.target.value),onBlur:g,placeholder:u,readOnly:w,className:x});return n?e.jsxs("div",{className:"form-group",children:[l&&e.jsx("label",{children:l}),e.jsxs("div",{className:p?"dfe-flex-input-wrapper":"",children:[e.jsx("span",{className:x,children:$||"-"}),p&&e.jsx(Y,{text:p,title:i,width:v})]})]}):e.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[l&&e.jsx("label",{children:l}),e.jsxs("div",{className:p?"dfe-flex-input-wrapper":"",children:[E(),p&&e.jsx(Y,{text:p,title:i,width:v})]}),!j&&e.jsx("input",{type:"hidden",name:t,value:b||""}),A&&e.jsx("p",{className:"text-danger",children:String(A)})]})}const ce=o.memo(ie);function oe({name:t,label:l="",options:u=[],placeholder:f="",labelKey:c="label",valueKey:a="value",enableSearch:h=!1,searchPlaceholder:d="Buscar...",loading:p=!1,onSearchChange:i,debounceTime:v=300,onSelect:O,forceReadOnly:S=!1,forceHidden:V=!1,helpText:j,helpTitle:R,helpWidth:F,valueManual:w,onChangeManual:y,errorManual:n}){var Q;const r=w!==void 0&&!!y,{isReadOnly:s,isHidden:m}=L.useSection(),b=S||!!s(t),A=V||!!m(t),{isView:I}=L.useFluigRuntime();let C="",k=()=>{},N,g=null,$=()=>{};if(r)C=w;else try{const _=B.useFormContext(),q=B.useController({name:t,control:_.control});C=q.field.value,k=q.field.onChange,N=q.field.ref,g=(Q=q.fieldState)==null?void 0:Q.error,$=_.clearErrors}catch{}const[x,E]=o.useState(!1),[T,U]=o.useState(""),D=o.useRef(null),P=o.useRef(i);o.useEffect(()=>{P.current=i},[i]),o.useEffect(()=>{const _=q=>{D.current&&!D.current.contains(q.target)&&E(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]),o.useEffect(()=>{x||U("")},[x]),o.useEffect(()=>{if(!h)return;const _=setTimeout(()=>{var q;(q=P.current)==null||q.call(P,T)},v);return()=>clearTimeout(_)},[T,h,v]);const J=o.useMemo(()=>h&&!i&&T.trim()?u.filter(_=>String((_==null?void 0:_[c])??"").toLowerCase().includes(T.toLowerCase())):u??[],[u,h,i,T,c]),W=o.useMemo(()=>{if(C==null)return"";if(typeof C=="object")return String(C[a]??"");const _=(u||[]).find(q=>String(q==null?void 0:q[a])===String(C));return String(_?(_==null?void 0:_[c])??"":C)},[C,u,a,c]),se=_=>{b||(r?y==null||y(_[a]):(k(_[a]),$==null||$(t)),O==null||O(_),E(!1))};return A?null:e.jsxs("div",{className:`select-wrapper form-group ${A?"hidden":""}`,ref:D,children:[e.jsx("label",{className:"control-label",children:l}),I?e.jsxs("div",{className:j?"dfe-flex-input-wrapper":"",children:[e.jsx("span",{className:"form-control",style:j?{flex:1}:void 0,children:W||"-"}),j&&e.jsx(Y,{text:j,title:R,width:F})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:j?"dfe-flex-input-wrapper":"",children:[e.jsxs("div",{className:`select-control ${g?"border-red":""} ${b?"readOnly":""}`,onClick:()=>!b&&E(_=>!_),ref:N,style:j?{flex:1}:void 0,children:[e.jsx("span",{className:`select-display ${b?"readOnly":""}`,children:W||f}),e.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),j&&e.jsx(Y,{text:j,title:R,width:F})]}),x&&!b&&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:_=>U(_.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..."}):J.length>0?J.map(_=>e.jsx("li",{onClick:()=>se(_),className:"select-option handleHover",children:_[c]},_[a])):e.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),!r&&e.jsx("input",{type:"hidden",name:t,value:C||""}),(g||n)&&e.jsx("p",{className:"text-danger",children:String((g==null?void 0:g.message)??n)})]})}const z=o.memo(oe);function de({name:t,options:l=[],label:u="",valueKey:f="value",labelKey:c="label",forceReadOnly:a=!1,forceHidden:h=!1,valueManual:d,onChangeManual:p}){var I,C;let i=null;try{i=B.useFormContext()}catch{}const v=d!==void 0&&!!p,{isView:O,isReadOnly:S}=L.useFluigRuntime(),{isReadOnly:V,isHidden:j}=L.useSection(),R=V?V(t):!1,F=j?j(t):!1,w=a||R,y=h||F,n=w||S||O,r=()=>l?l.reduce((k,N)=>{const g=String(N[f]);if(v)k[g]=!!(d!=null&&d[g]);else if(i){const $=i.getValues(g);k[g]=$==="on"}else k[g]=!1;return k},{}):{},s=!v&&i?i.watch(t):void 0,m=o.useMemo(()=>v&&d?d:s&&typeof s=="object"?s:r(),[s,d,l]);o.useEffect(()=>{if(v||!i)return;const k=i.getValues(t);(!k||typeof k!="object")&&i.setValue(t,m,{shouldDirty:!1,shouldValidate:!1})},[m,t,i,v]);const b=(k,N)=>{if(n)return;const g={...m,[k]:N};if(v){p&&p(g);return}i&&(i.setValue(t,g,{shouldDirty:!0,shouldValidate:!0}),i.setValue(k,N?"on":"",{shouldValidate:!1}))},A=v?null:(C=(I=i==null?void 0:i.formState)==null?void 0:I.errors)==null?void 0:C[t];return e.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[u&&e.jsx("label",{children:u}),e.jsx("div",{className:`checkbox-group-custom ${n?"readOnly":""}`,children:l.map(k=>{const N=String(k[f]),g=m[N]===!0;return e.jsxs("div",{children:[!v&&i&&e.jsx("input",{type:"hidden",...i.register(N)}),e.jsxs("label",{className:`custom-checkbox ${g?"checked":""} ${n?"readOnly":""}`,children:[e.jsx("input",{type:"checkbox",checked:g,disabled:n,onChange:$=>b(N,$.target.checked)}),e.jsx("span",{className:"checkmark"}),e.jsx("span",{children:k[c]})]})]},N)})}),A&&e.jsx("p",{className:"text-danger",children:String(A.message)})]})}function ae({name:t,label:l="",options:u=[],valueKey:f="value",labelKey:c="label",iconKey:a="icon",forceReadOnly:h=!1,forceHidden:d=!1,valueManual:p,onChangeManual:i,errorManual:v}){var I,C;const O=p!==void 0&&!!i,{isReadOnly:S,isHidden:V}=L.useSection(),j=h||!!S(t),R=d||!!V(t),{isView:F,isReadOnly:w}=L.useFluigRuntime();let y=null;try{y=B.useFormContext()}catch{}const n=!O&&y?B.useController({name:t,control:y.control,defaultValue:""}):null,r=!O&&y?B.useFormState({name:t}):null,s=O?v:(C=(I=r==null?void 0:r.errors)==null?void 0:I[t])==null?void 0:C.message,m=j||w||F,b=O?p:(n==null?void 0:n.field.value)??"",A=o.useCallback(k=>{m||(O?i==null||i(k):(n==null||n.field.onChange(k),n==null||n.field.onBlur()))},[m,O,i,n]);return e.jsxs("div",{className:`form-group column ${R?"hidden":""}`,children:[l&&e.jsx("label",{className:"control-label",children:l}),e.jsx("div",{className:`btn-group ${m?"view-mode":""}`,"data-field-name":t,children:u.map(k=>{const N=k[f],g=b===N,$=k.color?{"--customColor":k.color}:void 0;return e.jsxs("div",{style:$,className:`btn fs-ellipsis ${g?"active":""}`,onClick:()=>A(N),children:[k[a]&&e.jsx("i",{className:`${k[a]} icon-sm`})," ",k[c]]},N)})}),!O&&e.jsx("input",{type:"hidden",name:t,value:b||"",ref:n==null?void 0:n.field.ref}),(s||v)&&e.jsx("p",{className:"text-danger",children:String(s??v)})]})}const ue=o.memo(ae),fe=({name:t,label:l="",placeholder:u="",className:f="",rows:c=4,maxLength:a,forceReadOnly:h=!1,forceHidden:d=!1,valueManual:p,onChangeManual:i,errorManual:v})=>{var m;const O=p!==void 0&&!!i,{isReadOnly:S,isHidden:V}=L.useSection(),j=h||!!S(t),R=d||!!V(t),{isView:F}=L.useFluigRuntime(),w=o.useRef(null);let y={value:p??"",onChange:b=>i==null?void 0:i(b)},n=null;if(!O)try{const{control:b}=B.useFormContext(),A=B.useController({name:t,control:b});y=A.field,n=(m=A.fieldState)==null?void 0:m.error}catch{}const r=()=>{w.current&&(w.current.style.height="auto",w.current.style.height=`${w.current.scrollHeight}px`)};if(o.useEffect(()=>{r()},[y.value]),F)return e.jsxs("div",{className:`form-group ${R?"hidden":""}`,children:[e.jsx("label",{children:l}),e.jsx("span",{className:"form-control",children:y.value||"-"})]});const s=`form-control ${j?"readOnly":""} ${n||v?"border-red":""} ${f}`;return e.jsxs("div",{className:`form-group ${R?"hidden":""}`,children:[l&&e.jsx("label",{children:l}),e.jsx("textarea",{ref:w,rows:c,maxLength:a,value:y.value||"",placeholder:u,readOnly:j,className:s,style:{resize:"none",maxHeight:"400px",overflowY:"auto"},onChange:b=>{O?i==null||i(b.target.value):y.onChange(b)},onInput:r}),(n||v)&&e.jsx("p",{className:"text-danger",children:String((n==null?void 0:n.message)??v)})]})},me=o.memo(fe);/**
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);/**
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 ee=(...t)=>t.filter((l,u,f)=>!!l&&l.trim()!==""&&f.indexOf(l)===u).join(" ").trim();/**
6
+ */const te=(...t)=>t.filter((n,f,m)=>!!n&&n.trim()!==""&&m.indexOf(n)===f).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,(l,u,f)=>f?f.toUpperCase():u.toLowerCase());/**
16
+ */const xe=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,f,m)=>m?m.toUpperCase():f.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 Z=t=>{const l=xe(t);return l.charAt(0).toUpperCase()+l.slice(1)};/**
21
+ */const X=t=>{const n=xe(t);return n.charAt(0).toUpperCase()+n.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 l in t)if(l.startsWith("aria-")||l==="role"||l==="title")return!0;return!1};/**
31
+ */const ve=t=>{for(const n in t)if(n.startsWith("aria-")||n==="role"||n==="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:l=24,strokeWidth:u=2,absoluteStrokeWidth:f,className:c="",children:a,iconNode:h,...d},p)=>o.createElement("svg",{ref:p,...pe,width:l,height:l,stroke:t,strokeWidth:f?Number(u)*24/Number(l):u,className:ee("lucide",c),...!a&&!ve(d)&&{"aria-hidden":"true"},...d},[...h.map(([i,v])=>o.createElement(i,v)),...Array.isArray(a)?a:[a]]));/**
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]]));/**
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 G=(t,l)=>{const u=o.forwardRef(({className:f,...c},a)=>o.createElement(je,{ref:a,iconNode:l,className:ee(`lucide-${he(Z(t))}`,`lucide-${t}`,f),...c}));return u.displayName=Z(t),u};/**
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};/**
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"}]],be=G("calendar",ye);/**
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);/**
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 ge=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ne=G("chevron-left",ge);/**
51
+ */const be=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ne=Z("chevron-left",be);/**
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=G("chevron-right",ke),te="dd/MM/yyyy",X=t=>{if(!t)return null;const l=H.parse(t,te,new Date);return H.isValid(l)?l:null},Se=t=>t?H.format(t,te):"",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"}],K=1940,_e=2100,Oe=Array.from({length:_e-K+1},(t,l)=>{const u=K+l;return{value:u,label:String(u)}});function $e({name:t,label:l="",placeholder:u="dd/mm/aaaa",className:f="",forceReadOnly:c=!1,forceHidden:a=!1,valueManual:h,onChangeManual:d,errorManual:p}){var $;const i=h!==void 0&&!!d,{isReadOnly:v,isHidden:O}=L.useSection(),S=c||!!v(t),V=a||!!O(t),{isView:j}=L.useFluigRuntime();let R="",F=()=>{},w,y=null,n=()=>{};if(i)R=h;else try{const x=B.useFormContext(),E=B.useController({name:t,control:x.control});R=E.field.value,F=E.field.onChange,w=E.field.ref,y=($=E.fieldState)==null?void 0:$.error,n=x.clearErrors}catch{}const[r,s]=o.useState(!1),[m,b]=o.useState(new Date),A=o.useRef(null);o.useEffect(()=>{if(r){const x=X(R);b(x&&H.isValid(x)?x:new Date)}},[r,R]),o.useEffect(()=>{const x=E=>{A.current&&!A.current.contains(E.target)&&s(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const I=o.useMemo(()=>X(R),[R]),C=x=>{if(S)return;const E=Se(x);i?d==null||d(E):(F(E),n==null||n(t)),s(!1)},k=o.useMemo(()=>H.eachDayOfInterval({start:H.startOfWeek(H.startOfMonth(m)),end:H.endOfWeek(H.endOfMonth(m))}),[m]),N=m.getMonth(),g=H.getYear(m);return e.jsxs("div",{className:`dfe-datepicker-wrapper form-group ${V?"hidden":""} ${f}`,ref:A,children:[e.jsx("label",{className:"control-label",children:l}),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 ${y?"border-red":""} ${S?"readOnly":""}`,onClick:()=>!S&&s(x=>!x),ref:w,children:[e.jsx("span",{className:`dfe-datepicker-display ${S?"readOnly":""}`,children:R||u}),e.jsx(be,{size:16,className:"dfe-datepicker-icon"})]}),r&&!S&&e.jsxs("div",{className:"dfe-datepicker-dropdown",onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"dfe-datepicker-header",children:[e.jsx("button",{type:"button",onClick:()=>b(H.subMonths(m,1)),className:"dfe-datepicker-nav-btn",children:e.jsx(Ne,{size:16})}),e.jsxs("div",{className:"dfe-datepicker-selectors",children:[e.jsx(z,{name:"datepicker_internal_month",valueManual:N,onChangeManual:x=>b(H.setMonth(m,Number(x))),options:Re,placeholder:"Mês"}),e.jsx(z,{name:"datepicker_internal_year",valueManual:g,onChangeManual:x=>b(H.setYear(m,Number(x))),options:Oe,enableSearch:!0,searchPlaceholder:"Buscar ano...",placeholder:"Ano"})]}),e.jsx("button",{type:"button",onClick:()=>b(H.addMonths(m,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((x,E)=>e.jsx("span",{children:x},E))}),e.jsx("div",{className:"dfe-datepicker-grid",children:k.map((x,E)=>{const T=!H.isSameMonth(x,m),U=I&&H.isSameDay(x,I);return e.jsx("div",{onClick:()=>!T&&C(x),className:`dfe-datepicker-day
57
- ${U?"selected":"handleHover"}
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
58
  ${T?"outside":""}
59
- ${H.isToday(x)?"today":""}`,children:H.format(x,"d")},E)})})]})]}),!i&&e.jsx("input",{type:"hidden",name:t,value:R||""}),(y||p)&&e.jsx("p",{className:"text-danger",children:String((y==null?void 0:y.message)??p)})]})}const Ae=o.memo($e);function Ce({mapping:t={},defaultLabel:l="Não reconhecido",className:u="",hidden:f=!1,label:c}){const{activityId:a}=L.useFluigRuntime(),h=o.useMemo(()=>!t||a===null||a===void 0?null:t[a],[a,t]);if(!h)return e.jsxs("div",{className:`form-group ${f?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsx("div",{className:`status-badge default ${u}`,children:l})]});const d={"--customColor":h.color};return e.jsxs("div",{className:`form-group ${f?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsxs("div",{className:`status-badge ${u}`,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:l,defaultRowValue:u,isView:f,isReadOnly:c,filters:a=[]}){const{field:h}=B.useController({name:t,control:l}),[d,p]=o.useState([]),[i,v]=o.useState([]),O=()=>Date.now()+Math.random(),S=r=>{try{const s=JSON.parse(r);return Array.isArray(s)?s.map(m=>({...m,_uid:m._uid||O()})):[]}catch(s){return console.error(`Erro ao ler dados da tabela "${t}":`,s),[]}};o.useEffect(()=>{if(!(d.length>0&&!f)&&h.value&&typeof h.value=="string"){const r=JSON.stringify(d);if(h.value===r)return;const s=S(h.value);p(s)}},[h.value,f]),o.useEffect(()=>{if(c)return;const r=JSON.stringify(d);h.value!==r&&h.onChange(r)},[d,h,c]);const V=o.useCallback(()=>{const r={_uid:O(),...u};p(s=>[...s,r])},[u]),j=o.useCallback(()=>{p(r=>r.filter(s=>!i.includes(s._uid))),v([])},[i]),R=o.useCallback((r,s,m)=>{p(b=>b.map(A=>A._uid===r?{...A,[s]:m}:A))},[]),F=o.useCallback(r=>{v(s=>s.includes(r)?s.filter(m=>m!==r):[...s,r])},[]),w=o.useCallback(r=>{v(r?d.map(s=>s._uid):[])},[d]),y=d.length>0&&i.length===d.length,n=o.useMemo(()=>!a||a.length===0?d:d.filter(r=>a.every(s=>{if("custom"in s)return s.custom(r);const m=r[s.field];switch(s.operator){case"===":return m===s.value;case"!==":return m!==s.value;case">":return m>s.value;case"<":return m<s.value;case">=":return m>=s.value;case"<=":return m<=s.value;default:return!0}})),[d,a]);return{field:h,tableRows:d,visibleRows:n,selectedRowIds:i,isAllSelected:y,handle:{addRow:V,removeRows:j,updateCellValue:R,toggleSelection:F,toggleSelectAll:w}}}const Ie=({name:t,title:l="Tabela Dinâmica",columns:u,defaultRowValue:f={},forceReadOnly:c=!1,layout:a="fluid",actions:h=!0,filters:d=[]})=>{const{control:p}=B.useFormContext(),{isView:i,isReadOnly:v}=L.useFluigRuntime(),{isReadOnly:O}=L.useSection(),S=c||i||v||O&&O(t),{field:V,visibleRows:j,selectedRowIds:R,isAllSelected:F,handle:w}=Fe({name:t,control:p,defaultRowValue:f,isView:i,isReadOnly:!!S,filters:d}),y=a==="fixed";return e.jsxs("div",{className:`table-wrapper ${y?"table-fixed":"table-fluid"}`,children:[e.jsx("input",{type:"hidden",...V}),e.jsxs("div",{className:"header-handle",children:[e.jsx("h3",{children:l}),!S&&h&&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:w.removeRows,children:["Remover (",R.length,")"]}),e.jsx("button",{type:"button",className:"btn-add",onClick:w.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:[!S&&e.jsx("th",{style:{width:"50px"},children:e.jsx("input",{type:"checkbox",checked:F,onChange:n=>w.toggleSelectAll(n.target.checked)})}),u.map(n=>e.jsx("th",{style:n.width?{minWidth:y?n.width:"100%"}:{width:"max-content"},children:n.label},String(n.key)))]})}),e.jsxs("tbody",{children:[j.map((n,r)=>e.jsxs("tr",{children:[!S&&e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:R.includes(n._uid),onChange:()=>w.toggleSelection(n._uid)})}),u.map(s=>e.jsx("td",{children:s.render?s.render.length<=1?s.render({row:n,index:r,updateRow:(m,b)=>w.updateCellValue(n._uid,String(m),b),isLocked:!!S,isView:!!i}):s.render(n,r,(m,b)=>w.updateCellValue(n._uid,m,b),!!S,!!i):n[s.key]},`${n._uid}-${String(s.key)}`))]},n._uid)),j.length===0&&e.jsx("tr",{className:"empty-row",children:e.jsx("td",{colSpan:100,className:"text-center",children:S?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},Ve=(t,l)=>{const[u,f]=o.useState(null);let c=null;try{c=B.useFormContext().watch}catch{}const a=l!==void 0?l:c?c(t):void 0,h=o.useCallback(()=>{try{const p=window.top.__REACT_ATTACHMENT_BRIDGE__;if(p){const i=p.getAttachment(t,a);f(i||(a?{name:a,documentId:0}:null))}else f(a?{name:a,documentId:0}:null)}catch{f(a?{name:a,documentId:0}:null)}},[t,a,l]);return o.useEffect(()=>{h();const d=setInterval(h,2e3);return()=>clearInterval(d)},[h]),{attachment:u,sync:h}},De=({name:t,label:l,help:u,valueManual:f,onChangeManual:c,forceReadOnly:a=!1,forceHidden:h=!1,helpText:d,helpTitle:p,helpWidth:i})=>{const v=!!c,{isReadOnly:O,isHidden:S}=L.useSection(),{isView:V}=L.useFluigRuntime(),j=a||V||!!O(t),R=h||!!S(t),[F,w]=o.useState(!1);let y=null;try{y=B.useFormContext().control}catch{}const n=y&&!v?B.useController({name:t,control:y}).field:{value:f,onChange:N=>c==null?void 0:c(N)},{attachment:r,sync:s}=Ve(t,f),m=()=>{var N;try{const g=window.top;return{bridge:g.__REACT_ATTACHMENT_BRIDGE__,toast:(N=g.FLUIGC)==null?void 0:N.toast}}catch{return{bridge:null,toast:null}}},b=o.useCallback(()=>{if(j)return;const N=document.createElement("input");N.type="file",N.onchange=g=>{const $=g.target.files[0];if(!$)return;const{bridge:x,toast:E}=m();w(!0),x?x.upload($,t,T=>{v?c==null||c(T.name):n.onChange(T.name),setTimeout(()=>{w(!1),s()},1e3),E&&E({title:"Sucesso",message:"Arquivo enviado",type:"success"})}):(v?c==null||c($.name):n.onChange($.name),w(!1))},N.click()},[t,n,s,c,j,v]),A=N=>{if(N.stopPropagation(),j)return;const g=(r==null?void 0:r.name)||f||n.value;if(!g)return;const{bridge:$,toast:x}=m();$?$.removeByFileName(g)?(v?c==null||c(""):n.onChange(""),s()):x&&x({title:"Erro",message:"Erro ao remover anexo",type:"danger"}):(v?c==null||c(""):n.onChange(""),s())},I=!!r&&!F,C=(r==null?void 0:r.name)||f||n.value,k=["fluig-attachment__box",I?"fluig-attachment__box--has-file":"",F?"fluig-attachment__box--uploading":"",j&&!I?"readOnly":"",j&&I?"fluig-attachment__box--readonly-view":""].join(" ");return R?null:e.jsxs("div",{className:"form-group fluig-attachment",children:[l&&e.jsx("label",{className:"fluig-attachment__label",children:l}),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=m(),g=(r==null?void 0:r.physicalFileName)||(r==null?void 0:r.description)||(r==null?void 0:r.name)||C;N.bridge&&g&&N.bridge.view(g)}else b()},children:[e.jsxs("span",{className:"fluig-attachment__content",children:[e.jsx("i",{className:`flaticon icon-sm ${F?"flaticon-loading":I?"flaticon-file":"flaticon-paperclip"} fluig-attachment__icon`}),e.jsx("span",{className:"fluig-attachment__filename",children:F?" Enviando...":I?C:j?"Nenhum arquivo":u||"Anexar"})]}),I&&!j&&e.jsx("button",{type:"button",className:"fluig-attachment__btn-remove btn btn-link text-danger",onClick:A,children:e.jsx("i",{className:"flaticon flaticon-trash icon-sm"})})]}),d&&e.jsx(Y,{text:d,title:p,width:i})]}),!v&&y&&e.jsx("input",{type:"hidden",name:t,value:n.value||""})]})},He=o.memo(De);exports.Attachment=He;exports.Checkbox=de;exports.DatePicker=Ae;exports.Help=Y;exports.Input=ce;exports.Modal=M;exports.RadioBtn=ue;exports.Select=z;exports.SimpleTable=Ie;exports.StatusBadge=Ee;exports.TextArea=me;
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;