diefra_ecm_ui 1.2.6 → 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/index.cjs +11 -21
- package/dist/index.js +598 -602
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),P=require("react-hook-form"),le=require("react-imask"),q=require("@fluig-kit/ecm"),oe=require("react-dom"),T=require("date-fns");function ne({title:t,isOpen:c,onOpen:p,onClose:u,content:d,footer:a,width:x}){const i=r.useMemo(()=>{try{return window.top&&window.top.document?window.top.document:document}catch{return document}},[]),g=r.useCallback(s=>{s.key==="Escape"&&u()},[u]);return r.useEffect(()=>(c&&(i.addEventListener("keydown",g),p==null||p(),i.body.style.overflow="hidden"),()=>{i.removeEventListener("keydown",g),i.body.style.overflow="auto"}),[c,g,p,i]),r.useEffect(()=>{if(!c||i===document)return;const s="dfe-modal-global-styles";if(!i.getElementById(s)){const h=i.createElement("style");h.id=s,h.innerHTML=`
|
|
2
|
-
.modal-overlay { width: 100vw; height: 100vh; background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); position: fixed; top: 0; left: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
|
|
3
|
-
.modal-container { width: 100%; max-width: 90%; background-color: var(--dfe-bg, #ffffff); color: var(--dfe-fg, #333333); border-radius: var(--dfe-radius, 8px); overflow: hidden; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
|
|
4
|
-
.modal-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--dfe-border, #e5e5e5) !important; padding: 16px !important; }
|
|
5
|
-
.modal-header h3 { font-weight: 600; font-size: 18px !important; margin: 0 !important; color: var(--dfe-fg, #333333); }
|
|
6
|
-
.modal-header .btn-close-modal { background-color: var(--dfe-muted, #f5f5f5); color: var(--dfe-fg, #333333); display: flex; align-items: center; justify-content: center; padding: 4px; font-size: 14px !important; border-radius: var(--dfe-radius-sm, 4px); cursor: pointer; border: 1px solid var(--dfe-border, #e5e5e5); transition: opacity 0.2s ease; }
|
|
7
|
-
.modal-header .btn-close-modal:hover { opacity: 0.8; }
|
|
8
|
-
.modal-content { background-color: transparent !important; color: var(--dfe-fg, #333333) !important; border-radius: 0 !important; border: none !important; box-shadow: none !important; padding: var(--dfe-gap-lg, 16px) !important; max-height: 80vh; overflow-x: hidden; overflow-y: auto; }
|
|
9
|
-
.modal-footer { border: none !important; padding: 16px !important; }
|
|
10
|
-
.modal-footer .btn { height: 34px !important; font-size: 14px !important; }
|
|
11
|
-
`,i.head.appendChild(h)}},[c,i]),c?oe.createPortal(e.jsx("div",{className:"modal-overlay",onClick:u,"aria-modal":"true",role:"dialog",children:e.jsxs("div",{style:{maxWidth:x},className:"modal-container",onClick:s=>s.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})]})}),i.body):null}function de({text:t,title:c="Ajuda & Informações",width:p="500px",className:u=""}){const[d,a]=r.useState(!1),x=i=>{i.preventDefault(),i.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(ne,{title:c,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=r.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:c="",placeholder:p="",type:u="text",mask:d,className:a="",forceReadOnly:x=!1,forceHidden:i=!1,prefix:g,suffix:s,helpText:h,helpTitle:_,helpWidth:A,valueManual:L,onChangeManual:v,errorManual:F}){var G,Q;const R=L!==void 0&&!!v,{isReadOnly:$,isHidden:S}=q.useSection(),n=x||!!$(t),l=i||!!S(t),{isView:o}=q.useFluigRuntime();let f=null;try{f=P.useFormContext()}catch{}const m=!R&&f?P.useController({name:t,control:f.control}):null,E=!R&&f?P.useFormState({name:t}):null,I=R?L:m==null?void 0:m.field.value,C=R?F:(Q=(G=E==null?void 0:E.errors)==null?void 0:G[t])==null?void 0:Q.message,w=r.useMemo(()=>d?ae[d]??d:null,[d]),k=r.useCallback(B=>{if(B===""||B===null||B===void 0)return"";let O=String(B);if(u==="monetary"){const H=Number(B);return isNaN(H)?"":H.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})}if(u==="number"){O=O.replace(".",",");const H=O.split(",");H[0]=H[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),O=H.join(",")}return g&&(O=`${g}${O}`),s&&(O=`${O}${s}`),O},[g,s,u]),b=r.useMemo(()=>k(I),[I,k]),V=B=>{let O=B.target.value;const H=b,X=`${g||""}${s||""}`;if(!O||O===g||O===s||O===X){R?v==null||v(""):m==null||m.field.onChange("");return}if(s&&O.length>H.length&&H&&O.startsWith(H)){const N=O.slice(H.length);O=String(I||"")+N}g&&O.length>H.length&&H&&O.endsWith(H)&&(O=O.slice(0,O.length-H.length)+String(I||""));let D=O;if(s&&D.endsWith(s)&&(D=D.slice(0,-s.length)),g&&D.startsWith(g)&&(D=D.slice(g.length)),u==="monetary"){const N=D.replace(/\D/g,"");D=N?(Number(N)/100).toFixed(2):""}else u==="number"&&(D=D.replace(/[^\d.,-]/g,""),D=D.replace(/\./g,"").replace(",","."));O.length<H.length&&D===String(I||"")&&D.length>0&&(D=D.slice(0,-1)),R?v==null||v(D):m==null||m.field.onChange(D)},z=()=>{R||m==null||m.field.onBlur()};if(l)return null;const U=`form-control ${n?"readOnly":""} ${C?"border-red":""} ${a}`,J=()=>w?e.jsx(le.IMaskInput,{mask:w,value:b,unmask:!0,onAccept:B=>{R?v==null||v(B):m==null||m.field.onChange(B)},placeholder:p,readOnly:n,className:U,inputRef:R||m==null?void 0:m.field.ref,onBlur:z}):e.jsx("input",{type:"text",inputMode:u==="number"||u==="monetary"?"numeric":void 0,value:b,onChange:V,onBlur:z,placeholder:p,readOnly:n,className:U});return o?e.jsxs("div",{className:"form-group",children:[c&&e.jsx("label",{children:c}),e.jsxs("div",{className:h?"dfe-flex-input-wrapper":"",children:[e.jsx("span",{className:U,children:b||"-"}),h&&e.jsx(Z,{text:h,title:_,width:A})]})]}):e.jsxs("div",{className:`form-group ${l?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsxs("div",{className:h?"dfe-flex-input-wrapper":"",children:[J(),h&&e.jsx(Z,{text:h,title:_,width:A})]}),!R&&e.jsx("input",{type:"hidden",name:t,value:I||""}),C&&e.jsx("p",{className:"text-danger",children:String(C)})]})}const fe=r.memo(ue);function me({name:t,label:c="",options:p=[],placeholder:u="",labelKey:d="label",valueKey:a="value",enableSearch:x=!1,searchPlaceholder:i="Buscar...",loading:g=!1,onSearchChange:s,debounceTime:h=300,onSelect:_,forceReadOnly:A=!1,forceHidden:L=!1,helpText:v,helpTitle:F,helpWidth:R,valueManual:$,onChangeManual:S,errorManual:n}){var D;const l=$!==void 0&&!!S,{isReadOnly:o,isHidden:f}=q.useSection(),m=A||!!o(t),E=L||!!f(t),{isView:I}=q.useFluigRuntime();let C="",w=()=>{},k,b=null,V=()=>{};if(l)C=$;else try{const N=P.useFormContext(),Y=P.useController({name:t,control:N.control});C=Y.field.value,w=Y.field.onChange,k=Y.field.ref,b=(D=Y.fieldState)==null?void 0:D.error,V=N.clearErrors}catch{}const[z,U]=r.useState(!1),[J,G]=r.useState(""),Q=r.useRef(null),B=r.useRef(s);r.useEffect(()=>{B.current=s},[s]),r.useEffect(()=>{const N=Y=>{Q.current&&!Q.current.contains(Y.target)&&U(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),r.useEffect(()=>{z||G("")},[z]),r.useEffect(()=>{if(!x)return;const N=setTimeout(()=>{var Y;(Y=B.current)==null||Y.call(B,J)},h);return()=>clearTimeout(N)},[J,x,h]);const O=r.useMemo(()=>x&&!s&&J.trim()?p.filter(N=>String((N==null?void 0:N[d])??"").toLowerCase().includes(J.toLowerCase())):p??[],[p,x,s,J,d]),H=r.useMemo(()=>{if(C==null)return"";if(typeof C=="object")return String(C[a]??"");const N=(p||[]).find(Y=>String(Y==null?void 0:Y[a])===String(C));return String(N?(N==null?void 0:N[d])??"":C)},[C,p,a,d]),X=N=>{m||(l?S==null||S(N[a]):(w(N[a]),V==null||V(t)),_==null||_(N),U(!1))};return E?null:e.jsxs("div",{className:`select-wrapper form-group ${E?"hidden":""}`,ref:Q,children:[e.jsx("label",{className:"control-label",children:c}),I?e.jsxs("div",{className:v?"dfe-flex-input-wrapper":"",children:[e.jsx("span",{className:"form-control",style:v?{flex:1}:void 0,children:H||"-"}),v&&e.jsx(Z,{text:v,title:F,width:R})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:v?"dfe-flex-input-wrapper":"",children:[e.jsxs("div",{className:`select-control ${b?"border-red":""} ${m?"readOnly":""}`,onClick:()=>!m&&U(N=>!N),ref:k,style:v?{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"})]}),v&&e.jsx(Z,{text:v,title:F,width:R})]}),z&&!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...":i,autoFocus:!0,onClick:N=>N.stopPropagation()})}),e.jsx("ul",{className:"select-options",children:g?e.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):O.length>0?O.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:C||""}),(b||n)&&e.jsx("p",{className:"text-danger",children:String((b==null?void 0:b.message)??n)})]})}const he=r.memo(me);function pe({name:t,options:c=[],label:p="",valueKey:u="value",labelKey:d="label",forceReadOnly:a=!1,forceHidden:x=!1,valueManual:i,onChangeManual:g}){var I,C;let s=null;try{s=P.useFormContext()}catch{}const h=i!==void 0&&!!g,{isView:_,isReadOnly:A}=q.useFluigRuntime(),{isReadOnly:L,isHidden:v}=q.useSection(),F=L?L(t):!1,R=v?v(t):!1,$=a||F,S=x||R,n=$||A||_,l=()=>c?c.reduce((w,k)=>{const b=String(k[u]);if(h)w[b]=!!(i!=null&&i[b]);else if(s){const V=s.getValues(b);w[b]=V==="on"}else w[b]=!1;return w},{}):{},o=!h&&s?s.watch(t):void 0,f=r.useMemo(()=>h&&i?i:o&&typeof o=="object"?o:l(),[o,i,c]);r.useEffect(()=>{if(h||!s)return;const w=s.getValues(t);(!w||typeof w!="object")&&s.setValue(t,f,{shouldDirty:!1,shouldValidate:!1})},[f,t,s,h]);const m=(w,k)=>{if(n)return;const b={...f,[w]:k};if(h){g&&g(b);return}s&&(s.setValue(t,b,{shouldDirty:!0,shouldValidate:!0}),s.setValue(w,k?"on":"",{shouldValidate:!1}))},E=h?null:(C=(I=s==null?void 0:s.formState)==null?void 0:I.errors)==null?void 0:C[t];return e.jsxs("div",{className:`form-group ${S?"hidden":""}`,children:[p&&e.jsx("label",{children:p}),e.jsx("div",{className:`checkbox-group-custom ${n?"readOnly":""}`,children:c.map(w=>{const k=String(w[u]),b=f[k]===!0;return e.jsxs("div",{children:[!h&&s&&e.jsx("input",{type:"hidden",...s.register(k)}),e.jsxs("label",{className:`custom-checkbox ${b?"checked":""} ${n?"readOnly":""}`,children:[e.jsx("input",{type:"checkbox",checked:b,disabled:n,onChange:V=>m(k,V.target.checked)}),e.jsx("span",{className:"checkmark"}),e.jsx("span",{children:w[d]})]})]},k)})}),E&&e.jsx("p",{className:"text-danger",children:String(E.message)})]})}function xe({name:t,label:c="",options:p=[],valueKey:u="value",labelKey:d="label",iconKey:a="icon",forceReadOnly:x=!1,forceHidden:i=!1,valueManual:g,onChangeManual:s,errorManual:h}){var I,C;const _=g!==void 0&&!!s,{isReadOnly:A,isHidden:L}=q.useSection(),v=x||!!A(t),F=i||!!L(t),{isView:R,isReadOnly:$}=q.useFluigRuntime();let S=null;try{S=P.useFormContext()}catch{}const n=!_&&S?P.useController({name:t,control:S.control,defaultValue:""}):null,l=!_&&S?P.useFormState({name:t}):null,o=_?h:(C=(I=l==null?void 0:l.errors)==null?void 0:I[t])==null?void 0:C.message,f=v||$||R,m=_?g:(n==null?void 0:n.field.value)??"",E=r.useCallback(w=>{f||(_?s==null||s(w):(n==null||n.field.onChange(w),n==null||n.field.onBlur()))},[f,_,s,n]);return e.jsxs("div",{className:`form-group column ${F?"hidden":""}`,children:[c&&e.jsx("label",{className:"control-label",children:c}),e.jsx("div",{className:`btn-group ${f?"view-mode":""}`,"data-field-name":t,children:p.map(w=>{const k=w[u],b=m===k,V=w.color?{"--customColor":w.color}:void 0;return e.jsxs("div",{style:V,className:`btn fs-ellipsis ${b?"active":""}`,onClick:()=>E(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:n==null?void 0:n.field.ref}),(o||h)&&e.jsx("p",{className:"text-danger",children:String(o??h)})]})}const ge=r.memo(xe),ve=({name:t,label:c="",placeholder:p="",className:u="",rows:d=4,maxLength:a,forceReadOnly:x=!1,forceHidden:i=!1,valueManual:g,onChangeManual:s,errorManual:h})=>{var f;const _=g!==void 0&&!!s,{isReadOnly:A,isHidden:L}=q.useSection(),v=x||!!A(t),F=i||!!L(t),{isView:R}=q.useFluigRuntime(),$=r.useRef(null);let S={value:g??"",onChange:m=>s==null?void 0:s(m)},n=null;if(!_)try{const{control:m}=P.useFormContext(),E=P.useController({name:t,control:m});S=E.field,n=(f=E.fieldState)==null?void 0:f.error}catch{}const l=()=>{$.current&&($.current.style.height="auto",$.current.style.height=`${$.current.scrollHeight}px`)};if(r.useEffect(()=>{l()},[S.value]),R)return e.jsxs("div",{className:`form-group ${F?"hidden":""}`,children:[e.jsx("label",{children:c}),e.jsx("span",{className:"form-control",children:S.value||"-"})]});const o=`form-control ${v?"readOnly":""} ${n||h?"border-red":""} ${u}`;return e.jsxs("div",{className:`form-group ${F?"hidden":""}`,children:[c&&e.jsx("label",{children:c}),e.jsx("textarea",{ref:$,rows:d,maxLength:a,value:S.value||"",placeholder:p,readOnly:v,className:o,style:{resize:"none",maxHeight:"400px",overflowY:"auto"},onChange:m=>{_?s==null||s(m.target.value):S.onChange(m)},onInput:l}),(n||h)&&e.jsx("p",{className:"text-danger",children:String((n==null?void 0:n.message)??h)})]})},be=r.memo(ve);/**
|
|
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);/**
|
|
12
2
|
* @license lucide-react v0.575.0 - ISC
|
|
13
3
|
*
|
|
14
4
|
* This source code is licensed under the ISC license.
|
|
15
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
6
|
+
*/const ce=(...t)=>t.filter((i,p,u)=>!!i&&i.trim()!==""&&u.indexOf(i)===p).join(" ").trim();/**
|
|
17
7
|
* @license lucide-react v0.575.0 - ISC
|
|
18
8
|
*
|
|
19
9
|
* This source code is licensed under the ISC license.
|
|
20
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
11
|
+
*/const ye=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
22
12
|
* @license lucide-react v0.575.0 - ISC
|
|
23
13
|
*
|
|
24
14
|
* This source code is licensed under the ISC license.
|
|
25
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
16
|
+
*/const be=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(i,p,u)=>u?u.toUpperCase():p.toLowerCase());/**
|
|
27
17
|
* @license lucide-react v0.575.0 - ISC
|
|
28
18
|
*
|
|
29
19
|
* This source code is licensed under the ISC license.
|
|
30
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const te=t=>{const
|
|
21
|
+
*/const te=t=>{const i=be(t);return i.charAt(0).toUpperCase()+i.slice(1)};/**
|
|
32
22
|
* @license lucide-react v0.575.0 - ISC
|
|
33
23
|
*
|
|
34
24
|
* This source code is licensed under the ISC license.
|
|
@@ -38,17 +28,17 @@
|
|
|
38
28
|
*
|
|
39
29
|
* This source code is licensed under the ISC license.
|
|
40
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const ke=t=>{for(const
|
|
31
|
+
*/const ke=t=>{for(const i in t)if(i.startsWith("aria-")||i==="role"||i==="title")return!0;return!1};/**
|
|
42
32
|
* @license lucide-react v0.575.0 - ISC
|
|
43
33
|
*
|
|
44
34
|
* This source code is licensed under the ISC license.
|
|
45
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const we=
|
|
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]]));/**
|
|
47
37
|
* @license lucide-react v0.575.0 - ISC
|
|
48
38
|
*
|
|
49
39
|
* This source code is licensed under the ISC license.
|
|
50
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const M=(t,
|
|
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};/**
|
|
52
42
|
* @license lucide-react v0.575.0 - ISC
|
|
53
43
|
*
|
|
54
44
|
* This source code is licensed under the ISC license.
|
|
@@ -63,12 +53,12 @@
|
|
|
63
53
|
*
|
|
64
54
|
* This source code is licensed under the ISC license.
|
|
65
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
56
|
+
*/const _e=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Oe=M("chevron-left",_e);/**
|
|
67
57
|
* @license lucide-react v0.575.0 - ISC
|
|
68
58
|
*
|
|
69
59
|
* This source code is licensed under the ISC license.
|
|
70
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const
|
|
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
|
|
72
62
|
${K?"selected":"handleHover"}
|
|
73
63
|
${W?"outside":""}
|
|
74
|
-
${T.isToday(
|
|
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;
|