diefra_ecm_ui 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
*/const Ze=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ke=z("chevron-right",Ze);function Me(e){const s=u.useRef(null);return u.useEffect(()=>{function n(i){s.current&&!s.current.contains(i.target)&&e()}return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}},[e]),s}const J="dd/MM/yyyy",et=e=>{if(!e)return null;const s=T.parse(e,J,new Date);return T.isValid(s)?s:null},tt=e=>e?T.format(e,J):"",st=({name:e,label:s="",placeholder:n="dd/mm/aaaa",className:i="",forceReadOnly:r=!1,forceHidden:d=!1,valueManual:l,onChangeManual:o,errorManual:g})=>{var k;const[a,j]=u.useState(!1),[y,A]=u.useState(new Date),F=Me(()=>j(!1)),C=l!==void 0&&!!o;let R=null;try{R=W.useFormContext()}catch{}const{isView:_}=E.useFluigRuntime(),{isReadOnly:h,isHidden:p}=E.useSection(),m=r||!!h(e),f=d||!!p(e),c=!C&&R?W.useController({name:e,control:R.control}):null,x=C?l:c==null?void 0:c.field.value,v=C?g:(k=c==null?void 0:c.fieldState.error)==null?void 0:k.message,N=u.useMemo(()=>et(x),[x]),w=P=>{if(m)return;const O=tt(P);C?o==null||o(O):c==null||c.field.onChange(O),j(!1)},$=P=>{const O=T.eachDayOfInterval({start:T.startOfWeek(T.startOfMonth(P)),end:T.endOfWeek(T.endOfMonth(P))});return t.jsxs("div",{className:"dfe-calendar-pane",children:[t.jsxs("div",{className:"dfe-calendar-header",children:[t.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),A(T.subMonths(y,1))},className:"dfe-nav-btn",children:t.jsx(Je,{size:16})}),t.jsx("span",{className:"dfe-month-label",children:T.format(P,"MMMM yyyy",{locale:Ie})}),t.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),A(T.addMonths(y,1))},className:"dfe-nav-btn",children:t.jsx(Ke,{size:16})})]}),t.jsx("div",{className:"dfe-calendar-grid-header",children:["D","S","T","Q","Q","S","S"].map((b,D)=>t.jsx("span",{children:b},D))}),t.jsx("div",{className:"dfe-calendar-grid",children:O.map((b,D)=>{const H=!T.isSameMonth(b,P),q=N&&T.isSameDay(b,N);return t.jsx("div",{onClick:()=>!H&&w(b),className:`dfe-calendar-day
|
|
57
57
|
${q?"selected":""}
|
|
58
58
|
${H?"outside":""}
|
|
59
|
-
${T.isToday(b)?"today":""}`,children:T.format(b,"d")},D)})})]})};return f?null:_?t.jsxs("div",{className:`form-group ${i}`,children:[s&&t.jsx("label",{children:s}),t.jsx("span",{className:"form-control readOnly",style:{display:"block",height:"auto"},children:x||"-"})]}):t.jsxs("div",{ref:F,className:`form-group dfe-datepicker-container ${i}`,style:{position:"relative"},children:[s&&t.jsx("label",{children:s}),t.jsxs("div",{className:`form-control dfe-datepicker-trigger ${v?"border-red":""} ${m?"disabled":""}`,onClick:()=>!m&&j(!a),style:{display:"flex",alignItems:"center",cursor:m?"default":"pointer"},children:[t.jsx(Ye,{size:16,className:"dfe-calendar-icon",style:{marginRight:"8px",opacity:.5}}),t.jsx("span",{children:x||n})]}),a&&!m&&t.jsx("div",{className:"dfe-popover-content",children:t.jsx("div",{className:"dfe-calendars-wrapper",children:$(y)})}),v&&t.jsx("p",{className:"text-danger",children:String(v)})]})},nt=u.memo(st);function rt({mapping:e={},defaultLabel:s="Não reconhecido",className:n="",hidden:i=!1,label:r}){const{activityId:d}=E.useFluigRuntime(),l=u.useMemo(()=>!e||d===null||d===void 0?null:e[d],[d,e]);if(!l)return t.jsxs("div",{className:`form-group ${i?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsx("div",{className:`status-badge default ${n}`,children:s})]});const o={"--customColor":l.color};return t.jsxs("div",{className:`form-group ${i?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsxs("div",{className:`status-badge ${n}`,style:o,children:[l.icon&&t.jsx("i",{className:l.icon}),t.jsx("span",{children:l.label})]})]})}const it=u.memo(rt);function at({name:e,control:s,defaultRowValue:n,isView:i,isReadOnly:r,filters:d=[]}){const{field:l}=W.useController({name:e,control:s}),[o,g]=u.useState([]),[a,j]=u.useState([]),y=()=>Date.now()+Math.random(),A=f=>{try{const c=JSON.parse(f);return Array.isArray(c)?c.map(x=>({...x,_uid:x._uid||y()})):[]}catch(c){return console.error(`Erro ao ler dados da tabela "${e}":`,c),[]}};u.useEffect(()=>{if(!(o.length>0&&!i)&&l.value&&typeof l.value=="string"){const f=JSON.stringify(o);if(l.value===f)return;const c=A(l.value);g(c)}},[l.value,i]),u.useEffect(()=>{if(r)return;const f=JSON.stringify(o);l.value!==f&&l.onChange(f)},[o,l,r]);const F=u.useCallback(()=>{const f={_uid:y(),...n};g(c=>[...c,f])},[n]),C=u.useCallback(()=>{g(f=>f.filter(c=>!a.includes(c._uid))),j([])},[a]),R=u.useCallback((f,c,x)=>{g(v=>v.map(N=>N._uid===f?{...N,[c]:x}:N))},[]),_=u.useCallback(f=>{j(c=>c.includes(f)?c.filter(x=>x!==f):[...c,f])},[]),h=u.useCallback(f=>{j(f?o.map(c=>c._uid):[])},[o]),p=o.length>0&&a.length===o.length,m=u.useMemo(()=>!d||d.length===0?o:o.filter(f=>d.every(c=>{if("custom"in c)return c.custom(f);const x=f[c.field];switch(c.operator){case"===":return x===c.value;case"!==":return x!==c.value;case">":return x>c.value;case"<":return x<c.value;case">=":return x>=c.value;case"<=":return x<=c.value;default:return!0}})),[o,d]);return{field:l,tableRows:o,visibleRows:m,selectedRowIds:a,isAllSelected:p,handle:{addRow:F,removeRows:C,updateCellValue:R,toggleSelection:_,toggleSelectAll:h}}}const ot=({name:e,title:s="Tabela Dinâmica",columns:n,defaultRowValue:i={},forceReadOnly:r=!1,layout:d="fluid",actions:l=!0,filters:o=[]})=>{const{control:g}=W.useFormContext(),{isView:a,isReadOnly:j}=E.useFluigRuntime(),{isReadOnly:y}=E.useSection(),A=r||a||j||y&&y(e),{field:F,visibleRows:C,selectedRowIds:R,isAllSelected:_,handle:h}=at({name:e,control:g,defaultRowValue:i,isView:a,isReadOnly:!!A,filters:o}),p=d==="fixed";return t.jsxs("div",{className:`table-wrapper ${p?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...F}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:s}),!A&&l&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${R.length>0?"btn-danger":"btn-primary"}`,disabled:R.length===0,onClick:h.removeRows,children:["Remover (",R.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:h.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:[!A&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:_,onChange:m=>h.toggleSelectAll(m.target.checked)})}),n.map(m=>t.jsx("th",{style:m.width?{minWidth:p?m.width:"100%"}:{width:"max-content"},children:m.label},String(m.key)))]})}),t.jsxs("tbody",{children:[C.map((m,f)=>t.jsxs("tr",{children:[!A&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:R.includes(m._uid),onChange:()=>h.toggleSelection(m._uid)})}),n.map(c=>t.jsx("td",{children:c.render?c.render.length<=1?c.render({row:m,index:f,updateRow:(x,v)=>h.updateCellValue(m._uid,String(x),v),isLocked:!!A,isView:!!a}):c.render(m,f,(x,v)=>h.updateCellValue(m._uid,x,v),!!A,!!a):m[c.key]},`${m._uid}-${String(c.key)}`))]},m._uid)),C.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:A?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},ct=(e,s)=>{const[n,i]=u.useState(null);let r=null;try{r=W.useFormContext().watch}catch{}const d=s!==void 0?s:r?r(e):void 0,l=u.useCallback(()=>{try{const g=window.top.__REACT_ATTACHMENT_BRIDGE__;if(g){const a=g.getAttachment(e,d);i(a||(d?{name:d,documentId:0}:null))}else i(d?{name:d,documentId:0}:null)}catch{i(d?{name:d,documentId:0}:null)}},[e,d,s]);return u.useEffect(()=>{l();const o=setInterval(l,2e3);return()=>clearInterval(o)},[l]),{attachment:n,sync:l}},dt=({name:e,label:s,help:n,valueManual:i,onChangeManual:r,forceReadOnly:d=!1,forceHidden:l=!1})=>{const o
|
|
59
|
+
${T.isToday(b)?"today":""}`,children:T.format(b,"d")},D)})})]})};return f?null:_?t.jsxs("div",{className:`form-group ${i}`,children:[s&&t.jsx("label",{children:s}),t.jsx("span",{className:"form-control readOnly",style:{display:"block",height:"auto"},children:x||"-"})]}):t.jsxs("div",{ref:F,className:`form-group dfe-datepicker-container ${i}`,style:{position:"relative"},children:[s&&t.jsx("label",{children:s}),t.jsxs("div",{className:`form-control dfe-datepicker-trigger ${v?"border-red":""} ${m?"disabled":""}`,onClick:()=>!m&&j(!a),style:{display:"flex",alignItems:"center",cursor:m?"default":"pointer"},children:[t.jsx(Ye,{size:16,className:"dfe-calendar-icon",style:{marginRight:"8px",opacity:.5}}),t.jsx("span",{children:x||n})]}),a&&!m&&t.jsx("div",{className:"dfe-popover-content",children:t.jsx("div",{className:"dfe-calendars-wrapper",children:$(y)})}),v&&t.jsx("p",{className:"text-danger",children:String(v)})]})},nt=u.memo(st);function rt({mapping:e={},defaultLabel:s="Não reconhecido",className:n="",hidden:i=!1,label:r}){const{activityId:d}=E.useFluigRuntime(),l=u.useMemo(()=>!e||d===null||d===void 0?null:e[d],[d,e]);if(!l)return t.jsxs("div",{className:`form-group ${i?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsx("div",{className:`status-badge default ${n}`,children:s})]});const o={"--customColor":l.color};return t.jsxs("div",{className:`form-group ${i?"hidden":""}`,children:[r&&t.jsx("label",{children:r}),t.jsxs("div",{className:`status-badge ${n}`,style:o,children:[l.icon&&t.jsx("i",{className:l.icon}),t.jsx("span",{children:l.label})]})]})}const it=u.memo(rt);function at({name:e,control:s,defaultRowValue:n,isView:i,isReadOnly:r,filters:d=[]}){const{field:l}=W.useController({name:e,control:s}),[o,g]=u.useState([]),[a,j]=u.useState([]),y=()=>Date.now()+Math.random(),A=f=>{try{const c=JSON.parse(f);return Array.isArray(c)?c.map(x=>({...x,_uid:x._uid||y()})):[]}catch(c){return console.error(`Erro ao ler dados da tabela "${e}":`,c),[]}};u.useEffect(()=>{if(!(o.length>0&&!i)&&l.value&&typeof l.value=="string"){const f=JSON.stringify(o);if(l.value===f)return;const c=A(l.value);g(c)}},[l.value,i]),u.useEffect(()=>{if(r)return;const f=JSON.stringify(o);l.value!==f&&l.onChange(f)},[o,l,r]);const F=u.useCallback(()=>{const f={_uid:y(),...n};g(c=>[...c,f])},[n]),C=u.useCallback(()=>{g(f=>f.filter(c=>!a.includes(c._uid))),j([])},[a]),R=u.useCallback((f,c,x)=>{g(v=>v.map(N=>N._uid===f?{...N,[c]:x}:N))},[]),_=u.useCallback(f=>{j(c=>c.includes(f)?c.filter(x=>x!==f):[...c,f])},[]),h=u.useCallback(f=>{j(f?o.map(c=>c._uid):[])},[o]),p=o.length>0&&a.length===o.length,m=u.useMemo(()=>!d||d.length===0?o:o.filter(f=>d.every(c=>{if("custom"in c)return c.custom(f);const x=f[c.field];switch(c.operator){case"===":return x===c.value;case"!==":return x!==c.value;case">":return x>c.value;case"<":return x<c.value;case">=":return x>=c.value;case"<=":return x<=c.value;default:return!0}})),[o,d]);return{field:l,tableRows:o,visibleRows:m,selectedRowIds:a,isAllSelected:p,handle:{addRow:F,removeRows:C,updateCellValue:R,toggleSelection:_,toggleSelectAll:h}}}const ot=({name:e,title:s="Tabela Dinâmica",columns:n,defaultRowValue:i={},forceReadOnly:r=!1,layout:d="fluid",actions:l=!0,filters:o=[]})=>{const{control:g}=W.useFormContext(),{isView:a,isReadOnly:j}=E.useFluigRuntime(),{isReadOnly:y}=E.useSection(),A=r||a||j||y&&y(e),{field:F,visibleRows:C,selectedRowIds:R,isAllSelected:_,handle:h}=at({name:e,control:g,defaultRowValue:i,isView:a,isReadOnly:!!A,filters:o}),p=d==="fixed";return t.jsxs("div",{className:`table-wrapper ${p?"table-fixed":"table-fluid"}`,children:[t.jsx("input",{type:"hidden",...F}),t.jsxs("div",{className:"header-handle",children:[t.jsx("h3",{children:s}),!A&&l&&t.jsxs("div",{className:"handle-actions",children:[t.jsxs("button",{type:"button",className:`btn ${R.length>0?"btn-danger":"btn-primary"}`,disabled:R.length===0,onClick:h.removeRows,children:["Remover (",R.length,")"]}),t.jsx("button",{type:"button",className:"btn-add",onClick:h.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:[!A&&t.jsx("th",{style:{width:"50px"},children:t.jsx("input",{type:"checkbox",checked:_,onChange:m=>h.toggleSelectAll(m.target.checked)})}),n.map(m=>t.jsx("th",{style:m.width?{minWidth:p?m.width:"100%"}:{width:"max-content"},children:m.label},String(m.key)))]})}),t.jsxs("tbody",{children:[C.map((m,f)=>t.jsxs("tr",{children:[!A&&t.jsx("td",{children:t.jsx("input",{type:"checkbox",checked:R.includes(m._uid),onChange:()=>h.toggleSelection(m._uid)})}),n.map(c=>t.jsx("td",{children:c.render?c.render.length<=1?c.render({row:m,index:f,updateRow:(x,v)=>h.updateCellValue(m._uid,String(x),v),isLocked:!!A,isView:!!a}):c.render(m,f,(x,v)=>h.updateCellValue(m._uid,x,v),!!A,!!a):m[c.key]},`${m._uid}-${String(c.key)}`))]},m._uid)),C.length===0&&t.jsx("tr",{className:"empty-row",children:t.jsx("td",{colSpan:100,className:"text-center",children:A?"Nenhum registro encontrado.":"Nenhum registro."})})]})]})})]})},ct=(e,s)=>{const[n,i]=u.useState(null);let r=null;try{r=W.useFormContext().watch}catch{}const d=s!==void 0?s:r?r(e):void 0,l=u.useCallback(()=>{try{const g=window.top.__REACT_ATTACHMENT_BRIDGE__;if(g){const a=g.getAttachment(e,d);i(a||(d?{name:d,documentId:0}:null))}else i(d?{name:d,documentId:0}:null)}catch{i(d?{name:d,documentId:0}:null)}},[e,d,s]);return u.useEffect(()=>{l();const o=setInterval(l,2e3);return()=>clearInterval(o)},[l]),{attachment:n,sync:l}},dt=({name:e,label:s,help:n,valueManual:i,onChangeManual:r,forceReadOnly:d=!1,forceHidden:l=!1})=>{const o=!!r,{isReadOnly:g,isHidden:a}=E.useSection(),{isView:j}=E.useFluigRuntime(),y=d||j||!!g(e),A=l||!!a(e),[F,C]=u.useState(!1);let R=null;try{R=W.useFormContext().control}catch{}const _=R&&!o?W.useController({name:e,control:R}).field:{value:i,onChange:w=>r==null?void 0:r(w)},{attachment:h,sync:p}=ct(e,i),m=()=>{var w;try{const $=window.top;return{bridge:$.__REACT_ATTACHMENT_BRIDGE__,toast:(w=$.FLUIGC)==null?void 0:w.toast}}catch{return{bridge:null,toast:null}}},f=u.useCallback(()=>{if(y)return;const w=document.createElement("input");w.type="file",w.onchange=$=>{const k=$.target.files[0];if(!k)return;const{bridge:P,toast:O}=m();C(!0),P?P.upload(k,e,b=>{o?r==null||r(b.name):_.onChange(b.name),setTimeout(()=>{C(!1),p()},1e3),O&&O({title:"Sucesso",message:"Arquivo enviado",type:"success"})}):(o?r==null||r(k.name):_.onChange(k.name),C(!1))},w.click()},[e,_,p,r,y,o]),c=w=>{if(w.stopPropagation(),y)return;const $=(h==null?void 0:h.name)||i||_.value;if(!$)return;const{bridge:k,toast:P}=m();k?k.removeByFileName($)?(o?r==null||r(""):_.onChange(""),p()):P&&P({title:"Erro",message:"Erro ao remover anexo",type:"danger"}):(o?r==null||r(""):_.onChange(""),p())},x=!!h&&!F,v=(h==null?void 0:h.name)||i||_.value,N=["fluig-attachment__box",x?"fluig-attachment__box--has-file":"",F?"fluig-attachment__box--uploading":"",y&&!x?"readOnly":"",y&&x?"fluig-attachment__box--readonly-view":""].join(" ");return A?null:t.jsxs("div",{className:"form-group fluig-attachment",children:[s&&t.jsx("label",{className:"fluig-attachment__label",children:s}),t.jsxs("div",{className:N,onClick:()=>{if(x){const w=m(),$=(h==null?void 0:h.physicalFileName)||(h==null?void 0:h.description)||(h==null?void 0:h.name)||v;w.bridge&&$&&w.bridge.view($)}else f()},children:[t.jsxs("span",{className:"fluig-attachment__content",children:[t.jsx("i",{className:`flaticon icon-sm ${F?"flaticon-loading":x?"flaticon-file":"flaticon-paperclip"} fluig-attachment__icon`}),t.jsx("span",{className:"fluig-attachment__filename",children:F?" Enviando...":x?v:y?"Nenhum arquivo":n||"Anexar"})]}),x&&!y&&t.jsx("button",{type:"button",className:"fluig-attachment__btn-remove btn btn-link text-danger",onClick:c,children:t.jsx("i",{className:"flaticon flaticon-trash icon-sm"})})]}),!o&&R&&t.jsx("input",{type:"hidden",name:e,value:_.value||""})]})},lt=u.memo(dt);function ut({title:e,isOpen:s,onOpen:n,onClose:i,content:r,footer:d,width:l}){const o=u.useCallback(g=>{g.key==="Escape"&&i()},[i]);return u.useEffect(()=>(s&&(document.addEventListener("keydown",o),n==null||n(),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",o),document.body.style.overflow="auto"}),[s,o,n]),s?t.jsx("div",{className:"modal-overlay",onClick:i,"aria-modal":"true",role:"dialog",children:t.jsxs("div",{style:{maxWidth:l},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:i,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}),d&&t.jsx("div",{className:"modal-footer",children:d})]})}):null}exports.Attachment=lt;exports.Checkbox=re;exports.DatePicker=nt;exports.Input=te;exports.Modal=ut;exports.RadioBtn=ae;exports.Select=ne;exports.SimpleTable=ot;exports.StatusBadge=it;exports.TextArea=ce;
|
package/dist/index.js
CHANGED
|
@@ -1348,7 +1348,7 @@ const Lt = ({
|
|
|
1348
1348
|
forceReadOnly: c = !1,
|
|
1349
1349
|
forceHidden: l = !1
|
|
1350
1350
|
}) => {
|
|
1351
|
-
const o =
|
|
1351
|
+
const o = !!s, { isReadOnly: v, isHidden: a } = I(), { isView: w } = L(), p = c || w || !!v(e), V = l || !!a(e), [D, _] = F(!1);
|
|
1352
1352
|
let P = null;
|
|
1353
1353
|
try {
|
|
1354
1354
|
P = H().control;
|