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