@tech-diefra/fluig-ui 1.2.20 → 1.2.21
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 +266 -266
- 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"),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:r,className:l="",forceReadOnly:o=!1,forceHidden:n=!1}){const{isReadOnly:g,isHidden:h}=$.useSection(),m=o||!!g(e),v=n||!!h(e),{control:p}=S.useFormContext(),{isView:k}=$.useFluigRuntime(),{field:j}=S.useController({name:e,control:p}),{errors:f}=S.useFormState({name:e}),x=f==null?void 0:f[e],N=u.useMemo(()=>r?U[r]??r:null,[r]),R=u.useCallback(i=>{if(!i)return"";const d=i.replace(/\D/g,"");return(Number(d)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),y=u.useCallback(i=>c==="monetary"?R(i):i,[c,R]);return k?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:j.value||"-"})]}):t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),N?t.jsx(X.IMaskInput,{name:e,mask:N,value:String(j.value??""),unmask:!1,onAccept:i=>j.onChange(y(i)),placeholder:a,readOnly:m,className:`form-control ${x?"border-red":""} ${l}`,inputRef:j.ref,onBlur:j.onBlur}):t.jsx("input",{...j,type:"text",value:j.value??"",onChange:i=>j.onChange(y(i.target.value)),placeholder:a,readOnly:m,className:`form-control ${x?"border-red":""} ${l}`}),x&&t.jsx("p",{className:"text-danger",children:String(x.message)})]})}const G=u.memo(Y);function Q({name:e,label:s="",options:a=[],placeholder:c="",labelKey:r="label",valueKey:l="value",enableSearch:o=!1,searchPlaceholder:n="Buscar...",loading:g=!1,onSearchChange:h,debounceTime:m=300,onSelect:v,forceReadOnly:p=!1,forceHidden:k=!1}){const{isReadOnly:j,isHidden:f}=$.useSection(),x=p||!!j(e),N=k||!!f(e),{control:R,clearErrors:y}=S.useFormContext(),{isView:i}=$.useFluigRuntime(),{field:{onChange:d,value:b,ref:M},fieldState:{error:C}}=S.useController({name:e,control:R}),[P,F]=u.useState(!1),[V,q]=u.useState(""),T=u.useRef(null),_=u.useRef(h);u.useEffect(()=>{_.current=h},[h]),u.useEffect(()=>{const w=A=>{T.current&&!T.current.contains(A.target)&&F(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),u.useEffect(()=>{P||q("")},[P]),u.useEffect(()=>{if(!o)return;const w=setTimeout(()=>{_.current&&_.current(V)},m);return()=>clearTimeout(w)},[V,o,m]);const H=u.useMemo(()=>o&&!h&&V.trim()?a.filter(w=>String((w==null?void 0:w[r])??"").toLowerCase().includes(V.toLowerCase())):a??[],[a,o,h,V,r]),L=u.useMemo(()=>{if(b==null)return"";if(typeof b=="object")return String(b[l]??"");const w=(a||[]).find(A=>String(A==null?void 0:A[l])===String(b));return String(w?(w==null?void 0:w[r])??"":b)},[b,a,l,r]),z=w=>{x||(d(w[l]),v&&v(w),y(e),F(!1))};return t.jsxs("div",{className:`select-wrapper form-group ${N?"hidden":""}`,ref:T,children:[t.jsx("label",{className:"control-label",children:s}),i?t.jsx("span",{className:"form-control",children:L||"-"}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`select-control ${C?"border-red":""} ${x?"readOnly":""}`,onClick:()=>!x&&F(w=>!w),ref:M,children:[t.jsx("span",{className:`select-display ${x?"readOnly":""}`,children:L||c}),t.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),P&&!x&&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:V,onChange:w=>q(w.target.value),placeholder:g?"Carregando...":n,autoFocus:!0,onClick:w=>w.stopPropagation()})}),t.jsx("ul",{className:"select-options",children:g?t.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):H.length>0?H.map(w=>t.jsx("li",{onClick:()=>z(w),className:"select-option handleHover",children:w[r]},w[l])):t.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),t.jsx("input",{type:"hidden",name:e,value:b||""}),C&&t.jsx("p",{className:"text-danger",children:String(C.message)})]})}const J=u.memo(Q);function Z({name:e,options:s=[],label:a="",valueKey:c="value",labelKey:r="label",forceReadOnly:l=!1,forceHidden:o=!1}){var b,M;const n=S.useFormContext(),{isView:g,isReadOnly:h}=$.useFluigRuntime(),{isReadOnly:m,isHidden:v}=$.useSection(),p=m?m(e):!1,k=v?v(e):!1,j=l||p,f=o||k,x=j||h||g;if(!n||!e)return console.error("Checkbox requer contexto de formulário e nome."),null;const N=()=>!s||!n?{}:s.reduce((C,P)=>{const F=P[c],V=n.getValues(F);return C[F]=V==="on",C},{}),R=n.watch(e),y=u.useMemo(()=>R&&typeof R=="object"?R:N(),[R,s,c]);u.useEffect(()=>{const C=n.getValues(e);(!C||typeof C!="object")&&n.setValue(e,y,{shouldDirty:!1,shouldValidate:!1})},[y,e,n]);const i=(C,P)=>{if(x)return;const F={...y,[C]:P};n.setValue(e,F,{shouldDirty:!0,shouldValidate:!0}),n.setValue(C,P?"on":"",{shouldValidate:!1})},d=(M=(b=n.formState)==null?void 0:b.errors)==null?void 0:M[e];return t.jsxs("div",{className:`form-group ${f?"hidden":""}`,children:[a&&t.jsx("label",{children:a}),t.jsx("div",{className:`checkbox-group-custom ${x?"readOnly":""}`,children:s.map(C=>{const P=String(C[c]),F=y[P]===!0;return t.jsxs("div",{children:[t.jsx("input",{type:"hidden",...n.register(P)}),t.jsxs("label",{className:`custom-checkbox ${F?"checked":""} ${x?"readOnly":""}`,children:[t.jsx("input",{type:"checkbox",checked:F,disabled:x,onChange:V=>i(P,V.target.checked)}),t.jsx("span",{className:"checkmark"}),t.jsx("span",{children:C[r]})]})]},P)})}),d&&t.jsx("p",{className:"text-danger",children:String(d.message)})]})}function K({name:e,label:s="",options:a=[],valueKey:c="value",labelKey:r="label",iconKey:l="icon",forceReadOnly:o=!1,forceHidden:n=!1}){const{isReadOnly:g,isHidden:h}=$.useSection(),m=o||!!g(e),v=n||!!h(e),{control:p}=S.useFormContext(),{isView:k,isReadOnly:j}=$.useFluigRuntime(),{field:f,fieldState:{error:x}}=S.useController({name:e,control:p}),N=m||j||k,R=f.value??"",y=u.useCallback(i=>{N||f.onChange(i)},[N,f]);return t.jsxs("div",{className:`form-group column ${v?"hidden":""}`,children:[s&&t.jsx("label",{className:"control-label",children:s}),t.jsx("div",{className:`btn-group ${N?"view-mode":""}`,"data-field-name":e,children:a.map(i=>{const d=i[c],b=R===d,M=i.color?{"--customColor":i.color}:void 0;return t.jsxs("label",{htmlFor:`${e}_${d}`,style:M,className:`btn fs-ellipsis ${b?"active":""}`,children:[t.jsx("input",{type:"radio",id:`${e}_${d}`,name:e,value:d,checked:b,className:"hidden",onChange:()=>y(d),disabled:N}),i[l]&&t.jsx("i",{className:`${i[l]} icon-sm`})," ",i[r]]},d)})}),x&&t.jsx("p",{className:"text-danger",children:String(x.message)})]})}const ee=u.memo(K),te=({name:e,label:s="",placeholder:a="",className:c="",rows:r=4,maxLength:l,forceReadOnly:o=!1,forceHidden:n=!1})=>{const{isReadOnly:g,isHidden:h}=$.useSection(),m=o||!!g(e),v=n||!!h(e),{control:p}=S.useFormContext(),{isView:k}=$.useFluigRuntime(),{field:j,fieldState:{error:f}}=S.useController({name:e,control:p});return k?t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:j.value||"-"})]}):t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("textarea",{...j,rows:r,maxLength:l,value:j.value||"",placeholder:a,readOnly:m,className:`form-control ${f?"border-red":""} ${c}`}),f&&t.jsx("p",{className:"text-danger",children:String(f.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 O(e){return(s,a)=>{const c=a!=null&&a.context?String(a.context):"standalone";let r;if(c==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,n=a!=null&&a.width?String(a.width):o;r=e.formattingValues[n]||e.formattingValues[o]}else{const o=e.defaultWidth,n=a!=null&&a.width?String(a.width):e.defaultWidth;r=e.values[n]||e.values[o]}const l=e.argumentCallback?e.argumentCallback(s):s;return r[l]}}function W(e){return(s,a={})=>{const c=a.width,r=c&&e.matchPatterns[c]||e.matchPatterns[e.defaultMatchWidth],l=s.match(r);if(!l)return null;const o=l[0],n=c&&e.parsePatterns[c]||e.parsePatterns[e.defaultParseWidth],g=Array.isArray(n)?se(n,v=>v.test(o)):ae(n,v=>v.test(o));let h;h=e.valueCallback?e.valueCallback(g):g,h=a.valueCallback?a.valueCallback(h):h;const m=s.slice(o.length);return{value:h,rest:m}}}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 r=c[0],l=s.match(e.parsePattern);if(!l)return null;let o=e.valueCallback?e.valueCallback(l[0]):l[0];o=a.valueCallback?a.valueCallback(o):o;const n=s.slice(r.length);return{value:o,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 r=oe[e];return typeof r=="string"?c=r:s===1?c=r.one:c=r.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 r=me[e];return typeof r=="function"?r(s):r},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"}},pe={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,s)=>{const a=Number(e);return(s==null?void 0:s.unit)==="week"?a+"ª":a+"º"},ye={ordinalNumber:je,era:O({values:fe,defaultWidth:"wide"}),quarter:O({values:ge,defaultWidth:"wide",argumentCallback:e=>e-1}),month:O({values:xe,defaultWidth:"wide"}),day:O({values:be,defaultWidth:"wide"}),dayPeriod:O({values:ve,defaultWidth:"wide",formattingValues:pe,defaultFormattingWidth:"wide"})},Ce=/^(\d+)[ºªo]?/i,Ne=/\d+/i,we={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]},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},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]},Ve={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}},Oe={ordinalNumber:re({matchPattern:Ce,parsePattern:Ne,valueCallback:e=>parseInt(e,10)}),era:W({matchPatterns:we,defaultMatchWidth:"wide",parsePatterns:ke,defaultParseWidth:"any"}),quarter:W({matchPatterns:Re,defaultMatchWidth:"wide",parsePatterns:Se,defaultParseWidth:"any",valueCallback:e=>e+1}),month:W({matchPatterns:Pe,defaultMatchWidth:"wide",parsePatterns:$e,defaultParseWidth:"any"}),day:W({matchPatterns:Me,defaultMatchWidth:"wide",parsePatterns:Fe,defaultParseWidth:"any"}),dayPeriod:W({matchPatterns:Ve,defaultMatchWidth:"any",parsePatterns:Ae,defaultParseWidth:"any"})},We={code:"pt-BR",formatDistance:ie,formatLong:ue,formatRelative:he,localize:ye,match:Oe,options:{weekStartsOn:0,firstWeekContainsDate:1}};B.registerLocale("pt-BR",We);const I="dd/MM/yyyy",Te=e=>{if(!e)return null;const s=E.parse(e,I,new Date);return E.isValid(s)?s:null},_e=e=>e?E.format(e,I):"",De=u.forwardRef(({shimRef:e,className:s,name:a,...c},r)=>t.jsx("input",{name:a,...c,className:s,ref:l=>{typeof r=="function"?r(l):r&&(r.current=l),e&&e(l)}})),Ee=({name:e,label:s="",placeholder:a="dd/mm/aaaa",className:c="",forceReadOnly:r=!1,forceHidden:l=!1})=>{const{control:o}=S.useFormContext(),{isView:n}=$.useFluigRuntime(),{isReadOnly:g,isHidden:h}=$.useSection(),m=r||!!g(e),v=l||!!h(e),{field:{onChange:p,onBlur:k,value:j,ref:f},fieldState:{error:x}}=S.useController({name:e,control:o}),N=u.useMemo(()=>Te(j),[j]),R=u.useCallback(i=>{p(i?_e(i):"")},[p]),y=u.useCallback(i=>{var d,b;if(f(i),i&&((b=(d=o._fields)==null?void 0:d[e])!=null&&b._f)){const M=o._fields[e];M._f.ref={focus:()=>{var C;return(C=i.focus)==null?void 0:C.call(i)},select:()=>{var C;return(C=i.select)==null?void 0:C.call(i)},setCustomValidity:C=>{var P;return(P=i.setCustomValidity)==null?void 0:P.call(i,C)},reportValidity:()=>{var C;return(C=i.reportValidity)==null?void 0:C.call(i)}}}},[f,o,e]);return v?null:n?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:j||"-"})]}):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:`${x?"border-red":""}`,children:t.jsx(B,{id:e,name:e,selected:N,onChange:R,onBlur:k,dateFormat:I,placeholderText:a,disabled:m,readOnly:m,locale:"pt-BR",className:`form-control ${x?"border-red":""}`,wrapperClassName:"w-100",showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",isClearable:!m&&!!j,autoComplete:"off",customInput:t.jsx(De,{name:e,shimRef:y})})}),x&&t.jsx("span",{className:"help-block text-danger",children:String(x.message)})]})},Ie=u.memo(Ee);function qe({mapping:e={},defaultLabel:s="Não reconhecido",className:a="",hidden:c=!1,label:r}){const{activityId:l}=$.useFluigRuntime(),o=u.useMemo(()=>!e||l===null||l===void 0?null:e[l],[l,e]);if(!o)return t.jsxs("div",{className:`form-group ${c?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsx("div",{className:`status-badge default ${a}`,children:s})]});const n={"--customColor":o.color};return t.jsxs("div",{className:`form-group ${c?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsxs("div",{className:`status-badge ${a}`,style:n,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:s,defaultRowValue:a,isView:c,isReadOnly:r,filters:l=[]}){const{field:o}=S.useController({name:e,control:s}),[n,g]=u.useState([]),[h,m]=u.useState([]),v=()=>Date.now()+Math.random(),p=i=>{try{const d=JSON.parse(i);return Array.isArray(d)?d.map(b=>({...b,_uid:b._uid||v()})):[]}catch(d){return console.error(`Erro ao ler dados da tabela "${e}":`,d),[]}};u.useEffect(()=>{if(!(n.length>0&&!c)&&o.value&&typeof o.value=="string"){const i=JSON.stringify(n);if(o.value===i)return;const d=p(o.value);g(d)}},[o.value,c]),u.useEffect(()=>{if(r)return;const i=JSON.stringify(n);o.value!==i&&o.onChange(i)},[n,o,r]);const k=u.useCallback(()=>{const i={_uid:v(),...a};g(d=>[...d,i])},[a]),j=u.useCallback(()=>{g(i=>i.filter(d=>!h.includes(d._uid))),m([])},[h]),f=u.useCallback((i,d,b)=>{g(M=>M.map(C=>C._uid===i?{...C,[d]:b}:C))},[]),x=u.useCallback(i=>{m(d=>d.includes(i)?d.filter(b=>b!==i):[...d,i])},[]),N=u.useCallback(i=>{m(i?n.map(d=>d._uid):[])},[n]),R=n.length>0&&h.length===n.length,y=u.useMemo(()=>!l||l.length===0?n:n.filter(i=>l.every(d=>{if("custom"in d)return d.custom(i);const b=i[d.field];switch(d.operator){case"===":return b===d.value;case"!==":return b!==d.value;case">":return b>d.value;case"<":return b<d.value;case">=":return b>=d.value;case"<=":return b<=d.value;default:return!0}})),[n,l]);return{field:o,tableRows:n,visibleRows:y,selectedRowIds:h,isAllSelected:R,handle:{addRow:k,removeRows:j,updateCellValue:f,toggleSelection:x,toggleSelectAll:N}}}const Be=({name:e,title:s="Tabela Dinâmica",columns:a,defaultRowValue:c={},forceReadOnly:r=!1,layout:l="fluid",actions:o=!0,filters:n=[]})=>{const{control:g}=S.useFormContext(),{isView:h,isReadOnly:m}=$.useFluigRuntime(),{isReadOnly:v}=$.useSection(),p=r||h||m||v&&v(e),{field:k,visibleRows:j,selectedRowIds:f,isAllSelected:x,handle:N}=Le({name:e,control:g,defaultRowValue:c,isView:h,isReadOnly:!!p,filters:n}),R=l==="fixed";return t.jsxs("div",{className:`table-wrapper ${R?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...k}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:s}),!p&&o&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${f.length>0?"btn-danger":""}`,disabled:f.length===0,onClick:N.removeRows,children:["Remover (",f.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:[!p&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:x,onChange:y=>N.toggleSelectAll(y.target.checked)})}),a.map(y=>t.jsx("th",{style:y.width?{minWidth:R?y.width:"100%"}:{width:"max-content"},children:y.label},y.key))]})}),t.jsxs("tbody",{children:[j.map((y,i)=>t.jsxs("tr",{children:[!p&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:f.includes(y._uid),onChange:()=>N.toggleSelection(y._uid)})}),a.map(d=>t.jsx("td",{children:d.render?d.render.length<=1?d.render({row:y,index:i,updateRow:(b,M)=>N.updateCellValue(y._uid,b,M),isLocked:!!p,isView:!!h}):d.render(y,i,(b,M)=>N.updateCellValue(y._uid,b,M),!!p,!!h):y[d.key]},`${y._uid}-${d.key}`))]},y._uid)),j.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:p?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},ze=e=>{const[s,a]=u.useState(null),{watch:c}=S.useFormContext(),r=c(e),l=u.useCallback(()=>{try{const n=window.top.__REACT_ATTACHMENT_BRIDGE__;if(n){const g=n.getAttachment(e);a(g||(r?{name:r,documentId:0}:null))}else a(r?{name:r,documentId:0}:null)}catch{a(r?{name:r,documentId:0}:null)}},[e,r]);return u.useEffect(()=>{l();const o=setInterval(l,2e3);return()=>clearInterval(o)},[l]),{attachment:s,sync:l}};function Xe({name:e,label:s,help:a,className:c=""}){const[r,l]=u.useState(!1),{control:o}=S.useFormContext(),{field:n}=S.useController({name:e,control:o}),{attachment:g,sync:h}=ze(e),{bridge:m,toast:v}=(()=>{var f;try{const x=window.top;return{bridge:x.__REACT_ATTACHMENT_BRIDGE__,toast:(f=x.FLUIGC)==null?void 0:f.toast}}catch{return{bridge:null,toast:null}}})(),p=!!g&&!r,k=u.useCallback(()=>{const f=document.createElement("input");f.type="file",f.onchange=x=>{const N=x.target.files[0];N&&(l(!0),m?m.upload(N,e,R=>{n.onChange(R.name),setTimeout(()=>{l(!1),h()},1e3)}):(n.onChange(N.name),l(!1)))},f.click()},[m,e,n,h]),j=f=>{f.stopPropagation(),m?m.remove(e)?(n.onChange(""),h(),v&&v({title:"Sucesso",message:"Anexo removido",type:"success"})):v&&v({title:"Erro",message:"Não foi possível remover",type:"danger"}):n.onChange("")};return t.jsxs("div",{className:`form-group ${c}`,children:[s&&t.jsx("label",{children:s}),t.jsxs("div",{className:"attachment-container",style:{border:`1px ${p?"solid #5cb85c":"dashed #ccc"}`,padding:"10px",borderRadius:"4px",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:r?"#f9f9f9":"white"},onClick:p?()=>m==null?void 0:m.view(e):k,children:[t.jsxs("span",{children:[t.jsx("i",{className:`fluigicon ${r?"fluigicon-loop-test":p?"fluigicon-file-pdf":"fluigicon-paperclip"}`}),r?" Enviando...":p?` ${g.name}`:` ${a||"Anexar"}`]}),p&&t.jsx("button",{type:"button",className:"btn btn-link text-danger",onClick:j,children:t.jsx("i",{className:"fluigicon fluigicon-trash"})})]}),t.jsx("input",{type:"hidden",...n})]})}function Ue({items:e,time:s=0,showNavigation:a=!0,progressBar:c=!0}){const[r,l]=u.useState(0),[o,n]=u.useState(0),g=u.useRef(null),h=u.useRef(null),m=u.useCallback(()=>{l(f=>(f+1)%e.length),n(0)},[e.length]),v=u.useCallback(()=>{l(f=>(f-1+e.length)%e.length),n(0)},[e.length]);if(u.useEffect(()=>{if(s>0&&e.length>1){const x=100/s*100;g.current=setInterval(m,s),h.current=setInterval(()=>{n(N=>N>=100?0:N+x)},100)}return()=>{g.current&&clearInterval(g.current),h.current&&clearInterval(h.current)}},[s,m,e.length,r]),!e||e.length===0)return null;const p=e[r],k=typeof p=="string"?p:p.url,j=/\.(jpg|jpeg|png|gif|webp)$/i.test(k);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:v,children:t.jsx("i",{className:"flaticon flaticon-chevron-left"})}),t.jsx("button",{className:"nav-btn next",onClick:m,children:t.jsx("i",{className:"flaticon flaticon-chevron-right"})})]}),t.jsx("div",{className:"carousel-media",children:j?t.jsx("img",{src:k,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:k,target:"_blank",rel:"noreferrer",className:"btn-open",children:"Abrir Arquivo"})]})}),e.length>1&&t.jsx("div",{className:"carousel-dots",children:e.map((f,x)=>t.jsx("div",{className:`dot ${x===r?"active":""}`,onClick:()=>{l(x),n(0)}},x))})]}),c&&s>0&&e.length>1&&t.jsx("div",{className:"carousel-progress-container",children:t.jsx("div",{className:"carousel-progress-bar",style:{width:`${o}%`}})})]})}function Ye({title:e,isOpen:s,onOpen:a,onClose:c,content:r,footer:l,width:o}){const n=u.useCallback(g=>{g.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:o},className:"modal-container",onClick:g=>g.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:r}),l&&t.jsx("div",{className:"modal-footer",children:l})]})}):null}function Ge({logo:e,childs:s,footer:a,contentExternal:c,bg:r,color:l,onSelect:o}){return t.jsxs("div",{className:"main-container dfea",children:[t.jsxs("div",{className:"sidebar-wrapper",style:{backgroundColor:`${r}`},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 g,h;return n!=null&&n.options&&((g=n==null?void 0:n.options)==null?void 0:g.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 m;(m=n.action)==null||m.call(n),o==null||o(n.id)},style:{color:`${l}`},children:[n.icon&&t.jsx("i",{className:n.icon}),n.label]}),(h=n.options)==null?void 0:h.map(m=>t.jsx("li",{className:"sidebar-option",onClick:()=>{var v;(v=m.action)==null||v.call(m),o==null||o(m.id)},style:{color:`${l}`},children:m.label}))]})}):t.jsxs("li",{className:"sidebar-child",onClick:()=>{var m;(m=n.action)==null||m.call(n),o==null||o(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=Xe;exports.Carousel=Ue;exports.Checkbox=Z;exports.DatePicker=Ie;exports.Input=G;exports.Modal=Ye;exports.RadioBtn=ee;exports.Select=J;exports.Sidebar=Ge;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"),M=require("@fluig-kit/ecm"),L=require("react-datepicker"),D=require("date-fns"),U={cpf:"000.000.000-00",cnpj:"00.000.000/0000-00",telefone:"(00) 00000-0000",cep:"00000-000"};function G({name:e,label:s="",placeholder:a="",type:c="text",mask:r,className:l="",forceReadOnly:o=!1,forceHidden:n=!1}){const{isReadOnly:g,isHidden:h}=M.useSection(),m=o||!!g(e),v=n||!!h(e),{control:N}=S.useFormContext(),{isView:k}=M.useFluigRuntime(),{field:x}=S.useController({name:e,control:N}),{errors:b}=S.useFormState({name:e}),f=b==null?void 0:b[e],y=u.useMemo(()=>r?U[r]??r:null,[r]),R=u.useCallback(i=>{if(!i)return"";const d=i.replace(/\D/g,"");return(Number(d)/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})},[]),j=u.useCallback(i=>c==="monetary"?R(i):i,[c,R]);return k?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x.value||"-"})]}):t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),y?t.jsx(X.IMaskInput,{name:e,mask:y,value:String(x.value??""),unmask:!1,onAccept:i=>x.onChange(j(i)),placeholder:a,readOnly:m,className:`form-control ${f?"border-red":""} ${l}`,inputRef:x.ref,onBlur:x.onBlur}):t.jsx("input",{...x,type:"text",value:x.value??"",onChange:i=>x.onChange(j(i.target.value)),placeholder:a,readOnly:m,className:`form-control ${f?"border-red":""} ${l}`}),f&&t.jsx("p",{className:"text-danger",children:String(f.message)})]})}const Y=u.memo(G);function Q({name:e,label:s="",options:a=[],placeholder:c="",labelKey:r="label",valueKey:l="value",enableSearch:o=!1,searchPlaceholder:n="Buscar...",loading:g=!1,onSearchChange:h,debounceTime:m=300,onSelect:v,forceReadOnly:N=!1,forceHidden:k=!1}){const{isReadOnly:x,isHidden:b}=M.useSection(),f=N||!!x(e),y=k||!!b(e),{control:R,clearErrors:j}=S.useFormContext(),{isView:i}=M.useFluigRuntime(),{field:{onChange:d,value:p,ref:$},fieldState:{error:C}}=S.useController({name:e,control:R}),[P,F]=u.useState(!1),[A,q]=u.useState(""),O=u.useRef(null),E=u.useRef(h);u.useEffect(()=>{E.current=h},[h]),u.useEffect(()=>{const w=_=>{O.current&&!O.current.contains(_.target)&&F(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),u.useEffect(()=>{P||q("")},[P]),u.useEffect(()=>{if(!o)return;const w=setTimeout(()=>{E.current&&E.current(A)},m);return()=>clearTimeout(w)},[A,o,m]);const H=u.useMemo(()=>o&&!h&&A.trim()?a.filter(w=>String((w==null?void 0:w[r])??"").toLowerCase().includes(A.toLowerCase())):a??[],[a,o,h,A,r]),B=u.useMemo(()=>{if(p==null)return"";if(typeof p=="object")return String(p[l]??"");const w=(a||[]).find(_=>String(_==null?void 0:_[l])===String(p));return String(w?(w==null?void 0:w[r])??"":p)},[p,a,l,r]),z=w=>{f||(d(w[l]),v&&v(w),j(e),F(!1))};return t.jsxs("div",{className:`select-wrapper form-group ${y?"hidden":""}`,ref:O,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 ${C?"border-red":""} ${f?"readOnly":""}`,onClick:()=>!f&&F(w=>!w),ref:$,children:[t.jsx("span",{className:`select-display ${f?"readOnly":""}`,children:B||c}),t.jsx("i",{className:"flaticon flaticon-chevron-down select-icon"})]}),P&&!f&&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:w=>q(w.target.value),placeholder:g?"Carregando...":n,autoFocus:!0,onClick:w=>w.stopPropagation()})}),t.jsx("ul",{className:"select-options",children:g?t.jsx("li",{className:"select-option readOnly",children:"Carregando..."}):H.length>0?H.map(w=>t.jsx("li",{onClick:()=>z(w),className:"select-option handleHover",children:w[r]},w[l])):t.jsx("li",{className:"select-option readOnly",children:"Sem resultados"})})]})]}),t.jsx("input",{type:"hidden",name:e,value:p||""}),C&&t.jsx("p",{className:"text-danger",children:String(C.message)})]})}const J=u.memo(Q);function Z({name:e,options:s=[],label:a="",valueKey:c="value",labelKey:r="label",forceReadOnly:l=!1,forceHidden:o=!1}){var p,$;const n=S.useFormContext(),{isView:g,isReadOnly:h}=M.useFluigRuntime(),{isReadOnly:m,isHidden:v}=M.useSection(),N=m?m(e):!1,k=v?v(e):!1,x=l||N,b=o||k,f=x||h||g;if(!n||!e)return console.error("Checkbox requer contexto de formulário e nome."),null;const y=()=>!s||!n?{}:s.reduce((C,P)=>{const F=P[c],A=n.getValues(F);return C[F]=A==="on",C},{}),R=n.watch(e),j=u.useMemo(()=>R&&typeof R=="object"?R:y(),[R,s,c]);u.useEffect(()=>{const C=n.getValues(e);(!C||typeof C!="object")&&n.setValue(e,j,{shouldDirty:!1,shouldValidate:!1})},[j,e,n]);const i=(C,P)=>{if(f)return;const F={...j,[C]:P};n.setValue(e,F,{shouldDirty:!0,shouldValidate:!0}),n.setValue(C,P?"on":"",{shouldValidate:!1})},d=($=(p=n.formState)==null?void 0:p.errors)==null?void 0:$[e];return t.jsxs("div",{className:`form-group ${b?"hidden":""}`,children:[a&&t.jsx("label",{children:a}),t.jsx("div",{className:`checkbox-group-custom ${f?"readOnly":""}`,children:s.map(C=>{const P=String(C[c]),F=j[P]===!0;return t.jsxs("div",{children:[t.jsx("input",{type:"hidden",...n.register(P)}),t.jsxs("label",{className:`custom-checkbox ${F?"checked":""} ${f?"readOnly":""}`,children:[t.jsx("input",{type:"checkbox",checked:F,disabled:f,onChange:A=>i(P,A.target.checked)}),t.jsx("span",{className:"checkmark"}),t.jsx("span",{children:C[r]})]})]},P)})}),d&&t.jsx("p",{className:"text-danger",children:String(d.message)})]})}function K({name:e,label:s="",options:a=[],valueKey:c="value",labelKey:r="label",iconKey:l="icon",forceReadOnly:o=!1,forceHidden:n=!1}){const{isReadOnly:g,isHidden:h}=M.useSection(),m=o||!!g(e),v=n||!!h(e),{control:N}=S.useFormContext(),{isView:k,isReadOnly:x}=M.useFluigRuntime(),{field:b,fieldState:{error:f}}=S.useController({name:e,control:N}),y=m||x||k,R=b.value??"",j=u.useCallback(i=>{y||b.onChange(i)},[y,b]);return t.jsxs("div",{className:`form-group column ${v?"hidden":""}`,children:[s&&t.jsx("label",{className:"control-label",children:s}),t.jsx("div",{className:`btn-group ${y?"view-mode":""}`,"data-field-name":e,children:a.map(i=>{const d=i[c],p=R===d,$=i.color?{"--customColor":i.color}:void 0;return t.jsxs("label",{htmlFor:`${e}_${d}`,style:$,className:`btn fs-ellipsis ${p?"active":""}`,children:[t.jsx("input",{type:"radio",id:`${e}_${d}`,name:e,value:d,checked:p,className:"hidden",onChange:()=>j(d),disabled:y}),i[l]&&t.jsx("i",{className:`${i[l]} icon-sm`})," ",i[r]]},d)})}),f&&t.jsx("p",{className:"text-danger",children:String(f.message)})]})}const ee=u.memo(K),te=({name:e,label:s="",placeholder:a="",className:c="",rows:r=4,maxLength:l,forceReadOnly:o=!1,forceHidden:n=!1})=>{const{isReadOnly:g,isHidden:h}=M.useSection(),m=o||!!g(e),v=n||!!h(e),{control:N}=S.useFormContext(),{isView:k}=M.useFluigRuntime(),{field:x,fieldState:{error:b}}=S.useController({name:e,control:N});return k?t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x.value||"-"})]}):t.jsxs("div",{className:`form-group ${v?"hidden":""}`,children:[t.jsx("label",{children:s}),t.jsx("textarea",{...x,rows:r,maxLength:l,value:x.value||"",placeholder:a,readOnly:m,className:`form-control ${b?"border-red":""} ${c}`}),b&&t.jsx("p",{className:"text-danger",children:String(b.message)})]})},ne=u.memo(te);function W(e){return(s={})=>{const a=s.width?String(s.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}function V(e){return(s,a)=>{const c=a!=null&&a.context?String(a.context):"standalone";let r;if(c==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,n=a!=null&&a.width?String(a.width):o;r=e.formattingValues[n]||e.formattingValues[o]}else{const o=e.defaultWidth,n=a!=null&&a.width?String(a.width):e.defaultWidth;r=e.values[n]||e.values[o]}const l=e.argumentCallback?e.argumentCallback(s):s;return r[l]}}function T(e){return(s,a={})=>{const c=a.width,r=c&&e.matchPatterns[c]||e.matchPatterns[e.defaultMatchWidth],l=s.match(r);if(!l)return null;const o=l[0],n=c&&e.parsePatterns[c]||e.parsePatterns[e.defaultParseWidth],g=Array.isArray(n)?se(n,v=>v.test(o)):ae(n,v=>v.test(o));let h;h=e.valueCallback?e.valueCallback(g):g,h=a.valueCallback?a.valueCallback(h):h;const m=s.slice(o.length);return{value:h,rest:m}}}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 r=c[0],l=s.match(e.parsePattern);if(!l)return null;let o=e.valueCallback?e.valueCallback(l[0]):l[0];o=a.valueCallback?a.valueCallback(o):o;const n=s.slice(r.length);return{value:o,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 r=oe[e];return typeof r=="string"?c=r:s===1?c=r.one:c=r.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:W({formats:le,defaultWidth:"full"}),time:W({formats:ce,defaultWidth:"full"}),dateTime:W({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 r=me[e];return typeof r=="function"?r(s):r},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,s)=>{const a=Number(e);return(s==null?void 0:s.unit)==="week"?a+"ª":a+"º"},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,Ne=/\d+/i,we={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},Me={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]},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},_e={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:Ne,valueCallback:e=>parseInt(e,10)}),era:T({matchPatterns:we,defaultMatchWidth:"wide",parsePatterns:ke,defaultParseWidth:"any"}),quarter:T({matchPatterns:Re,defaultMatchWidth:"wide",parsePatterns:Se,defaultParseWidth:"any",valueCallback:e=>e+1}),month:T({matchPatterns:Pe,defaultMatchWidth:"wide",parsePatterns:Me,defaultParseWidth:"any"}),day:T({matchPatterns:$e,defaultMatchWidth:"wide",parsePatterns:Fe,defaultParseWidth:"any"}),dayPeriod:T({matchPatterns:Ae,defaultMatchWidth:"any",parsePatterns:_e,defaultParseWidth:"any"})},Te={code:"pt-BR",formatDistance:ie,formatLong:ue,formatRelative:he,localize:ye,match:Ve,options:{weekStartsOn:0,firstWeekContainsDate:1}};L.registerLocale("pt-BR",Te);const I="dd/MM/yyyy",Oe=e=>{if(!e)return null;const s=D.parse(e,I,new Date);return D.isValid(s)?s:null},Ee=e=>e?D.format(e,I):"",We=u.forwardRef(({shimRef:e,className:s,name:a,...c},r)=>t.jsx("input",{name:a,...c,className:s,ref:l=>{typeof r=="function"?r(l):r&&(r.current=l),e&&e(l)}})),De=({name:e,label:s="",placeholder:a="dd/mm/aaaa",className:c="",forceReadOnly:r=!1,forceHidden:l=!1})=>{const{control:o}=S.useFormContext(),{isView:n}=M.useFluigRuntime(),{isReadOnly:g,isHidden:h}=M.useSection(),m=r||!!g(e),v=l||!!h(e),{field:{onChange:N,onBlur:k,value:x,ref:b},fieldState:{error:f}}=S.useController({name:e,control:o}),y=u.useMemo(()=>Oe(x),[x]),R=u.useCallback(i=>{N(i?Ee(i):"")},[N]),j=u.useCallback(i=>{var d,p;if(b(i),i&&((p=(d=o._fields)==null?void 0:d[e])!=null&&p._f)){const $=o._fields[e];$._f.ref={focus:()=>{var C;return(C=i.focus)==null?void 0:C.call(i)},select:()=>{var C;return(C=i.select)==null?void 0:C.call(i)},setCustomValidity:C=>{var P;return(P=i.setCustomValidity)==null?void 0:P.call(i,C)},reportValidity:()=>{var C;return(C=i.reportValidity)==null?void 0:C.call(i)}}}},[b,o,e]);return v?null:n?t.jsxs("div",{className:"form-group",children:[t.jsx("label",{children:s}),t.jsx("span",{className:"form-control",children:x||"-"})]}):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:`${f?"border-red":""}`,children:t.jsx(L,{id:e,name:e,selected:y,onChange:R,onBlur:k,dateFormat:I,placeholderText:a,disabled:m,readOnly:m,locale:"pt-BR",className:`form-control ${f?"border-red":""}`,wrapperClassName:"w-100",showMonthDropdown:!0,showYearDropdown:!0,dropdownMode:"select",isClearable:!m&&!!x,autoComplete:"off",customInput:t.jsx(We,{name:e,shimRef:j})})}),f&&t.jsx("span",{className:"help-block text-danger",children:String(f.message)})]})},Ie=u.memo(De);function qe({mapping:e={},defaultLabel:s="Não reconhecido",className:a="",hidden:c=!1,label:r}){const{activityId:l}=M.useFluigRuntime(),o=u.useMemo(()=>!e||l===null||l===void 0?null:e[l],[l,e]);if(!o)return t.jsxs("div",{className:`form-group ${c?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsx("div",{className:`status-badge default ${a}`,children:s})]});const n={"--customColor":o.color};return t.jsxs("div",{className:`form-group ${c?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsxs("div",{className:`status-badge ${a}`,style:n,children:[o.icon&&t.jsx("i",{className:o.icon}),t.jsx("span",{children:o.label})]})]})}const He=u.memo(qe);function Be({name:e,control:s,defaultRowValue:a,isView:c,isReadOnly:r,filters:l=[]}){const{field:o}=S.useController({name:e,control:s}),[n,g]=u.useState([]),[h,m]=u.useState([]),v=()=>Date.now()+Math.random(),N=i=>{try{const d=JSON.parse(i);return Array.isArray(d)?d.map(p=>({...p,_uid:p._uid||v()})):[]}catch(d){return console.error(`Erro ao ler dados da tabela "${e}":`,d),[]}};u.useEffect(()=>{if(!(n.length>0&&!c)&&o.value&&typeof o.value=="string"){const i=JSON.stringify(n);if(o.value===i)return;const d=N(o.value);g(d)}},[o.value,c]),u.useEffect(()=>{if(r)return;const i=JSON.stringify(n);o.value!==i&&o.onChange(i)},[n,o,r]);const k=u.useCallback(()=>{const i={_uid:v(),...a};g(d=>[...d,i])},[a]),x=u.useCallback(()=>{g(i=>i.filter(d=>!h.includes(d._uid))),m([])},[h]),b=u.useCallback((i,d,p)=>{g($=>$.map(C=>C._uid===i?{...C,[d]:p}:C))},[]),f=u.useCallback(i=>{m(d=>d.includes(i)?d.filter(p=>p!==i):[...d,i])},[]),y=u.useCallback(i=>{m(i?n.map(d=>d._uid):[])},[n]),R=n.length>0&&h.length===n.length,j=u.useMemo(()=>!l||l.length===0?n:n.filter(i=>l.every(d=>{if("custom"in d)return d.custom(i);const p=i[d.field];switch(d.operator){case"===":return p===d.value;case"!==":return p!==d.value;case">":return p>d.value;case"<":return p<d.value;case">=":return p>=d.value;case"<=":return p<=d.value;default:return!0}})),[n,l]);return{field:o,tableRows:n,visibleRows:j,selectedRowIds:h,isAllSelected:R,handle:{addRow:k,removeRows:x,updateCellValue:b,toggleSelection:f,toggleSelectAll:y}}}const Le=({name:e,title:s="Tabela Dinâmica",columns:a,defaultRowValue:c={},forceReadOnly:r=!1,layout:l="fluid",actions:o=!0,filters:n=[]})=>{const{control:g}=S.useFormContext(),{isView:h,isReadOnly:m}=M.useFluigRuntime(),{isReadOnly:v}=M.useSection(),N=r||h||m||v&&v(e),{field:k,visibleRows:x,selectedRowIds:b,isAllSelected:f,handle:y}=Be({name:e,control:g,defaultRowValue:c,isView:h,isReadOnly:!!N,filters:n}),R=l==="fixed";return t.jsxs("div",{className:`table-wrapper ${R?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...k}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:s}),!N&&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:y.removeRows,children:["Remover (",b.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:y.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:[!N&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:f,onChange:j=>y.toggleSelectAll(j.target.checked)})}),a.map(j=>t.jsx("th",{style:j.width?{minWidth:R?j.width:"100%"}:{width:"max-content"},children:j.label},j.key))]})}),t.jsxs("tbody",{children:[x.map((j,i)=>t.jsxs("tr",{children:[!N&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:b.includes(j._uid),onChange:()=>y.toggleSelection(j._uid)})}),a.map(d=>t.jsx("td",{children:d.render?d.render.length<=1?d.render({row:j,index:i,updateRow:(p,$)=>y.updateCellValue(j._uid,p,$),isLocked:!!N,isView:!!h}):d.render(j,i,(p,$)=>y.updateCellValue(j._uid,p,$),!!N,!!h):j[d.key]},`${j._uid}-${d.key}`))]},j._uid)),x.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:N?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},ze=e=>{const[s,a]=u.useState(null),{watch:c}=S.useFormContext(),r=c(e),l=u.useCallback(()=>{try{const n=window.top.__REACT_ATTACHMENT_BRIDGE__;if(n){const g=n.getAttachment(e);a(g||(r?{name:r,documentId:0}:null))}else a(r?{name:r,documentId:0}:null)}catch{a(r?{name:r,documentId:0}:null)}},[e,r]);return u.useEffect(()=>{l();const o=setInterval(l,2e3);return()=>clearInterval(o)},[l]),{attachment:s,sync:l}};function Xe({name:e,label:s,help:a,className:c=""}){const[r,l]=u.useState(!1),{control:o}=S.useFormContext(),{field:n}=S.useController({name:e,control:o}),{attachment:g,sync:h}=ze(e),{bridge:m}=(()=>{try{return{bridge:window.top.__REACT_ATTACHMENT_BRIDGE__}}catch{return{bridge:null}}})(),v=!!g&&!r,N=u.useCallback(()=>{const x=document.createElement("input");x.type="file",x.onchange=b=>{const f=b.target.files[0];f&&(l(!0),m?m.upload(f,e,y=>{n.onChange(y.name),setTimeout(()=>{l(!1),h()},1e3)}):(n.onChange(f.name),l(!1)))},x.click()},[m,e,n,h]),k=x=>{var R;x.stopPropagation();const b=window.top,f=b.__REACT_ATTACHMENT_BRIDGE__,y=(R=b.FLUIGC)==null?void 0:R.toast;f?f.remove(e)?(n.onChange(""),h(),y&&y({title:"Sucesso: ",message:"Anexo removido com sucesso.",type:"success"})):y&&y({title:"Erro: ",message:"Não foi possível localizar o anexo para remoção.",type:"danger"}):(n.onChange(""),h())};return t.jsxs("div",{className:`form-group ${c}`,children:[s&&t.jsx("label",{children:s}),t.jsxs("div",{className:"attachment-container",style:{border:`1px ${v?"solid #5cb85c":"dashed #ccc"}`,padding:"10px",borderRadius:"4px",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:r?"#f9f9f9":"white"},onClick:v?()=>m==null?void 0:m.view(e):N,children:[t.jsxs("span",{children:[t.jsx("i",{className:`fluigicon ${r?"fluigicon-loop-test":v?"fluigicon-file-pdf":"fluigicon-paperclip"}`}),r?" Enviando...":v?` ${g.name}`:` ${a||"Anexar"}`]}),v&&t.jsx("button",{type:"button",className:"btn btn-link text-danger",onClick:k,children:t.jsx("i",{className:"fluigicon fluigicon-trash"})})]}),t.jsx("input",{type:"hidden",...n})]})}function Ue({items:e,time:s=0,showNavigation:a=!0,progressBar:c=!0}){const[r,l]=u.useState(0),[o,n]=u.useState(0),g=u.useRef(null),h=u.useRef(null),m=u.useCallback(()=>{l(b=>(b+1)%e.length),n(0)},[e.length]),v=u.useCallback(()=>{l(b=>(b-1+e.length)%e.length),n(0)},[e.length]);if(u.useEffect(()=>{if(s>0&&e.length>1){const f=100/s*100;g.current=setInterval(m,s),h.current=setInterval(()=>{n(y=>y>=100?0:y+f)},100)}return()=>{g.current&&clearInterval(g.current),h.current&&clearInterval(h.current)}},[s,m,e.length,r]),!e||e.length===0)return null;const N=e[r],k=typeof N=="string"?N:N.url,x=/\.(jpg|jpeg|png|gif|webp)$/i.test(k);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:v,children:t.jsx("i",{className:"flaticon flaticon-chevron-left"})}),t.jsx("button",{className:"nav-btn next",onClick:m,children:t.jsx("i",{className:"flaticon flaticon-chevron-right"})})]}),t.jsx("div",{className:"carousel-media",children:x?t.jsx("img",{src:k,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:k,target:"_blank",rel:"noreferrer",className:"btn-open",children:"Abrir Arquivo"})]})}),e.length>1&&t.jsx("div",{className:"carousel-dots",children:e.map((b,f)=>t.jsx("div",{className:`dot ${f===r?"active":""}`,onClick:()=>{l(f),n(0)}},f))})]}),c&&s>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:s,onOpen:a,onClose:c,content:r,footer:l,width:o}){const n=u.useCallback(g=>{g.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:o},className:"modal-container",onClick:g=>g.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:r}),l&&t.jsx("div",{className:"modal-footer",children:l})]})}):null}function Ye({logo:e,childs:s,footer:a,contentExternal:c,bg:r,color:l,onSelect:o}){return t.jsxs("div",{className:"main-container dfea",children:[t.jsxs("div",{className:"sidebar-wrapper",style:{backgroundColor:`${r}`},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 g,h;return n!=null&&n.options&&((g=n==null?void 0:n.options)==null?void 0:g.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 m;(m=n.action)==null||m.call(n),o==null||o(n.id)},style:{color:`${l}`},children:[n.icon&&t.jsx("i",{className:n.icon}),n.label]}),(h=n.options)==null?void 0:h.map(m=>t.jsx("li",{className:"sidebar-option",onClick:()=>{var v;(v=m.action)==null||v.call(m),o==null||o(m.id)},style:{color:`${l}`},children:m.label}))]})}):t.jsxs("li",{className:"sidebar-child",onClick:()=>{var m;(m=n.action)==null||m.call(n),o==null||o(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=Xe;exports.Carousel=Ue;exports.Checkbox=Z;exports.DatePicker=Ie;exports.Input=Y;exports.Modal=Ge;exports.RadioBtn=ee;exports.Select=J;exports.Sidebar=Ye;exports.SimpleTable=Le;exports.StatusBadge=He;exports.TextArea=ne;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as f, jsx as t, Fragment as U } from "react/jsx-runtime";
|
|
2
|
-
import { memo as E, useMemo as
|
|
3
|
-
import { useFormContext as
|
|
2
|
+
import { memo as E, useMemo as D, useCallback as S, useState as T, useRef as B, useEffect as V, forwardRef as K } from "react";
|
|
3
|
+
import { useFormContext as O, useController as j, useFormState as ee } from "react-hook-form";
|
|
4
4
|
import { IMaskInput as te } from "react-imask";
|
|
5
|
-
import { useSection as I, useFluigRuntime as
|
|
5
|
+
import { useSection as I, useFluigRuntime as W } from "@fluig-kit/ecm";
|
|
6
6
|
import ne, { registerLocale as ae } from "react-datepicker";
|
|
7
7
|
import { parse as re, isValid as se, format as oe } from "date-fns";
|
|
8
8
|
const ie = {
|
|
@@ -21,7 +21,7 @@ function le({
|
|
|
21
21
|
forceReadOnly: o = !1,
|
|
22
22
|
forceHidden: n = !1
|
|
23
23
|
}) {
|
|
24
|
-
const { isReadOnly: g, isHidden: m } = I(), u = o || !!g(e),
|
|
24
|
+
const { isReadOnly: g, isHidden: m } = I(), u = o || !!g(e), y = n || !!m(e), { control: k } = O(), { isView: R } = W(), { field: p } = j({ name: e, control: k }), { errors: b } = ee({ name: e }), h = b == null ? void 0 : b[e], w = D(
|
|
25
25
|
() => s ? ie[s] ?? s : null,
|
|
26
26
|
[s]
|
|
27
27
|
), P = S((i) => {
|
|
@@ -31,42 +31,42 @@ function le({
|
|
|
31
31
|
style: "currency",
|
|
32
32
|
currency: "BRL"
|
|
33
33
|
});
|
|
34
|
-
}, []),
|
|
34
|
+
}, []), N = S(
|
|
35
35
|
(i) => c === "monetary" ? P(i) : i,
|
|
36
36
|
[c, P]
|
|
37
37
|
);
|
|
38
38
|
return R ? /* @__PURE__ */ f("div", { className: "form-group", children: [
|
|
39
39
|
/* @__PURE__ */ t("label", { children: r }),
|
|
40
|
-
/* @__PURE__ */ t("span", { className: "form-control", children:
|
|
41
|
-
] }) : /* @__PURE__ */ f("div", { className: `form-group ${
|
|
40
|
+
/* @__PURE__ */ t("span", { className: "form-control", children: p.value || "-" })
|
|
41
|
+
] }) : /* @__PURE__ */ f("div", { className: `form-group ${y ? "hidden" : ""}`, children: [
|
|
42
42
|
/* @__PURE__ */ t("label", { children: r }),
|
|
43
|
-
|
|
43
|
+
w ? /* @__PURE__ */ t(
|
|
44
44
|
te,
|
|
45
45
|
{
|
|
46
46
|
name: e,
|
|
47
|
-
mask:
|
|
48
|
-
value: String(
|
|
47
|
+
mask: w,
|
|
48
|
+
value: String(p.value ?? ""),
|
|
49
49
|
unmask: !1,
|
|
50
|
-
onAccept: (i) =>
|
|
50
|
+
onAccept: (i) => p.onChange(N(i)),
|
|
51
51
|
placeholder: a,
|
|
52
52
|
readOnly: u,
|
|
53
|
-
className: `form-control ${
|
|
54
|
-
inputRef:
|
|
55
|
-
onBlur:
|
|
53
|
+
className: `form-control ${h ? "border-red" : ""} ${l}`,
|
|
54
|
+
inputRef: p.ref,
|
|
55
|
+
onBlur: p.onBlur
|
|
56
56
|
}
|
|
57
57
|
) : /* @__PURE__ */ t(
|
|
58
58
|
"input",
|
|
59
59
|
{
|
|
60
|
-
...
|
|
60
|
+
...p,
|
|
61
61
|
type: "text",
|
|
62
|
-
value:
|
|
63
|
-
onChange: (i) =>
|
|
62
|
+
value: p.value ?? "",
|
|
63
|
+
onChange: (i) => p.onChange(N(i.target.value)),
|
|
64
64
|
placeholder: a,
|
|
65
65
|
readOnly: u,
|
|
66
|
-
className: `form-control ${
|
|
66
|
+
className: `form-control ${h ? "border-red" : ""} ${l}`
|
|
67
67
|
}
|
|
68
68
|
),
|
|
69
|
-
|
|
69
|
+
h && /* @__PURE__ */ t("p", { className: "text-danger", children: String(h.message) })
|
|
70
70
|
] });
|
|
71
71
|
}
|
|
72
72
|
const st = E(le);
|
|
@@ -82,74 +82,74 @@ function ce({
|
|
|
82
82
|
loading: g = !1,
|
|
83
83
|
onSearchChange: m,
|
|
84
84
|
debounceTime: u = 300,
|
|
85
|
-
onSelect:
|
|
86
|
-
forceReadOnly:
|
|
85
|
+
onSelect: y,
|
|
86
|
+
forceReadOnly: k = !1,
|
|
87
87
|
forceHidden: R = !1
|
|
88
88
|
}) {
|
|
89
|
-
const { isReadOnly:
|
|
90
|
-
field: { onChange: d, value:
|
|
91
|
-
fieldState: { error:
|
|
92
|
-
} =
|
|
89
|
+
const { isReadOnly: p, isHidden: b } = I(), h = k || !!p(e), w = R || !!b(e), { control: P, clearErrors: N } = O(), { isView: i } = W(), {
|
|
90
|
+
field: { onChange: d, value: v, ref: M },
|
|
91
|
+
fieldState: { error: C }
|
|
92
|
+
} = j({
|
|
93
93
|
name: e,
|
|
94
94
|
control: P
|
|
95
|
-
}), [$,
|
|
96
|
-
|
|
95
|
+
}), [$, A] = T(!1), [_, Y] = T(""), L = B(null), z = B(m);
|
|
96
|
+
V(() => {
|
|
97
97
|
z.current = m;
|
|
98
|
-
}, [m]),
|
|
98
|
+
}, [m]), V(() => {
|
|
99
99
|
const x = (F) => {
|
|
100
|
-
|
|
100
|
+
L.current && !L.current.contains(F.target) && A(!1);
|
|
101
101
|
};
|
|
102
102
|
return document.addEventListener("mousedown", x), () => document.removeEventListener("mousedown", x);
|
|
103
|
-
}, []),
|
|
104
|
-
$ ||
|
|
105
|
-
}, [$]),
|
|
103
|
+
}, []), V(() => {
|
|
104
|
+
$ || Y("");
|
|
105
|
+
}, [$]), V(() => {
|
|
106
106
|
if (!o) return;
|
|
107
107
|
const x = setTimeout(() => {
|
|
108
|
-
z.current && z.current(
|
|
108
|
+
z.current && z.current(_);
|
|
109
109
|
}, u);
|
|
110
110
|
return () => clearTimeout(x);
|
|
111
|
-
}, [
|
|
112
|
-
const Q =
|
|
113
|
-
(x) => String((x == null ? void 0 : x[s]) ?? "").toLowerCase().includes(
|
|
114
|
-
) : a ?? [], [a, o, m,
|
|
115
|
-
if (
|
|
116
|
-
if (typeof
|
|
117
|
-
return String(
|
|
111
|
+
}, [_, o, u]);
|
|
112
|
+
const Q = D(() => o && !m && _.trim() ? a.filter(
|
|
113
|
+
(x) => String((x == null ? void 0 : x[s]) ?? "").toLowerCase().includes(_.toLowerCase())
|
|
114
|
+
) : a ?? [], [a, o, m, _, s]), J = D(() => {
|
|
115
|
+
if (v == null) return "";
|
|
116
|
+
if (typeof v == "object")
|
|
117
|
+
return String(v[l] ?? "");
|
|
118
118
|
const x = (a || []).find(
|
|
119
|
-
(F) => String(F == null ? void 0 : F[l]) === String(
|
|
119
|
+
(F) => String(F == null ? void 0 : F[l]) === String(v)
|
|
120
120
|
);
|
|
121
|
-
return String(x ? (x == null ? void 0 : x[s]) ?? "" :
|
|
122
|
-
}, [
|
|
123
|
-
|
|
121
|
+
return String(x ? (x == null ? void 0 : x[s]) ?? "" : v);
|
|
122
|
+
}, [v, a, l, s]), Z = (x) => {
|
|
123
|
+
h || (d(x[l]), y && y(x), N(e), A(!1));
|
|
124
124
|
};
|
|
125
125
|
return /* @__PURE__ */ f(
|
|
126
126
|
"div",
|
|
127
127
|
{
|
|
128
|
-
className: `select-wrapper form-group ${
|
|
129
|
-
ref:
|
|
128
|
+
className: `select-wrapper form-group ${w ? "hidden" : ""}`,
|
|
129
|
+
ref: L,
|
|
130
130
|
children: [
|
|
131
131
|
/* @__PURE__ */ t("label", { className: "control-label", children: r }),
|
|
132
132
|
i ? /* @__PURE__ */ t("span", { className: "form-control", children: J || "-" }) : /* @__PURE__ */ f(U, { children: [
|
|
133
133
|
/* @__PURE__ */ f(
|
|
134
134
|
"div",
|
|
135
135
|
{
|
|
136
|
-
className: `select-control ${
|
|
137
|
-
onClick: () => !
|
|
136
|
+
className: `select-control ${C ? "border-red" : ""} ${h ? "readOnly" : ""}`,
|
|
137
|
+
onClick: () => !h && A((x) => !x),
|
|
138
138
|
ref: M,
|
|
139
139
|
children: [
|
|
140
|
-
/* @__PURE__ */ t("span", { className: `select-display ${
|
|
140
|
+
/* @__PURE__ */ t("span", { className: `select-display ${h ? "readOnly" : ""}`, children: J || c }),
|
|
141
141
|
/* @__PURE__ */ t("i", { className: "flaticon flaticon-chevron-down select-icon" })
|
|
142
142
|
]
|
|
143
143
|
}
|
|
144
144
|
),
|
|
145
|
-
$ && !
|
|
145
|
+
$ && !h && /* @__PURE__ */ f("div", { className: "select-dropdown", children: [
|
|
146
146
|
o && /* @__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:
|
|
152
|
-
onChange: (x) =>
|
|
151
|
+
value: _,
|
|
152
|
+
onChange: (x) => Y(x.target.value),
|
|
153
153
|
placeholder: g ? "Carregando..." : n,
|
|
154
154
|
autoFocus: !0,
|
|
155
155
|
onClick: (x) => x.stopPropagation()
|
|
@@ -166,8 +166,8 @@ function ce({
|
|
|
166
166
|
)) : /* @__PURE__ */ t("li", { className: "select-option readOnly", children: "Sem resultados" }) })
|
|
167
167
|
] })
|
|
168
168
|
] }),
|
|
169
|
-
/* @__PURE__ */ t("input", { type: "hidden", name: e, value:
|
|
170
|
-
|
|
169
|
+
/* @__PURE__ */ t("input", { type: "hidden", name: e, value: v || "" }),
|
|
170
|
+
C && /* @__PURE__ */ t("p", { className: "text-danger", children: String(C.message) })
|
|
171
171
|
]
|
|
172
172
|
}
|
|
173
173
|
);
|
|
@@ -182,55 +182,55 @@ function it({
|
|
|
182
182
|
forceReadOnly: l = !1,
|
|
183
183
|
forceHidden: o = !1
|
|
184
184
|
}) {
|
|
185
|
-
var
|
|
186
|
-
const n =
|
|
185
|
+
var v, M;
|
|
186
|
+
const n = O(), { isView: g, isReadOnly: m } = W(), { isReadOnly: u, isHidden: y } = I(), k = u ? u(e) : !1, R = y ? y(e) : !1, p = l || k, b = o || R, h = p || m || g;
|
|
187
187
|
if (!n || !e)
|
|
188
188
|
return console.error("Checkbox requer contexto de formulário e nome."), null;
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
return
|
|
192
|
-
}, {}), P = n.watch(e),
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
(!
|
|
189
|
+
const w = () => !r || !n ? {} : r.reduce((C, $) => {
|
|
190
|
+
const A = $[c], _ = n.getValues(A);
|
|
191
|
+
return C[A] = _ === "on", C;
|
|
192
|
+
}, {}), P = n.watch(e), N = D(() => P && typeof P == "object" ? P : w(), [P, r, c]);
|
|
193
|
+
V(() => {
|
|
194
|
+
const C = n.getValues(e);
|
|
195
|
+
(!C || typeof C != "object") && n.setValue(e, N, {
|
|
196
196
|
shouldDirty: !1,
|
|
197
197
|
shouldValidate: !1
|
|
198
198
|
});
|
|
199
|
-
}, [
|
|
200
|
-
const i = (
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
n.setValue(e,
|
|
199
|
+
}, [N, e, n]);
|
|
200
|
+
const i = (C, $) => {
|
|
201
|
+
if (h) return;
|
|
202
|
+
const A = { ...N, [C]: $ };
|
|
203
|
+
n.setValue(e, A, {
|
|
204
204
|
shouldDirty: !0,
|
|
205
205
|
shouldValidate: !0
|
|
206
|
-
}), n.setValue(
|
|
207
|
-
}, d = (M = (
|
|
208
|
-
return /* @__PURE__ */ f("div", { className: `form-group ${
|
|
206
|
+
}), n.setValue(C, $ ? "on" : "", { shouldValidate: !1 });
|
|
207
|
+
}, d = (M = (v = n.formState) == null ? void 0 : v.errors) == null ? void 0 : M[e];
|
|
208
|
+
return /* @__PURE__ */ f("div", { className: `form-group ${b ? "hidden" : ""}`, children: [
|
|
209
209
|
a && /* @__PURE__ */ t("label", { children: a }),
|
|
210
210
|
/* @__PURE__ */ t(
|
|
211
211
|
"div",
|
|
212
212
|
{
|
|
213
|
-
className: `checkbox-group-custom ${
|
|
214
|
-
children: r.map((
|
|
215
|
-
const $ = String(
|
|
213
|
+
className: `checkbox-group-custom ${h ? "readOnly" : ""}`,
|
|
214
|
+
children: r.map((C) => {
|
|
215
|
+
const $ = String(C[c]), A = N[$] === !0;
|
|
216
216
|
return /* @__PURE__ */ f("div", { children: [
|
|
217
217
|
/* @__PURE__ */ t("input", { type: "hidden", ...n.register($) }),
|
|
218
218
|
/* @__PURE__ */ f(
|
|
219
219
|
"label",
|
|
220
220
|
{
|
|
221
|
-
className: `custom-checkbox ${
|
|
221
|
+
className: `custom-checkbox ${A ? "checked" : ""} ${h ? "readOnly" : ""}`,
|
|
222
222
|
children: [
|
|
223
223
|
/* @__PURE__ */ t(
|
|
224
224
|
"input",
|
|
225
225
|
{
|
|
226
226
|
type: "checkbox",
|
|
227
|
-
checked:
|
|
228
|
-
disabled:
|
|
229
|
-
onChange: (
|
|
227
|
+
checked: A,
|
|
228
|
+
disabled: h,
|
|
229
|
+
onChange: (_) => i($, _.target.checked)
|
|
230
230
|
}
|
|
231
231
|
),
|
|
232
232
|
/* @__PURE__ */ t("span", { className: "checkmark" }),
|
|
233
|
-
/* @__PURE__ */ t("span", { children:
|
|
233
|
+
/* @__PURE__ */ t("span", { children: C[s] })
|
|
234
234
|
]
|
|
235
235
|
}
|
|
236
236
|
)
|
|
@@ -251,33 +251,33 @@ function de({
|
|
|
251
251
|
forceReadOnly: o = !1,
|
|
252
252
|
forceHidden: n = !1
|
|
253
253
|
}) {
|
|
254
|
-
const { isReadOnly: g, isHidden: m } = I(), u = o || !!g(e),
|
|
255
|
-
field:
|
|
256
|
-
fieldState: { error:
|
|
257
|
-
} =
|
|
254
|
+
const { isReadOnly: g, isHidden: m } = I(), u = o || !!g(e), y = n || !!m(e), { control: k } = O(), { isView: R, isReadOnly: p } = W(), {
|
|
255
|
+
field: b,
|
|
256
|
+
fieldState: { error: h }
|
|
257
|
+
} = j({
|
|
258
258
|
name: e,
|
|
259
|
-
control:
|
|
260
|
-
}),
|
|
259
|
+
control: k
|
|
260
|
+
}), w = u || p || R, P = b.value ?? "", N = S(
|
|
261
261
|
(i) => {
|
|
262
|
-
|
|
262
|
+
w || b.onChange(i);
|
|
263
263
|
},
|
|
264
|
-
[
|
|
264
|
+
[w, b]
|
|
265
265
|
);
|
|
266
|
-
return /* @__PURE__ */ f("div", { className: `form-group column ${
|
|
266
|
+
return /* @__PURE__ */ f("div", { className: `form-group column ${y ? "hidden" : ""}`, children: [
|
|
267
267
|
r && /* @__PURE__ */ t("label", { className: "control-label", children: r }),
|
|
268
268
|
/* @__PURE__ */ t(
|
|
269
269
|
"div",
|
|
270
270
|
{
|
|
271
|
-
className: `btn-group ${
|
|
271
|
+
className: `btn-group ${w ? "view-mode" : ""}`,
|
|
272
272
|
"data-field-name": e,
|
|
273
273
|
children: a.map((i) => {
|
|
274
|
-
const d = i[c],
|
|
274
|
+
const d = i[c], v = P === d, M = i.color ? { "--customColor": i.color } : void 0;
|
|
275
275
|
return /* @__PURE__ */ f(
|
|
276
276
|
"label",
|
|
277
277
|
{
|
|
278
278
|
htmlFor: `${e}_${d}`,
|
|
279
279
|
style: M,
|
|
280
|
-
className: `btn fs-ellipsis ${
|
|
280
|
+
className: `btn fs-ellipsis ${v ? "active" : ""}`,
|
|
281
281
|
children: [
|
|
282
282
|
/* @__PURE__ */ t(
|
|
283
283
|
"input",
|
|
@@ -286,10 +286,10 @@ function de({
|
|
|
286
286
|
id: `${e}_${d}`,
|
|
287
287
|
name: e,
|
|
288
288
|
value: d,
|
|
289
|
-
checked:
|
|
289
|
+
checked: v,
|
|
290
290
|
className: "hidden",
|
|
291
|
-
onChange: () =>
|
|
292
|
-
disabled:
|
|
291
|
+
onChange: () => N(d),
|
|
292
|
+
disabled: w
|
|
293
293
|
}
|
|
294
294
|
),
|
|
295
295
|
i[l] && /* @__PURE__ */ t("i", { className: `${i[l]} icon-sm` }),
|
|
@@ -302,7 +302,7 @@ function de({
|
|
|
302
302
|
})
|
|
303
303
|
}
|
|
304
304
|
),
|
|
305
|
-
|
|
305
|
+
h && /* @__PURE__ */ t("p", { className: "text-danger", children: String(h.message) })
|
|
306
306
|
] });
|
|
307
307
|
}
|
|
308
308
|
const lt = E(de), ue = ({
|
|
@@ -315,31 +315,31 @@ const lt = E(de), ue = ({
|
|
|
315
315
|
forceReadOnly: o = !1,
|
|
316
316
|
forceHidden: n = !1
|
|
317
317
|
}) => {
|
|
318
|
-
const { isReadOnly: g, isHidden: m } = I(), u = o || !!g(e),
|
|
319
|
-
field:
|
|
320
|
-
fieldState: { error:
|
|
321
|
-
} =
|
|
318
|
+
const { isReadOnly: g, isHidden: m } = I(), u = o || !!g(e), y = n || !!m(e), { control: k } = O(), { isView: R } = W(), {
|
|
319
|
+
field: p,
|
|
320
|
+
fieldState: { error: b }
|
|
321
|
+
} = j({
|
|
322
322
|
name: e,
|
|
323
|
-
control:
|
|
323
|
+
control: k
|
|
324
324
|
});
|
|
325
|
-
return R ? /* @__PURE__ */ f("div", { className: `form-group ${
|
|
325
|
+
return R ? /* @__PURE__ */ f("div", { className: `form-group ${y ? "hidden" : ""}`, children: [
|
|
326
326
|
/* @__PURE__ */ t("label", { children: r }),
|
|
327
|
-
/* @__PURE__ */ t("span", { className: "form-control", children:
|
|
328
|
-
] }) : /* @__PURE__ */ f("div", { className: `form-group ${
|
|
327
|
+
/* @__PURE__ */ t("span", { className: "form-control", children: p.value || "-" })
|
|
328
|
+
] }) : /* @__PURE__ */ f("div", { className: `form-group ${y ? "hidden" : ""}`, children: [
|
|
329
329
|
/* @__PURE__ */ t("label", { children: r }),
|
|
330
330
|
/* @__PURE__ */ t(
|
|
331
331
|
"textarea",
|
|
332
332
|
{
|
|
333
|
-
...
|
|
333
|
+
...p,
|
|
334
334
|
rows: s,
|
|
335
335
|
maxLength: l,
|
|
336
|
-
value:
|
|
336
|
+
value: p.value || "",
|
|
337
337
|
placeholder: a,
|
|
338
338
|
readOnly: u,
|
|
339
|
-
className: `form-control ${
|
|
339
|
+
className: `form-control ${b ? "border-red" : ""} ${c}`
|
|
340
340
|
}
|
|
341
341
|
),
|
|
342
|
-
|
|
342
|
+
b && /* @__PURE__ */ t("p", { className: "text-danger", children: String(b.message) })
|
|
343
343
|
] });
|
|
344
344
|
}, ct = E(ue);
|
|
345
345
|
function X(e) {
|
|
@@ -368,9 +368,9 @@ function q(e) {
|
|
|
368
368
|
const c = a.width, s = c && e.matchPatterns[c] || e.matchPatterns[e.defaultMatchWidth], l = r.match(s);
|
|
369
369
|
if (!l)
|
|
370
370
|
return null;
|
|
371
|
-
const o = l[0], n = c && e.parsePatterns[c] || e.parsePatterns[e.defaultParseWidth], g = Array.isArray(n) ? he(n, (
|
|
371
|
+
const o = l[0], n = c && e.parsePatterns[c] || e.parsePatterns[e.defaultParseWidth], g = Array.isArray(n) ? he(n, (y) => y.test(o)) : (
|
|
372
372
|
// [TODO] -- I challenge you to fix the type
|
|
373
|
-
me(n, (
|
|
373
|
+
me(n, (y) => y.test(o))
|
|
374
374
|
);
|
|
375
375
|
let m;
|
|
376
376
|
m = e.valueCallback ? e.valueCallback(g) : g, m = a.valueCallback ? (
|
|
@@ -507,10 +507,10 @@ const ge = {
|
|
|
507
507
|
tomorrow: "'amanhã às' p",
|
|
508
508
|
nextWeek: "eeee 'às' p",
|
|
509
509
|
other: "P"
|
|
510
|
-
},
|
|
510
|
+
}, Ce = (e, r, a, c) => {
|
|
511
511
|
const s = we[e];
|
|
512
512
|
return typeof s == "function" ? s(r) : s;
|
|
513
|
-
},
|
|
513
|
+
}, ke = {
|
|
514
514
|
narrow: ["AC", "DC"],
|
|
515
515
|
abbreviated: ["AC", "DC"],
|
|
516
516
|
wide: ["antes de cristo", "depois de cristo"]
|
|
@@ -634,10 +634,10 @@ const ge = {
|
|
|
634
634
|
}, Me = (e, r) => {
|
|
635
635
|
const a = Number(e);
|
|
636
636
|
return (r == null ? void 0 : r.unit) === "week" ? a + "ª" : a + "º";
|
|
637
|
-
},
|
|
637
|
+
}, Ae = {
|
|
638
638
|
ordinalNumber: Me,
|
|
639
639
|
era: H({
|
|
640
|
-
values:
|
|
640
|
+
values: ke,
|
|
641
641
|
defaultWidth: "wide"
|
|
642
642
|
}),
|
|
643
643
|
quarter: H({
|
|
@@ -659,20 +659,20 @@ const ge = {
|
|
|
659
659
|
formattingValues: Se,
|
|
660
660
|
defaultFormattingWidth: "wide"
|
|
661
661
|
})
|
|
662
|
-
},
|
|
662
|
+
}, _e = /^(\d+)[ºªo]?/i, Ve = /\d+/i, Oe = {
|
|
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
|
|
666
|
-
},
|
|
666
|
+
}, Te = {
|
|
667
667
|
any: [/^ac/i, /^dc/i],
|
|
668
668
|
wide: [/^antes de cristo/i, /^depois de cristo/i]
|
|
669
|
-
},
|
|
669
|
+
}, We = {
|
|
670
670
|
narrow: /^[1234]/i,
|
|
671
671
|
abbreviated: /^T[1234]/i,
|
|
672
672
|
wide: /^[1234](º)? trimestre/i
|
|
673
|
-
},
|
|
673
|
+
}, De = {
|
|
674
674
|
any: [/1/i, /2/i, /3/i, /4/i]
|
|
675
|
-
},
|
|
675
|
+
}, je = {
|
|
676
676
|
narrow: /^[jfmajsond]/i,
|
|
677
677
|
abbreviated: /^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,
|
|
678
678
|
wide: /^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i
|
|
@@ -728,27 +728,27 @@ const ge = {
|
|
|
728
728
|
evening: /tarde/i,
|
|
729
729
|
night: /noite/i
|
|
730
730
|
}
|
|
731
|
-
},
|
|
731
|
+
}, Be = {
|
|
732
732
|
ordinalNumber: fe({
|
|
733
|
-
matchPattern:
|
|
734
|
-
parsePattern:
|
|
733
|
+
matchPattern: _e,
|
|
734
|
+
parsePattern: Ve,
|
|
735
735
|
valueCallback: (e) => parseInt(e, 10)
|
|
736
736
|
}),
|
|
737
737
|
era: q({
|
|
738
|
-
matchPatterns:
|
|
738
|
+
matchPatterns: Oe,
|
|
739
739
|
defaultMatchWidth: "wide",
|
|
740
|
-
parsePatterns:
|
|
740
|
+
parsePatterns: Te,
|
|
741
741
|
defaultParseWidth: "any"
|
|
742
742
|
}),
|
|
743
743
|
quarter: q({
|
|
744
|
-
matchPatterns:
|
|
744
|
+
matchPatterns: We,
|
|
745
745
|
defaultMatchWidth: "wide",
|
|
746
|
-
parsePatterns:
|
|
746
|
+
parsePatterns: De,
|
|
747
747
|
defaultParseWidth: "any",
|
|
748
748
|
valueCallback: (e) => e + 1
|
|
749
749
|
}),
|
|
750
750
|
month: q({
|
|
751
|
-
matchPatterns:
|
|
751
|
+
matchPatterns: je,
|
|
752
752
|
defaultMatchWidth: "wide",
|
|
753
753
|
parsePatterns: Ie,
|
|
754
754
|
defaultParseWidth: "any"
|
|
@@ -765,24 +765,24 @@ const ge = {
|
|
|
765
765
|
parsePatterns: qe,
|
|
766
766
|
defaultParseWidth: "any"
|
|
767
767
|
})
|
|
768
|
-
},
|
|
768
|
+
}, Le = {
|
|
769
769
|
code: "pt-BR",
|
|
770
770
|
formatDistance: pe,
|
|
771
771
|
formatLong: Ne,
|
|
772
|
-
formatRelative:
|
|
773
|
-
localize:
|
|
774
|
-
match:
|
|
772
|
+
formatRelative: Ce,
|
|
773
|
+
localize: Ae,
|
|
774
|
+
match: Be,
|
|
775
775
|
options: {
|
|
776
776
|
weekStartsOn: 0,
|
|
777
777
|
firstWeekContainsDate: 1
|
|
778
778
|
}
|
|
779
779
|
};
|
|
780
|
-
ae("pt-BR",
|
|
781
|
-
const
|
|
780
|
+
ae("pt-BR", Le);
|
|
781
|
+
const G = "dd/MM/yyyy", ze = (e) => {
|
|
782
782
|
if (!e) return null;
|
|
783
|
-
const r = re(e,
|
|
783
|
+
const r = re(e, G, /* @__PURE__ */ new Date());
|
|
784
784
|
return se(r) ? r : null;
|
|
785
|
-
}, Xe = (e) => e ? oe(e,
|
|
785
|
+
}, Xe = (e) => e ? oe(e, G) : "", Ue = K(
|
|
786
786
|
({ shimRef: e, className: r, name: a, ...c }, s) => /* @__PURE__ */ t(
|
|
787
787
|
"input",
|
|
788
788
|
{
|
|
@@ -794,7 +794,7 @@ const Y = "dd/MM/yyyy", ze = (e) => {
|
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
796
|
)
|
|
797
|
-
),
|
|
797
|
+
), Ge = ({
|
|
798
798
|
name: e,
|
|
799
799
|
label: r = "",
|
|
800
800
|
placeholder: a = "dd/mm/aaaa",
|
|
@@ -802,83 +802,83 @@ const Y = "dd/MM/yyyy", ze = (e) => {
|
|
|
802
802
|
forceReadOnly: s = !1,
|
|
803
803
|
forceHidden: l = !1
|
|
804
804
|
}) => {
|
|
805
|
-
const { control: o } =
|
|
806
|
-
field: { onChange:
|
|
807
|
-
fieldState: { error:
|
|
808
|
-
} =
|
|
805
|
+
const { control: o } = O(), { isView: n } = W(), { isReadOnly: g, isHidden: m } = I(), u = s || !!g(e), y = l || !!m(e), {
|
|
806
|
+
field: { onChange: k, onBlur: R, value: p, ref: b },
|
|
807
|
+
fieldState: { error: h }
|
|
808
|
+
} = j({
|
|
809
809
|
name: e,
|
|
810
810
|
control: o
|
|
811
|
-
}),
|
|
811
|
+
}), w = D(() => ze(p), [p]), P = S(
|
|
812
812
|
(i) => {
|
|
813
|
-
|
|
813
|
+
k(i ? Xe(i) : "");
|
|
814
814
|
},
|
|
815
|
-
[
|
|
816
|
-
),
|
|
815
|
+
[k]
|
|
816
|
+
), N = S(
|
|
817
817
|
(i) => {
|
|
818
|
-
var d,
|
|
819
|
-
if (
|
|
818
|
+
var d, v;
|
|
819
|
+
if (b(i), i && ((v = (d = o._fields) == null ? void 0 : d[e]) != null && v._f)) {
|
|
820
820
|
const M = o._fields[e];
|
|
821
821
|
M._f.ref = {
|
|
822
822
|
focus: () => {
|
|
823
|
-
var
|
|
824
|
-
return (
|
|
823
|
+
var C;
|
|
824
|
+
return (C = i.focus) == null ? void 0 : C.call(i);
|
|
825
825
|
},
|
|
826
826
|
select: () => {
|
|
827
|
-
var
|
|
828
|
-
return (
|
|
827
|
+
var C;
|
|
828
|
+
return (C = i.select) == null ? void 0 : C.call(i);
|
|
829
829
|
},
|
|
830
|
-
setCustomValidity: (
|
|
830
|
+
setCustomValidity: (C) => {
|
|
831
831
|
var $;
|
|
832
|
-
return ($ = i.setCustomValidity) == null ? void 0 : $.call(i,
|
|
832
|
+
return ($ = i.setCustomValidity) == null ? void 0 : $.call(i, C);
|
|
833
833
|
},
|
|
834
834
|
reportValidity: () => {
|
|
835
|
-
var
|
|
836
|
-
return (
|
|
835
|
+
var C;
|
|
836
|
+
return (C = i.reportValidity) == null ? void 0 : C.call(i);
|
|
837
837
|
}
|
|
838
838
|
};
|
|
839
839
|
}
|
|
840
840
|
},
|
|
841
|
-
[
|
|
841
|
+
[b, o, e]
|
|
842
842
|
);
|
|
843
|
-
return
|
|
843
|
+
return y ? null : n ? /* @__PURE__ */ f("div", { className: "form-group", children: [
|
|
844
844
|
/* @__PURE__ */ t("label", { children: r }),
|
|
845
|
-
/* @__PURE__ */ t("span", { className: "form-control", children:
|
|
845
|
+
/* @__PURE__ */ t("span", { className: "form-control", children: p || "-" })
|
|
846
846
|
] }) : /* @__PURE__ */ f("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: `${
|
|
848
|
+
/* @__PURE__ */ t("div", { className: `${h ? "border-red" : ""}`, children: /* @__PURE__ */ t(
|
|
849
849
|
ne,
|
|
850
850
|
{
|
|
851
851
|
id: e,
|
|
852
852
|
name: e,
|
|
853
|
-
selected:
|
|
853
|
+
selected: w,
|
|
854
854
|
onChange: P,
|
|
855
855
|
onBlur: R,
|
|
856
|
-
dateFormat:
|
|
856
|
+
dateFormat: G,
|
|
857
857
|
placeholderText: a,
|
|
858
858
|
disabled: u,
|
|
859
859
|
readOnly: u,
|
|
860
860
|
locale: "pt-BR",
|
|
861
|
-
className: `form-control ${
|
|
861
|
+
className: `form-control ${h ? "border-red" : ""}`,
|
|
862
862
|
wrapperClassName: "w-100",
|
|
863
863
|
showMonthDropdown: !0,
|
|
864
864
|
showYearDropdown: !0,
|
|
865
865
|
dropdownMode: "select",
|
|
866
|
-
isClearable: !u && !!
|
|
866
|
+
isClearable: !u && !!p,
|
|
867
867
|
autoComplete: "off",
|
|
868
|
-
customInput: /* @__PURE__ */ t(Ue, { name: e, shimRef:
|
|
868
|
+
customInput: /* @__PURE__ */ t(Ue, { name: e, shimRef: N })
|
|
869
869
|
}
|
|
870
870
|
) }),
|
|
871
|
-
|
|
871
|
+
h && /* @__PURE__ */ t("span", { className: "help-block text-danger", children: String(h.message) })
|
|
872
872
|
] });
|
|
873
|
-
}, dt = E(
|
|
874
|
-
function
|
|
873
|
+
}, dt = E(Ge);
|
|
874
|
+
function Ye({
|
|
875
875
|
mapping: e = {},
|
|
876
876
|
defaultLabel: r = "Não reconhecido",
|
|
877
877
|
className: a = "",
|
|
878
878
|
hidden: c = !1,
|
|
879
879
|
label: s
|
|
880
880
|
}) {
|
|
881
|
-
const { activityId: l } =
|
|
881
|
+
const { activityId: l } = W(), o = D(() => !e || l === null || l === void 0 ? null : e[l], [l, e]);
|
|
882
882
|
if (!o)
|
|
883
883
|
return /* @__PURE__ */ f("div", { className: `form-group ${c ? "hidden" : ""}`, children: [
|
|
884
884
|
s && /* @__PURE__ */ t("label", { children: s }),
|
|
@@ -895,7 +895,7 @@ function Ge({
|
|
|
895
895
|
] })
|
|
896
896
|
] });
|
|
897
897
|
}
|
|
898
|
-
const ut = E(
|
|
898
|
+
const ut = E(Ye);
|
|
899
899
|
function Qe({
|
|
900
900
|
name: e,
|
|
901
901
|
control: r,
|
|
@@ -904,72 +904,72 @@ function Qe({
|
|
|
904
904
|
isReadOnly: s,
|
|
905
905
|
filters: l = []
|
|
906
906
|
}) {
|
|
907
|
-
const { field: o } =
|
|
907
|
+
const { field: o } = j({ name: e, control: r }), [n, g] = T([]), [m, u] = T([]), y = () => Date.now() + Math.random(), k = (i) => {
|
|
908
908
|
try {
|
|
909
909
|
const d = JSON.parse(i);
|
|
910
|
-
return Array.isArray(d) ? d.map((
|
|
911
|
-
...
|
|
912
|
-
_uid:
|
|
910
|
+
return Array.isArray(d) ? d.map((v) => ({
|
|
911
|
+
...v,
|
|
912
|
+
_uid: v._uid || y()
|
|
913
913
|
})) : [];
|
|
914
914
|
} catch (d) {
|
|
915
915
|
return console.error(`Erro ao ler dados da tabela "${e}":`, d), [];
|
|
916
916
|
}
|
|
917
917
|
};
|
|
918
|
-
|
|
918
|
+
V(() => {
|
|
919
919
|
if (!(n.length > 0 && !c) && o.value && typeof o.value == "string") {
|
|
920
920
|
const i = JSON.stringify(n);
|
|
921
921
|
if (o.value === i) return;
|
|
922
|
-
const d =
|
|
922
|
+
const d = k(o.value);
|
|
923
923
|
g(d);
|
|
924
924
|
}
|
|
925
|
-
}, [o.value, c]),
|
|
925
|
+
}, [o.value, c]), V(() => {
|
|
926
926
|
if (s) return;
|
|
927
927
|
const i = JSON.stringify(n);
|
|
928
928
|
o.value !== i && o.onChange(i);
|
|
929
929
|
}, [n, o, s]);
|
|
930
930
|
const R = S(() => {
|
|
931
|
-
const i = { _uid:
|
|
931
|
+
const i = { _uid: y(), ...a };
|
|
932
932
|
g((d) => [...d, i]);
|
|
933
|
-
}, [a]),
|
|
933
|
+
}, [a]), p = S(() => {
|
|
934
934
|
g(
|
|
935
935
|
(i) => i.filter((d) => !m.includes(d._uid))
|
|
936
936
|
), u([]);
|
|
937
|
-
}, [m]),
|
|
938
|
-
(i, d,
|
|
937
|
+
}, [m]), b = S(
|
|
938
|
+
(i, d, v) => {
|
|
939
939
|
g(
|
|
940
940
|
(M) => M.map(
|
|
941
|
-
(
|
|
941
|
+
(C) => C._uid === i ? { ...C, [d]: v } : C
|
|
942
942
|
)
|
|
943
943
|
);
|
|
944
944
|
},
|
|
945
945
|
[]
|
|
946
|
-
),
|
|
946
|
+
), h = S((i) => {
|
|
947
947
|
u(
|
|
948
|
-
(d) => d.includes(i) ? d.filter((
|
|
948
|
+
(d) => d.includes(i) ? d.filter((v) => v !== i) : [...d, i]
|
|
949
949
|
);
|
|
950
|
-
}, []),
|
|
950
|
+
}, []), w = S(
|
|
951
951
|
(i) => {
|
|
952
952
|
u(i ? n.map((d) => d._uid) : []);
|
|
953
953
|
},
|
|
954
954
|
[n]
|
|
955
|
-
), P = n.length > 0 && m.length === n.length,
|
|
955
|
+
), P = n.length > 0 && m.length === n.length, N = D(() => !l || l.length === 0 ? n : n.filter(
|
|
956
956
|
(i) => l.every((d) => {
|
|
957
957
|
if ("custom" in d)
|
|
958
958
|
return d.custom(i);
|
|
959
|
-
const
|
|
959
|
+
const v = i[d.field];
|
|
960
960
|
switch (d.operator) {
|
|
961
961
|
case "===":
|
|
962
|
-
return
|
|
962
|
+
return v === d.value;
|
|
963
963
|
case "!==":
|
|
964
|
-
return
|
|
964
|
+
return v !== d.value;
|
|
965
965
|
case ">":
|
|
966
|
-
return
|
|
966
|
+
return v > d.value;
|
|
967
967
|
case "<":
|
|
968
|
-
return
|
|
968
|
+
return v < d.value;
|
|
969
969
|
case ">=":
|
|
970
|
-
return
|
|
970
|
+
return v >= d.value;
|
|
971
971
|
case "<=":
|
|
972
|
-
return
|
|
972
|
+
return v <= d.value;
|
|
973
973
|
default:
|
|
974
974
|
return !0;
|
|
975
975
|
}
|
|
@@ -978,15 +978,15 @@ function Qe({
|
|
|
978
978
|
return {
|
|
979
979
|
field: o,
|
|
980
980
|
tableRows: n,
|
|
981
|
-
visibleRows:
|
|
981
|
+
visibleRows: N,
|
|
982
982
|
selectedRowIds: m,
|
|
983
983
|
isAllSelected: P,
|
|
984
984
|
handle: {
|
|
985
985
|
addRow: R,
|
|
986
|
-
removeRows:
|
|
987
|
-
updateCellValue:
|
|
988
|
-
toggleSelection:
|
|
989
|
-
toggleSelectAll:
|
|
986
|
+
removeRows: p,
|
|
987
|
+
updateCellValue: b,
|
|
988
|
+
toggleSelection: h,
|
|
989
|
+
toggleSelectAll: w
|
|
990
990
|
}
|
|
991
991
|
};
|
|
992
992
|
}
|
|
@@ -1000,85 +1000,85 @@ const mt = ({
|
|
|
1000
1000
|
actions: o = !0,
|
|
1001
1001
|
filters: n = []
|
|
1002
1002
|
}) => {
|
|
1003
|
-
const { control: g } =
|
|
1003
|
+
const { control: g } = O(), { isView: m, isReadOnly: u } = W(), { isReadOnly: y } = I(), k = s || m || u || y && y(e), { field: R, visibleRows: p, selectedRowIds: b, isAllSelected: h, handle: w } = Qe({
|
|
1004
1004
|
name: e,
|
|
1005
1005
|
control: g,
|
|
1006
1006
|
defaultRowValue: c,
|
|
1007
1007
|
isView: m,
|
|
1008
|
-
isReadOnly: !!
|
|
1008
|
+
isReadOnly: !!k,
|
|
1009
1009
|
filters: n
|
|
1010
1010
|
}), P = l === "fixed";
|
|
1011
1011
|
return /* @__PURE__ */ f("div", { className: `table-wrapper ${P ? "table-fixed" : "table-fluid"}`, children: [
|
|
1012
1012
|
/* @__PURE__ */ t("input", { type: "hidden", ...R }),
|
|
1013
1013
|
/* @__PURE__ */ f("div", { className: "header-handle", children: [
|
|
1014
1014
|
/* @__PURE__ */ t("h3", { children: r }),
|
|
1015
|
-
!
|
|
1015
|
+
!k && o && /* @__PURE__ */ f("div", { className: "handle-actions", children: [
|
|
1016
1016
|
/* @__PURE__ */ f(
|
|
1017
1017
|
"button",
|
|
1018
1018
|
{
|
|
1019
1019
|
type: "button",
|
|
1020
|
-
className: `btn ${
|
|
1021
|
-
disabled:
|
|
1022
|
-
onClick:
|
|
1020
|
+
className: `btn ${b.length > 0 ? "btn-danger" : ""}`,
|
|
1021
|
+
disabled: b.length === 0,
|
|
1022
|
+
onClick: w.removeRows,
|
|
1023
1023
|
children: [
|
|
1024
1024
|
"Remover (",
|
|
1025
|
-
|
|
1025
|
+
b.length,
|
|
1026
1026
|
")"
|
|
1027
1027
|
]
|
|
1028
1028
|
}
|
|
1029
1029
|
),
|
|
1030
|
-
/* @__PURE__ */ t("button", { type: "button", className: "btn-add", onClick:
|
|
1030
|
+
/* @__PURE__ */ t("button", { type: "button", className: "btn-add", onClick: w.addRow, children: "Adicionar" })
|
|
1031
1031
|
] })
|
|
1032
1032
|
] }),
|
|
1033
1033
|
/* @__PURE__ */ t("div", { className: "table-scroll", children: /* @__PURE__ */ f("table", { className: "table-custom", children: [
|
|
1034
1034
|
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ f("tr", { children: [
|
|
1035
|
-
!
|
|
1035
|
+
!k && /* @__PURE__ */ t("th", { style: { width: "50px" }, children: /* @__PURE__ */ t(
|
|
1036
1036
|
"input",
|
|
1037
1037
|
{
|
|
1038
1038
|
type: "checkbox",
|
|
1039
|
-
checked:
|
|
1040
|
-
onChange: (
|
|
1039
|
+
checked: h,
|
|
1040
|
+
onChange: (N) => w.toggleSelectAll(N.target.checked)
|
|
1041
1041
|
}
|
|
1042
1042
|
) }),
|
|
1043
|
-
a.map((
|
|
1043
|
+
a.map((N) => /* @__PURE__ */ t(
|
|
1044
1044
|
"th",
|
|
1045
1045
|
{
|
|
1046
|
-
style:
|
|
1047
|
-
children:
|
|
1046
|
+
style: N.width ? { minWidth: P ? N.width : "100%" } : { width: "max-content" },
|
|
1047
|
+
children: N.label
|
|
1048
1048
|
},
|
|
1049
|
-
|
|
1049
|
+
N.key
|
|
1050
1050
|
))
|
|
1051
1051
|
] }) }),
|
|
1052
1052
|
/* @__PURE__ */ f("tbody", { children: [
|
|
1053
|
-
|
|
1054
|
-
!
|
|
1053
|
+
p.map((N, i) => /* @__PURE__ */ f("tr", { children: [
|
|
1054
|
+
!k && /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t(
|
|
1055
1055
|
"input",
|
|
1056
1056
|
{
|
|
1057
1057
|
type: "checkbox",
|
|
1058
|
-
checked:
|
|
1059
|
-
onChange: () =>
|
|
1058
|
+
checked: b.includes(N._uid),
|
|
1059
|
+
onChange: () => w.toggleSelection(N._uid)
|
|
1060
1060
|
}
|
|
1061
1061
|
) }),
|
|
1062
1062
|
a.map((d) => /* @__PURE__ */ t("td", { children: d.render ? d.render.length <= 1 ? d.render({
|
|
1063
|
-
row:
|
|
1063
|
+
row: N,
|
|
1064
1064
|
index: i,
|
|
1065
|
-
updateRow: (
|
|
1066
|
-
isLocked: !!
|
|
1065
|
+
updateRow: (v, M) => w.updateCellValue(N._uid, v, M),
|
|
1066
|
+
isLocked: !!k,
|
|
1067
1067
|
isView: !!m
|
|
1068
1068
|
}) : d.render(
|
|
1069
|
-
|
|
1069
|
+
N,
|
|
1070
1070
|
i,
|
|
1071
|
-
(
|
|
1072
|
-
!!
|
|
1071
|
+
(v, M) => w.updateCellValue(N._uid, v, M),
|
|
1072
|
+
!!k,
|
|
1073
1073
|
!!m
|
|
1074
|
-
) :
|
|
1075
|
-
] },
|
|
1076
|
-
|
|
1074
|
+
) : N[d.key] }, `${N._uid}-${d.key}`))
|
|
1075
|
+
] }, N._uid)),
|
|
1076
|
+
p.length === 0 && /* @__PURE__ */ t("tr", { className: "empty-row", children: /* @__PURE__ */ t("td", { colSpan: 100, className: "text-center", children: k ? "Nenhum registro encontrado." : "Nenhum registro." }) })
|
|
1077
1077
|
] })
|
|
1078
1078
|
] }) })
|
|
1079
1079
|
] });
|
|
1080
1080
|
}, Je = (e) => {
|
|
1081
|
-
const [r, a] =
|
|
1081
|
+
const [r, a] = T(null), { watch: c } = O(), s = c(e), l = S(() => {
|
|
1082
1082
|
try {
|
|
1083
1083
|
const n = window.top.__REACT_ATTACHMENT_BRIDGE__;
|
|
1084
1084
|
if (n) {
|
|
@@ -1090,7 +1090,7 @@ const mt = ({
|
|
|
1090
1090
|
a(s ? { name: s, documentId: 0 } : null);
|
|
1091
1091
|
}
|
|
1092
1092
|
}, [e, s]);
|
|
1093
|
-
return
|
|
1093
|
+
return V(() => {
|
|
1094
1094
|
l();
|
|
1095
1095
|
const o = setInterval(l, 2e3);
|
|
1096
1096
|
return () => clearInterval(o);
|
|
@@ -1102,37 +1102,37 @@ function ht({
|
|
|
1102
1102
|
help: a,
|
|
1103
1103
|
className: c = ""
|
|
1104
1104
|
}) {
|
|
1105
|
-
const [s, l] =
|
|
1106
|
-
var h;
|
|
1105
|
+
const [s, l] = T(!1), { control: o } = O(), { field: n } = j({ name: e, control: o }), { attachment: g, sync: m } = Je(e), { bridge: u } = (() => {
|
|
1107
1106
|
try {
|
|
1108
|
-
const p = window.top;
|
|
1109
1107
|
return {
|
|
1110
|
-
bridge:
|
|
1111
|
-
toast: (h = p.FLUIGC) == null ? void 0 : h.toast
|
|
1108
|
+
bridge: window.top.__REACT_ATTACHMENT_BRIDGE__
|
|
1112
1109
|
};
|
|
1113
1110
|
} catch {
|
|
1114
|
-
return { bridge: null
|
|
1111
|
+
return { bridge: null };
|
|
1115
1112
|
}
|
|
1116
|
-
})(), y = !!g && !s,
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
n.onChange(
|
|
1113
|
+
})(), y = !!g && !s, k = S(() => {
|
|
1114
|
+
const p = document.createElement("input");
|
|
1115
|
+
p.type = "file", p.onchange = (b) => {
|
|
1116
|
+
const h = b.target.files[0];
|
|
1117
|
+
h && (l(!0), u ? u.upload(h, e, (w) => {
|
|
1118
|
+
n.onChange(w.name), setTimeout(() => {
|
|
1122
1119
|
l(!1), m();
|
|
1123
1120
|
}, 1e3);
|
|
1124
|
-
}) : (n.onChange(
|
|
1125
|
-
},
|
|
1126
|
-
}, [u, e, n, m]),
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1121
|
+
}) : (n.onChange(h.name), l(!1)));
|
|
1122
|
+
}, p.click();
|
|
1123
|
+
}, [u, e, n, m]), R = (p) => {
|
|
1124
|
+
var P;
|
|
1125
|
+
p.stopPropagation();
|
|
1126
|
+
const b = window.top, h = b.__REACT_ATTACHMENT_BRIDGE__, w = (P = b.FLUIGC) == null ? void 0 : P.toast;
|
|
1127
|
+
h ? h.remove(e) ? (n.onChange(""), m(), w && w({
|
|
1128
|
+
title: "Sucesso: ",
|
|
1129
|
+
message: "Anexo removido com sucesso.",
|
|
1130
1130
|
type: "success"
|
|
1131
|
-
})) :
|
|
1132
|
-
title: "Erro",
|
|
1133
|
-
message: "Não foi possível
|
|
1131
|
+
})) : w && w({
|
|
1132
|
+
title: "Erro: ",
|
|
1133
|
+
message: "Não foi possível localizar o anexo para remoção.",
|
|
1134
1134
|
type: "danger"
|
|
1135
|
-
}) : n.onChange("");
|
|
1135
|
+
}) : (n.onChange(""), m());
|
|
1136
1136
|
};
|
|
1137
1137
|
return /* @__PURE__ */ f("div", { className: `form-group ${c}`, children: [
|
|
1138
1138
|
r && /* @__PURE__ */ t("label", { children: r }),
|
|
@@ -1150,7 +1150,7 @@ function ht({
|
|
|
1150
1150
|
alignItems: "center",
|
|
1151
1151
|
backgroundColor: s ? "#f9f9f9" : "white"
|
|
1152
1152
|
},
|
|
1153
|
-
onClick: y ? () => u == null ? void 0 : u.view(e) :
|
|
1153
|
+
onClick: y ? () => u == null ? void 0 : u.view(e) : k,
|
|
1154
1154
|
children: [
|
|
1155
1155
|
/* @__PURE__ */ f("span", { children: [
|
|
1156
1156
|
/* @__PURE__ */ t(
|
|
@@ -1166,7 +1166,7 @@ function ht({
|
|
|
1166
1166
|
{
|
|
1167
1167
|
type: "button",
|
|
1168
1168
|
className: "btn btn-link text-danger",
|
|
1169
|
-
onClick:
|
|
1169
|
+
onClick: R,
|
|
1170
1170
|
children: /* @__PURE__ */ t("i", { className: "fluigicon fluigicon-trash" })
|
|
1171
1171
|
}
|
|
1172
1172
|
)
|
|
@@ -1182,30 +1182,30 @@ function ft({
|
|
|
1182
1182
|
showNavigation: a = !0,
|
|
1183
1183
|
progressBar: c = !0
|
|
1184
1184
|
}) {
|
|
1185
|
-
const [s, l] =
|
|
1186
|
-
l((
|
|
1187
|
-
}, [e.length]),
|
|
1188
|
-
l((
|
|
1185
|
+
const [s, l] = T(0), [o, n] = T(0), g = B(null), m = B(null), u = S(() => {
|
|
1186
|
+
l((b) => (b + 1) % e.length), n(0);
|
|
1187
|
+
}, [e.length]), y = S(() => {
|
|
1188
|
+
l((b) => (b - 1 + e.length) % e.length), n(0);
|
|
1189
1189
|
}, [e.length]);
|
|
1190
|
-
if (
|
|
1190
|
+
if (V(() => {
|
|
1191
1191
|
if (r > 0 && e.length > 1) {
|
|
1192
|
-
const
|
|
1192
|
+
const h = 100 / r * 100;
|
|
1193
1193
|
g.current = setInterval(u, r), m.current = setInterval(() => {
|
|
1194
|
-
n((
|
|
1194
|
+
n((w) => w >= 100 ? 0 : w + h);
|
|
1195
1195
|
}, 100);
|
|
1196
1196
|
}
|
|
1197
1197
|
return () => {
|
|
1198
1198
|
g.current && clearInterval(g.current), m.current && clearInterval(m.current);
|
|
1199
1199
|
};
|
|
1200
1200
|
}, [r, u, e.length, s]), !e || e.length === 0) return null;
|
|
1201
|
-
const
|
|
1201
|
+
const k = e[s], R = typeof k == "string" ? k : k.url, p = /\.(jpg|jpeg|png|gif|webp)$/i.test(R);
|
|
1202
1202
|
return /* @__PURE__ */ f("div", { className: "carousel-root", children: [
|
|
1203
1203
|
/* @__PURE__ */ f("div", { className: "carousel-viewport", children: [
|
|
1204
1204
|
a && e.length > 1 && /* @__PURE__ */ f(U, { children: [
|
|
1205
|
-
/* @__PURE__ */ t("button", { className: "nav-btn prev", onClick:
|
|
1205
|
+
/* @__PURE__ */ t("button", { className: "nav-btn prev", onClick: y, children: /* @__PURE__ */ t("i", { className: "flaticon flaticon-chevron-left" }) }),
|
|
1206
1206
|
/* @__PURE__ */ t("button", { className: "nav-btn next", onClick: u, children: /* @__PURE__ */ t("i", { className: "flaticon flaticon-chevron-right" }) })
|
|
1207
1207
|
] }),
|
|
1208
|
-
/* @__PURE__ */ t("div", { className: "carousel-media", children:
|
|
1208
|
+
/* @__PURE__ */ t("div", { className: "carousel-media", children: p ? /* @__PURE__ */ t("img", { src: R, alt: "Slide", className: "carousel-image" }) : /* @__PURE__ */ f("div", { className: "carousel-file-fallback", children: [
|
|
1209
1209
|
/* @__PURE__ */ t("i", { className: "flaticon flaticon-file icon-xl" }),
|
|
1210
1210
|
/* @__PURE__ */ t(
|
|
1211
1211
|
"a",
|
|
@@ -1218,15 +1218,15 @@ function ft({
|
|
|
1218
1218
|
}
|
|
1219
1219
|
)
|
|
1220
1220
|
] }) }),
|
|
1221
|
-
e.length > 1 && /* @__PURE__ */ t("div", { className: "carousel-dots", children: e.map((
|
|
1221
|
+
e.length > 1 && /* @__PURE__ */ t("div", { className: "carousel-dots", children: e.map((b, h) => /* @__PURE__ */ t(
|
|
1222
1222
|
"div",
|
|
1223
1223
|
{
|
|
1224
|
-
className: `dot ${
|
|
1224
|
+
className: `dot ${h === s ? "active" : ""}`,
|
|
1225
1225
|
onClick: () => {
|
|
1226
|
-
l(
|
|
1226
|
+
l(h), n(0);
|
|
1227
1227
|
}
|
|
1228
1228
|
},
|
|
1229
|
-
|
|
1229
|
+
h
|
|
1230
1230
|
)) })
|
|
1231
1231
|
] }),
|
|
1232
1232
|
c && r > 0 && e.length > 1 && /* @__PURE__ */ t("div", { className: "carousel-progress-container", children: /* @__PURE__ */ t(
|
|
@@ -1253,7 +1253,7 @@ function gt({
|
|
|
1253
1253
|
},
|
|
1254
1254
|
[c]
|
|
1255
1255
|
);
|
|
1256
|
-
return
|
|
1256
|
+
return V(() => (r && (document.addEventListener("keydown", n), a == null || a(), document.body.style.overflow = "hidden"), () => {
|
|
1257
1257
|
document.removeEventListener("keydown", n), document.body.style.overflow = "auto";
|
|
1258
1258
|
}), [r, n, a]), r ? /* @__PURE__ */ t(
|
|
1259
1259
|
"div",
|
|
@@ -1332,8 +1332,8 @@ function pt({
|
|
|
1332
1332
|
{
|
|
1333
1333
|
className: "sidebar-option",
|
|
1334
1334
|
onClick: () => {
|
|
1335
|
-
var
|
|
1336
|
-
(
|
|
1335
|
+
var y;
|
|
1336
|
+
(y = u.action) == null || y.call(u), o == null || o(u.id);
|
|
1337
1337
|
},
|
|
1338
1338
|
style: { color: `${l}` },
|
|
1339
1339
|
children: u.label
|