@tech-diefra/fluig-ui 1.2.26 → 1.2.28

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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),S=require("react-hook-form"),X=require("react-imask"),_=require("@fluig-kit/ecm"),L=require("react-datepicker"),E=require("date-fns"),U={cpf:"000.000.000-00",cnpj:"00.000.000/0000-00",telefone:"(00) 00000-0000",cep:"00000-000"};function Y({name:e,label:s="",placeholder:a="",type:c="text",mask:o,className:l="",forceReadOnly:r=!1,forceHidden:n=!1}){const{isReadOnly:h,isHidden:m}=_.useSection(),f=r||!!h(e),y=n||!!m(e),{control:w}=S.useFormContext(),{isView:R}=_.useFluigRuntime(),{field:v}=S.useController({name:e,control:w}),{errors:p}=S.useFormState({name:e}),j=p==null?void 0:p[e],b=u.useMemo(()=>o?U[o]??o:null,[o]),C=u.useCallback(i=>{if(!i)return"";const d=i.replace(/\D/g,"");return(Number(d)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),g=u.useCallback(i=>c==="monetary"?C(i):i,[c,C]);return R?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:v.value||"-"})]}):t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:s}),b?t.jsx(X.IMaskInput,{name:e,mask:b,value:String(v.value??""),unmask:!1,onAccept:i=>v.onChange(g(i)),placeholder:a,readOnly:f,className:`form-control ${j?"border-red":""} ${l}`,inputRef:v.ref,onBlur:v.onBlur}):t.jsx("input",{...v,type:"text",value:v.value??"",onChange:i=>v.onChange(g(i.target.value)),placeholder:a,readOnly:f,className:`form-control ${j?"border-red":""} ${l}`}),j&&t.jsx("p",{className:"text-danger",children:String(j.message)})]})}const G=u.memo(Y);function Q({name:e,label:s="",options:a=[],placeholder:c="",labelKey:o="label",valueKey:l="value",enableSearch:r=!1,searchPlaceholder:n="Buscar...",loading:h=!1,onSearchChange:m,debounceTime:f=300,onSelect:y,forceReadOnly:w=!1,forceHidden:R=!1}){const{isReadOnly:v,isHidden:p}=_.useSection(),j=w||!!v(e),b=R||!!p(e),{control:C,clearErrors:g}=S.useFormContext(),{isView:i}=_.useFluigRuntime(),{field:{onChange:d,value:x,ref:$},fieldState:{error:N}}=S.useController({name:e,control:C}),[P,F]=u.useState(!1),[M,q]=u.useState(""),W=u.useRef(null),T=u.useRef(m);u.useEffect(()=>{T.current=m},[m]),u.useEffect(()=>{const k=V=>{W.current&&!W.current.contains(V.target)&&F(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]),u.useEffect(()=>{P||q("")},[P]),u.useEffect(()=>{if(!r)return;const k=setTimeout(()=>{T.current&&T.current(M)},f);return()=>clearTimeout(k)},[M,r,f]);const H=u.useMemo(()=>r&&!m&&M.trim()?a.filter(k=>String((k==null?void 0:k[o])??"").toLowerCase().includes(M.toLowerCase())):a??[],[a,r,m,M,o]),B=u.useMemo(()=>{if(x==null)return"";if(typeof x=="object")return String(x[l]??"");const k=(a||[]).find(V=>String(V==null?void 0:V[l])===String(x));return String(k?(k==null?void 0:k[o])??"":x)},[x,a,l,o]),z=k=>{j||(d(k[l]),y&&y(k),g(e),F(!1))};return t.jsxs("div",{className:`select-wrapper form-group ${b?"hidden":""}`,ref:W,children:[t.jsx("label",{className:"control-label",children:s}),i?t.jsx("span",{className:"form-control",children:B||"-"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`select-control ${N?"border-red":""} ${j?"readOnly":""}`,onClick:()=>!j&&F(k=>!k),ref:$,children:[t.jsx("span",{className:`select-display ${j?"readOnly":""}`,children:B||c}),t.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),P&&!j&&t.jsxs("div",{className:"select-dropdown",children:[r&&t.jsx("div",{className:"select-search",children:t.jsx("input",{type:"text",className:"select-search-input",value:M,onChange:k=>q(k.target.value),placeholder:h?"Carregando...":n,autoFocus:!0,onClick:k=>k.stopPropagation()})}),t.jsx("ul",{className:"select-options",children:h?t.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):H.length>0?H.map(k=>t.jsx("li",{onClick:()=>z(k),className:"select-option handleHover",children:k[o]},k[l])):t.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),t.jsx("input",{type:"hidden",name:e,value:x||""}),N&&t.jsx("p",{className:"text-danger",children:String(N.message)})]})}const J=u.memo(Q);function Z({name:e,options:s=[],label:a="",valueKey:c="value",labelKey:o="label",forceReadOnly:l=!1,forceHidden:r=!1}){var x,$;const n=S.useFormContext(),{isView:h,isReadOnly:m}=_.useFluigRuntime(),{isReadOnly:f,isHidden:y}=_.useSection(),w=f?f(e):!1,R=y?y(e):!1,v=l||w,p=r||R,j=v||m||h;if(!n||!e)return console.error("Checkbox requer contexto de formulário e nome."),null;const b=()=>!s||!n?{}:s.reduce((N,P)=>{const F=P[c],M=n.getValues(F);return N[F]=M==="on",N},{}),C=n.watch(e),g=u.useMemo(()=>C&&typeof C=="object"?C:b(),[C,s,c]);u.useEffect(()=>{const N=n.getValues(e);(!N||typeof N!="object")&&n.setValue(e,g,{shouldDirty:!1,shouldValidate:!1})},[g,e,n]);const i=(N,P)=>{if(j)return;const F={...g,[N]:P};n.setValue(e,F,{shouldDirty:!0,shouldValidate:!0}),n.setValue(N,P?"on":"",{shouldValidate:!1})},d=($=(x=n.formState)==null?void 0:x.errors)==null?void 0:$[e];return t.jsxs("div",{className:`form-group ${p?"hidden":""}`,children:[a&&t.jsx("label",{children:a}),t.jsx("div",{className:`checkbox-group-custom ${j?"readOnly":""}`,children:s.map(N=>{const P=String(N[c]),F=g[P]===!0;return t.jsxs("div",{children:[t.jsx("input",{type:"hidden",...n.register(P)}),t.jsxs("label",{className:`custom-checkbox ${F?"checked":""} ${j?"readOnly":""}`,children:[t.jsx("input",{type:"checkbox",checked:F,disabled:j,onChange:M=>i(P,M.target.checked)}),t.jsx("span",{className:"checkmark"}),t.jsx("span",{children:N[o]})]})]},P)})}),d&&t.jsx("p",{className:"text-danger",children:String(d.message)})]})}function K({name:e,label:s="",options:a=[],valueKey:c="value",labelKey:o="label",iconKey:l="icon",forceReadOnly:r=!1,forceHidden:n=!1}){const{isReadOnly:h,isHidden:m}=_.useSection(),f=r||!!h(e),y=n||!!m(e),{control:w}=S.useFormContext(),{isView:R,isReadOnly:v}=_.useFluigRuntime(),{field:p,fieldState:{error:j}}=S.useController({name:e,control:w}),b=f||v||R,C=p.value??"",g=u.useCallback(i=>{b||p.onChange(i)},[b,p]);return t.jsxs("div",{className:`form-group column ${y?"hidden":""}`,children:[s&&t.jsx("label",{className:"control-label",children:s}),t.jsx("div",{className:`btn-group ${b?"view-mode":""}`,"data-field-name":e,children:a.map(i=>{const d=i[c],x=C===d,$=i.color?{"--customColor":i.color}:void 0;return t.jsxs("label",{htmlFor:`${e}_${d}`,style:$,className:`btn fs-ellipsis ${x?"active":""}`,children:[t.jsx("input",{type:"radio",id:`${e}_${d}`,name:e,value:d,checked:x,className:"hidden",onChange:()=>g(d),disabled:b}),i[l]&&t.jsx("i",{className:`${i[l]} icon-sm`})," ",i[o]]},d)})}),j&&t.jsx("p",{className:"text-danger",children:String(j.message)})]})}const ee=u.memo(K),te=({name:e,label:s="",placeholder:a="",className:c="",rows:o=4,maxLength:l,forceReadOnly:r=!1,forceHidden:n=!1})=>{const{isReadOnly:h,isHidden:m}=_.useSection(),f=r||!!h(e),y=n||!!m(e),{control:w}=S.useFormContext(),{isView:R}=_.useFluigRuntime(),{field:v,fieldState:{error:p}}=S.useController({name:e,control:w});return R?t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:v.value||"-"})]}):t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("textarea",{...v,rows:o,maxLength:l,value:v.value||"",placeholder:a,readOnly:f,className:`form-control ${p?"border-red":""} ${c}`}),p&&t.jsx("p",{className:"text-danger",children:String(p.message)})]})},ne=u.memo(te);function D(e){return(s={})=>{const a=s.width?String(s.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}function A(e){return(s,a)=>{const c=a!=null&&a.context?String(a.context):"standalone";let o;if(c==="formatting"&&e.formattingValues){const r=e.defaultFormattingWidth||e.defaultWidth,n=a!=null&&a.width?String(a.width):r;o=e.formattingValues[n]||e.formattingValues[r]}else{const r=e.defaultWidth,n=a!=null&&a.width?String(a.width):e.defaultWidth;o=e.values[n]||e.values[r]}const l=e.argumentCallback?e.argumentCallback(s):s;return o[l]}}function O(e){return(s,a={})=>{const c=a.width,o=c&&e.matchPatterns[c]||e.matchPatterns[e.defaultMatchWidth],l=s.match(o);if(!l)return null;const r=l[0],n=c&&e.parsePatterns[c]||e.parsePatterns[e.defaultParseWidth],h=Array.isArray(n)?se(n,y=>y.test(r)):ae(n,y=>y.test(r));let m;m=e.valueCallback?e.valueCallback(h):h,m=a.valueCallback?a.valueCallback(m):m;const f=s.slice(r.length);return{value:m,rest:f}}}function ae(e,s){for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&s(e[a]))return a}function se(e,s){for(let a=0;a<e.length;a++)if(s(e[a]))return a}function re(e){return(s,a={})=>{const c=s.match(e.matchPattern);if(!c)return null;const o=c[0],l=s.match(e.parsePattern);if(!l)return null;let r=e.valueCallback?e.valueCallback(l[0]):l[0];r=a.valueCallback?a.valueCallback(r):r;const n=s.slice(o.length);return{value:r,rest:n}}}const oe={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},ie=(e,s,a)=>{let c;const o=oe[e];return typeof o=="string"?c=o:s===1?c=o.one:c=o.other.replace("{{count}}",String(s)),a!=null&&a.addSuffix?a.comparison&&a.comparison>0?"em "+c:"há "+c:c},le={full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},ce={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},de={full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ue={date:D({formats:le,defaultWidth:"full"}),time:D({formats:ce,defaultWidth:"full"}),dateTime:D({formats:de,defaultWidth:"full"})},me={lastWeek:e=>{const s=e.getDay();return"'"+(s===0||s===6?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},he=(e,s,a,c)=>{const o=me[e];return typeof o=="function"?o(s):o},fe={narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},ge={narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},xe={narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},be={narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},ve={narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},je={narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},pe=(e,s)=>{const a=Number(e);return(s==null?void 0:s.unit)==="week"?a+"ª":a+"º"},ye={ordinalNumber:pe,era:A({values:fe,defaultWidth:"wide"}),quarter:A({values:ge,defaultWidth:"wide",argumentCallback:e=>e-1}),month:A({values:xe,defaultWidth:"wide"}),day:A({values:be,defaultWidth:"wide"}),dayPeriod:A({values:ve,defaultWidth:"wide",formattingValues:je,defaultFormattingWidth:"wide"})},Ne=/^(\d+)[ºªo]?/i,we=/\d+/i,Ce={narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},ke={any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},Re={narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},Se={any:[/1/i,/2/i,/3/i,/4/i]},Pe={narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},_e={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},$e={narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},Fe={short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},Me={narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},Ve={any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},Ae={ordinalNumber:re({matchPattern:Ne,parsePattern:we,valueCallback:e=>parseInt(e,10)}),era:O({matchPatterns:Ce,defaultMatchWidth:"wide",parsePatterns:ke,defaultParseWidth:"any"}),quarter:O({matchPatterns:Re,defaultMatchWidth:"wide",parsePatterns:Se,defaultParseWidth:"any",valueCallback:e=>e+1}),month:O({matchPatterns:Pe,defaultMatchWidth:"wide",parsePatterns:_e,defaultParseWidth:"any"}),day:O({matchPatterns:$e,defaultMatchWidth:"wide",parsePatterns:Fe,defaultParseWidth:"any"}),dayPeriod:O({matchPatterns:Me,defaultMatchWidth:"any",parsePatterns:Ve,defaultParseWidth:"any"})},Oe={code:"pt-BR",formatDistance:ie,formatLong:ue,formatRelative:he,localize:ye,match:Ae,options:{weekStartsOn:0,firstWeekContainsDate:1}};L.registerLocale("pt-BR",Oe);const I="dd/MM/yyyy",We=e=>{if(!e)return null;const s=E.parse(e,I,new Date);return E.isValid(s)?s:null},Te=e=>e?E.format(e,I):"",De=u.forwardRef(({shimRef:e,className:s,name:a,...c},o)=>t.jsx("input",{name:a,...c,className:s,ref:l=>{typeof o=="function"?o(l):o&&(o.current=l),e&&e(l)}})),Ee=({name:e,label:s="",placeholder:a="dd/mm/aaaa",className:c="",forceReadOnly:o=!1,forceHidden:l=!1})=>{const{control:r}=S.useFormContext(),{isView:n}=_.useFluigRuntime(),{isReadOnly:h,isHidden:m}=_.useSection(),f=o||!!h(e),y=l||!!m(e),{field:{onChange:w,onBlur:R,value:v,ref:p},fieldState:{error:j}}=S.useController({name:e,control:r}),b=u.useMemo(()=>We(v),[v]),C=u.useCallback(i=>{w(i?Te(i):"")},[w]),g=u.useCallback(i=>{var d,x;if(p(i),i&&((x=(d=r._fields)==null?void 0:d[e])!=null&&x._f)){const $=r._fields[e];$._f.ref={focus:()=>{var N;return(N=i.focus)==null?void 0:N.call(i)},select:()=>{var N;return(N=i.select)==null?void 0:N.call(i)},setCustomValidity:N=>{var P;return(P=i.setCustomValidity)==null?void 0:P.call(i,N)},reportValidity:()=>{var N;return(N=i.reportValidity)==null?void 0:N.call(i)}}}},[p,r,e]);return y?null:n?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:v||"-"})]}):t.jsxs("div",{className:`form-group fluig-style-guide ${c}`,children:[s&&t.jsx("label",{className:"control-label",htmlFor:e,children:s}),t.jsx("div",{className:`${j?"border-red":""}`,children:t.jsx(L,{id:e,name:e,selected:b,onChange:C,onBlur:R,dateFormat:I,placeholderText:a,disabled:f,readOnly:f,locale:"pt-BR",className:`form-control ${j?"border-red":""}`,wrapperClassName:"w-100",showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",isClearable:!f&&!!v,autoComplete:"off",customInput:t.jsx(De,{name:e,shimRef:g})})}),j&&t.jsx("span",{className:"help-block text-danger",children:String(j.message)})]})},Ie=u.memo(Ee);function qe({mapping:e={},defaultLabel:s="Não reconhecido",className:a="",hidden:c=!1,label:o}){const{activityId:l}=_.useFluigRuntime(),r=u.useMemo(()=>!e||l===null||l===void 0?null:e[l],[l,e]);if(!r)return t.jsxs("div",{className:`form-group ${c?"hidden":""}`,children:[o&&t.jsx("label",{children:o}),t.jsx("div",{className:`status-badge default ${a}`,children:s})]});const n={"--customColor":r.color};return t.jsxs("div",{className:`form-group ${c?"hidden":""}`,children:[o&&t.jsx("label",{children:o}),t.jsxs("div",{className:`status-badge ${a}`,style:n,children:[r.icon&&t.jsx("i",{className:r.icon}),t.jsx("span",{children:r.label})]})]})}const He=u.memo(qe);function Be({name:e,control:s,defaultRowValue:a,isView:c,isReadOnly:o,filters:l=[]}){const{field:r}=S.useController({name:e,control:s}),[n,h]=u.useState([]),[m,f]=u.useState([]),y=()=>Date.now()+Math.random(),w=i=>{try{const d=JSON.parse(i);return Array.isArray(d)?d.map(x=>({...x,_uid:x._uid||y()})):[]}catch(d){return console.error(`Erro ao ler dados da tabela "${e}":`,d),[]}};u.useEffect(()=>{if(!(n.length>0&&!c)&&r.value&&typeof r.value=="string"){const i=JSON.stringify(n);if(r.value===i)return;const d=w(r.value);h(d)}},[r.value,c]),u.useEffect(()=>{if(o)return;const i=JSON.stringify(n);r.value!==i&&r.onChange(i)},[n,r,o]);const R=u.useCallback(()=>{const i={_uid:y(),...a};h(d=>[...d,i])},[a]),v=u.useCallback(()=>{h(i=>i.filter(d=>!m.includes(d._uid))),f([])},[m]),p=u.useCallback((i,d,x)=>{h($=>$.map(N=>N._uid===i?{...N,[d]:x}:N))},[]),j=u.useCallback(i=>{f(d=>d.includes(i)?d.filter(x=>x!==i):[...d,i])},[]),b=u.useCallback(i=>{f(i?n.map(d=>d._uid):[])},[n]),C=n.length>0&&m.length===n.length,g=u.useMemo(()=>!l||l.length===0?n:n.filter(i=>l.every(d=>{if("custom"in d)return d.custom(i);const x=i[d.field];switch(d.operator){case"===":return x===d.value;case"!==":return x!==d.value;case">":return x>d.value;case"<":return x<d.value;case">=":return x>=d.value;case"<=":return x<=d.value;default:return!0}})),[n,l]);return{field:r,tableRows:n,visibleRows:g,selectedRowIds:m,isAllSelected:C,handle:{addRow:R,removeRows:v,updateCellValue:p,toggleSelection:j,toggleSelectAll:b}}}const Le=({name:e,title:s="Tabela Dinâmica",columns:a,defaultRowValue:c={},forceReadOnly:o=!1,layout:l="fluid",actions:r=!0,filters:n=[]})=>{const{control:h}=S.useFormContext(),{isView:m,isReadOnly:f}=_.useFluigRuntime(),{isReadOnly:y}=_.useSection(),w=o||m||f||y&&y(e),{field:R,visibleRows:v,selectedRowIds:p,isAllSelected:j,handle:b}=Be({name:e,control:h,defaultRowValue:c,isView:m,isReadOnly:!!w,filters:n}),C=l==="fixed";return t.jsxs("div",{className:`table-wrapper ${C?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...R}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:s}),!w&&r&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${p.length>0?"btn-danger":""}`,disabled:p.length===0,onClick:b.removeRows,children:["Remover (",p.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:b.addRow,children:"Adicionar"})]})]}),t.jsx("div",{className:"table-scroll",children:t.jsxs("table",{className:"table-custom",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[!w&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:j,onChange:g=>b.toggleSelectAll(g.target.checked)})}),a.map(g=>t.jsx("th",{style:g.width?{minWidth:C?g.width:"100%"}:{width:"max-content"},children:g.label},g.key))]})}),t.jsxs("tbody",{children:[v.map((g,i)=>t.jsxs("tr",{children:[!w&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:p.includes(g._uid),onChange:()=>b.toggleSelection(g._uid)})}),a.map(d=>t.jsx("td",{children:d.render?d.render.length<=1?d.render({row:g,index:i,updateRow:(x,$)=>b.updateCellValue(g._uid,x,$),isLocked:!!w,isView:!!m}):d.render(g,i,(x,$)=>b.updateCellValue(g._uid,x,$),!!w,!!m):g[d.key]},`${g._uid}-${d.key}`))]},g._uid)),v.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:w?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},ze=(e,s)=>{const[a,c]=u.useState(null),{watch:o}=S.useFormContext(),l=s!==void 0?s:o(e),r=u.useCallback(()=>{try{const h=window.top.__REACT_ATTACHMENT_BRIDGE__;if(h){const m=h.getAttachment(e);c(m||(l?{name:l,documentId:0}:null))}else c(l?{name:l,documentId:0}:null)}catch{c(l?{name:l,documentId:0}:null)}},[e,l]);return u.useEffect(()=>{r();const n=setInterval(r,2e3);return()=>clearInterval(n)},[r]),{attachment:a,sync:r}},Xe=({name:e,label:s,help:a,valueManual:c,onChangeManual:o})=>{const[l,r]=u.useState(!1),{control:n}=S.useFormContext(),{field:h}=S.useController({name:e,control:n}),{attachment:m,sync:f}=ze(e,c),y=()=>{var b;try{const C=window.top;return{bridge:C.__REACT_ATTACHMENT_BRIDGE__,toast:(b=C.FLUIGC)==null?void 0:b.toast}}catch{return{bridge:null,toast:null}}},w=u.useCallback(()=>{const b=document.createElement("input");b.type="file",b.onchange=C=>{const g=C.target.files[0];if(!g)return;const{bridge:i,toast:d}=y();r(!0),i?i.upload(g,e,x=>{o?o(x.name):h.onChange(x.name),setTimeout(()=>{r(!1),f()},1e3),d&&d({title:"Sucesso",message:"Arquivo enviado",type:"success"})}):(o?o(g.name):h.onChange(g.name),r(!1))},b.click()},[e,h,f,o]),R=b=>{b.stopPropagation();const C=(m==null?void 0:m.name)||c||h.value;if(!C)return;const{bridge:g,toast:i}=y();g?g.removeByFileName(C)?(o?o(""):h.onChange(""),f()):i&&i({title:"Erro",message:"Erro ao remover anexo",type:"danger"}):(o?o(""):h.onChange(""),f())},v=!!m&&!l,p=(m==null?void 0:m.name)||c||h.value,j=["fluig-attachment__box",v?"fluig-attachment__box--has-file":"",l?"fluig-attachment__box--uploading":""].join(" ");return t.jsxs("div",{className:"form-group fluig-attachment",children:[s&&t.jsx("label",{className:"fluig-attachment__label",children:s}),t.jsxs("div",{className:j,onClick:v?()=>{var b;return(b=y().bridge)==null?void 0:b.view(p)}:w,children:[t.jsxs("span",{className:"fluig-attachment__content",children:[t.jsx("i",{className:`fluigicon icon-sm ${l?"fluigicon-loop-test":v?"fluigicon-file-pdf":"fluigicon-paperclip"} fluig-attachment__icon`}),t.jsx("span",{className:"fluig-attachment__filename",children:l?" Enviando...":v?p:a||"Anexar"})]}),v&&t.jsx("button",{type:"button",className:"fluig-attachment__btn-remove btn btn-link text-danger",onClick:R,children:t.jsx("i",{className:"flaticon flaticon-trash icon-sm","aria-hidden":"true"})})]}),!o&&t.jsx("input",{type:"hidden",name:e,value:h.value||""})]})},Ue=u.memo(Xe);function Ye({items:e,time:s=0,showNavigation:a=!0,progressBar:c=!0}){const[o,l]=u.useState(0),[r,n]=u.useState(0),h=u.useRef(null),m=u.useRef(null),f=u.useCallback(()=>{l(p=>(p+1)%e.length),n(0)},[e.length]),y=u.useCallback(()=>{l(p=>(p-1+e.length)%e.length),n(0)},[e.length]);if(u.useEffect(()=>{if(s>0&&e.length>1){const j=100/s*100;h.current=setInterval(f,s),m.current=setInterval(()=>{n(b=>b>=100?0:b+j)},100)}return()=>{h.current&&clearInterval(h.current),m.current&&clearInterval(m.current)}},[s,f,e.length,o]),!e||e.length===0)return null;const w=e[o],R=typeof w=="string"?w:w.url,v=/\.(jpg|jpeg|png|gif|webp)$/i.test(R);return t.jsxs("div",{className:"carousel-root",children:[t.jsxs("div",{className:"carousel-viewport",children:[a&&e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"nav-btn prev",onClick:y,children:t.jsx("i",{className:"flaticon flaticon-chevron-left"})}),t.jsx("button",{className:"nav-btn next",onClick:f,children:t.jsx("i",{className:"flaticon flaticon-chevron-right"})})]}),t.jsx("div",{className:"carousel-media",children:v?t.jsx("img",{src:R,alt:"Slide",className:"carousel-image"}):t.jsxs("div",{className:"carousel-file-fallback",children:[t.jsx("i",{className:"flaticon flaticon-file icon-xl"}),t.jsx("a",{href:R,target:"_blank",rel:"noreferrer",className:"btn-open",children:"Abrir Arquivo"})]})}),e.length>1&&t.jsx("div",{className:"carousel-dots",children:e.map((p,j)=>t.jsx("div",{className:`dot ${j===o?"active":""}`,onClick:()=>{l(j),n(0)}},j))})]}),c&&s>0&&e.length>1&&t.jsx("div",{className:"carousel-progress-container",children:t.jsx("div",{className:"carousel-progress-bar",style:{width:`${r}%`}})})]})}function Ge({title:e,isOpen:s,onOpen:a,onClose:c,content:o,footer:l,width:r}){const n=u.useCallback(h=>{h.key==="Escape"&&c()},[c]);return u.useEffect(()=>(s&&(document.addEventListener("keydown",n),a==null||a(),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",n),document.body.style.overflow="auto"}),[s,n,a]),s?t.jsx("div",{className:"modal-overlay",onClick:c,"aria-modal":"true",role:"dialog",children:t.jsxs("div",{style:{maxWidth:r},className:"modal-container",onClick:h=>h.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsx("h3",{children:e}),t.jsx("div",{className:"btn-close-modal",onClick:c,role:"button","aria-label":"Fechar modal",children:t.jsx("i",{className:"flaticon flaticon-close icon-md","aria-hidden":"true"})})]}),t.jsx("div",{className:"modal-content",children:o}),l&&t.jsx("div",{className:"modal-footer",children:l})]})}):null}function Qe({logo:e,childs:s,footer:a,contentExternal:c,bg:o,color:l,onSelect:r}){return t.jsxs("div",{className:"main-container dfea",children:[t.jsxs("div",{className:"sidebar-wrapper",style:{backgroundColor:`${o}`},children:[e&&t.jsx("div",{className:"sidebar-logo",children:t.jsx("img",{src:e,alt:"",width:"auto",height:"28px"})}),t.jsx("ul",{className:"sidebar-childs-content",children:s==null?void 0:s.map(n=>{var h,m;return n!=null&&n.options&&((h=n==null?void 0:n.options)==null?void 0:h.length)>0?t.jsx(t.Fragment,{children:t.jsxs("ul",{className:"sidebar-child sidebar-options-content",children:[t.jsxs("li",{className:"sidebar-child",onClick:()=>{var f;(f=n.action)==null||f.call(n),r==null||r(n.id)},style:{color:`${l}`},children:[n.icon&&t.jsx("i",{className:n.icon}),n.label]}),(m=n.options)==null?void 0:m.map(f=>t.jsx("li",{className:"sidebar-option",onClick:()=>{var y;(y=f.action)==null||y.call(f),r==null||r(f.id)},style:{color:`${l}`},children:f.label}))]})}):t.jsxs("li",{className:"sidebar-child",onClick:()=>{var f;(f=n.action)==null||f.call(n),r==null||r(n.id)},style:{color:`${l}`},children:[n.icon&&t.jsx("i",{className:n.icon}),n.label]})})}),a&&t.jsx("div",{className:"sidebar-footer",children:a})]}),t.jsx("div",{className:"sidebar-content-external",children:c})]})}exports.Attachment=Ue;exports.Carousel=Ye;exports.Checkbox=Z;exports.DatePicker=Ie;exports.Input=G;exports.Modal=Ge;exports.RadioBtn=ee;exports.Select=J;exports.Sidebar=Qe;exports.SimpleTable=Le;exports.StatusBadge=He;exports.TextArea=ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react"),S=require("react-hook-form"),X=require("react-imask"),_=require("@fluig-kit/ecm"),L=require("react-datepicker"),E=require("date-fns"),U={cpf:"000.000.000-00",cnpj:"00.000.000/0000-00",telefone:"(00) 00000-0000",cep:"00000-000"};function Y({name:e,label:a="",placeholder:s="",type:c="text",mask:o,className:l="",forceReadOnly:r=!1,forceHidden:n=!1}){const{isReadOnly:h,isHidden:m}=_.useSection(),f=r||!!h(e),y=n||!!m(e),{control:w}=S.useFormContext(),{isView:R}=_.useFluigRuntime(),{field:v}=S.useController({name:e,control:w}),{errors:j}=S.useFormState({name:e}),p=j==null?void 0:j[e],b=u.useMemo(()=>o?U[o]??o:null,[o]),C=u.useCallback(i=>{if(!i)return"";const d=i.replace(/\D/g,"");return(Number(d)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),g=u.useCallback(i=>c==="monetary"?C(i):i,[c,C]);return R?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:a}),t.jsx("span",{className:"form-control",children:v.value||"-"})]}):t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:a}),b?t.jsx(X.IMaskInput,{name:e,mask:b,value:String(v.value??""),unmask:!1,onAccept:i=>v.onChange(g(i)),placeholder:s,readOnly:f,className:`form-control ${p?"border-red":""} ${l}`,inputRef:v.ref,onBlur:v.onBlur}):t.jsx("input",{...v,type:"text",value:v.value??"",onChange:i=>v.onChange(g(i.target.value)),placeholder:s,readOnly:f,className:`form-control ${p?"border-red":""} ${l}`}),p&&t.jsx("p",{className:"text-danger",children:String(p.message)})]})}const G=u.memo(Y);function Q({name:e,label:a="",options:s=[],placeholder:c="",labelKey:o="label",valueKey:l="value",enableSearch:r=!1,searchPlaceholder:n="Buscar...",loading:h=!1,onSearchChange:m,debounceTime:f=300,onSelect:y,forceReadOnly:w=!1,forceHidden:R=!1}){const{isReadOnly:v,isHidden:j}=_.useSection(),p=w||!!v(e),b=R||!!j(e),{control:C,clearErrors:g}=S.useFormContext(),{isView:i}=_.useFluigRuntime(),{field:{onChange:d,value:x,ref:$},fieldState:{error:N}}=S.useController({name:e,control:C}),[P,F]=u.useState(!1),[M,q]=u.useState(""),W=u.useRef(null),T=u.useRef(m);u.useEffect(()=>{T.current=m},[m]),u.useEffect(()=>{const k=A=>{W.current&&!W.current.contains(A.target)&&F(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]),u.useEffect(()=>{P||q("")},[P]),u.useEffect(()=>{if(!r)return;const k=setTimeout(()=>{T.current&&T.current(M)},f);return()=>clearTimeout(k)},[M,r,f]);const H=u.useMemo(()=>r&&!m&&M.trim()?s.filter(k=>String((k==null?void 0:k[o])??"").toLowerCase().includes(M.toLowerCase())):s??[],[s,r,m,M,o]),B=u.useMemo(()=>{if(x==null)return"";if(typeof x=="object")return String(x[l]??"");const k=(s||[]).find(A=>String(A==null?void 0:A[l])===String(x));return String(k?(k==null?void 0:k[o])??"":x)},[x,s,l,o]),z=k=>{p||(d(k[l]),y&&y(k),g(e),F(!1))};return t.jsxs("div",{className:`select-wrapper form-group ${b?"hidden":""}`,ref:W,children:[t.jsx("label",{className:"control-label",children:a}),i?t.jsx("span",{className:"form-control",children:B||"-"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`select-control ${N?"border-red":""} ${p?"readOnly":""}`,onClick:()=>!p&&F(k=>!k),ref:$,children:[t.jsx("span",{className:`select-display ${p?"readOnly":""}`,children:B||c}),t.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),P&&!p&&t.jsxs("div",{className:"select-dropdown",children:[r&&t.jsx("div",{className:"select-search",children:t.jsx("input",{type:"text",className:"select-search-input",value:M,onChange:k=>q(k.target.value),placeholder:h?"Carregando...":n,autoFocus:!0,onClick:k=>k.stopPropagation()})}),t.jsx("ul",{className:"select-options",children:h?t.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):H.length>0?H.map(k=>t.jsx("li",{onClick:()=>z(k),className:"select-option handleHover",children:k[o]},k[l])):t.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),t.jsx("input",{type:"hidden",name:e,value:x||""}),N&&t.jsx("p",{className:"text-danger",children:String(N.message)})]})}const J=u.memo(Q);function Z({name:e,options:a=[],label:s="",valueKey:c="value",labelKey:o="label",forceReadOnly:l=!1,forceHidden:r=!1}){var x,$;const n=S.useFormContext(),{isView:h,isReadOnly:m}=_.useFluigRuntime(),{isReadOnly:f,isHidden:y}=_.useSection(),w=f?f(e):!1,R=y?y(e):!1,v=l||w,j=r||R,p=v||m||h;if(!n||!e)return console.error("Checkbox requer contexto de formulário e nome."),null;const b=()=>!a||!n?{}:a.reduce((N,P)=>{const F=P[c],M=n.getValues(F);return N[F]=M==="on",N},{}),C=n.watch(e),g=u.useMemo(()=>C&&typeof C=="object"?C:b(),[C,a,c]);u.useEffect(()=>{const N=n.getValues(e);(!N||typeof N!="object")&&n.setValue(e,g,{shouldDirty:!1,shouldValidate:!1})},[g,e,n]);const i=(N,P)=>{if(p)return;const F={...g,[N]:P};n.setValue(e,F,{shouldDirty:!0,shouldValidate:!0}),n.setValue(N,P?"on":"",{shouldValidate:!1})},d=($=(x=n.formState)==null?void 0:x.errors)==null?void 0:$[e];return t.jsxs("div",{className:`form-group ${j?"hidden":""}`,children:[s&&t.jsx("label",{children:s}),t.jsx("div",{className:`checkbox-group-custom ${p?"readOnly":""}`,children:a.map(N=>{const P=String(N[c]),F=g[P]===!0;return t.jsxs("div",{children:[t.jsx("input",{type:"hidden",...n.register(P)}),t.jsxs("label",{className:`custom-checkbox ${F?"checked":""} ${p?"readOnly":""}`,children:[t.jsx("input",{type:"checkbox",checked:F,disabled:p,onChange:M=>i(P,M.target.checked)}),t.jsx("span",{className:"checkmark"}),t.jsx("span",{children:N[o]})]})]},P)})}),d&&t.jsx("p",{className:"text-danger",children:String(d.message)})]})}function K({name:e,label:a="",options:s=[],valueKey:c="value",labelKey:o="label",iconKey:l="icon",forceReadOnly:r=!1,forceHidden:n=!1}){const{isReadOnly:h,isHidden:m}=_.useSection(),f=r||!!h(e),y=n||!!m(e),{control:w}=S.useFormContext(),{isView:R,isReadOnly:v}=_.useFluigRuntime(),{field:j,fieldState:{error:p}}=S.useController({name:e,control:w}),b=f||v||R,C=j.value??"",g=u.useCallback(i=>{b||j.onChange(i)},[b,j]);return t.jsxs("div",{className:`form-group column ${y?"hidden":""}`,children:[a&&t.jsx("label",{className:"control-label",children:a}),t.jsx("div",{className:`btn-group ${b?"view-mode":""}`,"data-field-name":e,children:s.map(i=>{const d=i[c],x=C===d,$=i.color?{"--customColor":i.color}:void 0;return t.jsxs("label",{htmlFor:`${e}_${d}`,style:$,className:`btn fs-ellipsis ${x?"active":""}`,children:[t.jsx("input",{type:"radio",id:`${e}_${d}`,name:e,value:d,checked:x,className:"hidden",onChange:()=>g(d),disabled:b}),i[l]&&t.jsx("i",{className:`${i[l]} icon-sm`})," ",i[o]]},d)})}),p&&t.jsx("p",{className:"text-danger",children:String(p.message)})]})}const ee=u.memo(K),te=({name:e,label:a="",placeholder:s="",className:c="",rows:o=4,maxLength:l,forceReadOnly:r=!1,forceHidden:n=!1})=>{const{isReadOnly:h,isHidden:m}=_.useSection(),f=r||!!h(e),y=n||!!m(e),{control:w}=S.useFormContext(),{isView:R}=_.useFluigRuntime(),{field:v,fieldState:{error:j}}=S.useController({name:e,control:w});return R?t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:a}),t.jsx("span",{className:"form-control",children:v.value||"-"})]}):t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:a}),t.jsx("textarea",{...v,rows:o,maxLength:l,value:v.value||"",placeholder:s,readOnly:f,className:`form-control ${j?"border-red":""} ${c}`}),j&&t.jsx("p",{className:"text-danger",children:String(j.message)})]})},ne=u.memo(te);function D(e){return(a={})=>{const s=a.width?String(a.width):e.defaultWidth;return e.formats[s]||e.formats[e.defaultWidth]}}function V(e){return(a,s)=>{const c=s!=null&&s.context?String(s.context):"standalone";let o;if(c==="formatting"&&e.formattingValues){const r=e.defaultFormattingWidth||e.defaultWidth,n=s!=null&&s.width?String(s.width):r;o=e.formattingValues[n]||e.formattingValues[r]}else{const r=e.defaultWidth,n=s!=null&&s.width?String(s.width):e.defaultWidth;o=e.values[n]||e.values[r]}const l=e.argumentCallback?e.argumentCallback(a):a;return o[l]}}function O(e){return(a,s={})=>{const c=s.width,o=c&&e.matchPatterns[c]||e.matchPatterns[e.defaultMatchWidth],l=a.match(o);if(!l)return null;const r=l[0],n=c&&e.parsePatterns[c]||e.parsePatterns[e.defaultParseWidth],h=Array.isArray(n)?ae(n,y=>y.test(r)):se(n,y=>y.test(r));let m;m=e.valueCallback?e.valueCallback(h):h,m=s.valueCallback?s.valueCallback(m):m;const f=a.slice(r.length);return{value:m,rest:f}}}function se(e,a){for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&a(e[s]))return s}function ae(e,a){for(let s=0;s<e.length;s++)if(a(e[s]))return s}function re(e){return(a,s={})=>{const c=a.match(e.matchPattern);if(!c)return null;const o=c[0],l=a.match(e.parsePattern);if(!l)return null;let r=e.valueCallback?e.valueCallback(l[0]):l[0];r=s.valueCallback?s.valueCallback(r):r;const n=a.slice(o.length);return{value:r,rest:n}}}const oe={lessThanXSeconds:{one:"menos de um segundo",other:"menos de {{count}} segundos"},xSeconds:{one:"1 segundo",other:"{{count}} segundos"},halfAMinute:"meio minuto",lessThanXMinutes:{one:"menos de um minuto",other:"menos de {{count}} minutos"},xMinutes:{one:"1 minuto",other:"{{count}} minutos"},aboutXHours:{one:"cerca de 1 hora",other:"cerca de {{count}} horas"},xHours:{one:"1 hora",other:"{{count}} horas"},xDays:{one:"1 dia",other:"{{count}} dias"},aboutXWeeks:{one:"cerca de 1 semana",other:"cerca de {{count}} semanas"},xWeeks:{one:"1 semana",other:"{{count}} semanas"},aboutXMonths:{one:"cerca de 1 mês",other:"cerca de {{count}} meses"},xMonths:{one:"1 mês",other:"{{count}} meses"},aboutXYears:{one:"cerca de 1 ano",other:"cerca de {{count}} anos"},xYears:{one:"1 ano",other:"{{count}} anos"},overXYears:{one:"mais de 1 ano",other:"mais de {{count}} anos"},almostXYears:{one:"quase 1 ano",other:"quase {{count}} anos"}},ie=(e,a,s)=>{let c;const o=oe[e];return typeof o=="string"?c=o:a===1?c=o.one:c=o.other.replace("{{count}}",String(a)),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"em "+c:"há "+c:c},le={full:"EEEE, d 'de' MMMM 'de' y",long:"d 'de' MMMM 'de' y",medium:"d MMM y",short:"dd/MM/yyyy"},ce={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},de={full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ue={date:D({formats:le,defaultWidth:"full"}),time:D({formats:ce,defaultWidth:"full"}),dateTime:D({formats:de,defaultWidth:"full"})},me={lastWeek:e=>{const a=e.getDay();return"'"+(a===0||a===6?"último":"última")+"' eeee 'às' p"},yesterday:"'ontem às' p",today:"'hoje às' p",tomorrow:"'amanhã às' p",nextWeek:"eeee 'às' p",other:"P"},he=(e,a,s,c)=>{const o=me[e];return typeof o=="function"?o(a):o},fe={narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},ge={narrow:["1","2","3","4"],abbreviated:["T1","T2","T3","T4"],wide:["1º trimestre","2º trimestre","3º trimestre","4º trimestre"]},xe={narrow:["j","f","m","a","m","j","j","a","s","o","n","d"],abbreviated:["jan","fev","mar","abr","mai","jun","jul","ago","set","out","nov","dez"],wide:["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]},be={narrow:["D","S","T","Q","Q","S","S"],short:["dom","seg","ter","qua","qui","sex","sab"],abbreviated:["domingo","segunda","terça","quarta","quinta","sexta","sábado"],wide:["domingo","segunda-feira","terça-feira","quarta-feira","quinta-feira","sexta-feira","sábado"]},ve={narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"manhã",afternoon:"tarde",evening:"tarde",night:"noite"}},je={narrow:{am:"a",pm:"p",midnight:"mn",noon:"md",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},abbreviated:{am:"AM",pm:"PM",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"},wide:{am:"a.m.",pm:"p.m.",midnight:"meia-noite",noon:"meio-dia",morning:"da manhã",afternoon:"da tarde",evening:"da tarde",night:"da noite"}},pe=(e,a)=>{const s=Number(e);return(a==null?void 0:a.unit)==="week"?s+"ª":s+"º"},ye={ordinalNumber:pe,era:V({values:fe,defaultWidth:"wide"}),quarter:V({values:ge,defaultWidth:"wide",argumentCallback:e=>e-1}),month:V({values:xe,defaultWidth:"wide"}),day:V({values:be,defaultWidth:"wide"}),dayPeriod:V({values:ve,defaultWidth:"wide",formattingValues:je,defaultFormattingWidth:"wide"})},Ne=/^(\d+)[ºªo]?/i,we=/\d+/i,Ce={narrow:/^(ac|dc|a|d)/i,abbreviated:/^(a\.?\s?c\.?|d\.?\s?c\.?)/i,wide:/^(antes de cristo|depois de cristo)/i},ke={any:[/^ac/i,/^dc/i],wide:[/^antes de cristo/i,/^depois de cristo/i]},Re={narrow:/^[1234]/i,abbreviated:/^T[1234]/i,wide:/^[1234](º)? trimestre/i},Se={any:[/1/i,/2/i,/3/i,/4/i]},Pe={narrow:/^[jfmajsond]/i,abbreviated:/^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,wide:/^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i},_e={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^fev/i,/^mar/i,/^abr/i,/^mai/i,/^jun/i,/^jul/i,/^ago/i,/^set/i,/^out/i,/^nov/i,/^dez/i]},$e={narrow:/^(dom|[23456]ª?|s[aá]b)/i,short:/^(dom|[23456]ª?|s[aá]b)/i,abbreviated:/^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,wide:/^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i},Fe={short:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],narrow:[/^d/i,/^2/i,/^3/i,/^4/i,/^5/i,/^6/i,/^s[aá]/i],any:[/^d/i,/^seg/i,/^t/i,/^qua/i,/^qui/i,/^sex/i,/^s[aá]b/i]},Me={narrow:/^(a|p|mn|md|(da) (manhã|tarde|noite))/i,any:/^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i},Ae={any:{am:/^a/i,pm:/^p/i,midnight:/^mn|^meia[-\s]noite/i,noon:/^md|^meio[-\s]dia/i,morning:/manhã/i,afternoon:/tarde/i,evening:/tarde/i,night:/noite/i}},Ve={ordinalNumber:re({matchPattern:Ne,parsePattern:we,valueCallback:e=>parseInt(e,10)}),era:O({matchPatterns:Ce,defaultMatchWidth:"wide",parsePatterns:ke,defaultParseWidth:"any"}),quarter:O({matchPatterns:Re,defaultMatchWidth:"wide",parsePatterns:Se,defaultParseWidth:"any",valueCallback:e=>e+1}),month:O({matchPatterns:Pe,defaultMatchWidth:"wide",parsePatterns:_e,defaultParseWidth:"any"}),day:O({matchPatterns:$e,defaultMatchWidth:"wide",parsePatterns:Fe,defaultParseWidth:"any"}),dayPeriod:O({matchPatterns:Me,defaultMatchWidth:"any",parsePatterns:Ae,defaultParseWidth:"any"})},Oe={code:"pt-BR",formatDistance:ie,formatLong:ue,formatRelative:he,localize:ye,match:Ve,options:{weekStartsOn:0,firstWeekContainsDate:1}};L.registerLocale("pt-BR",Oe);const I="dd/MM/yyyy",We=e=>{if(!e)return null;const a=E.parse(e,I,new Date);return E.isValid(a)?a:null},Te=e=>e?E.format(e,I):"",De=u.forwardRef(({shimRef:e,className:a,name:s,...c},o)=>t.jsx("input",{name:s,...c,className:a,ref:l=>{typeof o=="function"?o(l):o&&(o.current=l),e&&e(l)}})),Ee=({name:e,label:a="",placeholder:s="dd/mm/aaaa",className:c="",forceReadOnly:o=!1,forceHidden:l=!1})=>{const{control:r}=S.useFormContext(),{isView:n}=_.useFluigRuntime(),{isReadOnly:h,isHidden:m}=_.useSection(),f=o||!!h(e),y=l||!!m(e),{field:{onChange:w,onBlur:R,value:v,ref:j},fieldState:{error:p}}=S.useController({name:e,control:r}),b=u.useMemo(()=>We(v),[v]),C=u.useCallback(i=>{w(i?Te(i):"")},[w]),g=u.useCallback(i=>{var d,x;if(j(i),i&&((x=(d=r._fields)==null?void 0:d[e])!=null&&x._f)){const $=r._fields[e];$._f.ref={focus:()=>{var N;return(N=i.focus)==null?void 0:N.call(i)},select:()=>{var N;return(N=i.select)==null?void 0:N.call(i)},setCustomValidity:N=>{var P;return(P=i.setCustomValidity)==null?void 0:P.call(i,N)},reportValidity:()=>{var N;return(N=i.reportValidity)==null?void 0:N.call(i)}}}},[j,r,e]);return y?null:n?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:a}),t.jsx("span",{className:"form-control",children:v||"-"})]}):t.jsxs("div",{className:`form-group fluig-style-guide ${c}`,children:[a&&t.jsx("label",{className:"control-label",htmlFor:e,children:a}),t.jsx("div",{className:`${p?"border-red":""}`,children:t.jsx(L,{id:e,name:e,selected:b,onChange:C,onBlur:R,dateFormat:I,placeholderText:s,disabled:f,readOnly:f,locale:"pt-BR",className:`form-control ${p?"border-red":""}`,wrapperClassName:"w-100",showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",isClearable:!f&&!!v,autoComplete:"off",customInput:t.jsx(De,{name:e,shimRef:g})})}),p&&t.jsx("span",{className:"help-block text-danger",children:String(p.message)})]})},Ie=u.memo(Ee);function qe({mapping:e={},defaultLabel:a="Não reconhecido",className:s="",hidden:c=!1,label:o}){const{activityId:l}=_.useFluigRuntime(),r=u.useMemo(()=>!e||l===null||l===void 0?null:e[l],[l,e]);if(!r)return t.jsxs("div",{className:`form-group ${c?"hidden":""}`,children:[o&&t.jsx("label",{children:o}),t.jsx("div",{className:`status-badge default ${s}`,children:a})]});const n={"--customColor":r.color};return t.jsxs("div",{className:`form-group ${c?"hidden":""}`,children:[o&&t.jsx("label",{children:o}),t.jsxs("div",{className:`status-badge ${s}`,style:n,children:[r.icon&&t.jsx("i",{className:r.icon}),t.jsx("span",{children:r.label})]})]})}const He=u.memo(qe);function Be({name:e,control:a,defaultRowValue:s,isView:c,isReadOnly:o,filters:l=[]}){const{field:r}=S.useController({name:e,control:a}),[n,h]=u.useState([]),[m,f]=u.useState([]),y=()=>Date.now()+Math.random(),w=i=>{try{const d=JSON.parse(i);return Array.isArray(d)?d.map(x=>({...x,_uid:x._uid||y()})):[]}catch(d){return console.error(`Erro ao ler dados da tabela "${e}":`,d),[]}};u.useEffect(()=>{if(!(n.length>0&&!c)&&r.value&&typeof r.value=="string"){const i=JSON.stringify(n);if(r.value===i)return;const d=w(r.value);h(d)}},[r.value,c]),u.useEffect(()=>{if(o)return;const i=JSON.stringify(n);r.value!==i&&r.onChange(i)},[n,r,o]);const R=u.useCallback(()=>{const i={_uid:y(),...s};h(d=>[...d,i])},[s]),v=u.useCallback(()=>{h(i=>i.filter(d=>!m.includes(d._uid))),f([])},[m]),j=u.useCallback((i,d,x)=>{h($=>$.map(N=>N._uid===i?{...N,[d]:x}:N))},[]),p=u.useCallback(i=>{f(d=>d.includes(i)?d.filter(x=>x!==i):[...d,i])},[]),b=u.useCallback(i=>{f(i?n.map(d=>d._uid):[])},[n]),C=n.length>0&&m.length===n.length,g=u.useMemo(()=>!l||l.length===0?n:n.filter(i=>l.every(d=>{if("custom"in d)return d.custom(i);const x=i[d.field];switch(d.operator){case"===":return x===d.value;case"!==":return x!==d.value;case">":return x>d.value;case"<":return x<d.value;case">=":return x>=d.value;case"<=":return x<=d.value;default:return!0}})),[n,l]);return{field:r,tableRows:n,visibleRows:g,selectedRowIds:m,isAllSelected:C,handle:{addRow:R,removeRows:v,updateCellValue:j,toggleSelection:p,toggleSelectAll:b}}}const Le=({name:e,title:a="Tabela Dinâmica",columns:s,defaultRowValue:c={},forceReadOnly:o=!1,layout:l="fluid",actions:r=!0,filters:n=[]})=>{const{control:h}=S.useFormContext(),{isView:m,isReadOnly:f}=_.useFluigRuntime(),{isReadOnly:y}=_.useSection(),w=o||m||f||y&&y(e),{field:R,visibleRows:v,selectedRowIds:j,isAllSelected:p,handle:b}=Be({name:e,control:h,defaultRowValue:c,isView:m,isReadOnly:!!w,filters:n}),C=l==="fixed";return t.jsxs("div",{className:`table-wrapper ${C?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...R}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:a}),!w&&r&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${j.length>0?"btn-danger":""}`,disabled:j.length===0,onClick:b.removeRows,children:["Remover (",j.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:b.addRow,children:"Adicionar"})]})]}),t.jsx("div",{className:"table-scroll",children:t.jsxs("table",{className:"table-custom",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[!w&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:p,onChange:g=>b.toggleSelectAll(g.target.checked)})}),s.map(g=>t.jsx("th",{style:g.width?{minWidth:C?g.width:"100%"}:{width:"max-content"},children:g.label},g.key))]})}),t.jsxs("tbody",{children:[v.map((g,i)=>t.jsxs("tr",{children:[!w&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:j.includes(g._uid),onChange:()=>b.toggleSelection(g._uid)})}),s.map(d=>t.jsx("td",{children:d.render?d.render.length<=1?d.render({row:g,index:i,updateRow:(x,$)=>b.updateCellValue(g._uid,x,$),isLocked:!!w,isView:!!m}):d.render(g,i,(x,$)=>b.updateCellValue(g._uid,x,$),!!w,!!m):g[d.key]},`${g._uid}-${d.key}`))]},g._uid)),v.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:w?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},ze=(e,a)=>{const[s,c]=u.useState(null),{watch:o}=S.useFormContext(),l=a!==void 0?a:o(e),r=u.useCallback(()=>{try{const h=window.top.__REACT_ATTACHMENT_BRIDGE__;if(h){const m=h.getAttachment(e,l);c(m||(l?{name:l,documentId:0}:null))}else c(l?{name:l,documentId:0}:null)}catch{c(l?{name:l,documentId:0}:null)}},[e,l,a]);return u.useEffect(()=>{r();const n=setInterval(r,2e3);return()=>clearInterval(n)},[r]),{attachment:s,sync:r}},Xe=({name:e,label:a,help:s,valueManual:c,onChangeManual:o})=>{const[l,r]=u.useState(!1),{control:n}=S.useFormContext(),{field:h}=S.useController({name:e,control:n}),{attachment:m,sync:f}=ze(e,c),y=()=>{var b;try{const C=window.top;return{bridge:C.__REACT_ATTACHMENT_BRIDGE__,toast:(b=C.FLUIGC)==null?void 0:b.toast}}catch{return{bridge:null,toast:null}}},w=u.useCallback(()=>{const b=document.createElement("input");b.type="file",b.onchange=C=>{const g=C.target.files[0];if(!g)return;const{bridge:i,toast:d}=y();r(!0),i?i.upload(g,e,x=>{o?o(x.name):h.onChange(x.name),setTimeout(()=>{r(!1),f()},1e3),d&&d({title:"Sucesso",message:"Arquivo enviado",type:"success"})}):(o?o(g.name):h.onChange(g.name),r(!1))},b.click()},[e,h,f,o]),R=b=>{b.stopPropagation();const C=(m==null?void 0:m.name)||c||h.value;if(!C)return;const{bridge:g,toast:i}=y();g?g.removeByFileName(C)?(o?o(""):h.onChange(""),f()):i&&i({title:"Erro",message:"Erro ao remover anexo",type:"danger"}):(o?o(""):h.onChange(""),f())},v=!!m&&!l,j=(m==null?void 0:m.name)||c||h.value,p=["fluig-attachment__box",v?"fluig-attachment__box--has-file":"",l?"fluig-attachment__box--uploading":""].join(" ");return t.jsxs("div",{className:"form-group fluig-attachment",children:[a&&t.jsx("label",{className:"fluig-attachment__label",children:a}),t.jsxs("div",{className:p,onClick:()=>{if(v){const b=y();b.bridge&&j&&b.bridge.view(j)}else w()},children:[t.jsxs("span",{className:"fluig-attachment__content",children:[t.jsx("i",{className:`fluigicon icon-sm ${l?"fluigicon-loop-test":v?"fluigicon-file-pdf":"fluigicon-paperclip"} fluig-attachment__icon`}),t.jsx("span",{className:"fluig-attachment__filename",children:l?" Enviando...":v?j:s||"Anexar"})]}),v&&t.jsx("button",{type:"button",className:"fluig-attachment__btn-remove btn btn-link text-danger",onClick:R,children:t.jsx("i",{className:"flaticon flaticon-trash icon-sm","aria-hidden":"true"})})]}),!o&&t.jsx("input",{type:"hidden",name:e,value:h.value||""})]})},Ue=u.memo(Xe);function Ye({items:e,time:a=0,showNavigation:s=!0,progressBar:c=!0}){const[o,l]=u.useState(0),[r,n]=u.useState(0),h=u.useRef(null),m=u.useRef(null),f=u.useCallback(()=>{l(j=>(j+1)%e.length),n(0)},[e.length]),y=u.useCallback(()=>{l(j=>(j-1+e.length)%e.length),n(0)},[e.length]);if(u.useEffect(()=>{if(a>0&&e.length>1){const p=100/a*100;h.current=setInterval(f,a),m.current=setInterval(()=>{n(b=>b>=100?0:b+p)},100)}return()=>{h.current&&clearInterval(h.current),m.current&&clearInterval(m.current)}},[a,f,e.length,o]),!e||e.length===0)return null;const w=e[o],R=typeof w=="string"?w:w.url,v=/\.(jpg|jpeg|png|gif|webp)$/i.test(R);return t.jsxs("div",{className:"carousel-root",children:[t.jsxs("div",{className:"carousel-viewport",children:[s&&e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"nav-btn prev",onClick:y,children:t.jsx("i",{className:"flaticon flaticon-chevron-left"})}),t.jsx("button",{className:"nav-btn next",onClick:f,children:t.jsx("i",{className:"flaticon flaticon-chevron-right"})})]}),t.jsx("div",{className:"carousel-media",children:v?t.jsx("img",{src:R,alt:"Slide",className:"carousel-image"}):t.jsxs("div",{className:"carousel-file-fallback",children:[t.jsx("i",{className:"flaticon flaticon-file icon-xl"}),t.jsx("a",{href:R,target:"_blank",rel:"noreferrer",className:"btn-open",children:"Abrir Arquivo"})]})}),e.length>1&&t.jsx("div",{className:"carousel-dots",children:e.map((j,p)=>t.jsx("div",{className:`dot ${p===o?"active":""}`,onClick:()=>{l(p),n(0)}},p))})]}),c&&a>0&&e.length>1&&t.jsx("div",{className:"carousel-progress-container",children:t.jsx("div",{className:"carousel-progress-bar",style:{width:`${r}%`}})})]})}function Ge({title:e,isOpen:a,onOpen:s,onClose:c,content:o,footer:l,width:r}){const n=u.useCallback(h=>{h.key==="Escape"&&c()},[c]);return u.useEffect(()=>(a&&(document.addEventListener("keydown",n),s==null||s(),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",n),document.body.style.overflow="auto"}),[a,n,s]),a?t.jsx("div",{className:"modal-overlay",onClick:c,"aria-modal":"true",role:"dialog",children:t.jsxs("div",{style:{maxWidth:r},className:"modal-container",onClick:h=>h.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsx("h3",{children:e}),t.jsx("div",{className:"btn-close-modal",onClick:c,role:"button","aria-label":"Fechar modal",children:t.jsx("i",{className:"flaticon flaticon-close icon-md","aria-hidden":"true"})})]}),t.jsx("div",{className:"modal-content",children:o}),l&&t.jsx("div",{className:"modal-footer",children:l})]})}):null}function Qe({logo:e,childs:a,footer:s,contentExternal:c,bg:o,color:l,onSelect:r}){return t.jsxs("div",{className:"main-container dfea",children:[t.jsxs("div",{className:"sidebar-wrapper",style:{backgroundColor:`${o}`},children:[e&&t.jsx("div",{className:"sidebar-logo",children:t.jsx("img",{src:e,alt:"",width:"auto",height:"28px"})}),t.jsx("ul",{className:"sidebar-childs-content",children:a==null?void 0:a.map(n=>{var h,m;return n!=null&&n.options&&((h=n==null?void 0:n.options)==null?void 0:h.length)>0?t.jsx(t.Fragment,{children:t.jsxs("ul",{className:"sidebar-child sidebar-options-content",children:[t.jsxs("li",{className:"sidebar-child",onClick:()=>{var f;(f=n.action)==null||f.call(n),r==null||r(n.id)},style:{color:`${l}`},children:[n.icon&&t.jsx("i",{className:n.icon}),n.label]}),(m=n.options)==null?void 0:m.map(f=>t.jsx("li",{className:"sidebar-option",onClick:()=>{var y;(y=f.action)==null||y.call(f),r==null||r(f.id)},style:{color:`${l}`},children:f.label}))]})}):t.jsxs("li",{className:"sidebar-child",onClick:()=>{var f;(f=n.action)==null||f.call(n),r==null||r(n.id)},style:{color:`${l}`},children:[n.icon&&t.jsx("i",{className:n.icon}),n.label]})})}),s&&t.jsx("div",{className:"sidebar-footer",children:s})]}),t.jsx("div",{className:"sidebar-content-external",children:c})]})}exports.Attachment=Ue;exports.Carousel=Ye;exports.Checkbox=Z;exports.DatePicker=Ie;exports.Input=G;exports.Modal=Ge;exports.RadioBtn=ee;exports.Select=J;exports.Sidebar=Qe;exports.SimpleTable=Le;exports.StatusBadge=He;exports.TextArea=ne;
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ function le({
21
21
  forceReadOnly: s = !1,
22
22
  forceHidden: n = !1
23
23
  }) {
24
- const { isReadOnly: m, isHidden: u } = E(), h = s || !!m(e), w = n || !!u(e), { control: C } = W(), { isView: P } = M(), { field: p } = I({ name: e, control: C }), { errors: N } = ee({ name: e }), y = N == null ? void 0 : N[e], v = j(
24
+ const { isReadOnly: m, isHidden: u } = E(), h = s || !!m(e), w = n || !!u(e), { control: C } = W(), { isView: P } = M(), { field: p } = I({ name: e, control: C }), { errors: y } = ee({ name: e }), N = y == null ? void 0 : y[e], v = j(
25
25
  () => i ? oe[i] ?? i : null,
26
26
  [i]
27
27
  ), x = $((o) => {
@@ -50,7 +50,7 @@ function le({
50
50
  onAccept: (o) => p.onChange(f(o)),
51
51
  placeholder: a,
52
52
  readOnly: h,
53
- className: `form-control ${y ? "border-red" : ""} ${l}`,
53
+ className: `form-control ${N ? "border-red" : ""} ${l}`,
54
54
  inputRef: p.ref,
55
55
  onBlur: p.onBlur
56
56
  }
@@ -63,10 +63,10 @@ function le({
63
63
  onChange: (o) => p.onChange(f(o.target.value)),
64
64
  placeholder: a,
65
65
  readOnly: h,
66
- className: `form-control ${y ? "border-red" : ""} ${l}`
66
+ className: `form-control ${N ? "border-red" : ""} ${l}`
67
67
  }
68
68
  ),
69
- y && /* @__PURE__ */ t("p", { className: "text-danger", children: String(y.message) })
69
+ N && /* @__PURE__ */ t("p", { className: "text-danger", children: String(N.message) })
70
70
  ] });
71
71
  }
72
72
  const it = T(le);
@@ -86,18 +86,18 @@ function ce({
86
86
  forceReadOnly: C = !1,
87
87
  forceHidden: P = !1
88
88
  }) {
89
- const { isReadOnly: p, isHidden: N } = E(), y = C || !!p(e), v = P || !!N(e), { control: x, clearErrors: f } = W(), { isView: o } = M(), {
89
+ const { isReadOnly: p, isHidden: y } = E(), N = C || !!p(e), v = P || !!y(e), { control: x, clearErrors: f } = W(), { isView: o } = M(), {
90
90
  field: { onChange: d, value: b, ref: S },
91
91
  fieldState: { error: k }
92
92
  } = I({
93
93
  name: e,
94
94
  control: x
95
- }), [_, V] = D(!1), [A, G] = D(""), L = B(null), z = B(u);
95
+ }), [_, A] = D(!1), [V, G] = D(""), L = B(null), z = B(u);
96
96
  O(() => {
97
97
  z.current = u;
98
98
  }, [u]), O(() => {
99
99
  const R = (F) => {
100
- L.current && !L.current.contains(F.target) && V(!1);
100
+ L.current && !L.current.contains(F.target) && A(!1);
101
101
  };
102
102
  return document.addEventListener("mousedown", R), () => document.removeEventListener("mousedown", R);
103
103
  }, []), O(() => {
@@ -105,13 +105,13 @@ function ce({
105
105
  }, [_]), O(() => {
106
106
  if (!s) return;
107
107
  const R = setTimeout(() => {
108
- z.current && z.current(A);
108
+ z.current && z.current(V);
109
109
  }, h);
110
110
  return () => clearTimeout(R);
111
- }, [A, s, h]);
112
- const Q = j(() => s && !u && A.trim() ? a.filter(
113
- (R) => String((R == null ? void 0 : R[i]) ?? "").toLowerCase().includes(A.toLowerCase())
114
- ) : a ?? [], [a, s, u, A, i]), J = j(() => {
111
+ }, [V, s, h]);
112
+ const Q = j(() => s && !u && V.trim() ? a.filter(
113
+ (R) => String((R == null ? void 0 : R[i]) ?? "").toLowerCase().includes(V.toLowerCase())
114
+ ) : a ?? [], [a, s, u, V, i]), J = j(() => {
115
115
  if (b == null) return "";
116
116
  if (typeof b == "object")
117
117
  return String(b[l] ?? "");
@@ -120,7 +120,7 @@ function ce({
120
120
  );
121
121
  return String(R ? (R == null ? void 0 : R[i]) ?? "" : b);
122
122
  }, [b, a, l, i]), Z = (R) => {
123
- y || (d(R[l]), w && w(R), f(e), V(!1));
123
+ N || (d(R[l]), w && w(R), f(e), A(!1));
124
124
  };
125
125
  return /* @__PURE__ */ g(
126
126
  "div",
@@ -133,22 +133,22 @@ function ce({
133
133
  /* @__PURE__ */ g(
134
134
  "div",
135
135
  {
136
- className: `select-control ${k ? "border-red" : ""} ${y ? "readOnly" : ""}`,
137
- onClick: () => !y && V((R) => !R),
136
+ className: `select-control ${k ? "border-red" : ""} ${N ? "readOnly" : ""}`,
137
+ onClick: () => !N && A((R) => !R),
138
138
  ref: S,
139
139
  children: [
140
- /* @__PURE__ */ t("span", { className: `select-display ${y ? "readOnly" : ""}`, children: J || c }),
140
+ /* @__PURE__ */ t("span", { className: `select-display ${N ? "readOnly" : ""}`, children: J || c }),
141
141
  /* @__PURE__ */ t("i", { className: "flaticon flaticon-chevron-down select-icon" })
142
142
  ]
143
143
  }
144
144
  ),
145
- _ && !y && /* @__PURE__ */ g("div", { className: "select-dropdown", children: [
145
+ _ && !N && /* @__PURE__ */ g("div", { className: "select-dropdown", children: [
146
146
  s && /* @__PURE__ */ t("div", { className: "select-search", children: /* @__PURE__ */ t(
147
147
  "input",
148
148
  {
149
149
  type: "text",
150
150
  className: "select-search-input",
151
- value: A,
151
+ value: V,
152
152
  onChange: (R) => G(R.target.value),
153
153
  placeholder: m ? "Carregando..." : n,
154
154
  autoFocus: !0,
@@ -183,12 +183,12 @@ function lt({
183
183
  forceHidden: s = !1
184
184
  }) {
185
185
  var b, S;
186
- const n = W(), { isView: m, isReadOnly: u } = M(), { isReadOnly: h, isHidden: w } = E(), C = h ? h(e) : !1, P = w ? w(e) : !1, p = l || C, N = s || P, y = p || u || m;
186
+ const n = W(), { isView: m, isReadOnly: u } = M(), { isReadOnly: h, isHidden: w } = E(), C = h ? h(e) : !1, P = w ? w(e) : !1, p = l || C, y = s || P, N = p || u || m;
187
187
  if (!n || !e)
188
188
  return console.error("Checkbox requer contexto de formulário e nome."), null;
189
189
  const v = () => !r || !n ? {} : r.reduce((k, _) => {
190
- const V = _[c], A = n.getValues(V);
191
- return k[V] = A === "on", k;
190
+ const A = _[c], V = n.getValues(A);
191
+ return k[A] = V === "on", k;
192
192
  }, {}), x = n.watch(e), f = j(() => x && typeof x == "object" ? x : v(), [x, r, c]);
193
193
  O(() => {
194
194
  const k = n.getValues(e);
@@ -198,35 +198,35 @@ function lt({
198
198
  });
199
199
  }, [f, e, n]);
200
200
  const o = (k, _) => {
201
- if (y) return;
202
- const V = { ...f, [k]: _ };
203
- n.setValue(e, V, {
201
+ if (N) return;
202
+ const A = { ...f, [k]: _ };
203
+ n.setValue(e, A, {
204
204
  shouldDirty: !0,
205
205
  shouldValidate: !0
206
206
  }), n.setValue(k, _ ? "on" : "", { shouldValidate: !1 });
207
207
  }, d = (S = (b = n.formState) == null ? void 0 : b.errors) == null ? void 0 : S[e];
208
- return /* @__PURE__ */ g("div", { className: `form-group ${N ? "hidden" : ""}`, children: [
208
+ return /* @__PURE__ */ g("div", { className: `form-group ${y ? "hidden" : ""}`, children: [
209
209
  a && /* @__PURE__ */ t("label", { children: a }),
210
210
  /* @__PURE__ */ t(
211
211
  "div",
212
212
  {
213
- className: `checkbox-group-custom ${y ? "readOnly" : ""}`,
213
+ className: `checkbox-group-custom ${N ? "readOnly" : ""}`,
214
214
  children: r.map((k) => {
215
- const _ = String(k[c]), V = f[_] === !0;
215
+ const _ = String(k[c]), A = f[_] === !0;
216
216
  return /* @__PURE__ */ g("div", { children: [
217
217
  /* @__PURE__ */ t("input", { type: "hidden", ...n.register(_) }),
218
218
  /* @__PURE__ */ g(
219
219
  "label",
220
220
  {
221
- className: `custom-checkbox ${V ? "checked" : ""} ${y ? "readOnly" : ""}`,
221
+ className: `custom-checkbox ${A ? "checked" : ""} ${N ? "readOnly" : ""}`,
222
222
  children: [
223
223
  /* @__PURE__ */ t(
224
224
  "input",
225
225
  {
226
226
  type: "checkbox",
227
- checked: V,
228
- disabled: y,
229
- onChange: (A) => o(_, A.target.checked)
227
+ checked: A,
228
+ disabled: N,
229
+ onChange: (V) => o(_, V.target.checked)
230
230
  }
231
231
  ),
232
232
  /* @__PURE__ */ t("span", { className: "checkmark" }),
@@ -252,16 +252,16 @@ function de({
252
252
  forceHidden: n = !1
253
253
  }) {
254
254
  const { isReadOnly: m, isHidden: u } = E(), h = s || !!m(e), w = n || !!u(e), { control: C } = W(), { isView: P, isReadOnly: p } = M(), {
255
- field: N,
256
- fieldState: { error: y }
255
+ field: y,
256
+ fieldState: { error: N }
257
257
  } = I({
258
258
  name: e,
259
259
  control: C
260
- }), v = h || p || P, x = N.value ?? "", f = $(
260
+ }), v = h || p || P, x = y.value ?? "", f = $(
261
261
  (o) => {
262
- v || N.onChange(o);
262
+ v || y.onChange(o);
263
263
  },
264
- [v, N]
264
+ [v, y]
265
265
  );
266
266
  return /* @__PURE__ */ g("div", { className: `form-group column ${w ? "hidden" : ""}`, children: [
267
267
  r && /* @__PURE__ */ t("label", { className: "control-label", children: r }),
@@ -302,7 +302,7 @@ function de({
302
302
  })
303
303
  }
304
304
  ),
305
- y && /* @__PURE__ */ t("p", { className: "text-danger", children: String(y.message) })
305
+ N && /* @__PURE__ */ t("p", { className: "text-danger", children: String(N.message) })
306
306
  ] });
307
307
  }
308
308
  const ct = T(de), ue = ({
@@ -317,7 +317,7 @@ const ct = T(de), ue = ({
317
317
  }) => {
318
318
  const { isReadOnly: m, isHidden: u } = E(), h = s || !!m(e), w = n || !!u(e), { control: C } = W(), { isView: P } = M(), {
319
319
  field: p,
320
- fieldState: { error: N }
320
+ fieldState: { error: y }
321
321
  } = I({
322
322
  name: e,
323
323
  control: C
@@ -336,10 +336,10 @@ const ct = T(de), ue = ({
336
336
  value: p.value || "",
337
337
  placeholder: a,
338
338
  readOnly: h,
339
- className: `form-control ${N ? "border-red" : ""} ${c}`
339
+ className: `form-control ${y ? "border-red" : ""} ${c}`
340
340
  }
341
341
  ),
342
- N && /* @__PURE__ */ t("p", { className: "text-danger", children: String(N.message) })
342
+ y && /* @__PURE__ */ t("p", { className: "text-danger", children: String(y.message) })
343
343
  ] });
344
344
  }, dt = T(ue);
345
345
  function X(e) {
@@ -634,7 +634,7 @@ const ge = {
634
634
  }, Se = (e, r) => {
635
635
  const a = Number(e);
636
636
  return (r == null ? void 0 : r.unit) === "week" ? a + "ª" : a + "º";
637
- }, Ve = {
637
+ }, Ae = {
638
638
  ordinalNumber: Se,
639
639
  era: H({
640
640
  values: Ce,
@@ -659,7 +659,7 @@ const ge = {
659
659
  formattingValues: $e,
660
660
  defaultFormattingWidth: "wide"
661
661
  })
662
- }, Ae = /^(\d+)[ºªo]?/i, Oe = /\d+/i, We = {
662
+ }, Ve = /^(\d+)[ºªo]?/i, Oe = /\d+/i, We = {
663
663
  narrow: /^(ac|dc|a|d)/i,
664
664
  abbreviated: /^(a\.?\s?c\.?|d\.?\s?c\.?)/i,
665
665
  wide: /^(antes de cristo|depois de cristo)/i
@@ -730,7 +730,7 @@ const ge = {
730
730
  }
731
731
  }, Be = {
732
732
  ordinalNumber: fe({
733
- matchPattern: Ae,
733
+ matchPattern: Ve,
734
734
  parsePattern: Oe,
735
735
  valueCallback: (e) => parseInt(e, 10)
736
736
  }),
@@ -770,7 +770,7 @@ const ge = {
770
770
  formatDistance: be,
771
771
  formatLong: Ne,
772
772
  formatRelative: ke,
773
- localize: Ve,
773
+ localize: Ae,
774
774
  match: Be,
775
775
  options: {
776
776
  weekStartsOn: 0,
@@ -803,8 +803,8 @@ const Y = "dd/MM/yyyy", ze = (e) => {
803
803
  forceHidden: l = !1
804
804
  }) => {
805
805
  const { control: s } = W(), { isView: n } = M(), { isReadOnly: m, isHidden: u } = E(), h = i || !!m(e), w = l || !!u(e), {
806
- field: { onChange: C, onBlur: P, value: p, ref: N },
807
- fieldState: { error: y }
806
+ field: { onChange: C, onBlur: P, value: p, ref: y },
807
+ fieldState: { error: N }
808
808
  } = I({
809
809
  name: e,
810
810
  control: s
@@ -816,7 +816,7 @@ const Y = "dd/MM/yyyy", ze = (e) => {
816
816
  ), f = $(
817
817
  (o) => {
818
818
  var d, b;
819
- if (N(o), o && ((b = (d = s._fields) == null ? void 0 : d[e]) != null && b._f)) {
819
+ if (y(o), o && ((b = (d = s._fields) == null ? void 0 : d[e]) != null && b._f)) {
820
820
  const S = s._fields[e];
821
821
  S._f.ref = {
822
822
  focus: () => {
@@ -838,14 +838,14 @@ const Y = "dd/MM/yyyy", ze = (e) => {
838
838
  };
839
839
  }
840
840
  },
841
- [N, s, e]
841
+ [y, s, e]
842
842
  );
843
843
  return w ? null : n ? /* @__PURE__ */ g("div", { className: "form-group", children: [
844
844
  /* @__PURE__ */ t("label", { children: r }),
845
845
  /* @__PURE__ */ t("span", { className: "form-control", children: p || "-" })
846
846
  ] }) : /* @__PURE__ */ g("div", { className: `form-group fluig-style-guide ${c}`, children: [
847
847
  r && /* @__PURE__ */ t("label", { className: "control-label", htmlFor: e, children: r }),
848
- /* @__PURE__ */ t("div", { className: `${y ? "border-red" : ""}`, children: /* @__PURE__ */ t(
848
+ /* @__PURE__ */ t("div", { className: `${N ? "border-red" : ""}`, children: /* @__PURE__ */ t(
849
849
  ne,
850
850
  {
851
851
  id: e,
@@ -858,7 +858,7 @@ const Y = "dd/MM/yyyy", ze = (e) => {
858
858
  disabled: h,
859
859
  readOnly: h,
860
860
  locale: "pt-BR",
861
- className: `form-control ${y ? "border-red" : ""}`,
861
+ className: `form-control ${N ? "border-red" : ""}`,
862
862
  wrapperClassName: "w-100",
863
863
  showMonthDropdown: !0,
864
864
  showYearDropdown: !0,
@@ -868,7 +868,7 @@ const Y = "dd/MM/yyyy", ze = (e) => {
868
868
  customInput: /* @__PURE__ */ t(Ue, { name: e, shimRef: f })
869
869
  }
870
870
  ) }),
871
- y && /* @__PURE__ */ t("span", { className: "help-block text-danger", children: String(y.message) })
871
+ N && /* @__PURE__ */ t("span", { className: "help-block text-danger", children: String(N.message) })
872
872
  ] });
873
873
  }, ut = T(Ye);
874
874
  function Ge({
@@ -934,7 +934,7 @@ function Qe({
934
934
  m(
935
935
  (o) => o.filter((d) => !u.includes(d._uid))
936
936
  ), h([]);
937
- }, [u]), N = $(
937
+ }, [u]), y = $(
938
938
  (o, d, b) => {
939
939
  m(
940
940
  (S) => S.map(
@@ -943,7 +943,7 @@ function Qe({
943
943
  );
944
944
  },
945
945
  []
946
- ), y = $((o) => {
946
+ ), N = $((o) => {
947
947
  h(
948
948
  (d) => d.includes(o) ? d.filter((b) => b !== o) : [...d, o]
949
949
  );
@@ -984,8 +984,8 @@ function Qe({
984
984
  handle: {
985
985
  addRow: P,
986
986
  removeRows: p,
987
- updateCellValue: N,
988
- toggleSelection: y,
987
+ updateCellValue: y,
988
+ toggleSelection: N,
989
989
  toggleSelectAll: v
990
990
  }
991
991
  };
@@ -1000,7 +1000,7 @@ const ht = ({
1000
1000
  actions: s = !0,
1001
1001
  filters: n = []
1002
1002
  }) => {
1003
- const { control: m } = W(), { isView: u, isReadOnly: h } = M(), { isReadOnly: w } = E(), C = i || u || h || w && w(e), { field: P, visibleRows: p, selectedRowIds: N, isAllSelected: y, handle: v } = Qe({
1003
+ const { control: m } = W(), { isView: u, isReadOnly: h } = M(), { isReadOnly: w } = E(), C = i || u || h || w && w(e), { field: P, visibleRows: p, selectedRowIds: y, isAllSelected: N, handle: v } = Qe({
1004
1004
  name: e,
1005
1005
  control: m,
1006
1006
  defaultRowValue: c,
@@ -1017,12 +1017,12 @@ const ht = ({
1017
1017
  "button",
1018
1018
  {
1019
1019
  type: "button",
1020
- className: `btn ${N.length > 0 ? "btn-danger" : ""}`,
1021
- disabled: N.length === 0,
1020
+ className: `btn ${y.length > 0 ? "btn-danger" : ""}`,
1021
+ disabled: y.length === 0,
1022
1022
  onClick: v.removeRows,
1023
1023
  children: [
1024
1024
  "Remover (",
1025
- N.length,
1025
+ y.length,
1026
1026
  ")"
1027
1027
  ]
1028
1028
  }
@@ -1036,7 +1036,7 @@ const ht = ({
1036
1036
  "input",
1037
1037
  {
1038
1038
  type: "checkbox",
1039
- checked: y,
1039
+ checked: N,
1040
1040
  onChange: (f) => v.toggleSelectAll(f.target.checked)
1041
1041
  }
1042
1042
  ) }),
@@ -1055,7 +1055,7 @@ const ht = ({
1055
1055
  "input",
1056
1056
  {
1057
1057
  type: "checkbox",
1058
- checked: N.includes(f._uid),
1058
+ checked: y.includes(f._uid),
1059
1059
  onChange: () => v.toggleSelection(f._uid)
1060
1060
  }
1061
1061
  ) }),
@@ -1082,14 +1082,14 @@ const ht = ({
1082
1082
  try {
1083
1083
  const m = window.top.__REACT_ATTACHMENT_BRIDGE__;
1084
1084
  if (m) {
1085
- const u = m.getAttachment(e);
1085
+ const u = m.getAttachment(e, l);
1086
1086
  c(u || (l ? { name: l, documentId: 0 } : null));
1087
1087
  } else
1088
1088
  c(l ? { name: l, documentId: 0 } : null);
1089
1089
  } catch {
1090
1090
  c(l ? { name: l, documentId: 0 } : null);
1091
1091
  }
1092
- }, [e, l]);
1092
+ }, [e, l, r]);
1093
1093
  return O(() => {
1094
1094
  s();
1095
1095
  const n = setInterval(s, 2e3);
@@ -1139,7 +1139,7 @@ const ht = ({
1139
1139
  message: "Erro ao remover anexo",
1140
1140
  type: "danger"
1141
1141
  }) : (i ? i("") : m.onChange(""), h());
1142
- }, p = !!u && !l, N = (u == null ? void 0 : u.name) || c || m.value, y = [
1142
+ }, p = !!u && !l, y = (u == null ? void 0 : u.name) || c || m.value, N = [
1143
1143
  "fluig-attachment__box",
1144
1144
  p ? "fluig-attachment__box--has-file" : "",
1145
1145
  l ? "fluig-attachment__box--uploading" : ""
@@ -1149,11 +1149,14 @@ const ht = ({
1149
1149
  /* @__PURE__ */ g(
1150
1150
  "div",
1151
1151
  {
1152
- className: y,
1153
- onClick: p ? () => {
1154
- var v;
1155
- return (v = w().bridge) == null ? void 0 : v.view(N);
1156
- } : C,
1152
+ className: N,
1153
+ onClick: () => {
1154
+ if (p) {
1155
+ const v = w();
1156
+ v.bridge && y && v.bridge.view(y);
1157
+ } else
1158
+ C();
1159
+ },
1157
1160
  children: [
1158
1161
  /* @__PURE__ */ g("span", { className: "fluig-attachment__content", children: [
1159
1162
  /* @__PURE__ */ t(
@@ -1162,7 +1165,7 @@ const ht = ({
1162
1165
  className: `fluigicon icon-sm ${l ? "fluigicon-loop-test" : p ? "fluigicon-file-pdf" : "fluigicon-paperclip"} fluig-attachment__icon`
1163
1166
  }
1164
1167
  ),
1165
- /* @__PURE__ */ t("span", { className: "fluig-attachment__filename", children: l ? " Enviando..." : p ? N : a || "Anexar" })
1168
+ /* @__PURE__ */ t("span", { className: "fluig-attachment__filename", children: l ? " Enviando..." : p ? y : a || "Anexar" })
1166
1169
  ] }),
1167
1170
  p && /* @__PURE__ */ t(
1168
1171
  "button",
@@ -1186,15 +1189,15 @@ function gt({
1186
1189
  progressBar: c = !0
1187
1190
  }) {
1188
1191
  const [i, l] = D(0), [s, n] = D(0), m = B(null), u = B(null), h = $(() => {
1189
- l((N) => (N + 1) % e.length), n(0);
1192
+ l((y) => (y + 1) % e.length), n(0);
1190
1193
  }, [e.length]), w = $(() => {
1191
- l((N) => (N - 1 + e.length) % e.length), n(0);
1194
+ l((y) => (y - 1 + e.length) % e.length), n(0);
1192
1195
  }, [e.length]);
1193
1196
  if (O(() => {
1194
1197
  if (r > 0 && e.length > 1) {
1195
- const y = 100 / r * 100;
1198
+ const N = 100 / r * 100;
1196
1199
  m.current = setInterval(h, r), u.current = setInterval(() => {
1197
- n((v) => v >= 100 ? 0 : v + y);
1200
+ n((v) => v >= 100 ? 0 : v + N);
1198
1201
  }, 100);
1199
1202
  }
1200
1203
  return () => {
@@ -1221,15 +1224,15 @@ function gt({
1221
1224
  }
1222
1225
  )
1223
1226
  ] }) }),
1224
- e.length > 1 && /* @__PURE__ */ t("div", { className: "carousel-dots", children: e.map((N, y) => /* @__PURE__ */ t(
1227
+ e.length > 1 && /* @__PURE__ */ t("div", { className: "carousel-dots", children: e.map((y, N) => /* @__PURE__ */ t(
1225
1228
  "div",
1226
1229
  {
1227
- className: `dot ${y === i ? "active" : ""}`,
1230
+ className: `dot ${N === i ? "active" : ""}`,
1228
1231
  onClick: () => {
1229
- l(y), n(0);
1232
+ l(N), n(0);
1230
1233
  }
1231
1234
  },
1232
- y
1235
+ N
1233
1236
  )) })
1234
1237
  ] }),
1235
1238
  c && r > 0 && e.length > 1 && /* @__PURE__ */ t("div", { className: "carousel-progress-container", children: /* @__PURE__ */ t(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tech-diefra/fluig-ui",
3
- "version": "1.2.26",
3
+ "version": "1.2.28",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",