diefra_ecm_ui 1.2.5 → 1.2.6
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 +25 -15
- package/dist/index.js +678 -645
- 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,9 +1,19 @@
|
|
|
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"),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);/**
|
|
2
12
|
* @license lucide-react v0.575.0 - ISC
|
|
3
13
|
*
|
|
4
14
|
* This source code is licensed under the ISC license.
|
|
5
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
16
|
+
*/const ie=(...t)=>t.filter((c,p,u)=>!!c&&c.trim()!==""&&u.indexOf(c)===p).join(" ").trim();/**
|
|
7
17
|
* @license lucide-react v0.575.0 - ISC
|
|
8
18
|
*
|
|
9
19
|
* This source code is licensed under the ISC license.
|
|
@@ -13,52 +23,52 @@
|
|
|
13
23
|
*
|
|
14
24
|
* This source code is licensed under the ISC license.
|
|
15
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
26
|
+
*/const ye=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(c,p,u)=>u?u.toUpperCase():p.toLowerCase());/**
|
|
17
27
|
* @license lucide-react v0.575.0 - ISC
|
|
18
28
|
*
|
|
19
29
|
* This source code is licensed under the ISC license.
|
|
20
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
31
|
+
*/const te=t=>{const c=ye(t);return c.charAt(0).toUpperCase()+c.slice(1)};/**
|
|
22
32
|
* @license lucide-react v0.575.0 - ISC
|
|
23
33
|
*
|
|
24
34
|
* This source code is licensed under the ISC license.
|
|
25
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/var
|
|
36
|
+
*/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
37
|
* @license lucide-react v0.575.0 - ISC
|
|
28
38
|
*
|
|
29
39
|
* This source code is licensed under the ISC license.
|
|
30
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
41
|
+
*/const ke=t=>{for(const c in t)if(c.startsWith("aria-")||c==="role"||c==="title")return!0;return!1};/**
|
|
32
42
|
* @license lucide-react v0.575.0 - ISC
|
|
33
43
|
*
|
|
34
44
|
* This source code is licensed under the ISC license.
|
|
35
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
46
|
+
*/const we=r.forwardRef(({color:t="currentColor",size:c=24,strokeWidth:p=2,absoluteStrokeWidth:u,className:d="",children:a,iconNode:x,...i},g)=>r.createElement("svg",{ref:g,...Ne,width:c,height:c,stroke:t,strokeWidth:u?Number(p)*24/Number(c):p,className:ie("lucide",d),...!a&&!ke(i)&&{"aria-hidden":"true"},...i},[...x.map(([s,h])=>r.createElement(s,h)),...Array.isArray(a)?a:[a]]));/**
|
|
37
47
|
* @license lucide-react v0.575.0 - ISC
|
|
38
48
|
*
|
|
39
49
|
* This source code is licensed under the ISC license.
|
|
40
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
51
|
+
*/const M=(t,c)=>{const p=r.forwardRef(({className:u,...d},a)=>r.createElement(we,{ref:a,iconNode:c,className:ie(`lucide-${je(te(t))}`,`lucide-${t}`,u),...d}));return p.displayName=te(t),p};/**
|
|
42
52
|
* @license lucide-react v0.575.0 - ISC
|
|
43
53
|
*
|
|
44
54
|
* This source code is licensed under the ISC license.
|
|
45
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
56
|
+
*/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
57
|
* @license lucide-react v0.575.0 - ISC
|
|
48
58
|
*
|
|
49
59
|
* This source code is licensed under the ISC license.
|
|
50
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
61
|
+
*/const $e=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],se=M("chevron-down",$e);/**
|
|
52
62
|
* @license lucide-react v0.575.0 - ISC
|
|
53
63
|
*
|
|
54
64
|
* This source code is licensed under the ISC license.
|
|
55
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
66
|
+
*/const Oe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],_e=M("chevron-left",Oe);/**
|
|
57
67
|
* @license lucide-react v0.575.0 - ISC
|
|
58
68
|
*
|
|
59
69
|
* This source code is licensed under the ISC license.
|
|
60
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
62
|
-
${
|
|
63
|
-
${
|
|
64
|
-
${
|
|
71
|
+
*/const Ae=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ee=M("chevron-right",Ae),ce="dd/MM/yyyy",ee=t=>{if(!t)return null;const c=T.parse(t,ce,new Date);return T.isValid(c)?c:null},Ce=t=>t?T.format(t,ce):"",re=["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"];function Fe({name:t,label:c="",placeholder:p="dd/mm/aaaa",className:u="",forceReadOnly:d=!1,forceHidden:a=!1,valueManual:x,onChangeManual:i,errorManual:g}){var Y;const s=x!==void 0&&!!i,{isReadOnly:h,isHidden:_}=q.useSection(),A=d||!!h(t),L=a||!!_(t),{isView:v}=q.useFluigRuntime();let F="",R=()=>{},$,S=null,n=()=>{};if(s)F=x;else try{const j=P.useFormContext(),y=P.useController({name:t,control:j.control});F=y.field.value,R=y.field.onChange,$=y.field.ref,S=(Y=y.fieldState)==null?void 0:Y.error,n=j.clearErrors}catch{}const[l,o]=r.useState(!1),[f,m]=r.useState(new Date),[E,I]=r.useState(F||""),[C,w]=r.useState(!1),[k,b]=r.useState(!1),V=r.useRef(null),z=r.useRef(null),U=r.useRef(null),J=r.useRef(null),G=r.useRef(null);r.useEffect(()=>{I(F||"")},[F]),r.useEffect(()=>{if(l){const j=ee(E);m(j&&T.isValid(j)?j:new Date),w(!1),b(!1)}},[l,E]),r.useEffect(()=>{const j=y=>{V.current&&!V.current.contains(y.target)&&(o(!1),w(!1),b(!1))};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]),r.useEffect(()=>{if(C&&z.current&&J.current){const j=J.current,y=z.current;j.scrollTop=y.offsetTop-j.clientHeight/2+y.clientHeight/2}},[C]),r.useEffect(()=>{if(k&&U.current&&G.current){const j=G.current,y=U.current;j.scrollTop=y.offsetTop-j.clientHeight/2+y.clientHeight/2}},[k]);const Q=r.useMemo(()=>{const j=new Date().getFullYear();return Array.from({length:101},(y,W)=>j-50+W)},[]),B=r.useMemo(()=>ee(E),[E]),O=j=>{if(A)return;const y=Ce(j);I(y),s?i==null||i(y):(R(y),n==null||n(t)),o(!1)},H=j=>{let y=j.target.value.replace(/\D/g,"");y.length>8&&(y=y.slice(0,8));let W=y;if(y.length>4?W=`${y.slice(0,2)}/${y.slice(2,4)}/${y.slice(4)}`:y.length>2&&(W=`${y.slice(0,2)}/${y.slice(2)}`),I(W),W.length===10||W===""){s?i==null||i(W):(R(W),n==null||n(t));const K=ee(W);K&&T.isValid(K)&&m(K)}},X=r.useMemo(()=>T.eachDayOfInterval({start:T.startOfWeek(T.startOfMonth(f)),end:T.endOfWeek(T.endOfMonth(f))}),[f]),D=f.getMonth(),N=T.getYear(f);return e.jsxs("div",{className:`dfe-datepicker-wrapper form-group ${L?"hidden":""} ${u}`,ref:V,children:[e.jsx("label",{className:"control-label",children:c}),v?e.jsx("span",{className:"form-control",children:E||"-"}):e.jsxs("div",{className:"dfe-datepicker-inner-container",children:[e.jsxs("div",{className:`dfe-datepicker-input-group ${S?"border-red":""} ${A?"readOnly":""}`,children:[e.jsx("input",{type:"text",className:"dfe-datepicker-input",value:E,onChange:H,placeholder:p,readOnly:A,ref:$,maxLength:10}),e.jsx("button",{type:"button",className:"dfe-datepicker-trigger-btn",onClick:()=>!A&&o(j=>!j),disabled:A,tabIndex:-1,children:e.jsx(Re,{size:16,className:"dfe-datepicker-icon"})})]}),l&&!A&&e.jsxs("div",{className:"dfe-datepicker-dropdown",onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:"dfe-datepicker-header",children:[e.jsx("button",{type:"button",onClick:()=>m(T.subMonths(f,1)),className:"dfe-datepicker-nav-btn",children:e.jsx(_e,{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:()=>{b(!k),w(!1)},children:[re[D]," ",e.jsx(se,{size:14})]}),k&&e.jsx("div",{className:"dfe-datepicker-listbox",ref:G,children:re.map((j,y)=>{const W=D===y;return e.jsx("button",{type:"button",ref:W?U:null,className:`dfe-datepicker-listbox-item ${W?"selected":""}`,onClick:()=>{m(T.setMonth(f,y)),b(!1)},children:j},y)})})]}),e.jsxs("div",{className:"dfe-datepicker-selector-wrapper",children:[e.jsxs("button",{type:"button",className:"dfe-datepicker-selector-btn",onClick:()=>{w(!C),b(!1)},children:[N," ",e.jsx(se,{size:14})]}),C&&e.jsx("div",{className:"dfe-datepicker-listbox",ref:J,children:Q.map(j=>{const y=N===j;return e.jsx("button",{type:"button",ref:y?z:null,className:`dfe-datepicker-listbox-item ${y?"selected":""}`,onClick:()=>{m(T.setYear(f,j)),w(!1)},children:j},j)})})]})]}),e.jsx("button",{type:"button",onClick:()=>m(T.addMonths(f,1)),className:"dfe-datepicker-nav-btn",children:e.jsx(Ee,{size:16})})]}),e.jsx("div",{className:"dfe-datepicker-grid-header",children:["D","S","T","Q","Q","S","S"].map((j,y)=>e.jsx("span",{children:j},y))}),e.jsx("div",{className:"dfe-datepicker-grid",children:X.map((j,y)=>{const W=!T.isSameMonth(j,f),K=B&&T.isSameDay(j,B);return e.jsx("div",{onClick:()=>!W&&O(j),className:`dfe-datepicker-day
|
|
72
|
+
${K?"selected":"handleHover"}
|
|
73
|
+
${W?"outside":""}
|
|
74
|
+
${T.isToday(j)?"today":""}`,children:T.format(j,"d")},y)})})]})]}),!s&&e.jsx("input",{type:"hidden",name:t,value:E||""}),(S||g)&&e.jsx("p",{className:"text-danger",children:String((S==null?void 0:S.message)??g)})]})}const Ie=r.memo(Fe);function Ve({mapping:t={},defaultLabel:c="Não reconhecido",className:p="",hidden:u=!1,label:d}){const{activityId:a}=q.useFluigRuntime(),x=r.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:c})]});const i={"--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:i,children:[x.icon&&e.jsx("i",{className:x.icon}),e.jsx("span",{children:x.label})]})]})}const De=r.memo(Ve);function He({name:t,control:c,defaultRowValue:p,isView:u,isReadOnly:d,filters:a=[]}){const{field:x}=P.useController({name:t,control:c}),[i,g]=r.useState([]),[s,h]=r.useState([]),_=()=>Date.now()+Math.random(),A=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),[]}};r.useEffect(()=>{if(!(i.length>0&&!u)&&x.value&&typeof x.value=="string"){const l=JSON.stringify(i);if(x.value===l)return;const o=A(x.value);g(o)}},[x.value,u]),r.useEffect(()=>{if(d)return;const l=JSON.stringify(i);x.value!==l&&x.onChange(l)},[i,x,d]);const L=r.useCallback(()=>{const l={_uid:_(),...p};g(o=>[...o,l])},[p]),v=r.useCallback(()=>{g(l=>l.filter(o=>!s.includes(o._uid))),h([])},[s]),F=r.useCallback((l,o,f)=>{g(m=>m.map(E=>E._uid===l?{...E,[o]:f}:E))},[]),R=r.useCallback(l=>{h(o=>o.includes(l)?o.filter(f=>f!==l):[...o,l])},[]),$=r.useCallback(l=>{h(l?i.map(o=>o._uid):[])},[i]),S=i.length>0&&s.length===i.length,n=r.useMemo(()=>!a||a.length===0?i:i.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}})),[i,a]);return{field:x,tableRows:i,visibleRows:n,selectedRowIds:s,isAllSelected:S,handle:{addRow:L,removeRows:v,updateCellValue:F,toggleSelection:R,toggleSelectAll:$}}}const Le=({name:t,title:c="Tabela Dinâmica",columns:p,defaultRowValue:u={},forceReadOnly:d=!1,layout:a="fluid",actions:x=!0,filters:i=[]})=>{const{control:g}=P.useFormContext(),{isView:s,isReadOnly:h}=q.useFluigRuntime(),{isReadOnly:_}=q.useSection(),A=d||s||h||_&&_(t),{field:L,visibleRows:v,selectedRowIds:F,isAllSelected:R,handle:$}=He({name:t,control:g,defaultRowValue:u,isView:s,isReadOnly:!!A,filters:i}),S=a==="fixed";return e.jsxs("div",{className:`table-wrapper ${S?"table-fixed":"table-fluid"}`,children:[e.jsx("input",{type:"hidden",...L}),e.jsxs("div",{className:"header-handle",children:[e.jsx("h3",{children:c}),!A&&x&&e.jsxs("div",{className:"handle-actions",children:[e.jsxs("button",{type:"button",className:`btn ${F.length>0?"btn-danger":"btn-primary"}`,disabled:F.length===0,onClick:$.removeRows,children:["Remover (",F.length,")"]}),e.jsx("button",{type:"button",className:"btn-add",onClick:$.addRow,children:"Adicionar"})]})]}),e.jsx("div",{className:"table-scroll",children:e.jsxs("table",{className:"table-custom",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[!A&&e.jsx("th",{style:{width:"50px"},children:e.jsx("input",{type:"checkbox",checked:R,onChange:n=>$.toggleSelectAll(n.target.checked)})}),p.map(n=>e.jsx("th",{style:n.width?{minWidth:S?n.width:"100%"}:{width:"max-content"},children:n.label},String(n.key)))]})}),e.jsxs("tbody",{children:[v.map((n,l)=>e.jsxs("tr",{children:[!A&&e.jsx("td",{children:e.jsx("input",{type:"checkbox",checked:F.includes(n._uid),onChange:()=>$.toggleSelection(n._uid)})}),p.map(o=>e.jsx("td",{children:o.render?o.render.length<=1?o.render({row:n,index:l,updateRow:(f,m)=>$.updateCellValue(n._uid,String(f),m),isLocked:!!A,isView:!!s}):o.render(n,l,(f,m)=>$.updateCellValue(n._uid,f,m),!!A,!!s):n[o.key]},`${n._uid}-${String(o.key)}`))]},n._uid)),v.length===0&&e.jsx("tr",{className:"empty-row",children:e.jsx("td",{colSpan:100,className:"text-center",children:A?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},Te=(t,c)=>{const[p,u]=r.useState(null);let d=null;try{d=P.useFormContext().watch}catch{}const a=c!==void 0?c:d?d(t):void 0,x=r.useCallback(()=>{try{const g=window.top.__REACT_ATTACHMENT_BRIDGE__;if(g){const s=g.getAttachment(t,a);u(s||(a?{name:a,documentId:0}:null))}else u(a?{name:a,documentId:0}:null)}catch{u(a?{name:a,documentId:0}:null)}},[t,a,c]);return r.useEffect(()=>{x();const i=setInterval(x,2e3);return()=>clearInterval(i)},[x]),{attachment:p,sync:x}},Be=({name:t,label:c,help:p,valueManual:u,onChangeManual:d,forceReadOnly:a=!1,forceHidden:x=!1,helpText:i,helpTitle:g,helpWidth:s})=>{const h=!!d,{isReadOnly:_,isHidden:A}=q.useSection(),{isView:L}=q.useFluigRuntime(),v=a||L||!!_(t),F=x||!!A(t),[R,$]=r.useState(!1);let S=null;try{S=P.useFormContext().control}catch{}const n=S&&!h?P.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 b=window.top;return{bridge:b.__REACT_ATTACHMENT_BRIDGE__,toast:(k=b.FLUIGC)==null?void 0:k.toast}}catch{return{bridge:null,toast:null}}},m=r.useCallback(()=>{if(v)return;const k=document.createElement("input");k.type="file",k.onchange=b=>{const V=b.target.files[0];if(!V)return;const{bridge:z,toast:U}=f();$(!0),z?z.upload(V,t,J=>{h?d==null||d(J.name):n.onChange(J.name),setTimeout(()=>{$(!1),o()},1e3),U&&U({title:"Sucesso",message:"Arquivo enviado",type:"success"})}):(h?d==null||d(V.name):n.onChange(V.name),$(!1))},k.click()},[t,n,o,d,v,h]),E=k=>{if(k.stopPropagation(),v)return;const b=(l==null?void 0:l.name)||u||n.value;if(!b)return;const{bridge:V,toast:z}=f();V?V.removeByFileName(b)?(h?d==null||d(""):n.onChange(""),o()):z&&z({title:"Erro",message:"Erro ao remover anexo",type:"danger"}):(h?d==null||d(""):n.onChange(""),o())},I=!!l&&!R,C=(l==null?void 0:l.name)||u||n.value,w=["fluig-attachment__box",I?"fluig-attachment__box--has-file":"",R?"fluig-attachment__box--uploading":"",v&&!I?"readOnly":"",v&&I?"fluig-attachment__box--readonly-view":""].join(" ");return F?null:e.jsxs("div",{className:"form-group fluig-attachment",children:[c&&e.jsx("label",{className:"fluig-attachment__label",children:c}),e.jsxs("div",{className:i?"dfe-flex-input-wrapper":"",children:[e.jsxs("div",{className:w,style:i?{flex:1}:void 0,onClick:()=>{if(I){const k=f(),b=(l==null?void 0:l.physicalFileName)||(l==null?void 0:l.description)||(l==null?void 0:l.name)||C;k.bridge&&b&&k.bridge.view(b)}else m()},children:[e.jsxs("span",{className:"fluig-attachment__content",children:[e.jsx("i",{className:`flaticon icon-sm ${R?"flaticon-loading":I?"flaticon-file":"flaticon-paperclip"} fluig-attachment__icon`}),e.jsx("span",{className:"fluig-attachment__filename",children:R?" Enviando...":I?C:v?"Nenhum arquivo":p||"Anexar"})]}),I&&!v&&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"})})]}),i&&e.jsx(Z,{text:i,title:g,width:s})]}),!h&&S&&e.jsx("input",{type:"hidden",name:t,value:n.value||""})]})},Pe=r.memo(Be);exports.Attachment=Pe;exports.Checkbox=pe;exports.DatePicker=Ie;exports.Help=Z;exports.Input=fe;exports.Modal=ne;exports.RadioBtn=ge;exports.Select=he;exports.SimpleTable=Le;exports.StatusBadge=De;exports.TextArea=be;
|