@tech-diefra/fluig-ui 1.2.17 → 1.2.18
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 +1 -1
- package/dist/index.js +49 -51
- package/package.json +1 -1
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"),B=require("react-datepicker"),I=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:n="",type:d="text",mask:i,className:c="",forceReadOnly:o=!1,forceHidden:s=!1}){const{isReadOnly:x,isHidden:f}=$.useSection(),h=o||!!x(e),y=s||!!f(e),{control:C}=S.useFormContext(),{isView:p}=$.useFluigRuntime(),{field:j}=S.useController({name:e,control:C}),{errors:b}=S.useFormState({name:e}),v=b==null?void 0:b[e],N=u.useMemo(()=>i?U[i]??i:null,[i]),R=u.useCallback(r=>{if(!r)return"";const l=r.replace(/\D/g,"");return(Number(l)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),m=u.useCallback(r=>d==="monetary"?R(r):r,[d,R]);return p?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:a}),t.jsx("span",{className:"form-control",children:j.value||"-"})]}):t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:a}),N?t.jsx(X.IMaskInput,{name:e,mask:N,value:String(j.value??""),unmask:!1,onAccept:r=>j.onChange(m(r)),placeholder:n,readOnly:h,className:`form-control ${v?"border-red":""} ${c}`,inputRef:j.ref,onBlur:j.onBlur}):t.jsx("input",{...j,type:"text",value:j.value??"",onChange:r=>j.onChange(m(r.target.value)),placeholder:n,readOnly:h,className:`form-control ${v?"border-red":""} ${c}`}),v&&t.jsx("p",{className:"text-danger",children:String(v.message)})]})}const G=u.memo(Y);function Q({name:e,label:a="",options:n=[],placeholder:d="",labelKey:i="label",valueKey:c="value",enableSearch:o=!1,searchPlaceholder:s="Buscar...",loading:x=!1,onSearchChange:f,debounceTime:h=300,onSelect:y,forceReadOnly:C=!1,forceHidden:p=!1}){const{isReadOnly:j,isHidden:b}=$.useSection(),v=C||!!j(e),N=p||!!b(e),{control:R,clearErrors:m}=S.useFormContext(),{isView:r}=$.useFluigRuntime(),{field:{onChange:l,value:g,ref:P},fieldState:{error:w}}=S.useController({name:e,control:R}),[M,O]=u.useState(!1),[A,q]=u.useState(""),W=u.useRef(null),D=u.useRef(f);u.useEffect(()=>{D.current=f},[f]),u.useEffect(()=>{const k=F=>{W.current&&!W.current.contains(F.target)&&O(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]),u.useEffect(()=>{M||q("")},[M]),u.useEffect(()=>{if(!o)return;const k=setTimeout(()=>{D.current&&D.current(A)},h);return()=>clearTimeout(k)},[A,o,h]);const H=u.useMemo(()=>o&&!f&&A.trim()?n.filter(k=>String((k==null?void 0:k[i])??"").toLowerCase().includes(A.toLowerCase())):n??[],[n,o,f,A,i]),L=u.useMemo(()=>{if(g==null)return"";if(typeof g=="object")return String(g[c]??"");const k=(n||[]).find(F=>String(F==null?void 0:F[c])===String(g));return String(k?(k==null?void 0:k[i])??"":g)},[g,n,c,i]),z=k=>{v||(l(k[c]),y&&y(k),m(e),O(!1))};return t.jsxs("div",{className:`select-wrapper form-group ${N?"hidden":""}`,ref:W,children:[t.jsx("label",{className:"control-label",children:a}),r?t.jsx("span",{className:"form-control",children:L||"-"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`select-control ${w?"border-red":""} ${v?"readOnly":""}`,onClick:()=>!v&&O(k=>!k),ref:P,children:[t.jsx("span",{className:`select-display ${v?"readOnly":""}`,children:L||d}),t.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),M&&!v&&t.jsxs("div",{className:"select-dropdown",children:[o&&t.jsx("div",{className:"select-search",children:t.jsx("input",{type:"text",className:"select-search-input",value:A,onChange:k=>q(k.target.value),placeholder:x?"Carregando...":s,autoFocus:!0,onClick:k=>k.stopPropagation()})}),t.jsx("ul",{className:"select-options",children:x?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[i]},k[c])):t.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),t.jsx("input",{type:"hidden",name:e,value:g||""}),w&&t.jsx("p",{className:"text-danger",children:String(w.message)})]})}const J=u.memo(Q);function Z({name:e,options:a=[],label:n="",valueKey:d="value",labelKey:i="label",forceReadOnly:c=!1,forceHidden:o=!1}){var g,P;const s=S.useFormContext(),{isView:x,isReadOnly:f}=$.useFluigRuntime(),{isReadOnly:h,isHidden:y}=$.useSection(),C=h?h(e):!1,p=y?y(e):!1,j=c||C,b=o||p,v=j||f||x;if(!s||!e)return console.error("Checkbox requer contexto de formulário e nome."),null;const N=()=>!a||!s?{}:a.reduce((w,M)=>{const O=M[d],A=s.getValues(O);return w[O]=A==="on",w},{}),R=s.watch(e),m=u.useMemo(()=>R&&typeof R=="object"?R:N(),[R,a,d]);u.useEffect(()=>{const w=s.getValues(e);(!w||typeof w!="object")&&s.setValue(e,m,{shouldDirty:!1,shouldValidate:!1})},[m,e,s]);const r=(w,M)=>{if(v)return;const O={...m,[w]:M};s.setValue(e,O,{shouldDirty:!0,shouldValidate:!0}),s.setValue(w,M?"on":"",{shouldValidate:!1})},l=(P=(g=s.formState)==null?void 0:g.errors)==null?void 0:P[e];return t.jsxs("div",{className:`form-group ${b?"hidden":""}`,children:[n&&t.jsx("label",{children:n}),t.jsx("div",{className:`checkbox-group-custom ${v?"readOnly":""}`,children:a.map(w=>{const M=String(w[d]),O=m[M]===!0;return t.jsxs("div",{children:[t.jsx("input",{type:"hidden",...s.register(M)}),t.jsxs("label",{className:`custom-checkbox ${O?"checked":""} ${v?"readOnly":""}`,children:[t.jsx("input",{type:"checkbox",checked:O,disabled:v,onChange:A=>r(M,A.target.checked)}),t.jsx("span",{className:"checkmark"}),t.jsx("span",{children:w[i]})]})]},M)})}),l&&t.jsx("p",{className:"text-danger",children:String(l.message)})]})}function K({name:e,label:a="",options:n=[],valueKey:d="value",labelKey:i="label",iconKey:c="icon",forceReadOnly:o=!1,forceHidden:s=!1}){const{isReadOnly:x,isHidden:f}=$.useSection(),h=o||!!x(e),y=s||!!f(e),{control:C}=S.useFormContext(),{isView:p,isReadOnly:j}=$.useFluigRuntime(),{field:b,fieldState:{error:v}}=S.useController({name:e,control:C}),N=h||j||p,R=b.value??"",m=u.useCallback(r=>{N||b.onChange(r)},[N,b]);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 ${N?"view-mode":""}`,"data-field-name":e,children:n.map(r=>{const l=r[d],g=R===l,P=r.color?{"--customColor":r.color}:void 0;return t.jsxs("label",{htmlFor:`${e}_${l}`,style:P,className:`btn fs-ellipsis ${g?"active":""}`,children:[t.jsx("input",{type:"radio",id:`${e}_${l}`,name:e,value:l,checked:g,className:"hidden",onChange:()=>m(l),disabled:N}),r[c]&&t.jsx("i",{className:`${r[c]} icon-sm`})," ",r[i]]},l)})}),v&&t.jsx("p",{className:"text-danger",children:String(v.message)})]})}const ee=u.memo(K),te=({name:e,label:a="",placeholder:n="",className:d="",rows:i=4,maxLength:c,forceReadOnly:o=!1,forceHidden:s=!1})=>{const{isReadOnly:x,isHidden:f}=$.useSection(),h=o||!!x(e),y=s||!!f(e),{control:C}=S.useFormContext(),{isView:p}=$.useFluigRuntime(),{field:j,fieldState:{error:b}}=S.useController({name:e,control:C});return p?t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:a}),t.jsx("span",{className:"form-control",children:j.value||"-"})]}):t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:a}),t.jsx("textarea",{...j,rows:i,maxLength:c,value:j.value||"",placeholder:n,readOnly:h,className:`form-control ${b?"border-red":""} ${d}`}),b&&t.jsx("p",{className:"text-danger",children:String(b.message)})]})},ne=u.memo(te);function _(e){return(a={})=>{const n=a.width?String(a.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function V(e){return(a,n)=>{const d=n!=null&&n.context?String(n.context):"standalone";let i;if(d==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,s=n!=null&&n.width?String(n.width):o;i=e.formattingValues[s]||e.formattingValues[o]}else{const o=e.defaultWidth,s=n!=null&&n.width?String(n.width):e.defaultWidth;i=e.values[s]||e.values[o]}const c=e.argumentCallback?e.argumentCallback(a):a;return i[c]}}function T(e){return(a,n={})=>{const d=n.width,i=d&&e.matchPatterns[d]||e.matchPatterns[e.defaultMatchWidth],c=a.match(i);if(!c)return null;const o=c[0],s=d&&e.parsePatterns[d]||e.parsePatterns[e.defaultParseWidth],x=Array.isArray(s)?ae(s,y=>y.test(o)):se(s,y=>y.test(o));let f;f=e.valueCallback?e.valueCallback(x):x,f=n.valueCallback?n.valueCallback(f):f;const h=a.slice(o.length);return{value:f,rest:h}}}function se(e,a){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&a(e[n]))return n}function ae(e,a){for(let n=0;n<e.length;n++)if(a(e[n]))return n}function re(e){return(a,n={})=>{const d=a.match(e.matchPattern);if(!d)return null;const i=d[0],c=a.match(e.parsePattern);if(!c)return null;let o=e.valueCallback?e.valueCallback(c[0]):c[0];o=n.valueCallback?n.valueCallback(o):o;const s=a.slice(i.length);return{value:o,rest:s}}}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,n)=>{let d;const i=oe[e];return typeof i=="string"?d=i:a===1?d=i.one:d=i.other.replace("{{count}}",String(a)),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"em "+d:"há "+d:d},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:_({formats:le,defaultWidth:"full"}),time:_({formats:ce,defaultWidth:"full"}),dateTime:_({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,n,d)=>{const i=me[e];return typeof i=="function"?i(a):i},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"]},pe={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"}},ve={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"}},je=(e,a)=>{const n=Number(e);return(a==null?void 0:a.unit)==="week"?n+"ª":n+"º"},ye={ordinalNumber:je,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:pe,defaultWidth:"wide",formattingValues:ve,defaultFormattingWidth:"wide"})},Ce=/^(\d+)[ºªo]?/i,we=/\d+/i,Ne={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]},$e={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},Pe={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]},Me={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},Oe={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]},Ae={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},Fe={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:Ce,parsePattern:we,valueCallback:e=>parseInt(e,10)}),era:T({matchPatterns:Ne,defaultMatchWidth:"wide",parsePatterns:ke,defaultParseWidth:"any"}),quarter:T({matchPatterns:Re,defaultMatchWidth:"wide",parsePatterns:Se,defaultParseWidth:"any",valueCallback:e=>e+1}),month:T({matchPatterns:$e,defaultMatchWidth:"wide",parsePatterns:Pe,defaultParseWidth:"any"}),day:T({matchPatterns:Me,defaultMatchWidth:"wide",parsePatterns:Oe,defaultParseWidth:"any"}),dayPeriod:T({matchPatterns:Ae,defaultMatchWidth:"any",parsePatterns:Fe,defaultParseWidth:"any"})},Te={code:"pt-BR",formatDistance:ie,formatLong:ue,formatRelative:he,localize:ye,match:Ve,options:{weekStartsOn:0,firstWeekContainsDate:1}};B.registerLocale("pt-BR",Te);const E="dd/MM/yyyy",We=e=>{if(!e)return null;const a=I.parse(e,E,new Date);return I.isValid(a)?a:null},De=e=>e?I.format(e,E):"",_e=u.forwardRef(({shimRef:e,className:a,name:n,...d},i)=>t.jsx("input",{name:n,...d,className:a,ref:c=>{typeof i=="function"?i(c):i&&(i.current=c),e&&e(c)}})),Ie=({name:e,label:a="",placeholder:n="dd/mm/aaaa",className:d="",forceReadOnly:i=!1,forceHidden:c=!1})=>{const{control:o}=S.useFormContext(),{isView:s}=$.useFluigRuntime(),{isReadOnly:x,isHidden:f}=$.useSection(),h=i||!!x(e),y=c||!!f(e),{field:{onChange:C,onBlur:p,value:j,ref:b},fieldState:{error:v}}=S.useController({name:e,control:o}),N=u.useMemo(()=>We(j),[j]),R=u.useCallback(r=>{C(r?De(r):"")},[C]),m=u.useCallback(r=>{var l,g;if(b(r),r&&((g=(l=o._fields)==null?void 0:l[e])!=null&&g._f)){const P=o._fields[e];P._f.ref={focus:()=>{var w;return(w=r.focus)==null?void 0:w.call(r)},select:()=>{var w;return(w=r.select)==null?void 0:w.call(r)},setCustomValidity:w=>{var M;return(M=r.setCustomValidity)==null?void 0:M.call(r,w)},reportValidity:()=>{var w;return(w=r.reportValidity)==null?void 0:w.call(r)}}}},[b,o,e]);return y?null:s?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:a}),t.jsx("span",{className:"form-control",children:j||"-"})]}):t.jsxs("div",{className:`form-group fluig-style-guide ${d}`,children:[a&&t.jsx("label",{className:"control-label",htmlFor:e,children:a}),t.jsx("div",{className:`${v?"border-red":""}`,children:t.jsx(B,{id:e,name:e,selected:N,onChange:R,onBlur:p,dateFormat:E,placeholderText:n,disabled:h,readOnly:h,locale:"pt-BR",className:`form-control ${v?"border-red":""}`,wrapperClassName:"w-100",showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",isClearable:!h&&!!j,autoComplete:"off",customInput:t.jsx(_e,{name:e,shimRef:m})})}),v&&t.jsx("span",{className:"help-block text-danger",children:String(v.message)})]})},Ee=u.memo(Ie);function qe({mapping:e={},defaultLabel:a="Não reconhecido",className:n="",hidden:d=!1,label:i}){const{activityId:c}=$.useFluigRuntime(),o=u.useMemo(()=>!e||c===null||c===void 0?null:e[c],[c,e]);if(!o)return t.jsxs("div",{className:`form-group ${d?"hidden":""}`,children:[i&&t.jsx("label",{children:i}),t.jsx("div",{className:`status-badge default ${n}`,children:a})]});const s={"--customColor":o.color};return t.jsxs("div",{className:`form-group ${d?"hidden":""}`,children:[i&&t.jsx("label",{children:i}),t.jsxs("div",{className:`status-badge ${n}`,style:s,children:[o.icon&&t.jsx("i",{className:o.icon}),t.jsx("span",{children:o.label})]})]})}const He=u.memo(qe);function Le({name:e,control:a,defaultRowValue:n,isView:d,isReadOnly:i,filters:c=[]}){const{field:o}=S.useController({name:e,control:a}),[s,x]=u.useState([]),[f,h]=u.useState([]),y=()=>Date.now()+Math.random(),C=r=>{try{const l=JSON.parse(r);return Array.isArray(l)?l.map(g=>({...g,_uid:g._uid||y()})):[]}catch(l){return console.error(`Erro ao ler dados da tabela "${e}":`,l),[]}};u.useEffect(()=>{if(!(s.length>0&&!d)&&o.value&&typeof o.value=="string"){const r=JSON.stringify(s);if(o.value===r)return;const l=C(o.value);x(l)}},[o.value,d]),u.useEffect(()=>{if(i)return;const r=JSON.stringify(s);o.value!==r&&o.onChange(r)},[s,o,i]);const p=u.useCallback(()=>{const r={_uid:y(),...n};x(l=>[...l,r])},[n]),j=u.useCallback(()=>{x(r=>r.filter(l=>!f.includes(l._uid))),h([])},[f]),b=u.useCallback((r,l,g)=>{x(P=>P.map(w=>w._uid===r?{...w,[l]:g}:w))},[]),v=u.useCallback(r=>{h(l=>l.includes(r)?l.filter(g=>g!==r):[...l,r])},[]),N=u.useCallback(r=>{h(r?s.map(l=>l._uid):[])},[s]),R=s.length>0&&f.length===s.length,m=u.useMemo(()=>!c||c.length===0?s:s.filter(r=>c.every(l=>{if("custom"in l)return l.custom(r);const g=r[l.field];switch(l.operator){case"===":return g===l.value;case"!==":return g!==l.value;case">":return g>l.value;case"<":return g<l.value;case">=":return g>=l.value;case"<=":return g<=l.value;default:return!0}})),[s,c]);return{field:o,tableRows:s,visibleRows:m,selectedRowIds:f,isAllSelected:R,handle:{addRow:p,removeRows:j,updateCellValue:b,toggleSelection:v,toggleSelectAll:N}}}const Be=({name:e,title:a="Tabela Dinâmica",columns:n,defaultRowValue:d={},forceReadOnly:i=!1,layout:c="fluid",actions:o=!0,filters:s=[]})=>{const{control:x}=S.useFormContext(),{isView:f,isReadOnly:h}=$.useFluigRuntime(),{isReadOnly:y}=$.useSection(),C=i||f||h||y&&y(e),{field:p,visibleRows:j,selectedRowIds:b,isAllSelected:v,handle:N}=Le({name:e,control:x,defaultRowValue:d,isView:f,isReadOnly:!!C,filters:s}),R=c==="fixed";return t.jsxs("div",{className:`table-wrapper ${R?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...p}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:a}),!C&&o&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${b.length>0?"btn-danger":""}`,disabled:b.length===0,onClick:N.removeRows,children:["Remover (",b.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:N.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:[!C&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:v,onChange:m=>N.toggleSelectAll(m.target.checked)})}),n.map(m=>t.jsx("th",{style:m.width?{minWidth:R?m.width:"100%"}:{width:"max-content"},children:m.label},m.key))]})}),t.jsxs("tbody",{children:[j.map((m,r)=>t.jsxs("tr",{children:[!C&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:b.includes(m._uid),onChange:()=>N.toggleSelection(m._uid)})}),n.map(l=>t.jsx("td",{children:l.render?l.render.length<=1?l.render({row:m,index:r,updateRow:(g,P)=>N.updateCellValue(m._uid,g,P),isLocked:!!C,isView:!!f}):l.render(m,r,(g,P)=>N.updateCellValue(m._uid,g,P),!!C,!!f):m[l.key]},`${m._uid}-${l.key}`))]},m._uid)),j.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:C?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},ze=e=>{const[a,n]=u.useState(null),{watch:d}=S.useFormContext(),i=d(e),c=u.useCallback(()=>{if(!i){n(null);return}try{const s=window.top.__REACT_ATTACHMENT_BRIDGE__;if(s){const x=s.getAttachment(e);n(x||{name:i,documentId:0})}else n({name:i,documentId:0})}catch{n({name:i,documentId:0})}},[e,i]);return u.useEffect(()=>{c();const o=setInterval(c,1500);return()=>clearInterval(o)},[c]),{attachment:a,sync:c}},Xe=({name:e,label:a,help:n,className:d="",showRemove:i=!0,showUpdate:c=!0})=>{const{isReadOnly:o}=$.useSection(),{isView:s}=$.useFluigRuntime(),{control:x}=S.useFormContext(),{field:f}=S.useController({name:e,control:x}),{attachment:h,sync:y}=ze(e),C=s||!!o(e),p=!!h,j=()=>{var m;try{const r=window.top;return{bridge:r.__REACT_ATTACHMENT_BRIDGE__,toast:(m=r.FLUIGC)==null?void 0:m.toast}}catch{return{bridge:null,toast:null}}},b=(m,r="info")=>{const{toast:l}=j();l?l({title:"Anexos: ",message:m,type:r}):console.log(`[LOCALHOST TOAST - ${r.toUpperCase()}]: ${m}`)},v=u.useCallback(()=>{if(C||p)return;const m=document.createElement("input");m.type="file",m.onchange=r=>{const l=r.target.files[0];if(!l)return;const{bridge:g}=j();g?(f.onChange(l.name),g.upload(l,e,P=>{f.onChange(P.name),b(`Arquivo ${l.name} enviado com sucesso!`,"success"),y()})):(f.onChange(l.name),b(`[LOCALHOST] Arquivo "${l.name}" simulado.`,"info"))},m.click()},[C,p,e,f,y]),N=()=>{if(!p)return;const{bridge:m}=j();m?m.view(e):b(`Visualização não disponível em localhost (${h.name})`,"warning")},R=m=>{m.stopPropagation();const{bridge:r}=j(),l=(h==null?void 0:h.name)||"";window.confirm(`Deseja remover o anexo "${l}"?`)&&(r?r.remove(e)?(f.onChange(""),b("Anexo removido com sucesso.","success")):b("Erro ao tentar remover o anexo no Fluig.","danger"):(f.onChange(""),b("[LOCALHOST] Anexo removido da UI.","success")),setTimeout(()=>y(),500))};return t.jsxs("div",{className:`form-group ${d}`,style:{marginBottom:"15px"},children:[a&&t.jsx("label",{className:"control-label",children:a}),t.jsxs("div",{className:`attachment-container ${p?"has-file":""}`,style:{border:`1px ${p?"solid":"dashed"} ${p?"#5cb85c":"#ccc"}`,borderRadius:"4px",padding:"8px 15px",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:C?"#f5f5f5":p?"#f9fff9":"#fff",cursor:C&&!p?"default":"pointer",minHeight:"48px",transition:"all 0.3s ease"},onClick:p?N:v,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1,overflow:"hidden"},children:[t.jsx("i",{className:`fluigicon ${p?"fluigicon-file-pdf":"fluigicon-paperclip"} icon-sm`,style:{color:p?"#5cb85c":"#777"}}),t.jsx("span",{style:{fontSize:"14px",fontWeight:p?"500":"400",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:p?"#333":"#777"},children:p?h.name:n||"Anexar arquivo"})]}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginLeft:"10px"},children:[p&&t.jsx("button",{type:"button",className:"btn btn-sm btn-link",title:"Visualizar",style:{padding:"0 5px",color:"#555"},children:t.jsx("i",{className:"fluigicon fluigicon-eye-open"})}),!C&&p&&t.jsxs(t.Fragment,{children:[c&&t.jsx("button",{type:"button",className:"btn btn-sm btn-link",title:"Substituir",style:{padding:"0 5px",color:"#31708f"},onClick:m=>{R(m),setTimeout(v,400)},children:t.jsx("i",{className:"fluigicon fluigicon-refresh"})}),i&&t.jsx("button",{type:"button",className:"btn btn-sm btn-link text-danger",title:"Remover",style:{padding:"0 5px"},onClick:R,children:t.jsx("i",{className:"fluigicon fluigicon-trash"})})]})]})]}),t.jsx("input",{type:"hidden",name:e,value:f.value||""})]})},Ue=u.memo(Xe);function Ye({items:e,time:a=0,showNavigation:n=!0,progressBar:d=!0}){const[i,c]=u.useState(0),[o,s]=u.useState(0),x=u.useRef(null),f=u.useRef(null),h=u.useCallback(()=>{c(b=>(b+1)%e.length),s(0)},[e.length]),y=u.useCallback(()=>{c(b=>(b-1+e.length)%e.length),s(0)},[e.length]);if(u.useEffect(()=>{if(a>0&&e.length>1){const v=100/a*100;x.current=setInterval(h,a),f.current=setInterval(()=>{s(N=>N>=100?0:N+v)},100)}return()=>{x.current&&clearInterval(x.current),f.current&&clearInterval(f.current)}},[a,h,e.length,i]),!e||e.length===0)return null;const C=e[i],p=typeof C=="string"?C:C.url,j=/\.(jpg|jpeg|png|gif|webp)$/i.test(p);return t.jsxs("div",{className:"carousel-root",children:[t.jsxs("div",{className:"carousel-viewport",children:[n&&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:h,children:t.jsx("i",{className:"flaticon flaticon-chevron-right"})})]}),t.jsx("div",{className:"carousel-media",children:j?t.jsx("img",{src:p,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:p,target:"_blank",rel:"noreferrer",className:"btn-open",children:"Abrir Arquivo"})]})}),e.length>1&&t.jsx("div",{className:"carousel-dots",children:e.map((b,v)=>t.jsx("div",{className:`dot ${v===i?"active":""}`,onClick:()=>{c(v),s(0)}},v))})]}),d&&a>0&&e.length>1&&t.jsx("div",{className:"carousel-progress-container",children:t.jsx("div",{className:"carousel-progress-bar",style:{width:`${o}%`}})})]})}function Ge({title:e,isOpen:a,onOpen:n,onClose:d,content:i,footer:c,width:o}){const s=u.useCallback(x=>{x.key==="Escape"&&d()},[d]);return u.useEffect(()=>(a&&(document.addEventListener("keydown",s),n==null||n(),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",s),document.body.style.overflow="auto"}),[a,s,n]),a?t.jsx("div",{className:"modal-overlay",onClick:d,"aria-modal":"true",role:"dialog",children:t.jsxs("div",{style:{maxWidth:o},className:"modal-container",onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsx("h3",{children:e}),t.jsx("div",{className:"btn-close-modal",onClick:d,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:i}),c&&t.jsx("div",{className:"modal-footer",children:c})]})}):null}function Qe({logo:e,childs:a,footer:n,contentExternal:d,bg:i,color:c,onSelect:o}){return t.jsxs("div",{className:"main-container dfea",children:[t.jsxs("div",{className:"sidebar-wrapper",style:{backgroundColor:`${i}`},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(s=>{var x,f;return s!=null&&s.options&&((x=s==null?void 0:s.options)==null?void 0:x.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 h;(h=s.action)==null||h.call(s),o==null||o(s.id)},style:{color:`${c}`},children:[s.icon&&t.jsx("i",{className:s.icon}),s.label]}),(f=s.options)==null?void 0:f.map(h=>t.jsx("li",{className:"sidebar-option",onClick:()=>{var y;(y=h.action)==null||y.call(h),o==null||o(h.id)},style:{color:`${c}`},children:h.label}))]})}):t.jsxs("li",{className:"sidebar-child",onClick:()=>{var h;(h=s.action)==null||h.call(s),o==null||o(s.id)},style:{color:`${c}`},children:[s.icon&&t.jsx("i",{className:s.icon}),s.label]})})}),n&&t.jsx("div",{className:"sidebar-footer",children:n})]}),t.jsx("div",{className:"sidebar-content-external",children:d})]})}exports.Attachment=Ue;exports.Carousel=Ye;exports.Checkbox=Z;exports.DatePicker=Ee;exports.Input=G;exports.Modal=Ge;exports.RadioBtn=ee;exports.Select=J;exports.Sidebar=Qe;exports.SimpleTable=Be;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"),B=require("react-datepicker"),I=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:n="",type:d="text",mask:i,className:c="",forceReadOnly:o=!1,forceHidden:s=!1}){const{isReadOnly:x,isHidden:f}=$.useSection(),h=o||!!x(e),y=s||!!f(e),{control:w}=S.useFormContext(),{isView:p}=$.useFluigRuntime(),{field:j}=S.useController({name:e,control:w}),{errors:b}=S.useFormState({name:e}),v=b==null?void 0:b[e],N=u.useMemo(()=>i?U[i]??i:null,[i]),R=u.useCallback(r=>{if(!r)return"";const l=r.replace(/\D/g,"");return(Number(l)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),m=u.useCallback(r=>d==="monetary"?R(r):r,[d,R]);return p?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:a}),t.jsx("span",{className:"form-control",children:j.value||"-"})]}):t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:a}),N?t.jsx(X.IMaskInput,{name:e,mask:N,value:String(j.value??""),unmask:!1,onAccept:r=>j.onChange(m(r)),placeholder:n,readOnly:h,className:`form-control ${v?"border-red":""} ${c}`,inputRef:j.ref,onBlur:j.onBlur}):t.jsx("input",{...j,type:"text",value:j.value??"",onChange:r=>j.onChange(m(r.target.value)),placeholder:n,readOnly:h,className:`form-control ${v?"border-red":""} ${c}`}),v&&t.jsx("p",{className:"text-danger",children:String(v.message)})]})}const G=u.memo(Y);function Q({name:e,label:a="",options:n=[],placeholder:d="",labelKey:i="label",valueKey:c="value",enableSearch:o=!1,searchPlaceholder:s="Buscar...",loading:x=!1,onSearchChange:f,debounceTime:h=300,onSelect:y,forceReadOnly:w=!1,forceHidden:p=!1}){const{isReadOnly:j,isHidden:b}=$.useSection(),v=w||!!j(e),N=p||!!b(e),{control:R,clearErrors:m}=S.useFormContext(),{isView:r}=$.useFluigRuntime(),{field:{onChange:l,value:g,ref:P},fieldState:{error:C}}=S.useController({name:e,control:R}),[M,O]=u.useState(!1),[F,q]=u.useState(""),W=u.useRef(null),D=u.useRef(f);u.useEffect(()=>{D.current=f},[f]),u.useEffect(()=>{const k=A=>{W.current&&!W.current.contains(A.target)&&O(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]),u.useEffect(()=>{M||q("")},[M]),u.useEffect(()=>{if(!o)return;const k=setTimeout(()=>{D.current&&D.current(F)},h);return()=>clearTimeout(k)},[F,o,h]);const H=u.useMemo(()=>o&&!f&&F.trim()?n.filter(k=>String((k==null?void 0:k[i])??"").toLowerCase().includes(F.toLowerCase())):n??[],[n,o,f,F,i]),L=u.useMemo(()=>{if(g==null)return"";if(typeof g=="object")return String(g[c]??"");const k=(n||[]).find(A=>String(A==null?void 0:A[c])===String(g));return String(k?(k==null?void 0:k[i])??"":g)},[g,n,c,i]),z=k=>{v||(l(k[c]),y&&y(k),m(e),O(!1))};return t.jsxs("div",{className:`select-wrapper form-group ${N?"hidden":""}`,ref:W,children:[t.jsx("label",{className:"control-label",children:a}),r?t.jsx("span",{className:"form-control",children:L||"-"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`select-control ${C?"border-red":""} ${v?"readOnly":""}`,onClick:()=>!v&&O(k=>!k),ref:P,children:[t.jsx("span",{className:`select-display ${v?"readOnly":""}`,children:L||d}),t.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),M&&!v&&t.jsxs("div",{className:"select-dropdown",children:[o&&t.jsx("div",{className:"select-search",children:t.jsx("input",{type:"text",className:"select-search-input",value:F,onChange:k=>q(k.target.value),placeholder:x?"Carregando...":s,autoFocus:!0,onClick:k=>k.stopPropagation()})}),t.jsx("ul",{className:"select-options",children:x?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[i]},k[c])):t.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),t.jsx("input",{type:"hidden",name:e,value:g||""}),C&&t.jsx("p",{className:"text-danger",children:String(C.message)})]})}const J=u.memo(Q);function Z({name:e,options:a=[],label:n="",valueKey:d="value",labelKey:i="label",forceReadOnly:c=!1,forceHidden:o=!1}){var g,P;const s=S.useFormContext(),{isView:x,isReadOnly:f}=$.useFluigRuntime(),{isReadOnly:h,isHidden:y}=$.useSection(),w=h?h(e):!1,p=y?y(e):!1,j=c||w,b=o||p,v=j||f||x;if(!s||!e)return console.error("Checkbox requer contexto de formulário e nome."),null;const N=()=>!a||!s?{}:a.reduce((C,M)=>{const O=M[d],F=s.getValues(O);return C[O]=F==="on",C},{}),R=s.watch(e),m=u.useMemo(()=>R&&typeof R=="object"?R:N(),[R,a,d]);u.useEffect(()=>{const C=s.getValues(e);(!C||typeof C!="object")&&s.setValue(e,m,{shouldDirty:!1,shouldValidate:!1})},[m,e,s]);const r=(C,M)=>{if(v)return;const O={...m,[C]:M};s.setValue(e,O,{shouldDirty:!0,shouldValidate:!0}),s.setValue(C,M?"on":"",{shouldValidate:!1})},l=(P=(g=s.formState)==null?void 0:g.errors)==null?void 0:P[e];return t.jsxs("div",{className:`form-group ${b?"hidden":""}`,children:[n&&t.jsx("label",{children:n}),t.jsx("div",{className:`checkbox-group-custom ${v?"readOnly":""}`,children:a.map(C=>{const M=String(C[d]),O=m[M]===!0;return t.jsxs("div",{children:[t.jsx("input",{type:"hidden",...s.register(M)}),t.jsxs("label",{className:`custom-checkbox ${O?"checked":""} ${v?"readOnly":""}`,children:[t.jsx("input",{type:"checkbox",checked:O,disabled:v,onChange:F=>r(M,F.target.checked)}),t.jsx("span",{className:"checkmark"}),t.jsx("span",{children:C[i]})]})]},M)})}),l&&t.jsx("p",{className:"text-danger",children:String(l.message)})]})}function K({name:e,label:a="",options:n=[],valueKey:d="value",labelKey:i="label",iconKey:c="icon",forceReadOnly:o=!1,forceHidden:s=!1}){const{isReadOnly:x,isHidden:f}=$.useSection(),h=o||!!x(e),y=s||!!f(e),{control:w}=S.useFormContext(),{isView:p,isReadOnly:j}=$.useFluigRuntime(),{field:b,fieldState:{error:v}}=S.useController({name:e,control:w}),N=h||j||p,R=b.value??"",m=u.useCallback(r=>{N||b.onChange(r)},[N,b]);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 ${N?"view-mode":""}`,"data-field-name":e,children:n.map(r=>{const l=r[d],g=R===l,P=r.color?{"--customColor":r.color}:void 0;return t.jsxs("label",{htmlFor:`${e}_${l}`,style:P,className:`btn fs-ellipsis ${g?"active":""}`,children:[t.jsx("input",{type:"radio",id:`${e}_${l}`,name:e,value:l,checked:g,className:"hidden",onChange:()=>m(l),disabled:N}),r[c]&&t.jsx("i",{className:`${r[c]} icon-sm`})," ",r[i]]},l)})}),v&&t.jsx("p",{className:"text-danger",children:String(v.message)})]})}const ee=u.memo(K),te=({name:e,label:a="",placeholder:n="",className:d="",rows:i=4,maxLength:c,forceReadOnly:o=!1,forceHidden:s=!1})=>{const{isReadOnly:x,isHidden:f}=$.useSection(),h=o||!!x(e),y=s||!!f(e),{control:w}=S.useFormContext(),{isView:p}=$.useFluigRuntime(),{field:j,fieldState:{error:b}}=S.useController({name:e,control:w});return p?t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:a}),t.jsx("span",{className:"form-control",children:j.value||"-"})]}):t.jsxs("div",{className:`form-group ${y?"hidden":""}`,children:[t.jsx("label",{children:a}),t.jsx("textarea",{...j,rows:i,maxLength:c,value:j.value||"",placeholder:n,readOnly:h,className:`form-control ${b?"border-red":""} ${d}`}),b&&t.jsx("p",{className:"text-danger",children:String(b.message)})]})},ne=u.memo(te);function _(e){return(a={})=>{const n=a.width?String(a.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function V(e){return(a,n)=>{const d=n!=null&&n.context?String(n.context):"standalone";let i;if(d==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,s=n!=null&&n.width?String(n.width):o;i=e.formattingValues[s]||e.formattingValues[o]}else{const o=e.defaultWidth,s=n!=null&&n.width?String(n.width):e.defaultWidth;i=e.values[s]||e.values[o]}const c=e.argumentCallback?e.argumentCallback(a):a;return i[c]}}function T(e){return(a,n={})=>{const d=n.width,i=d&&e.matchPatterns[d]||e.matchPatterns[e.defaultMatchWidth],c=a.match(i);if(!c)return null;const o=c[0],s=d&&e.parsePatterns[d]||e.parsePatterns[e.defaultParseWidth],x=Array.isArray(s)?ae(s,y=>y.test(o)):se(s,y=>y.test(o));let f;f=e.valueCallback?e.valueCallback(x):x,f=n.valueCallback?n.valueCallback(f):f;const h=a.slice(o.length);return{value:f,rest:h}}}function se(e,a){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&a(e[n]))return n}function ae(e,a){for(let n=0;n<e.length;n++)if(a(e[n]))return n}function re(e){return(a,n={})=>{const d=a.match(e.matchPattern);if(!d)return null;const i=d[0],c=a.match(e.parsePattern);if(!c)return null;let o=e.valueCallback?e.valueCallback(c[0]):c[0];o=n.valueCallback?n.valueCallback(o):o;const s=a.slice(i.length);return{value:o,rest:s}}}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,n)=>{let d;const i=oe[e];return typeof i=="string"?d=i:a===1?d=i.one:d=i.other.replace("{{count}}",String(a)),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"em "+d:"há "+d:d},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:_({formats:le,defaultWidth:"full"}),time:_({formats:ce,defaultWidth:"full"}),dateTime:_({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,n,d)=>{const i=me[e];return typeof i=="function"?i(a):i},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"]},pe={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"}},ve={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"}},je=(e,a)=>{const n=Number(e);return(a==null?void 0:a.unit)==="week"?n+"ª":n+"º"},ye={ordinalNumber:je,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:pe,defaultWidth:"wide",formattingValues:ve,defaultFormattingWidth:"wide"})},we=/^(\d+)[ºªo]?/i,Ce=/\d+/i,Ne={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]},$e={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},Pe={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]},Me={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},Oe={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]},Fe={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:we,parsePattern:Ce,valueCallback:e=>parseInt(e,10)}),era:T({matchPatterns:Ne,defaultMatchWidth:"wide",parsePatterns:ke,defaultParseWidth:"any"}),quarter:T({matchPatterns:Re,defaultMatchWidth:"wide",parsePatterns:Se,defaultParseWidth:"any",valueCallback:e=>e+1}),month:T({matchPatterns:$e,defaultMatchWidth:"wide",parsePatterns:Pe,defaultParseWidth:"any"}),day:T({matchPatterns:Me,defaultMatchWidth:"wide",parsePatterns:Oe,defaultParseWidth:"any"}),dayPeriod:T({matchPatterns:Fe,defaultMatchWidth:"any",parsePatterns:Ae,defaultParseWidth:"any"})},Te={code:"pt-BR",formatDistance:ie,formatLong:ue,formatRelative:he,localize:ye,match:Ve,options:{weekStartsOn:0,firstWeekContainsDate:1}};B.registerLocale("pt-BR",Te);const E="dd/MM/yyyy",We=e=>{if(!e)return null;const a=I.parse(e,E,new Date);return I.isValid(a)?a:null},De=e=>e?I.format(e,E):"",_e=u.forwardRef(({shimRef:e,className:a,name:n,...d},i)=>t.jsx("input",{name:n,...d,className:a,ref:c=>{typeof i=="function"?i(c):i&&(i.current=c),e&&e(c)}})),Ie=({name:e,label:a="",placeholder:n="dd/mm/aaaa",className:d="",forceReadOnly:i=!1,forceHidden:c=!1})=>{const{control:o}=S.useFormContext(),{isView:s}=$.useFluigRuntime(),{isReadOnly:x,isHidden:f}=$.useSection(),h=i||!!x(e),y=c||!!f(e),{field:{onChange:w,onBlur:p,value:j,ref:b},fieldState:{error:v}}=S.useController({name:e,control:o}),N=u.useMemo(()=>We(j),[j]),R=u.useCallback(r=>{w(r?De(r):"")},[w]),m=u.useCallback(r=>{var l,g;if(b(r),r&&((g=(l=o._fields)==null?void 0:l[e])!=null&&g._f)){const P=o._fields[e];P._f.ref={focus:()=>{var C;return(C=r.focus)==null?void 0:C.call(r)},select:()=>{var C;return(C=r.select)==null?void 0:C.call(r)},setCustomValidity:C=>{var M;return(M=r.setCustomValidity)==null?void 0:M.call(r,C)},reportValidity:()=>{var C;return(C=r.reportValidity)==null?void 0:C.call(r)}}}},[b,o,e]);return y?null:s?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:a}),t.jsx("span",{className:"form-control",children:j||"-"})]}):t.jsxs("div",{className:`form-group fluig-style-guide ${d}`,children:[a&&t.jsx("label",{className:"control-label",htmlFor:e,children:a}),t.jsx("div",{className:`${v?"border-red":""}`,children:t.jsx(B,{id:e,name:e,selected:N,onChange:R,onBlur:p,dateFormat:E,placeholderText:n,disabled:h,readOnly:h,locale:"pt-BR",className:`form-control ${v?"border-red":""}`,wrapperClassName:"w-100",showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",isClearable:!h&&!!j,autoComplete:"off",customInput:t.jsx(_e,{name:e,shimRef:m})})}),v&&t.jsx("span",{className:"help-block text-danger",children:String(v.message)})]})},Ee=u.memo(Ie);function qe({mapping:e={},defaultLabel:a="Não reconhecido",className:n="",hidden:d=!1,label:i}){const{activityId:c}=$.useFluigRuntime(),o=u.useMemo(()=>!e||c===null||c===void 0?null:e[c],[c,e]);if(!o)return t.jsxs("div",{className:`form-group ${d?"hidden":""}`,children:[i&&t.jsx("label",{children:i}),t.jsx("div",{className:`status-badge default ${n}`,children:a})]});const s={"--customColor":o.color};return t.jsxs("div",{className:`form-group ${d?"hidden":""}`,children:[i&&t.jsx("label",{children:i}),t.jsxs("div",{className:`status-badge ${n}`,style:s,children:[o.icon&&t.jsx("i",{className:o.icon}),t.jsx("span",{children:o.label})]})]})}const He=u.memo(qe);function Le({name:e,control:a,defaultRowValue:n,isView:d,isReadOnly:i,filters:c=[]}){const{field:o}=S.useController({name:e,control:a}),[s,x]=u.useState([]),[f,h]=u.useState([]),y=()=>Date.now()+Math.random(),w=r=>{try{const l=JSON.parse(r);return Array.isArray(l)?l.map(g=>({...g,_uid:g._uid||y()})):[]}catch(l){return console.error(`Erro ao ler dados da tabela "${e}":`,l),[]}};u.useEffect(()=>{if(!(s.length>0&&!d)&&o.value&&typeof o.value=="string"){const r=JSON.stringify(s);if(o.value===r)return;const l=w(o.value);x(l)}},[o.value,d]),u.useEffect(()=>{if(i)return;const r=JSON.stringify(s);o.value!==r&&o.onChange(r)},[s,o,i]);const p=u.useCallback(()=>{const r={_uid:y(),...n};x(l=>[...l,r])},[n]),j=u.useCallback(()=>{x(r=>r.filter(l=>!f.includes(l._uid))),h([])},[f]),b=u.useCallback((r,l,g)=>{x(P=>P.map(C=>C._uid===r?{...C,[l]:g}:C))},[]),v=u.useCallback(r=>{h(l=>l.includes(r)?l.filter(g=>g!==r):[...l,r])},[]),N=u.useCallback(r=>{h(r?s.map(l=>l._uid):[])},[s]),R=s.length>0&&f.length===s.length,m=u.useMemo(()=>!c||c.length===0?s:s.filter(r=>c.every(l=>{if("custom"in l)return l.custom(r);const g=r[l.field];switch(l.operator){case"===":return g===l.value;case"!==":return g!==l.value;case">":return g>l.value;case"<":return g<l.value;case">=":return g>=l.value;case"<=":return g<=l.value;default:return!0}})),[s,c]);return{field:o,tableRows:s,visibleRows:m,selectedRowIds:f,isAllSelected:R,handle:{addRow:p,removeRows:j,updateCellValue:b,toggleSelection:v,toggleSelectAll:N}}}const Be=({name:e,title:a="Tabela Dinâmica",columns:n,defaultRowValue:d={},forceReadOnly:i=!1,layout:c="fluid",actions:o=!0,filters:s=[]})=>{const{control:x}=S.useFormContext(),{isView:f,isReadOnly:h}=$.useFluigRuntime(),{isReadOnly:y}=$.useSection(),w=i||f||h||y&&y(e),{field:p,visibleRows:j,selectedRowIds:b,isAllSelected:v,handle:N}=Le({name:e,control:x,defaultRowValue:d,isView:f,isReadOnly:!!w,filters:s}),R=c==="fixed";return t.jsxs("div",{className:`table-wrapper ${R?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...p}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:a}),!w&&o&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${b.length>0?"btn-danger":""}`,disabled:b.length===0,onClick:N.removeRows,children:["Remover (",b.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:N.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:v,onChange:m=>N.toggleSelectAll(m.target.checked)})}),n.map(m=>t.jsx("th",{style:m.width?{minWidth:R?m.width:"100%"}:{width:"max-content"},children:m.label},m.key))]})}),t.jsxs("tbody",{children:[j.map((m,r)=>t.jsxs("tr",{children:[!w&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:b.includes(m._uid),onChange:()=>N.toggleSelection(m._uid)})}),n.map(l=>t.jsx("td",{children:l.render?l.render.length<=1?l.render({row:m,index:r,updateRow:(g,P)=>N.updateCellValue(m._uid,g,P),isLocked:!!w,isView:!!f}):l.render(m,r,(g,P)=>N.updateCellValue(m._uid,g,P),!!w,!!f):m[l.key]},`${m._uid}-${l.key}`))]},m._uid)),j.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=>{const[a,n]=u.useState(null),{watch:d}=S.useFormContext(),i=d(e),c=u.useCallback(()=>{try{const s=window.top.__REACT_ATTACHMENT_BRIDGE__;if(s){const x=s.getAttachment(e);n(x||(i?{name:i,documentId:0}:null))}else n(i?{name:i,documentId:0}:null)}catch{n(i?{name:i,documentId:0}:null)}},[e,i]);return u.useEffect(()=>{c();const o=setInterval(c,2e3);return()=>clearInterval(o)},[c]),{attachment:a,sync:c}},Xe=({name:e,label:a,help:n,className:d="",showRemove:i=!0,showUpdate:c=!0})=>{const{isReadOnly:o}=$.useSection(),{isView:s}=$.useFluigRuntime(),{control:x}=S.useFormContext(),{field:f}=S.useController({name:e,control:x}),{attachment:h,sync:y}=ze(e),w=s||!!o(e),p=!!h,j=()=>{var m;try{const r=window.top;return{bridge:r.__REACT_ATTACHMENT_BRIDGE__,toast:(m=r.FLUIGC)==null?void 0:m.toast}}catch{return{bridge:null,toast:null}}},b=(m,r="info")=>{const{toast:l}=j();l?l({title:"Anexos: ",message:m,type:r}):console.log(`[LOCALHOST TOAST - ${r.toUpperCase()}]: ${m}`)},v=u.useCallback(()=>{if(w||p)return;const m=document.createElement("input");m.type="file",m.onchange=r=>{const l=r.target.files[0];if(!l)return;const{bridge:g}=j();g?(f.onChange(l.name),g.upload(l,e,P=>{f.onChange(P.name),b(`Arquivo ${l.name} enviado com sucesso!`,"success"),y()})):(f.onChange(l.name),b(`[LOCALHOST] Arquivo "${l.name}" simulado.`,"info"))},m.click()},[w,p,e,f,y]),N=()=>{if(!p)return;const{bridge:m}=j();m?m.view(e):b(`Visualização não disponível em localhost (${h.name})`,"warning")},R=m=>{m.stopPropagation();const{bridge:r}=j(),l=(h==null?void 0:h.name)||f.value;window.confirm(`Deseja remover o anexo "${l}"?`)&&(f.onChange(""),r?r.remove(e)?b("Anexo removido com sucesso.","success"):console.warn("Fluig não encontrou o arquivo para deletar fisicamente."):b("[LOCALHOST] Removido.","success"),setTimeout(()=>y(),200))};return t.jsxs("div",{className:`form-group ${d}`,style:{marginBottom:"15px"},children:[a&&t.jsx("label",{className:"control-label",children:a}),t.jsxs("div",{className:`attachment-container ${p?"has-file":""}`,style:{border:`1px ${p?"solid":"dashed"} ${p?"#5cb85c":"#ccc"}`,borderRadius:"4px",padding:"8px 15px",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:w?"#f5f5f5":p?"#f9fff9":"#fff",cursor:w&&!p?"default":"pointer",minHeight:"48px",transition:"all 0.3s ease"},onClick:p?N:v,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1,overflow:"hidden"},children:[t.jsx("i",{className:`fluigicon ${p?"fluigicon-file-pdf":"fluigicon-paperclip"} icon-sm`,style:{color:p?"#5cb85c":"#777"}}),t.jsx("span",{style:{fontSize:"14px",fontWeight:p?"500":"400",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:p?"#333":"#777"},children:p?h.name:n||"Anexar arquivo"})]}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginLeft:"10px"},children:[p&&t.jsx("button",{type:"button",className:"btn btn-sm btn-link",title:"Visualizar",style:{padding:"0 5px",color:"#555"},children:t.jsx("i",{className:"fluigicon fluigicon-eye-open"})}),!w&&p&&t.jsxs(t.Fragment,{children:[c&&t.jsx("button",{type:"button",className:"btn btn-sm btn-link",title:"Substituir",style:{padding:"0 5px",color:"#31708f"},onClick:m=>{R(m),setTimeout(v,400)},children:t.jsx("i",{className:"fluigicon fluigicon-refresh"})}),i&&t.jsx("button",{type:"button",className:"btn btn-sm btn-link text-danger",title:"Remover",style:{padding:"0 5px"},onClick:R,children:t.jsx("i",{className:"fluigicon fluigicon-trash"})})]})]})]}),t.jsx("input",{type:"hidden",name:e,value:f.value||""})]})},Ue=u.memo(Xe);function Ye({items:e,time:a=0,showNavigation:n=!0,progressBar:d=!0}){const[i,c]=u.useState(0),[o,s]=u.useState(0),x=u.useRef(null),f=u.useRef(null),h=u.useCallback(()=>{c(b=>(b+1)%e.length),s(0)},[e.length]),y=u.useCallback(()=>{c(b=>(b-1+e.length)%e.length),s(0)},[e.length]);if(u.useEffect(()=>{if(a>0&&e.length>1){const v=100/a*100;x.current=setInterval(h,a),f.current=setInterval(()=>{s(N=>N>=100?0:N+v)},100)}return()=>{x.current&&clearInterval(x.current),f.current&&clearInterval(f.current)}},[a,h,e.length,i]),!e||e.length===0)return null;const w=e[i],p=typeof w=="string"?w:w.url,j=/\.(jpg|jpeg|png|gif|webp)$/i.test(p);return t.jsxs("div",{className:"carousel-root",children:[t.jsxs("div",{className:"carousel-viewport",children:[n&&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:h,children:t.jsx("i",{className:"flaticon flaticon-chevron-right"})})]}),t.jsx("div",{className:"carousel-media",children:j?t.jsx("img",{src:p,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:p,target:"_blank",rel:"noreferrer",className:"btn-open",children:"Abrir Arquivo"})]})}),e.length>1&&t.jsx("div",{className:"carousel-dots",children:e.map((b,v)=>t.jsx("div",{className:`dot ${v===i?"active":""}`,onClick:()=>{c(v),s(0)}},v))})]}),d&&a>0&&e.length>1&&t.jsx("div",{className:"carousel-progress-container",children:t.jsx("div",{className:"carousel-progress-bar",style:{width:`${o}%`}})})]})}function Ge({title:e,isOpen:a,onOpen:n,onClose:d,content:i,footer:c,width:o}){const s=u.useCallback(x=>{x.key==="Escape"&&d()},[d]);return u.useEffect(()=>(a&&(document.addEventListener("keydown",s),n==null||n(),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",s),document.body.style.overflow="auto"}),[a,s,n]),a?t.jsx("div",{className:"modal-overlay",onClick:d,"aria-modal":"true",role:"dialog",children:t.jsxs("div",{style:{maxWidth:o},className:"modal-container",onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsx("h3",{children:e}),t.jsx("div",{className:"btn-close-modal",onClick:d,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:i}),c&&t.jsx("div",{className:"modal-footer",children:c})]})}):null}function Qe({logo:e,childs:a,footer:n,contentExternal:d,bg:i,color:c,onSelect:o}){return t.jsxs("div",{className:"main-container dfea",children:[t.jsxs("div",{className:"sidebar-wrapper",style:{backgroundColor:`${i}`},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(s=>{var x,f;return s!=null&&s.options&&((x=s==null?void 0:s.options)==null?void 0:x.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 h;(h=s.action)==null||h.call(s),o==null||o(s.id)},style:{color:`${c}`},children:[s.icon&&t.jsx("i",{className:s.icon}),s.label]}),(f=s.options)==null?void 0:f.map(h=>t.jsx("li",{className:"sidebar-option",onClick:()=>{var y;(y=h.action)==null||y.call(h),o==null||o(h.id)},style:{color:`${c}`},children:h.label}))]})}):t.jsxs("li",{className:"sidebar-child",onClick:()=>{var h;(h=s.action)==null||h.call(s),o==null||o(s.id)},style:{color:`${c}`},children:[s.icon&&t.jsx("i",{className:s.icon}),s.label]})})}),n&&t.jsx("div",{className:"sidebar-footer",children:n})]}),t.jsx("div",{className:"sidebar-content-external",children:d})]})}exports.Attachment=Ue;exports.Carousel=Ye;exports.Checkbox=Z;exports.DatePicker=Ee;exports.Input=G;exports.Modal=Ge;exports.RadioBtn=ee;exports.Select=J;exports.Sidebar=Qe;exports.SimpleTable=Be;exports.StatusBadge=He;exports.TextArea=ne;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as f, jsx as t, Fragment as B } from "react/jsx-runtime";
|
|
2
|
-
import { memo as I, useMemo as _, useCallback as
|
|
2
|
+
import { memo as I, useMemo as _, useCallback as O, useState as j, useRef as E, useEffect as V, forwardRef as K } from "react";
|
|
3
3
|
import { useFormContext as T, useController as H, useFormState as ee } from "react-hook-form";
|
|
4
4
|
import { IMaskInput as te } from "react-imask";
|
|
5
5
|
import { useSection as D, useFluigRuntime as W } from "@fluig-kit/ecm";
|
|
@@ -24,14 +24,14 @@ function le({
|
|
|
24
24
|
const { isReadOnly: p, isHidden: h } = D(), m = o || !!p(e), N = a || !!h(e), { control: x } = T(), { isView: v } = W(), { field: w } = H({ name: e, control: x }), { errors: b } = ee({ name: e }), y = b == null ? void 0 : b[e], k = _(
|
|
25
25
|
() => i ? ie[i] ?? i : null,
|
|
26
26
|
[i]
|
|
27
|
-
), $ =
|
|
27
|
+
), $ = O((s) => {
|
|
28
28
|
if (!s) return "";
|
|
29
29
|
const l = s.replace(/\D/g, "");
|
|
30
30
|
return (Number(l) / 100).toLocaleString("pt-BR", {
|
|
31
31
|
style: "currency",
|
|
32
32
|
currency: "BRL"
|
|
33
33
|
});
|
|
34
|
-
}, []), u =
|
|
34
|
+
}, []), u = O(
|
|
35
35
|
(s) => d === "monetary" ? $(s) : s,
|
|
36
36
|
[d, $]
|
|
37
37
|
);
|
|
@@ -92,12 +92,12 @@ function ce({
|
|
|
92
92
|
} = H({
|
|
93
93
|
name: e,
|
|
94
94
|
control: $
|
|
95
|
-
}), [S,
|
|
95
|
+
}), [S, A] = j(!1), [M, G] = j(""), z = E(null), X = E(h);
|
|
96
96
|
V(() => {
|
|
97
97
|
X.current = h;
|
|
98
98
|
}, [h]), V(() => {
|
|
99
99
|
const R = (F) => {
|
|
100
|
-
z.current && !z.current.contains(F.target) &&
|
|
100
|
+
z.current && !z.current.contains(F.target) && A(!1);
|
|
101
101
|
};
|
|
102
102
|
return document.addEventListener("mousedown", R), () => document.removeEventListener("mousedown", R);
|
|
103
103
|
}, []), V(() => {
|
|
@@ -120,7 +120,7 @@ function ce({
|
|
|
120
120
|
);
|
|
121
121
|
return String(R ? (R == null ? void 0 : R[i]) ?? "" : g);
|
|
122
122
|
}, [g, n, c, i]), Z = (R) => {
|
|
123
|
-
y || (l(R[c]), N && N(R), u(e),
|
|
123
|
+
y || (l(R[c]), N && N(R), u(e), A(!1));
|
|
124
124
|
};
|
|
125
125
|
return /* @__PURE__ */ f(
|
|
126
126
|
"div",
|
|
@@ -134,7 +134,7 @@ function ce({
|
|
|
134
134
|
"div",
|
|
135
135
|
{
|
|
136
136
|
className: `select-control ${C ? "border-red" : ""} ${y ? "readOnly" : ""}`,
|
|
137
|
-
onClick: () => !y &&
|
|
137
|
+
onClick: () => !y && A((R) => !R),
|
|
138
138
|
ref: P,
|
|
139
139
|
children: [
|
|
140
140
|
/* @__PURE__ */ t("span", { className: `select-display ${y ? "readOnly" : ""}`, children: J || d }),
|
|
@@ -187,8 +187,8 @@ function lt({
|
|
|
187
187
|
if (!a || !e)
|
|
188
188
|
return console.error("Checkbox requer contexto de formulário e nome."), null;
|
|
189
189
|
const k = () => !r || !a ? {} : r.reduce((C, S) => {
|
|
190
|
-
const
|
|
191
|
-
return C[
|
|
190
|
+
const A = S[d], M = a.getValues(A);
|
|
191
|
+
return C[A] = M === "on", C;
|
|
192
192
|
}, {}), $ = a.watch(e), u = _(() => $ && typeof $ == "object" ? $ : k(), [$, r, d]);
|
|
193
193
|
V(() => {
|
|
194
194
|
const C = a.getValues(e);
|
|
@@ -199,8 +199,8 @@ function lt({
|
|
|
199
199
|
}, [u, e, a]);
|
|
200
200
|
const s = (C, S) => {
|
|
201
201
|
if (y) return;
|
|
202
|
-
const
|
|
203
|
-
a.setValue(e,
|
|
202
|
+
const A = { ...u, [C]: S };
|
|
203
|
+
a.setValue(e, A, {
|
|
204
204
|
shouldDirty: !0,
|
|
205
205
|
shouldValidate: !0
|
|
206
206
|
}), a.setValue(C, S ? "on" : "", { shouldValidate: !1 });
|
|
@@ -212,19 +212,19 @@ function lt({
|
|
|
212
212
|
{
|
|
213
213
|
className: `checkbox-group-custom ${y ? "readOnly" : ""}`,
|
|
214
214
|
children: r.map((C) => {
|
|
215
|
-
const S = String(C[d]),
|
|
215
|
+
const S = String(C[d]), A = u[S] === !0;
|
|
216
216
|
return /* @__PURE__ */ f("div", { children: [
|
|
217
217
|
/* @__PURE__ */ t("input", { type: "hidden", ...a.register(S) }),
|
|
218
218
|
/* @__PURE__ */ f(
|
|
219
219
|
"label",
|
|
220
220
|
{
|
|
221
|
-
className: `custom-checkbox ${
|
|
221
|
+
className: `custom-checkbox ${A ? "checked" : ""} ${y ? "readOnly" : ""}`,
|
|
222
222
|
children: [
|
|
223
223
|
/* @__PURE__ */ t(
|
|
224
224
|
"input",
|
|
225
225
|
{
|
|
226
226
|
type: "checkbox",
|
|
227
|
-
checked:
|
|
227
|
+
checked: A,
|
|
228
228
|
disabled: y,
|
|
229
229
|
onChange: (M) => s(S, M.target.checked)
|
|
230
230
|
}
|
|
@@ -257,7 +257,7 @@ function de({
|
|
|
257
257
|
} = H({
|
|
258
258
|
name: e,
|
|
259
259
|
control: x
|
|
260
|
-
}), k = m || w || v, $ = b.value ?? "", u =
|
|
260
|
+
}), k = m || w || v, $ = b.value ?? "", u = O(
|
|
261
261
|
(s) => {
|
|
262
262
|
k || b.onChange(s);
|
|
263
263
|
},
|
|
@@ -363,7 +363,7 @@ function L(e) {
|
|
|
363
363
|
return i[c];
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function q(e) {
|
|
367
367
|
return (r, n = {}) => {
|
|
368
368
|
const d = n.width, i = d && e.matchPatterns[d] || e.matchPatterns[e.defaultMatchWidth], c = r.match(i);
|
|
369
369
|
if (!c)
|
|
@@ -631,11 +631,11 @@ const ge = {
|
|
|
631
631
|
evening: "da tarde",
|
|
632
632
|
night: "da noite"
|
|
633
633
|
}
|
|
634
|
-
},
|
|
634
|
+
}, Oe = (e, r) => {
|
|
635
635
|
const n = Number(e);
|
|
636
636
|
return (r == null ? void 0 : r.unit) === "week" ? n + "ª" : n + "º";
|
|
637
|
-
},
|
|
638
|
-
ordinalNumber:
|
|
637
|
+
}, Ae = {
|
|
638
|
+
ordinalNumber: Oe,
|
|
639
639
|
era: L({
|
|
640
640
|
values: Ce,
|
|
641
641
|
defaultWidth: "wide"
|
|
@@ -717,7 +717,7 @@ const ge = {
|
|
|
717
717
|
}, Le = {
|
|
718
718
|
narrow: /^(a|p|mn|md|(da) (manhã|tarde|noite))/i,
|
|
719
719
|
any: /^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i
|
|
720
|
-
},
|
|
720
|
+
}, qe = {
|
|
721
721
|
any: {
|
|
722
722
|
am: /^a/i,
|
|
723
723
|
pm: /^p/i,
|
|
@@ -728,41 +728,41 @@ const ge = {
|
|
|
728
728
|
evening: /tarde/i,
|
|
729
729
|
night: /noite/i
|
|
730
730
|
}
|
|
731
|
-
},
|
|
731
|
+
}, Ee = {
|
|
732
732
|
ordinalNumber: fe({
|
|
733
733
|
matchPattern: Me,
|
|
734
734
|
parsePattern: Ve,
|
|
735
735
|
valueCallback: (e) => parseInt(e, 10)
|
|
736
736
|
}),
|
|
737
|
-
era:
|
|
737
|
+
era: q({
|
|
738
738
|
matchPatterns: Te,
|
|
739
739
|
defaultMatchWidth: "wide",
|
|
740
740
|
parsePatterns: We,
|
|
741
741
|
defaultParseWidth: "any"
|
|
742
742
|
}),
|
|
743
|
-
quarter:
|
|
743
|
+
quarter: q({
|
|
744
744
|
matchPatterns: De,
|
|
745
745
|
defaultMatchWidth: "wide",
|
|
746
746
|
parsePatterns: _e,
|
|
747
747
|
defaultParseWidth: "any",
|
|
748
748
|
valueCallback: (e) => e + 1
|
|
749
749
|
}),
|
|
750
|
-
month:
|
|
750
|
+
month: q({
|
|
751
751
|
matchPatterns: je,
|
|
752
752
|
defaultMatchWidth: "wide",
|
|
753
753
|
parsePatterns: Ie,
|
|
754
754
|
defaultParseWidth: "any"
|
|
755
755
|
}),
|
|
756
|
-
day:
|
|
756
|
+
day: q({
|
|
757
757
|
matchPatterns: He,
|
|
758
758
|
defaultMatchWidth: "wide",
|
|
759
759
|
parsePatterns: Fe,
|
|
760
760
|
defaultParseWidth: "any"
|
|
761
761
|
}),
|
|
762
|
-
dayPeriod:
|
|
762
|
+
dayPeriod: q({
|
|
763
763
|
matchPatterns: Le,
|
|
764
764
|
defaultMatchWidth: "any",
|
|
765
|
-
parsePatterns:
|
|
765
|
+
parsePatterns: qe,
|
|
766
766
|
defaultParseWidth: "any"
|
|
767
767
|
})
|
|
768
768
|
}, Be = {
|
|
@@ -770,8 +770,8 @@ const ge = {
|
|
|
770
770
|
formatDistance: pe,
|
|
771
771
|
formatLong: we,
|
|
772
772
|
formatRelative: xe,
|
|
773
|
-
localize:
|
|
774
|
-
match:
|
|
773
|
+
localize: Ae,
|
|
774
|
+
match: Ee,
|
|
775
775
|
options: {
|
|
776
776
|
weekStartsOn: 0,
|
|
777
777
|
firstWeekContainsDate: 1
|
|
@@ -808,12 +808,12 @@ const Y = "dd/MM/yyyy", ze = (e) => {
|
|
|
808
808
|
} = H({
|
|
809
809
|
name: e,
|
|
810
810
|
control: o
|
|
811
|
-
}), k = _(() => ze(w), [w]), $ =
|
|
811
|
+
}), k = _(() => ze(w), [w]), $ = O(
|
|
812
812
|
(s) => {
|
|
813
813
|
x(s ? Xe(s) : "");
|
|
814
814
|
},
|
|
815
815
|
[x]
|
|
816
|
-
), u =
|
|
816
|
+
), u = O(
|
|
817
817
|
(s) => {
|
|
818
818
|
var l, g;
|
|
819
819
|
if (b(s), s && ((g = (l = o._fields) == null ? void 0 : l[e]) != null && g._f)) {
|
|
@@ -927,14 +927,14 @@ function Qe({
|
|
|
927
927
|
const s = JSON.stringify(a);
|
|
928
928
|
o.value !== s && o.onChange(s);
|
|
929
929
|
}, [a, o, i]);
|
|
930
|
-
const v =
|
|
930
|
+
const v = O(() => {
|
|
931
931
|
const s = { _uid: N(), ...n };
|
|
932
932
|
p((l) => [...l, s]);
|
|
933
|
-
}, [n]), w =
|
|
933
|
+
}, [n]), w = O(() => {
|
|
934
934
|
p(
|
|
935
935
|
(s) => s.filter((l) => !h.includes(l._uid))
|
|
936
936
|
), m([]);
|
|
937
|
-
}, [h]), b =
|
|
937
|
+
}, [h]), b = O(
|
|
938
938
|
(s, l, g) => {
|
|
939
939
|
p(
|
|
940
940
|
(P) => P.map(
|
|
@@ -943,11 +943,11 @@ function Qe({
|
|
|
943
943
|
);
|
|
944
944
|
},
|
|
945
945
|
[]
|
|
946
|
-
), y =
|
|
946
|
+
), y = O((s) => {
|
|
947
947
|
m(
|
|
948
948
|
(l) => l.includes(s) ? l.filter((g) => g !== s) : [...l, s]
|
|
949
949
|
);
|
|
950
|
-
}, []), k =
|
|
950
|
+
}, []), k = O(
|
|
951
951
|
(s) => {
|
|
952
952
|
m(s ? a.map((l) => l._uid) : []);
|
|
953
953
|
},
|
|
@@ -1078,25 +1078,21 @@ const ht = ({
|
|
|
1078
1078
|
] }) })
|
|
1079
1079
|
] });
|
|
1080
1080
|
}, Je = (e) => {
|
|
1081
|
-
const [r, n] = j(null), { watch: d } = T(), i = d(e), c =
|
|
1082
|
-
if (!i) {
|
|
1083
|
-
n(null);
|
|
1084
|
-
return;
|
|
1085
|
-
}
|
|
1081
|
+
const [r, n] = j(null), { watch: d } = T(), i = d(e), c = O(() => {
|
|
1086
1082
|
try {
|
|
1087
1083
|
const a = window.top.__REACT_ATTACHMENT_BRIDGE__;
|
|
1088
1084
|
if (a) {
|
|
1089
1085
|
const p = a.getAttachment(e);
|
|
1090
|
-
n(p || { name: i, documentId: 0 });
|
|
1086
|
+
n(p || (i ? { name: i, documentId: 0 } : null));
|
|
1091
1087
|
} else
|
|
1092
|
-
n({ name: i, documentId: 0 });
|
|
1088
|
+
n(i ? { name: i, documentId: 0 } : null);
|
|
1093
1089
|
} catch {
|
|
1094
|
-
n({ name: i, documentId: 0 });
|
|
1090
|
+
n(i ? { name: i, documentId: 0 } : null);
|
|
1095
1091
|
}
|
|
1096
1092
|
}, [e, i]);
|
|
1097
1093
|
return V(() => {
|
|
1098
1094
|
c();
|
|
1099
|
-
const o = setInterval(c,
|
|
1095
|
+
const o = setInterval(c, 2e3);
|
|
1100
1096
|
return () => clearInterval(o);
|
|
1101
1097
|
}, [c]), { attachment: r, sync: c };
|
|
1102
1098
|
}, Ze = ({
|
|
@@ -1121,7 +1117,7 @@ const ht = ({
|
|
|
1121
1117
|
}, b = (u, s = "info") => {
|
|
1122
1118
|
const { toast: l } = w();
|
|
1123
1119
|
l ? l({ title: "Anexos: ", message: u, type: s }) : console.log(`[LOCALHOST TOAST - ${s.toUpperCase()}]: ${u}`);
|
|
1124
|
-
}, y =
|
|
1120
|
+
}, y = O(() => {
|
|
1125
1121
|
if (x || v) return;
|
|
1126
1122
|
const u = document.createElement("input");
|
|
1127
1123
|
u.type = "file", u.onchange = (s) => {
|
|
@@ -1144,8 +1140,10 @@ const ht = ({
|
|
|
1144
1140
|
);
|
|
1145
1141
|
}, $ = (u) => {
|
|
1146
1142
|
u.stopPropagation();
|
|
1147
|
-
const { bridge: s } = w(), l = (m == null ? void 0 : m.name) ||
|
|
1148
|
-
window.confirm(`Deseja remover o anexo "${l}"?`) && (s ? s.remove(e) ?
|
|
1143
|
+
const { bridge: s } = w(), l = (m == null ? void 0 : m.name) || h.value;
|
|
1144
|
+
window.confirm(`Deseja remover o anexo "${l}"?`) && (h.onChange(""), s ? s.remove(e) ? b("Anexo removido com sucesso.", "success") : console.warn(
|
|
1145
|
+
"Fluig não encontrou o arquivo para deletar fisicamente."
|
|
1146
|
+
) : b("[LOCALHOST] Removido.", "success"), setTimeout(() => N(), 200));
|
|
1149
1147
|
};
|
|
1150
1148
|
return /* @__PURE__ */ f("div", { className: `form-group ${d}`, style: { marginBottom: "15px" }, children: [
|
|
1151
1149
|
r && /* @__PURE__ */ t("label", { className: "control-label", children: r }),
|
|
@@ -1252,9 +1250,9 @@ function gt({
|
|
|
1252
1250
|
showNavigation: n = !0,
|
|
1253
1251
|
progressBar: d = !0
|
|
1254
1252
|
}) {
|
|
1255
|
-
const [i, c] = j(0), [o, a] = j(0), p =
|
|
1253
|
+
const [i, c] = j(0), [o, a] = j(0), p = E(null), h = E(null), m = O(() => {
|
|
1256
1254
|
c((b) => (b + 1) % e.length), a(0);
|
|
1257
|
-
}, [e.length]), N =
|
|
1255
|
+
}, [e.length]), N = O(() => {
|
|
1258
1256
|
c((b) => (b - 1 + e.length) % e.length), a(0);
|
|
1259
1257
|
}, [e.length]);
|
|
1260
1258
|
if (V(() => {
|
|
@@ -1317,7 +1315,7 @@ function pt({
|
|
|
1317
1315
|
footer: c,
|
|
1318
1316
|
width: o
|
|
1319
1317
|
}) {
|
|
1320
|
-
const a =
|
|
1318
|
+
const a = O(
|
|
1321
1319
|
(p) => {
|
|
1322
1320
|
p.key === "Escape" && d();
|
|
1323
1321
|
},
|