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