@fluig-kit/ecm 1.0.22 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),l=require("react"),F=require("react-hook-form"),N=require("@hookform/resolvers"),W=require("zod"),A=require("@fluig-kit/core");var U=function(e,o){for(var t={};e.length;){var n=e[0],i=n.code,s=n.message,a=n.path.join(".");if(!t[a])if("unionErrors"in n){var u=n.unionErrors[0].errors[0];t[a]={message:u.message,type:u.code}}else t[a]={message:s,type:i};if("unionErrors"in n&&n.unionErrors.forEach(function(h){return h.errors.forEach(function(d){return e.push(d)})}),o){var c=t[a].types,r=c&&c[n.code];t[a]=F.appendErrors(a,o,t,i,r?[].concat(r,n.message):n.message)}e.shift()}return t},z=function(e,o,t){return t===void 0&&(t={}),function(n,i,s){try{return Promise.resolve(function(a,u){try{var c=Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](n,o)).then(function(r){return s.shouldUseNativeValidation&&N.validateFieldsNatively({},s),{errors:{},values:t.raw?n:r}})}catch(r){return u(r)}return c&&c.then?c.then(void 0,u):c}(0,function(a){if(function(u){return Array.isArray(u==null?void 0:u.errors)}(a))return{values:{},errors:N.toNestErrors(U(a.errors,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw a}))}catch(a){return Promise.reject(a)}}};const j=l.createContext(null);function B({children:e,baseSchema:o}){const[t,n]=l.useState([]),i=l.useMemo(()=>o??W.z.object({}),[o]),s=l.useCallback((r,h)=>{n(d=>d.some(w=>w.id===r)?d:[...d,{id:r,schema:h}])},[]),a=l.useCallback(r=>{n(h=>h.some(d=>d.id===r)?h.filter(d=>d.id!==r):h)},[]),u=l.useMemo(()=>t.length?t.map(r=>r.schema).reduce((r,h)=>r.and(h),i):i,[t,i]),c=l.useMemo(()=>({registerSchema:s,unregisterSchema:a,mergedSchema:u}),[s,a,u]);return p.jsx(j.Provider,{value:c,children:e})}function R(){const e=l.useContext(j);if(!e)throw new Error("useSchemaRegistry deve ser usado dentro de <SchemaRegistryProvider>");return e}function O(e){return typeof e=="number"?e:isNaN(Number(e))?null:Number(e)}function L(e,o,t){if(!e)return!0;const n=Array.isArray(o)?o[0]:o,i=e.field??n,s=t==null?void 0:t[i];return e.hasValue!==void 0?e.hasValue?s!=null&&s!=="":s==null||s==="":e.equals!==void 0?s===e.equals:e.notEquals!==void 0?s!==e.notEquals:!0}function G(e,o,t,n,i){const s=new Set(e),a=new Set(o);return t==null||t.forEach(u=>{if(u.from!==void 0){const r=Array.isArray(u.from)?u.from:[u.from];if(n===null||!r.includes(n))return}if(!L(u.when,u.target,i))return;const c=Array.isArray(u.target)?u.target:[u.target];switch(u.type){case"readonly":c.forEach(r=>{a.add(r),s.delete(r)});break;case"active":c.forEach(r=>{s.add(r),a.delete(r)});break;case"hidden":c.forEach(r=>{s.delete(r),a.delete(r)});break}}),{active:Array.from(s),readonly:Array.from(a)}}function $(e,o,t,n){const i=new Set(e.active),s=new Set(e.readonly),a=new Set(e.hidden??[]);return o==null||o.forEach(u=>{if(u.from!==void 0){const r=Array.isArray(u.from)?u.from:[u.from];if(t===null||!r.includes(t))return}if(!L(u.when,u.target,n))return;const c=Array.isArray(u.target)?u.target:[u.target];switch(u.type){case"hidden":c.forEach(r=>{a.add(r),i.delete(r),s.delete(r)});break;case"active":c.forEach(r=>{i.add(r),s.delete(r),a.delete(r)});break;case"readonly":c.forEach(r=>{s.add(r),i.delete(r),a.delete(r)});break}}),{active:Array.from(i),readonly:Array.from(s),hidden:Array.from(a)}}function H(e,o){if(!(e!=null&&e.length))return o;const t=new Map(o.map(i=>[i.name,i])),n=[];return e.forEach(i=>{t.has(i)&&(n.push(t.get(i)),t.delete(i))}),t.forEach(i=>n.push(i)),n}function K(e){var n,i;const o=new Set,t=(s=[])=>{s.forEach(a=>{var u;a.target&&(Array.isArray(a.target)?a.target:[a.target]).forEach(r=>o.add(r)),(u=a.when)!=null&&u.field&&o.add(a.when.field)})};return t((n=e==null?void 0:e.fields)==null?void 0:n.rules),t((i=e==null?void 0:e.sections)==null?void 0:i.rules),Array.from(o)}function J({activityId:e,previousActivityId:o,control:t,workflowStructure:n,sectionsRegistry:i}){const{registerSchema:s,unregisterSchema:a}=R(),u=O(e),c=O(o),r=u!==null?n[u]:null,h=l.useMemo(()=>K(r),[u,r]),d=F.useWatch({control:t,name:h,defaultValue:{}}),w=l.useMemo(()=>{const m={};return h.forEach((f,v)=>{m[f]=Array.isArray(d)?d[v]:d}),m},[d,h]),y=l.useMemo(()=>{if(!r)return{sections:[],fields:{active:[],readonly:[],hidden:[]}};const m=G(r.sections.active,r.sections.readonly,r.sections.rules,c,w);let f=[...m.readonly.map(g=>({name:g,mode:"readonly"})),...m.active.map(g=>({name:g,mode:"active"}))];f=H(r.sections.order,f);const v=$({active:r.fields.active,readonly:r.fields.readonly,hidden:r.fields.hidden},r.fields.rules,c,w);return{sections:f,fields:v}},[r,c,w,i]);return l.useEffect(()=>{const m=y.sections.filter(f=>f.mode==="active").map(f=>f.name);m.forEach(f=>{var g;const v=(g=i==null?void 0:i[f])==null?void 0:g.schema;v&&s(f,v)}),Object.keys(i??{}).filter(f=>!m.includes(f)).forEach(a)},[y.sections,i,s,a]),y}function Q(){if(typeof document>"u")return{};const e={};return document.querySelectorAll("input[type='radio'][name]").forEach(o=>{const t=o,n=t.getAttribute("name");n&&t.checked&&(e[n]=t.value)}),document.querySelectorAll("input[name], textarea[name], select[name]").forEach(o=>{const t=o,n=t.getAttribute("name");if(!n||e[n]!==void 0)return;const i=t.getAttribute("value")??t.value??t.textContent??"";e[n]=String(i).trim()}),document.querySelectorAll("span[name]").forEach(o=>{var i;const t=o,n=t.getAttribute("name");if(n){const s=((i=t.textContent)==null?void 0:i.trim())??"";s!==""&&(e[n]=s)}}),e}const q=l.createContext(null);function X({children:e,devConfig:o}){const[t,n]=l.useState(null),i=l.useRef(o);l.useEffect(()=>{i.current=o},[o]);const s=l.useMemo(()=>Q()??{},[]);return l.useEffect(()=>{let a=!0;return(async()=>{var m,f;const c=typeof window<"u"&&window.location.hostname==="localhost";let r=null;try{const v=await((m=A.parentProxy.top.ECM)==null?void 0:m.workflowView);if(v){const g=await v.sequence;r=g!==void 0?Number(g):null}}catch(v){c||console.warn("[FluigRuntime] Erro Proxy:",v)}const d=(s.FORM_MODE||"")==="VIEW",w={isView:d,isReadOnly:d,activityId:r,previousActivityId:s.LASTACTIVITYID?Number(s.LASTACTIVITYID):null,prefilledValues:s,showDebugSubmit:!1,showDebugLogs:!1,isDev:!1};let y={...w};if((f=i.current)!=null&&f.enabled){const v=i.current,g=v.isView??w.isView;y={...w,...v,isView:g,isReadOnly:g,isDev:!0,activityId:v.activityId!==void 0?v.activityId:r}}a&&n(y)})(),()=>{a=!1}},[s]),t?p.jsx(q.Provider,{value:t,children:e}):null}function x(){const e=l.useContext(q);if(!e)throw new Error("useFluigRuntime deve ser usado dentro de <FluigRuntimeProvider>");return e}function Z(e){const{activityId:o,previousActivityId:t}=x();l.useEffect(()=>{o!=null&&e.setValue("CURRENTACTIVITYID",o),t!=null&&e.setValue("LASTACTIVITYID",t)},[o,t,e]),l.useEffect(()=>{if(typeof window>"u"||!window.top)return;const n=window.top.document,i=a=>{e.setValue("FORM_MODE",a);const u=document.querySelector('input[name="FORM_MODE"]');u&&(u.value=a),console.log(`[FORM_MODE] ${a}`)},s=a=>{const u=a.target;if(u.closest("#send-process-button")||u.closest("#workflow-actions-send")){i("VIEW");return}u.closest("[data-take-decision], [data-take-task], .movement-button")&&i("EDIT")};return n.addEventListener("mousedown",s,!0),()=>n.removeEventListener("mousedown",s,!0)},[e]),l.useEffect(()=>{if(typeof window>"u")return;let n=!1;window.beforeSendValidate=()=>n?!0:(e.handleSubmit(i=>(window.top.__FLUIG_REACT_FORM_DATA__=i,n=!0,!0),i=>{var s,a;console.error("[Validation Errors]",i),n=!1,(a=(s=window.top)==null?void 0:s.FLUIGC)!=null&&a.toast&&window.top.FLUIGC.toast({title:"Atenção",message:"Verifique os campos obrigatórios.",type:"danger"})})(),!1)},[e])}const ee=({workflowStructure:e,sectionsRegistry:o,className:t})=>{const{control:n,handleSubmit:i,register:s,setValue:a,watch:u}=F.useFormContext(),c=x(),r=u("FORM_MODE"),h=l.useRef(!1);l.useEffect(()=>{h.current||(c.activityId!=null&&a("CURRENTACTIVITYID",c.activityId),c.previousActivityId!=null&&a("LASTACTIVITYID",c.previousActivityId),h.current=!0)},[c,a]);const{sections:d,fields:w}=J({control:n,activityId:c.activityId,previousActivityId:c.previousActivityId,workflowStructure:e,sectionsRegistry:o}),y=m=>{console.log("✅ [FluigWorkflowForm] Dados válidos:",m)};return p.jsxs("form",{id:"fluig-react-form",className:t,onSubmit:i(y),noValidate:!0,children:[p.jsxs("div",{className:"hidden",style:{display:"none"},children:[p.jsx("input",{type:"hidden",...s("CURRENTACTIVITYID")}),p.jsx("input",{type:"hidden",...s("LASTACTIVITYID")}),p.jsx("input",{type:"hidden",...s("FORM_MODE")})]}),d.length===0&&c.activityId!==null&&p.jsxs("p",{children:["Não foi possível encontrar a atividade: ",String(c.activityId)]}),d.map(({name:m,mode:f})=>{if(f==="hidden")return null;const v=o[m];if(!v)return null;const g=v.Component,D=r==="VIEW";return p.jsx(g,{id:m,fields:w,readOnly:f==="readonly"||D},m)}),c.isDev&&c.showDebugSubmit&&p.jsx("div",{style:{width:"100%",padding:"16px",paddingTop:"0"},children:p.jsx("button",{type:"submit",className:"btn btn-primary btn-lg btn-block",children:"Submit (Debug)"})})]})},te=e=>{const{mergedSchema:o}=R(),t=x(),n=F.useForm({resolver:o?z(o):void 0,defaultValues:t.prefilledValues,mode:"onBlur"});return Z(n),l.useEffect(()=>{t.showDebugLogs&&(A.DebugLogger.header("Form Initialized"),A.DebugLogger.table("Prefilled Values (DOM Capture)",t.prefilledValues),A.DebugLogger.info("RHF Current Values",n.getValues()),A.DebugLogger.end())},[t.showDebugLogs,t.prefilledValues,n]),p.jsx(F.FormProvider,{...n,children:p.jsx(ee,{...e})})};async function ne(e){if(!e)return console.warn("[setFluigNextActivity] Nenhuma atividade informada."),!1;const{wfView:o,wkfView:t}=await re();if(!o||!t)return!1;oe(o);const n=Number(e),i=ie(o,n);return i?(se(o,t,i,n),console.log(`[setFluigNextActivity] Próxima atividade definida: ${n}`),!0):(console.warn(`[setFluigNextActivity] Estado ${n} não encontrado nas próximas atividades disponíveis.`),console.log("Estados disponíveis:",o.availableStatesCOPY||o.availableStates),!1)}async function re(){const e=await A.parentProxy.top.ECM.workflowView,o=await A.parentProxy.top.ECM_WKFView;return!e||!o?(console.warn("[setFluigNextActivity] Contexto Fluig inválido ou não carregado."),{}):{wfView:e,wkfView:o}}function oe(e){e.availableStatesCOPY||(e.availableStatesCOPY=e.availableStates)}function ie(e,o){const t=e.availableStatesCOPY||e.availableStates;return t==null?void 0:t.find(n=>n.sequence===o)}function se(e,o,t,n){e.availableUsers.users=[],e.availableStates=[t],o.selectActivity=()=>n}const _=l.createContext(null);function ae(){const e=l.useContext(_);if(!e)throw new Error("useSection deve ser usado dentro de um componente <Section>");return e}function ue({id:e,className:o,schema:t,children:n,form:i,prefilledValues:s,readOnly:a,fields:u={},hidden:c=!1}){const{isView:r,activityId:h}=x(),d=h,w=F.useFormContext(),y=i||w;if(!y)return console.error(`[FluigWorkflowReact] Section "${e}" não encontrou o 'form'.`),null;if(c)return null;const m=l.useCallback(b=>{var E,I,C;return(E=u.hidden)!=null&&E.includes(b)?"hidden":(I=u.readonly)!=null&&I.includes(b)?"readonly":(C=u.active)!=null&&C.includes(b)?"active":a?"readonly":"active"},[u,a]),f=l.useCallback(b=>m(b)==="hidden",[m]),v=l.useCallback(b=>m(b)==="readonly",[m]),g=l.useCallback(b=>{if(!b)return;const E=y.getValues("CURRENTACTIVITYID");y.setValue("LASTACTIVITYID",E),y.setValue("CURRENTACTIVITYID",d),ne(Number(b))},[y,d]);l.useEffect(()=>{if(!r||!s||!t||!y)return;const b=y.getValues(),E=t.shape;E&&Object.entries(E).forEach(([I,C])=>{var M,P;let S=C;for(;(M=S==null?void 0:S._def)!=null&&M.schema;)S=S._def.schema;const V=(P=S==null?void 0:S._def)==null?void 0:P.fluig;if((V==null?void 0:V.type)!=="options"||!Array.isArray(V.values)||b[I]!==void 0)return;const T={};V.values.forEach(k=>{T[k]=s[k]==="on"}),y.setValue(I,T,{shouldDirty:!1,shouldValidate:!1})})},[r,s,t,y]);const D=l.useMemo(()=>({id:e,form:y,isHidden:f,isReadOnly:v,isView:r,next:g,wf_activity_id:d}),[e,y,f,v,r,g,d]);return p.jsx(_.Provider,{value:D,children:p.jsx("section",{id:e,className:[e,o].filter(Boolean).join(" "),children:n})})}const Y=l.createContext(null);function ce({children:e,config:o}){const t=l.useMemo(()=>A.createFluigClient(o),[o]);return p.jsx(Y.Provider,{value:t,children:e})}function le(){const e=l.useContext(Y);if(!e)throw new Error("useFluigApi deve ser usado dentro de um <FluigApiProvider>");return e}Object.defineProperty(exports,"DebugLogger",{enumerable:!0,get:()=>A.DebugLogger});Object.defineProperty(exports,"createFluigClient",{enumerable:!0,get:()=>A.createFluigClient});Object.defineProperty(exports,"parentProxy",{enumerable:!0,get:()=>A.parentProxy});exports.FluigApiProvider=ce;exports.FluigRuntimeProvider=X;exports.FluigWorkflowForm=te;exports.SchemaRegistryProvider=B;exports.Section=ue;exports.useFluigApi=le;exports.useFluigRuntime=x;exports.useSchemaRegistry=R;exports.useSection=ae;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),l=require("react"),I=require("react-hook-form"),N=require("@hookform/resolvers"),W=require("zod"),h=require("@fluig-kit/core");var B=function(e,n){for(var t={};e.length;){var o=e[0],i=o.code,s=o.message,u=o.path.join(".");if(!t[u])if("unionErrors"in o){var a=o.unionErrors[0].errors[0];t[u]={message:a.message,type:a.code}}else t[u]={message:s,type:i};if("unionErrors"in o&&o.unionErrors.forEach(function(y){return y.errors.forEach(function(m){return e.push(m)})}),n){var c=t[u].types,r=c&&c[o.code];t[u]=I.appendErrors(u,n,t,i,r?[].concat(r,o.message):o.message)}e.shift()}return t},z=function(e,n,t){return t===void 0&&(t={}),function(o,i,s){try{return Promise.resolve(function(u,a){try{var c=Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](o,n)).then(function(r){return s.shouldUseNativeValidation&&N.validateFieldsNatively({},s),{errors:{},values:t.raw?o:r}})}catch(r){return a(r)}return c&&c.then?c.then(void 0,a):c}(0,function(u){if(function(a){return Array.isArray(a==null?void 0:a.errors)}(u))return{values:{},errors:N.toNestErrors(B(u.errors,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw u}))}catch(u){return Promise.reject(u)}}};const j=l.createContext(null);function G({children:e,baseSchema:n}){const[t,o]=l.useState([]),i=l.useMemo(()=>n??W.z.object({}),[n]),s=l.useCallback((r,y)=>{o(m=>m.some(w=>w.id===r)?m:[...m,{id:r,schema:y}])},[]),u=l.useCallback(r=>{o(y=>y.some(m=>m.id===r)?y.filter(m=>m.id!==r):y)},[]),a=l.useMemo(()=>t.length?t.map(r=>r.schema).reduce((r,y)=>r.and(y),i):i,[t,i]),c=l.useMemo(()=>({registerSchema:s,unregisterSchema:u,mergedSchema:a}),[s,u,a]);return g.jsx(j.Provider,{value:c,children:e})}function D(){const e=l.useContext(j);if(!e)throw new Error("useSchemaRegistry deve ser usado dentro de <SchemaRegistryProvider>");return e}function L(e){return typeof e=="number"?e:isNaN(Number(e))?null:Number(e)}function M(e,n,t){if(!e)return!0;const o=Array.isArray(n)?n[0]:n,i=e.field??o,s=t==null?void 0:t[i];return e.hasValue!==void 0?e.hasValue?s!=null&&s!=="":s==null||s==="":e.equals!==void 0?s===e.equals:e.notEquals!==void 0?s!==e.notEquals:!0}function H(e,n,t,o,i){const s=new Set(e),u=new Set(n);return t==null||t.forEach(a=>{if(a.from!==void 0){const r=Array.isArray(a.from)?a.from:[a.from];if(o===null||!r.includes(o))return}if(!M(a.when,a.target,i))return;const c=Array.isArray(a.target)?a.target:[a.target];switch(a.type){case"readonly":c.forEach(r=>{u.add(r),s.delete(r)});break;case"active":c.forEach(r=>{s.add(r),u.delete(r)});break;case"hidden":c.forEach(r=>{s.delete(r),u.delete(r)});break}}),{active:Array.from(s),readonly:Array.from(u)}}function $(e,n,t,o){const i=new Set(e.active),s=new Set(e.readonly),u=new Set(e.hidden??[]);return n==null||n.forEach(a=>{if(a.from!==void 0){const r=Array.isArray(a.from)?a.from:[a.from];if(t===null||!r.includes(t))return}if(!M(a.when,a.target,o))return;const c=Array.isArray(a.target)?a.target:[a.target];switch(a.type){case"hidden":c.forEach(r=>{u.add(r),i.delete(r),s.delete(r)});break;case"active":c.forEach(r=>{i.add(r),s.delete(r),u.delete(r)});break;case"readonly":c.forEach(r=>{s.add(r),i.delete(r),u.delete(r)});break}}),{active:Array.from(i),readonly:Array.from(s),hidden:Array.from(u)}}function K(e,n){if(!(e!=null&&e.length))return n;const t=new Map(n.map(i=>[i.name,i])),o=[];return e.forEach(i=>{t.has(i)&&(o.push(t.get(i)),t.delete(i))}),t.forEach(i=>o.push(i)),o}function J(e){var o,i;const n=new Set,t=(s=[])=>{s.forEach(u=>{var a;u.target&&(Array.isArray(u.target)?u.target:[u.target]).forEach(r=>n.add(r)),(a=u.when)!=null&&a.field&&n.add(u.when.field)})};return t((o=e==null?void 0:e.fields)==null?void 0:o.rules),t((i=e==null?void 0:e.sections)==null?void 0:i.rules),Array.from(n)}function Q({activityId:e,previousActivityId:n,control:t,workflowStructure:o,sectionsRegistry:i}){const{registerSchema:s,unregisterSchema:u}=D(),a=L(e),c=L(n),r=a!==null?o[a]:null,y=l.useMemo(()=>J(r),[a,r]),m=I.useWatch({control:t,name:y,defaultValue:{}}),w=l.useMemo(()=>{const f={};return y.forEach((v,b)=>{f[v]=Array.isArray(m)?m[b]:m}),f},[m,y]),d=l.useMemo(()=>{if(!r)return{sections:[],fields:{active:[],readonly:[],hidden:[]}};const f=H(r.sections.active,r.sections.readonly,r.sections.rules,c,w);let v=[...f.readonly.map(A=>({name:A,mode:"readonly"})),...f.active.map(A=>({name:A,mode:"active"}))];v=K(r.sections.order,v);const b=$({active:r.fields.active,readonly:r.fields.readonly,hidden:r.fields.hidden},r.fields.rules,c,w);return{sections:v,fields:b}},[r,c,w,i]);return l.useEffect(()=>{const f=d.sections.filter(v=>v.mode==="active").map(v=>v.name);f.forEach(v=>{var A;const b=(A=i==null?void 0:i[v])==null?void 0:A.schema;b&&s(v,b)}),Object.keys(i??{}).filter(v=>!f.includes(v)).forEach(u)},[d.sections,i,s,u]),d}function X(){if(typeof document>"u")return{};const e={};return document.querySelectorAll("input[type='radio'][name]").forEach(n=>{const t=n,o=t.getAttribute("name");o&&t.checked&&(e[o]=t.value)}),document.querySelectorAll("input[name], textarea[name], select[name]").forEach(n=>{const t=n,o=t.getAttribute("name");if(!o||e[o]!==void 0)return;const i=t.getAttribute("value")??t.value??t.textContent??"";e[o]=String(i).trim()}),document.querySelectorAll("span[name]").forEach(n=>{var i;const t=n,o=t.getAttribute("name");if(o){const s=((i=t.textContent)==null?void 0:i.trim())??"";s!==""&&(e[o]=s)}}),e}const q=()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("edit"),Z=()=>{var e,n;return typeof window>"u"?null:(n=(e=window.top)==null?void 0:e.ECM)!=null&&n.workflowView?"process":"document"},ee=()=>{var t,o;if(Z()!=="process")return q()===null;const n=(o=(t=window.top)==null?void 0:t.ECM)==null?void 0:o.workflowView;return n?n.newRequest===!0||n.isNewRequest===!0:!1},te=()=>q()==="true",_=l.createContext(null);function ne({children:e,devConfig:n}){const[t,o]=l.useState(null),i=l.useMemo(()=>X()??{},[]);return l.useEffect(()=>{let s=!0;return(async()=>{const a=typeof window<"u"&&window.location.hostname==="localhost",c=typeof window<"u"&&window.self!==window.top;let r=null;try{const f=await h.parentProxy.top.ECM.workflowView.sequence;f!=null&&(r=Number(f),n!=null&&n.showDebugLogs&&console.log("[FluigRuntime] Atividade:",r))}catch(f){console.warn("[FluigRuntime] Falha ao detectar atividade:",f)}const y=!a&&c&&!(ee()||te()),m=i.LASTACTIVITYID?Number(i.LASTACTIVITYID):null,w={isView:y,isReadOnly:y,activityId:r,previousActivityId:m,prefilledValues:i,showDebugSubmit:!1,showDebugLogs:!1,isDev:!1};let d=w;if(n!=null&&n.enabled){const f=n.isView??w.isView;d={...w,...n,isView:f,isReadOnly:f,isDev:!0,activityId:n.activityId!==void 0?n.activityId:r}}typeof window<"u"&&(window.__FLUIG_DEBUG_ENABLED__=d.showDebugLogs),d.showDebugLogs&&s&&(h.DebugLogger.header("Runtime Initialized"),h.DebugLogger.table("State",{"Detected Activity":r,"Final Activity":d.activityId,"Dev Mode":d.isDev}),h.DebugLogger.end()),s&&o(d)})(),()=>{s=!1}},[n,i]),t?g.jsx(_.Provider,{value:t,children:e}):null}function V(){const e=l.useContext(_);if(!e)throw new Error("useFluigRuntime deve ser usado dentro de <FluigRuntimeProvider>");return e}function re(e){const{activityId:n,previousActivityId:t}=V();l.useEffect(()=>{n!=null&&e.setValue("CURRENTACTIVITYID",n),t!=null&&e.setValue("LASTACTIVITYID",t)},[n,t,e]),l.useEffect(()=>{var i,s;if(typeof window>"u")return;const o=((i=window.top)==null?void 0:i.document.getElementById("send-process-button"))||((s=window.parent)==null?void 0:s.document.getElementById("workflow-actions-send"))||document.getElementById("send-process-button");if(!o){console.warn("[FluigWorkflowReact] Botão de envio do Fluig não encontrado. A validação automática pode falhar.");return}return window.beforeSendValidate=()=>(e.handleSubmit(()=>{window.top.__FLUIG_REACT_FORM_DATA__=e.getValues(),window.beforeSendValidate=()=>!0;try{o.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0}))}catch{o.click()}},u=>{var a,c,r;console.error("[Validation Errors]",u),(c=(a=window.top)==null?void 0:a.FLUIGC)!=null&&c.toast?(r=window.top)==null||r.FLUIGC.toast({title:"Atenção",message:"Verifique os campos obrigatórios destacados em vermelho.",type:"danger"}):alert("Verifique os campos obrigatórios.")})(),!1),()=>{}},[e])}const oe=({workflowStructure:e,sectionsRegistry:n,className:t})=>{const{control:o,handleSubmit:i,register:s,setValue:u,getValues:a}=I.useFormContext(),c=V(),r=l.useRef(!1);l.useEffect(()=>{r.current||(c.activityId!=null&&u("CURRENTACTIVITYID",c.activityId),c.previousActivityId!=null&&u("LASTACTIVITYID",c.previousActivityId),r.current=!0)},[c,u]);const{sections:y,fields:m}=Q({control:o,activityId:c.activityId,previousActivityId:c.previousActivityId,workflowStructure:e,sectionsRegistry:n}),w=d=>{console.log("✅ [FluigWorkflowForm] Dados válidos:",d)};return g.jsxs("form",{id:"fluig-react-form",className:t,onSubmit:i(w),noValidate:!0,children:[g.jsxs("div",{className:"hidden",style:{display:"none"},children:[g.jsx("input",{type:"hidden",...s("CURRENTACTIVITYID")}),g.jsx("input",{type:"hidden",...s("LASTACTIVITYID")})]}),y.length===0&&c.activityId!==null&&g.jsxs("p",{children:["Não foi possível encontrar a atividade: ",String(c.activityId)]}),y.map(({name:d,mode:f})=>{if(f==="hidden")return null;const v=n[d];if(!v)return null;const b=v.Component;return g.jsx(b,{id:d,fields:m,readOnly:f==="readonly"},d)}),c.isDev&&c.showDebugSubmit&&g.jsx("div",{style:{width:"100%",padding:"16px",paddingTop:"0"},children:g.jsx("button",{type:"submit",className:"btn btn-primary btn-lg btn-block",children:"Submit (Debug)"})})]})},ie=e=>{const{mergedSchema:n}=D(),t=V(),o=I.useForm({resolver:n?z(n):void 0,defaultValues:t.prefilledValues,mode:"onBlur"});return re(o),l.useEffect(()=>{t.showDebugLogs&&(h.DebugLogger.header("Form Initialized"),h.DebugLogger.table("Prefilled Values (DOM Capture)",t.prefilledValues),h.DebugLogger.info("RHF Current Values",o.getValues()),h.DebugLogger.end())},[t.showDebugLogs,t.prefilledValues,o]),g.jsx(I.FormProvider,{...o,children:g.jsx(oe,{...e})})};async function se(e){if(!e)return console.warn("[setFluigNextActivity] Nenhuma atividade informada."),!1;const{wfView:n,wkfView:t}=await ae();if(!n||!t)return!1;ue(n);const o=Number(e),i=ce(n,o);return i?(le(n,t,i,o),console.log(`[setFluigNextActivity] Próxima atividade definida: ${o}`),!0):(console.warn(`[setFluigNextActivity] Estado ${o} não encontrado nas próximas atividades disponíveis.`),console.log("Estados disponíveis:",n.availableStatesCOPY||n.availableStates),!1)}async function ae(){const e=await h.parentProxy.top.ECM.workflowView,n=await h.parentProxy.top.ECM_WKFView;return!e||!n?(console.warn("[setFluigNextActivity] Contexto Fluig inválido ou não carregado."),{}):{wfView:e,wkfView:n}}function ue(e){e.availableStatesCOPY||(e.availableStatesCOPY=e.availableStates)}function ce(e,n){const t=e.availableStatesCOPY||e.availableStates;return t==null?void 0:t.find(o=>o.sequence===n)}function le(e,n,t,o){e.availableUsers.users=[],e.availableStates=[t],n.selectActivity=()=>o}const O=l.createContext(null);function de(){const e=l.useContext(O);if(!e)throw new Error("useSection deve ser usado dentro de um componente <Section>");return e}function fe({id:e,className:n,schema:t,children:o,form:i,prefilledValues:s,readOnly:u,fields:a={},hidden:c=!1}){const{isView:r,activityId:y}=V(),m=y,w=I.useFormContext(),d=i||w;if(!d)return console.error(`[FluigWorkflowReact] Section "${e}" não encontrou o 'form'.`),null;if(c)return null;const f=l.useCallback(p=>{var E,x,C;return(E=a.hidden)!=null&&E.includes(p)?"hidden":(x=a.readonly)!=null&&x.includes(p)?"readonly":(C=a.active)!=null&&C.includes(p)?"active":u?"readonly":"active"},[a,u]),v=l.useCallback(p=>f(p)==="hidden",[f]),b=l.useCallback(p=>f(p)==="readonly",[f]),A=l.useCallback(p=>{if(!p)return;const E=d.getValues("CURRENTACTIVITYID");d.setValue("LASTACTIVITYID",E),d.setValue("CURRENTACTIVITYID",m),se(Number(p))},[d,m]);l.useEffect(()=>{if(!r||!s||!t||!d)return;const p=d.getValues(),E=t.shape;E&&Object.entries(E).forEach(([x,C])=>{var R,T;let S=C;for(;(R=S==null?void 0:S._def)!=null&&R.schema;)S=S._def.schema;const F=(T=S==null?void 0:S._def)==null?void 0:T.fluig;if((F==null?void 0:F.type)!=="options"||!Array.isArray(F.values)||p[x]!==void 0)return;const P={};F.values.forEach(k=>{P[k]=s[k]==="on"}),d.setValue(x,P,{shouldDirty:!1,shouldValidate:!1})})},[r,s,t,d]);const U=l.useMemo(()=>({id:e,form:d,isHidden:v,isReadOnly:b,isView:r,next:A,wf_activity_id:m}),[e,d,v,b,r,A,m]);return g.jsx(O.Provider,{value:U,children:g.jsx("section",{id:e,className:[e,n].filter(Boolean).join(" "),children:o})})}const Y=l.createContext(null);function me({children:e,config:n}){const t=l.useMemo(()=>h.createFluigClient(n),[n]);return g.jsx(Y.Provider,{value:t,children:e})}function ye(){const e=l.useContext(Y);if(!e)throw new Error("useFluigApi deve ser usado dentro de um <FluigApiProvider>");return e}Object.defineProperty(exports,"DebugLogger",{enumerable:!0,get:()=>h.DebugLogger});Object.defineProperty(exports,"createFluigClient",{enumerable:!0,get:()=>h.createFluigClient});Object.defineProperty(exports,"parentProxy",{enumerable:!0,get:()=>h.parentProxy});exports.FluigApiProvider=me;exports.FluigRuntimeProvider=ne;exports.FluigWorkflowForm=ie;exports.SchemaRegistryProvider=G;exports.Section=fe;exports.useFluigApi=ye;exports.useFluigRuntime=V;exports.useSchemaRegistry=D;exports.useSection=de;
package/dist/index.d.ts CHANGED
@@ -67,6 +67,9 @@ export declare interface FluigRuntimeState {
67
67
  isDev: boolean;
68
68
  }
69
69
 
70
+ /**
71
+ * COMPONENTE PAI: Estável.
72
+ */
70
73
  export declare const FluigWorkflowForm: default_2.FC<FluigWorkflowFormProps>;
71
74
 
72
75
  declare interface FluigWorkflowFormProps {
package/dist/index.js CHANGED
@@ -1,206 +1,206 @@
1
- import { jsx as g, jsxs as N } from "react/jsx-runtime";
2
- import { createContext as x, useState as q, useMemo as A, useCallback as I, useContext as D, useEffect as b, useRef as W } from "react";
3
- import { appendErrors as K, useWatch as J, useForm as Q, FormProvider as X, useFormContext as U } from "react-hook-form";
4
- import { validateFieldsNatively as Z, toNestErrors as ee } from "@hookform/resolvers";
5
- import { z as te } from "zod";
6
- import { parentProxy as M, DebugLogger as T, createFluigClient as ne } from "@fluig-kit/core";
7
- import { DebugLogger as Me, createFluigClient as ke, parentProxy as Oe } from "@fluig-kit/core";
8
- var re = function(e, o) {
1
+ import { jsx as w, jsxs as N } from "react/jsx-runtime";
2
+ import { createContext as C, useState as Y, useMemo as A, useCallback as V, useContext as D, useEffect as E, useRef as K } from "react";
3
+ import { appendErrors as J, useWatch as Q, useForm as X, FormProvider as Z, useFormContext as U } from "react-hook-form";
4
+ import { validateFieldsNatively as ee, toNestErrors as te } from "@hookform/resolvers";
5
+ import { z as ne } from "zod";
6
+ import { parentProxy as P, DebugLogger as I, createFluigClient as re } from "@fluig-kit/core";
7
+ import { DebugLogger as Me, createFluigClient as qe, parentProxy as Ye } from "@fluig-kit/core";
8
+ var oe = function(e, n) {
9
9
  for (var t = {}; e.length; ) {
10
- var n = e[0], i = n.code, a = n.message, s = n.path.join(".");
11
- if (!t[s]) if ("unionErrors" in n) {
12
- var c = n.unionErrors[0].errors[0];
13
- t[s] = { message: c.message, type: c.code };
14
- } else t[s] = { message: a, type: i };
15
- if ("unionErrors" in n && n.unionErrors.forEach(function(v) {
16
- return v.errors.forEach(function(l) {
17
- return e.push(l);
10
+ var o = e[0], i = o.code, a = o.message, c = o.path.join(".");
11
+ if (!t[c]) if ("unionErrors" in o) {
12
+ var s = o.unionErrors[0].errors[0];
13
+ t[c] = { message: s.message, type: s.code };
14
+ } else t[c] = { message: a, type: i };
15
+ if ("unionErrors" in o && o.unionErrors.forEach(function(m) {
16
+ return m.errors.forEach(function(f) {
17
+ return e.push(f);
18
18
  });
19
- }), o) {
20
- var u = t[s].types, r = u && u[n.code];
21
- t[s] = K(s, o, t, i, r ? [].concat(r, n.message) : n.message);
19
+ }), n) {
20
+ var u = t[c].types, r = u && u[o.code];
21
+ t[c] = J(c, n, t, i, r ? [].concat(r, o.message) : o.message);
22
22
  }
23
23
  e.shift();
24
24
  }
25
25
  return t;
26
- }, oe = function(e, o, t) {
27
- return t === void 0 && (t = {}), function(n, i, a) {
26
+ }, ie = function(e, n, t) {
27
+ return t === void 0 && (t = {}), function(o, i, a) {
28
28
  try {
29
- return Promise.resolve(function(s, c) {
29
+ return Promise.resolve(function(c, s) {
30
30
  try {
31
- var u = Promise.resolve(e[t.mode === "sync" ? "parse" : "parseAsync"](n, o)).then(function(r) {
32
- return a.shouldUseNativeValidation && Z({}, a), { errors: {}, values: t.raw ? n : r };
31
+ var u = Promise.resolve(e[t.mode === "sync" ? "parse" : "parseAsync"](o, n)).then(function(r) {
32
+ return a.shouldUseNativeValidation && ee({}, a), { errors: {}, values: t.raw ? o : r };
33
33
  });
34
34
  } catch (r) {
35
- return c(r);
35
+ return s(r);
36
36
  }
37
- return u && u.then ? u.then(void 0, c) : u;
38
- }(0, function(s) {
39
- if (function(c) {
40
- return Array.isArray(c == null ? void 0 : c.errors);
41
- }(s)) return { values: {}, errors: ee(re(s.errors, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a) };
42
- throw s;
37
+ return u && u.then ? u.then(void 0, s) : u;
38
+ }(0, function(c) {
39
+ if (function(s) {
40
+ return Array.isArray(s == null ? void 0 : s.errors);
41
+ }(c)) return { values: {}, errors: te(oe(c.errors, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a) };
42
+ throw c;
43
43
  }));
44
- } catch (s) {
45
- return Promise.reject(s);
44
+ } catch (c) {
45
+ return Promise.reject(c);
46
46
  }
47
47
  };
48
48
  };
49
- const j = x(
49
+ const O = C(
50
50
  null
51
51
  );
52
- function Ie({
52
+ function Te({
53
53
  children: e,
54
- baseSchema: o
54
+ baseSchema: n
55
55
  }) {
56
- const [t, n] = q([]), i = A(() => o ?? te.object({}), [o]), a = I((r, v) => {
57
- n((l) => l.some((p) => p.id === r) ? l : [...l, { id: r, schema: v }]);
58
- }, []), s = I((r) => {
59
- n((v) => v.some((l) => l.id === r) ? v.filter((l) => l.id !== r) : v);
60
- }, []), c = A(() => t.length ? t.map((r) => r.schema).reduce((r, v) => r.and(v), i) : i, [t, i]), u = A(
56
+ const [t, o] = Y([]), i = A(() => n ?? ne.object({}), [n]), a = V((r, m) => {
57
+ o((f) => f.some((v) => v.id === r) ? f : [...f, { id: r, schema: m }]);
58
+ }, []), c = V((r) => {
59
+ o((m) => m.some((f) => f.id === r) ? m.filter((f) => f.id !== r) : m);
60
+ }, []), s = A(() => t.length ? t.map((r) => r.schema).reduce((r, m) => r.and(m), i) : i, [t, i]), u = A(
61
61
  () => ({
62
62
  registerSchema: a,
63
- unregisterSchema: s,
64
- mergedSchema: c
63
+ unregisterSchema: c,
64
+ mergedSchema: s
65
65
  }),
66
- [a, s, c]
66
+ [a, c, s]
67
67
  );
68
- return /* @__PURE__ */ g(j.Provider, { value: u, children: e });
68
+ return /* @__PURE__ */ w(O.Provider, { value: u, children: e });
69
69
  }
70
- function z() {
71
- const e = D(j);
70
+ function W() {
71
+ const e = D(O);
72
72
  if (!e)
73
73
  throw new Error(
74
74
  "useSchemaRegistry deve ser usado dentro de <SchemaRegistryProvider>"
75
75
  );
76
76
  return e;
77
77
  }
78
- function Y(e) {
78
+ function q(e) {
79
79
  return typeof e == "number" ? e : isNaN(Number(e)) ? null : Number(e);
80
80
  }
81
- function B(e, o, t) {
81
+ function B(e, n, t) {
82
82
  if (!e) return !0;
83
- const n = Array.isArray(o) ? o[0] : o, i = e.field ?? n, a = t == null ? void 0 : t[i];
83
+ const o = Array.isArray(n) ? n[0] : n, i = e.field ?? o, a = t == null ? void 0 : t[i];
84
84
  return e.hasValue !== void 0 ? e.hasValue ? a != null && a !== "" : a == null || a === "" : e.equals !== void 0 ? a === e.equals : e.notEquals !== void 0 ? a !== e.notEquals : !0;
85
85
  }
86
- function ie(e, o, t, n, i) {
87
- const a = new Set(e), s = new Set(o);
88
- return t == null || t.forEach((c) => {
89
- if (c.from !== void 0) {
90
- const r = Array.isArray(c.from) ? c.from : [c.from];
91
- if (n === null || !r.includes(n)) return;
86
+ function ae(e, n, t, o, i) {
87
+ const a = new Set(e), c = new Set(n);
88
+ return t == null || t.forEach((s) => {
89
+ if (s.from !== void 0) {
90
+ const r = Array.isArray(s.from) ? s.from : [s.from];
91
+ if (o === null || !r.includes(o)) return;
92
92
  }
93
- if (!B(c.when, c.target, i)) return;
94
- const u = Array.isArray(c.target) ? c.target : [c.target];
95
- switch (c.type) {
93
+ if (!B(s.when, s.target, i)) return;
94
+ const u = Array.isArray(s.target) ? s.target : [s.target];
95
+ switch (s.type) {
96
96
  case "readonly":
97
97
  u.forEach((r) => {
98
- s.add(r), a.delete(r);
98
+ c.add(r), a.delete(r);
99
99
  });
100
100
  break;
101
101
  case "active":
102
102
  u.forEach((r) => {
103
- a.add(r), s.delete(r);
103
+ a.add(r), c.delete(r);
104
104
  });
105
105
  break;
106
106
  case "hidden":
107
107
  u.forEach((r) => {
108
- a.delete(r), s.delete(r);
108
+ a.delete(r), c.delete(r);
109
109
  });
110
110
  break;
111
111
  }
112
- }), { active: Array.from(a), readonly: Array.from(s) };
112
+ }), { active: Array.from(a), readonly: Array.from(c) };
113
113
  }
114
- function ae(e, o, t, n) {
115
- const i = new Set(e.active), a = new Set(e.readonly), s = new Set(e.hidden ?? []);
116
- return o == null || o.forEach((c) => {
117
- if (c.from !== void 0) {
118
- const r = Array.isArray(c.from) ? c.from : [c.from];
114
+ function se(e, n, t, o) {
115
+ const i = new Set(e.active), a = new Set(e.readonly), c = new Set(e.hidden ?? []);
116
+ return n == null || n.forEach((s) => {
117
+ if (s.from !== void 0) {
118
+ const r = Array.isArray(s.from) ? s.from : [s.from];
119
119
  if (t === null || !r.includes(t)) return;
120
120
  }
121
- if (!B(c.when, c.target, n)) return;
122
- const u = Array.isArray(c.target) ? c.target : [c.target];
123
- switch (c.type) {
121
+ if (!B(s.when, s.target, o)) return;
122
+ const u = Array.isArray(s.target) ? s.target : [s.target];
123
+ switch (s.type) {
124
124
  case "hidden":
125
125
  u.forEach((r) => {
126
- s.add(r), i.delete(r), a.delete(r);
126
+ c.add(r), i.delete(r), a.delete(r);
127
127
  });
128
128
  break;
129
129
  case "active":
130
130
  u.forEach((r) => {
131
- i.add(r), a.delete(r), s.delete(r);
131
+ i.add(r), a.delete(r), c.delete(r);
132
132
  });
133
133
  break;
134
134
  case "readonly":
135
135
  u.forEach((r) => {
136
- a.add(r), i.delete(r), s.delete(r);
136
+ a.add(r), i.delete(r), c.delete(r);
137
137
  });
138
138
  break;
139
139
  }
140
140
  }), {
141
141
  active: Array.from(i),
142
142
  readonly: Array.from(a),
143
- hidden: Array.from(s)
143
+ hidden: Array.from(c)
144
144
  };
145
145
  }
146
- function se(e, o) {
147
- if (!(e != null && e.length)) return o;
148
- const t = new Map(o.map((i) => [i.name, i])), n = [];
146
+ function ce(e, n) {
147
+ if (!(e != null && e.length)) return n;
148
+ const t = new Map(n.map((i) => [i.name, i])), o = [];
149
149
  return e.forEach((i) => {
150
- t.has(i) && (n.push(t.get(i)), t.delete(i));
151
- }), t.forEach((i) => n.push(i)), n;
150
+ t.has(i) && (o.push(t.get(i)), t.delete(i));
151
+ }), t.forEach((i) => o.push(i)), o;
152
152
  }
153
- function ce(e) {
154
- var n, i;
155
- const o = /* @__PURE__ */ new Set(), t = (a = []) => {
156
- a.forEach((s) => {
157
- var c;
158
- s.target && (Array.isArray(s.target) ? s.target : [s.target]).forEach((r) => o.add(r)), (c = s.when) != null && c.field && o.add(s.when.field);
153
+ function ue(e) {
154
+ var o, i;
155
+ const n = /* @__PURE__ */ new Set(), t = (a = []) => {
156
+ a.forEach((c) => {
157
+ var s;
158
+ c.target && (Array.isArray(c.target) ? c.target : [c.target]).forEach((r) => n.add(r)), (s = c.when) != null && s.field && n.add(c.when.field);
159
159
  });
160
160
  };
161
- return t((n = e == null ? void 0 : e.fields) == null ? void 0 : n.rules), t((i = e == null ? void 0 : e.sections) == null ? void 0 : i.rules), Array.from(o);
161
+ return t((o = e == null ? void 0 : e.fields) == null ? void 0 : o.rules), t((i = e == null ? void 0 : e.sections) == null ? void 0 : i.rules), Array.from(n);
162
162
  }
163
- function ue({
163
+ function le({
164
164
  activityId: e,
165
- previousActivityId: o,
165
+ previousActivityId: n,
166
166
  control: t,
167
- workflowStructure: n,
167
+ workflowStructure: o,
168
168
  sectionsRegistry: i
169
169
  }) {
170
- const { registerSchema: a, unregisterSchema: s } = z(), c = Y(e), u = Y(o), r = c !== null ? n[c] : null, v = A(() => ce(r), [c, r]), l = J({
170
+ const { registerSchema: a, unregisterSchema: c } = W(), s = q(e), u = q(n), r = s !== null ? o[s] : null, m = A(() => ue(r), [s, r]), f = Q({
171
171
  control: t,
172
- name: v,
172
+ name: m,
173
173
  defaultValue: {}
174
- }), p = A(() => {
175
- const f = {};
176
- return v.forEach((d, m) => {
177
- f[d] = Array.isArray(l) ? l[m] : l;
178
- }), f;
179
- }, [l, v]), y = A(() => {
174
+ }), v = A(() => {
175
+ const d = {};
176
+ return m.forEach((y, p) => {
177
+ d[y] = Array.isArray(f) ? f[p] : f;
178
+ }), d;
179
+ }, [f, m]), l = A(() => {
180
180
  if (!r)
181
181
  return {
182
182
  sections: [],
183
183
  fields: { active: [], readonly: [], hidden: [] }
184
184
  };
185
- const f = ie(
185
+ const d = ae(
186
186
  r.sections.active,
187
187
  r.sections.readonly,
188
188
  r.sections.rules,
189
189
  u,
190
- p
190
+ v
191
191
  );
192
- let d = [
193
- ...f.readonly.map((h) => ({
194
- name: h,
192
+ let y = [
193
+ ...d.readonly.map((g) => ({
194
+ name: g,
195
195
  mode: "readonly"
196
196
  })),
197
- ...f.active.map((h) => ({
198
- name: h,
197
+ ...d.active.map((g) => ({
198
+ name: g,
199
199
  mode: "active"
200
200
  }))
201
201
  ];
202
- d = se(r.sections.order, d);
203
- const m = ae(
202
+ y = ce(r.sections.order, y);
203
+ const p = se(
204
204
  {
205
205
  active: r.fields.active,
206
206
  readonly: r.fields.readonly,
@@ -208,91 +208,99 @@ function ue({
208
208
  },
209
209
  r.fields.rules,
210
210
  u,
211
- p
211
+ v
212
212
  );
213
- return { sections: d, fields: m };
214
- }, [r, u, p, i]);
215
- return b(() => {
216
- const f = y.sections.filter((d) => d.mode === "active").map((d) => d.name);
217
- f.forEach((d) => {
218
- var h;
219
- const m = (h = i == null ? void 0 : i[d]) == null ? void 0 : h.schema;
220
- m && a(d, m);
221
- }), Object.keys(i ?? {}).filter((d) => !f.includes(d)).forEach(s);
222
- }, [y.sections, i, a, s]), y;
213
+ return { sections: y, fields: p };
214
+ }, [r, u, v, i]);
215
+ return E(() => {
216
+ const d = l.sections.filter((y) => y.mode === "active").map((y) => y.name);
217
+ d.forEach((y) => {
218
+ var g;
219
+ const p = (g = i == null ? void 0 : i[y]) == null ? void 0 : g.schema;
220
+ p && a(y, p);
221
+ }), Object.keys(i ?? {}).filter((y) => !d.includes(y)).forEach(c);
222
+ }, [l.sections, i, a, c]), l;
223
223
  }
224
- function le() {
224
+ function de() {
225
225
  if (typeof document > "u") return {};
226
226
  const e = {};
227
- return document.querySelectorAll("input[type='radio'][name]").forEach((o) => {
228
- const t = o, n = t.getAttribute("name");
229
- n && t.checked && (e[n] = t.value);
230
- }), document.querySelectorAll("input[name], textarea[name], select[name]").forEach((o) => {
231
- const t = o, n = t.getAttribute("name");
232
- if (!n || e[n] !== void 0) return;
227
+ return document.querySelectorAll("input[type='radio'][name]").forEach((n) => {
228
+ const t = n, o = t.getAttribute("name");
229
+ o && t.checked && (e[o] = t.value);
230
+ }), document.querySelectorAll("input[name], textarea[name], select[name]").forEach((n) => {
231
+ const t = n, o = t.getAttribute("name");
232
+ if (!o || e[o] !== void 0) return;
233
233
  const i = t.getAttribute("value") ?? t.value ?? t.textContent ?? "";
234
- e[n] = String(i).trim();
235
- }), document.querySelectorAll("span[name]").forEach((o) => {
234
+ e[o] = String(i).trim();
235
+ }), document.querySelectorAll("span[name]").forEach((n) => {
236
236
  var i;
237
- const t = o, n = t.getAttribute("name");
238
- if (n) {
237
+ const t = n, o = t.getAttribute("name");
238
+ if (o) {
239
239
  const a = ((i = t.textContent) == null ? void 0 : i.trim()) ?? "";
240
- a !== "" && (e[n] = a);
240
+ a !== "" && (e[o] = a);
241
241
  }
242
242
  }), e;
243
243
  }
244
- const G = x(null);
245
- function Ve({
244
+ const j = () => typeof window > "u" ? null : new URLSearchParams(window.location.search).get("edit"), fe = () => {
245
+ var e, n;
246
+ return typeof window > "u" ? null : (n = (e = window.top) == null ? void 0 : e.ECM) != null && n.workflowView ? "process" : "document";
247
+ }, me = () => {
248
+ var t, o;
249
+ if (fe() !== "process")
250
+ return j() === null;
251
+ const n = (o = (t = window.top) == null ? void 0 : t.ECM) == null ? void 0 : o.workflowView;
252
+ return n ? n.newRequest === !0 || n.isNewRequest === !0 : !1;
253
+ }, ye = () => j() === "true", G = C(null);
254
+ function Ce({
246
255
  children: e,
247
- devConfig: o
256
+ devConfig: n
248
257
  }) {
249
- const [t, n] = q(null), i = W(o);
250
- b(() => {
251
- i.current = o;
252
- }, [o]);
253
- const a = A(() => le() ?? {}, []);
254
- return b(() => {
255
- let s = !0;
258
+ const [t, o] = Y(null), i = A(() => de() ?? {}, []);
259
+ return E(() => {
260
+ let a = !0;
256
261
  return (async () => {
257
- var f, d;
258
- const u = typeof window < "u" && window.location.hostname === "localhost";
262
+ const s = typeof window < "u" && window.location.hostname === "localhost", u = typeof window < "u" && window.self !== window.top;
259
263
  let r = null;
260
264
  try {
261
- const m = await ((f = M.top.ECM) == null ? void 0 : f.workflowView);
262
- if (m) {
263
- const h = await m.sequence;
264
- r = h !== void 0 ? Number(h) : null;
265
- }
266
- } catch (m) {
267
- u || console.warn("[FluigRuntime] Erro Proxy:", m);
265
+ const d = await P.top.ECM.workflowView.sequence;
266
+ d != null && (r = Number(d), n != null && n.showDebugLogs && console.log("[FluigRuntime] Atividade:", r));
267
+ } catch (d) {
268
+ console.warn("[FluigRuntime] Falha ao detectar atividade:", d);
268
269
  }
269
- const l = (a.FORM_MODE || "") === "VIEW", p = {
270
- isView: l,
271
- isReadOnly: l,
270
+ const m = !s && u && !(me() || ye()), f = i.LASTACTIVITYID ? Number(i.LASTACTIVITYID) : null, v = {
271
+ isView: m,
272
+ isReadOnly: m,
272
273
  activityId: r,
273
- previousActivityId: a.LASTACTIVITYID ? Number(a.LASTACTIVITYID) : null,
274
- prefilledValues: a,
274
+ // Usa o valor real detectado
275
+ previousActivityId: f,
276
+ prefilledValues: i,
275
277
  showDebugSubmit: !1,
276
278
  showDebugLogs: !1,
277
279
  isDev: !1
278
280
  };
279
- let y = { ...p };
280
- if ((d = i.current) != null && d.enabled) {
281
- const m = i.current, h = m.isView ?? p.isView;
282
- y = {
283
- ...p,
284
- ...m,
285
- isView: h,
286
- isReadOnly: h,
281
+ let l = v;
282
+ if (n != null && n.enabled) {
283
+ const d = n.isView ?? v.isView;
284
+ l = {
285
+ ...v,
286
+ ...n,
287
+ isView: d,
288
+ isReadOnly: d,
287
289
  isDev: !0,
288
- activityId: m.activityId !== void 0 ? m.activityId : r
290
+ // Se devConfig tiver activityId definido explicitamente, usa ele.
291
+ // Se não, mantém o detectado (permite usar devConfig só para logs, por exemplo)
292
+ activityId: n.activityId !== void 0 ? n.activityId : r
289
293
  };
290
294
  }
291
- s && n(y);
295
+ typeof window < "u" && (window.__FLUIG_DEBUG_ENABLED__ = l.showDebugLogs), l.showDebugLogs && a && (I.header("Runtime Initialized"), I.table("State", {
296
+ "Detected Activity": r,
297
+ "Final Activity": l.activityId,
298
+ "Dev Mode": l.isDev
299
+ }), I.end()), a && o(l);
292
300
  })(), () => {
293
- s = !1;
301
+ a = !1;
294
302
  };
295
- }, [a]), t ? /* @__PURE__ */ g(G.Provider, { value: t, children: e }) : null;
303
+ }, [n, i]), t ? /* @__PURE__ */ w(G.Provider, { value: t, children: e }) : null;
296
304
  }
297
305
  function R() {
298
306
  const e = D(G);
@@ -302,221 +310,222 @@ function R() {
302
310
  );
303
311
  return e;
304
312
  }
305
- function de(e) {
306
- const { activityId: o, previousActivityId: t } = R();
307
- b(() => {
308
- o != null && e.setValue("CURRENTACTIVITYID", o), t != null && e.setValue("LASTACTIVITYID", t);
309
- }, [o, t, e]), b(() => {
310
- if (typeof window > "u" || !window.top) return;
311
- const n = window.top.document, i = (s) => {
312
- e.setValue("FORM_MODE", s);
313
- const c = document.querySelector(
314
- 'input[name="FORM_MODE"]'
315
- );
316
- c && (c.value = s), console.log(`[FORM_MODE] ${s}`);
317
- }, a = (s) => {
318
- const c = s.target;
319
- if (c.closest("#send-process-button") || c.closest("#workflow-actions-send")) {
320
- i("VIEW");
321
- return;
322
- }
323
- c.closest(
324
- "[data-take-decision], [data-take-task], .movement-button"
325
- ) && i("EDIT");
326
- };
327
- return n.addEventListener("mousedown", a, !0), () => n.removeEventListener("mousedown", a, !0);
328
- }, [e]), b(() => {
313
+ function ve(e) {
314
+ const { activityId: n, previousActivityId: t } = R();
315
+ E(() => {
316
+ n != null && e.setValue("CURRENTACTIVITYID", n), t != null && e.setValue("LASTACTIVITYID", t);
317
+ }, [n, t, e]), E(() => {
318
+ var i, a;
329
319
  if (typeof window > "u") return;
330
- let n = !1;
331
- window.beforeSendValidate = () => n ? !0 : (e.handleSubmit(
332
- (i) => (window.top.__FLUIG_REACT_FORM_DATA__ = i, n = !0, !0),
333
- (i) => {
334
- var a, s;
335
- console.error("[Validation Errors]", i), n = !1, (s = (a = window.top) == null ? void 0 : a.FLUIGC) != null && s.toast && window.top.FLUIGC.toast({
320
+ const o = ((i = window.top) == null ? void 0 : i.document.getElementById("send-process-button")) || ((a = window.parent) == null ? void 0 : a.document.getElementById("workflow-actions-send")) || document.getElementById("send-process-button");
321
+ if (!o) {
322
+ console.warn(
323
+ "[FluigWorkflowReact] Botão de envio do Fluig não encontrado. A validação automática pode falhar."
324
+ );
325
+ return;
326
+ }
327
+ return window.beforeSendValidate = () => (e.handleSubmit(
328
+ () => {
329
+ window.top.__FLUIG_REACT_FORM_DATA__ = e.getValues(), window.beforeSendValidate = () => !0;
330
+ try {
331
+ o.dispatchEvent(
332
+ new MouseEvent("click", {
333
+ view: window,
334
+ bubbles: !0,
335
+ cancelable: !0
336
+ })
337
+ );
338
+ } catch {
339
+ o.click();
340
+ }
341
+ },
342
+ (c) => {
343
+ var s, u, r;
344
+ console.error("[Validation Errors]", c), (u = (s = window.top) == null ? void 0 : s.FLUIGC) != null && u.toast ? (r = window.top) == null || r.FLUIGC.toast({
336
345
  title: "Atenção",
337
- message: "Verifique os campos obrigatórios.",
346
+ message: "Verifique os campos obrigatórios destacados em vermelho.",
338
347
  type: "danger"
339
- });
348
+ }) : alert("Verifique os campos obrigatórios.");
340
349
  }
341
- )(), !1);
350
+ )(), !1), () => {
351
+ };
342
352
  }, [e]);
343
353
  }
344
- const fe = ({
354
+ const he = ({
345
355
  workflowStructure: e,
346
- sectionsRegistry: o,
356
+ sectionsRegistry: n,
347
357
  className: t
348
358
  }) => {
349
- const { control: n, handleSubmit: i, register: a, setValue: s, watch: c } = U(), u = R(), r = c("FORM_MODE"), v = W(!1);
350
- b(() => {
351
- v.current || (u.activityId != null && s("CURRENTACTIVITYID", u.activityId), u.previousActivityId != null && s("LASTACTIVITYID", u.previousActivityId), v.current = !0);
352
- }, [u, s]);
353
- const { sections: l, fields: p } = ue({
354
- control: n,
359
+ const { control: o, handleSubmit: i, register: a, setValue: c, getValues: s } = U(), u = R(), r = K(!1);
360
+ E(() => {
361
+ r.current || (u.activityId != null && c("CURRENTACTIVITYID", u.activityId), u.previousActivityId != null && c("LASTACTIVITYID", u.previousActivityId), r.current = !0);
362
+ }, [u, c]);
363
+ const { sections: m, fields: f } = le({
364
+ control: o,
355
365
  activityId: u.activityId,
356
366
  previousActivityId: u.previousActivityId,
357
367
  workflowStructure: e,
358
- sectionsRegistry: o
368
+ sectionsRegistry: n
359
369
  });
360
370
  return /* @__PURE__ */ N(
361
371
  "form",
362
372
  {
363
373
  id: "fluig-react-form",
364
374
  className: t,
365
- onSubmit: i((f) => {
366
- console.log("✅ [FluigWorkflowForm] Dados válidos:", f);
375
+ onSubmit: i((l) => {
376
+ console.log("✅ [FluigWorkflowForm] Dados válidos:", l);
367
377
  }),
368
378
  noValidate: !0,
369
379
  children: [
370
380
  /* @__PURE__ */ N("div", { className: "hidden", style: { display: "none" }, children: [
371
- /* @__PURE__ */ g("input", { type: "hidden", ...a("CURRENTACTIVITYID") }),
372
- /* @__PURE__ */ g("input", { type: "hidden", ...a("LASTACTIVITYID") }),
373
- /* @__PURE__ */ g("input", { type: "hidden", ...a("FORM_MODE") })
381
+ /* @__PURE__ */ w("input", { type: "hidden", ...a("CURRENTACTIVITYID") }),
382
+ /* @__PURE__ */ w("input", { type: "hidden", ...a("LASTACTIVITYID") })
374
383
  ] }),
375
- l.length === 0 && u.activityId !== null && /* @__PURE__ */ N("p", { children: [
384
+ m.length === 0 && u.activityId !== null && /* @__PURE__ */ N("p", { children: [
376
385
  "Não foi possível encontrar a atividade: ",
377
386
  String(u.activityId)
378
387
  ] }),
379
- l.map(({ name: f, mode: d }) => {
388
+ m.map(({ name: l, mode: d }) => {
380
389
  if (d === "hidden") return null;
381
- const m = o[f];
382
- if (!m) return null;
383
- const h = m.Component;
384
- return /* @__PURE__ */ g(
385
- h,
390
+ const y = n[l];
391
+ if (!y) return null;
392
+ const p = y.Component;
393
+ return /* @__PURE__ */ w(
394
+ p,
386
395
  {
387
- id: f,
388
- fields: p,
389
- readOnly: d === "readonly" || r === "VIEW"
396
+ id: l,
397
+ fields: f,
398
+ readOnly: d === "readonly"
390
399
  },
391
- f
400
+ l
392
401
  );
393
402
  }),
394
- u.isDev && u.showDebugSubmit && /* @__PURE__ */ g("div", { style: { width: "100%", padding: "16px", paddingTop: "0" }, children: /* @__PURE__ */ g("button", { type: "submit", className: "btn btn-primary btn-lg btn-block", children: "Submit (Debug)" }) })
403
+ u.isDev && u.showDebugSubmit && /* @__PURE__ */ w("div", { style: { width: "100%", padding: "16px", paddingTop: "0" }, children: /* @__PURE__ */ w("button", { type: "submit", className: "btn btn-primary btn-lg btn-block", children: "Submit (Debug)" }) })
395
404
  ]
396
405
  }
397
406
  );
398
- }, Fe = (e) => {
399
- const { mergedSchema: o } = z(), t = R(), n = Q({
400
- resolver: o ? oe(o) : void 0,
407
+ }, De = (e) => {
408
+ const { mergedSchema: n } = W(), t = R(), o = X({
409
+ resolver: n ? ie(n) : void 0,
401
410
  defaultValues: t.prefilledValues,
402
411
  mode: "onBlur"
403
412
  });
404
- return de(n), b(() => {
405
- t.showDebugLogs && (T.header("Form Initialized"), T.table(
413
+ return ve(o), E(() => {
414
+ t.showDebugLogs && (I.header("Form Initialized"), I.table(
406
415
  "Prefilled Values (DOM Capture)",
407
416
  t.prefilledValues
408
- ), T.info("RHF Current Values", n.getValues()), T.end());
409
- }, [t.showDebugLogs, t.prefilledValues, n]), /* @__PURE__ */ g(X, { ...n, children: /* @__PURE__ */ g(fe, { ...e }) });
417
+ ), I.info("RHF Current Values", o.getValues()), I.end());
418
+ }, [t.showDebugLogs, t.prefilledValues, o]), /* @__PURE__ */ w(Z, { ...o, children: /* @__PURE__ */ w(he, { ...e }) });
410
419
  };
411
- async function me(e) {
420
+ async function we(e) {
412
421
  if (!e)
413
422
  return console.warn("[setFluigNextActivity] Nenhuma atividade informada."), !1;
414
- const { wfView: o, wkfView: t } = await ve();
415
- if (!o || !t) return !1;
416
- ye(o);
417
- const n = Number(e), i = he(o, n);
418
- return i ? (pe(o, t, i, n), console.log(`[setFluigNextActivity] Próxima atividade definida: ${n}`), !0) : (console.warn(`[setFluigNextActivity] Estado ${n} não encontrado nas próximas atividades disponíveis.`), console.log("Estados disponíveis:", o.availableStatesCOPY || o.availableStates), !1);
423
+ const { wfView: n, wkfView: t } = await pe();
424
+ if (!n || !t) return !1;
425
+ ge(n);
426
+ const o = Number(e), i = Ae(n, o);
427
+ return i ? (be(n, t, i, o), console.log(`[setFluigNextActivity] Próxima atividade definida: ${o}`), !0) : (console.warn(`[setFluigNextActivity] Estado ${o} não encontrado nas próximas atividades disponíveis.`), console.log("Estados disponíveis:", n.availableStatesCOPY || n.availableStates), !1);
419
428
  }
420
- async function ve() {
421
- const e = await M.top.ECM.workflowView, o = await M.top.ECM_WKFView;
422
- return !e || !o ? (console.warn("[setFluigNextActivity] Contexto Fluig inválido ou não carregado."), {}) : { wfView: e, wkfView: o };
429
+ async function pe() {
430
+ const e = await P.top.ECM.workflowView, n = await P.top.ECM_WKFView;
431
+ return !e || !n ? (console.warn("[setFluigNextActivity] Contexto Fluig inválido ou não carregado."), {}) : { wfView: e, wkfView: n };
423
432
  }
424
- function ye(e) {
433
+ function ge(e) {
425
434
  e.availableStatesCOPY || (e.availableStatesCOPY = e.availableStates);
426
435
  }
427
- function he(e, o) {
436
+ function Ae(e, n) {
428
437
  const t = e.availableStatesCOPY || e.availableStates;
429
- return t == null ? void 0 : t.find((n) => n.sequence === o);
438
+ return t == null ? void 0 : t.find((o) => o.sequence === n);
430
439
  }
431
- function pe(e, o, t, n) {
432
- e.availableUsers.users = [], e.availableStates = [t], o.selectActivity = () => n;
440
+ function be(e, n, t, o) {
441
+ e.availableUsers.users = [], e.availableStates = [t], n.selectActivity = () => o;
433
442
  }
434
- const $ = x(null);
435
- function Ce() {
436
- const e = D($);
443
+ const z = C(null);
444
+ function Re() {
445
+ const e = D(z);
437
446
  if (!e)
438
447
  throw new Error(
439
448
  "useSection deve ser usado dentro de um componente <Section>"
440
449
  );
441
450
  return e;
442
451
  }
443
- function Te({
452
+ function Ne({
444
453
  id: e,
445
- className: o,
454
+ className: n,
446
455
  schema: t,
447
- children: n,
456
+ children: o,
448
457
  form: i,
449
458
  prefilledValues: a,
450
- readOnly: s,
451
- fields: c = {},
459
+ readOnly: c,
460
+ fields: s = {},
452
461
  hidden: u = !1
453
462
  }) {
454
- const { isView: r, activityId: v } = R(), l = v, p = U(), y = i || p;
455
- if (!y)
463
+ const { isView: r, activityId: m } = R(), f = m, v = U(), l = i || v;
464
+ if (!l)
456
465
  return console.error(
457
466
  `[FluigWorkflowReact] Section "${e}" não encontrou o 'form'.`
458
467
  ), null;
459
468
  if (u) return null;
460
- const f = I(
461
- (w) => {
462
- var E, V, C;
463
- return (E = c.hidden) != null && E.includes(w) ? "hidden" : (V = c.readonly) != null && V.includes(w) ? "readonly" : (C = c.active) != null && C.includes(w) ? "active" : s ? "readonly" : "active";
469
+ const d = V(
470
+ (h) => {
471
+ var S, F, T;
472
+ return (S = s.hidden) != null && S.includes(h) ? "hidden" : (F = s.readonly) != null && F.includes(h) ? "readonly" : (T = s.active) != null && T.includes(h) ? "active" : c ? "readonly" : "active";
464
473
  },
465
- [c, s]
466
- ), d = I(
467
- (w) => f(w) === "hidden",
468
- [f]
469
- ), m = I(
470
- (w) => f(w) === "readonly",
471
- [f]
472
- ), h = I(
473
- (w) => {
474
- if (!w) return;
475
- const E = y.getValues("CURRENTACTIVITYID");
476
- y.setValue("LASTACTIVITYID", E), y.setValue("CURRENTACTIVITYID", l), me(Number(w));
474
+ [s, c]
475
+ ), y = V(
476
+ (h) => d(h) === "hidden",
477
+ [d]
478
+ ), p = V(
479
+ (h) => d(h) === "readonly",
480
+ [d]
481
+ ), g = V(
482
+ (h) => {
483
+ if (!h) return;
484
+ const S = l.getValues("CURRENTACTIVITYID");
485
+ l.setValue("LASTACTIVITYID", S), l.setValue("CURRENTACTIVITYID", f), we(Number(h));
477
486
  },
478
- [y, l]
487
+ [l, f]
479
488
  );
480
- b(() => {
481
- if (!r || !a || !t || !y) return;
482
- const w = y.getValues(), E = t.shape;
483
- E && Object.entries(E).forEach(([V, C]) => {
484
- var P, L;
485
- let S = C;
486
- for (; (P = S == null ? void 0 : S._def) != null && P.schema; )
487
- S = S._def.schema;
488
- const F = (L = S == null ? void 0 : S._def) == null ? void 0 : L.fluig;
489
- if ((F == null ? void 0 : F.type) !== "options" || !Array.isArray(F.values) || w[V] !== void 0) return;
490
- const O = {};
491
- F.values.forEach((_) => {
492
- O[_] = a[_] === "on";
493
- }), y.setValue(V, O, {
489
+ E(() => {
490
+ if (!r || !a || !t || !l) return;
491
+ const h = l.getValues(), S = t.shape;
492
+ S && Object.entries(S).forEach(([F, T]) => {
493
+ var L, _;
494
+ let b = T;
495
+ for (; (L = b == null ? void 0 : b._def) != null && L.schema; )
496
+ b = b._def.schema;
497
+ const x = (_ = b == null ? void 0 : b._def) == null ? void 0 : _.fluig;
498
+ if ((x == null ? void 0 : x.type) !== "options" || !Array.isArray(x.values) || h[F] !== void 0) return;
499
+ const k = {};
500
+ x.values.forEach((M) => {
501
+ k[M] = a[M] === "on";
502
+ }), l.setValue(F, k, {
494
503
  shouldDirty: !1,
495
504
  shouldValidate: !1
496
505
  });
497
506
  });
498
- }, [r, a, t, y]);
499
- const k = A(
507
+ }, [r, a, t, l]);
508
+ const H = A(
500
509
  () => ({
501
510
  id: e,
502
- form: y,
503
- isHidden: d,
504
- isReadOnly: m,
511
+ form: l,
512
+ isHidden: y,
513
+ isReadOnly: p,
505
514
  isView: r,
506
- next: h,
507
- wf_activity_id: l
515
+ next: g,
516
+ wf_activity_id: f
508
517
  }),
509
- [e, y, d, m, r, h, l]
518
+ [e, l, y, p, r, g, f]
510
519
  );
511
- return /* @__PURE__ */ g($.Provider, { value: k, children: /* @__PURE__ */ g("section", { id: e, className: [e, o].filter(Boolean).join(" "), children: n }) });
520
+ return /* @__PURE__ */ w(z.Provider, { value: H, children: /* @__PURE__ */ w("section", { id: e, className: [e, n].filter(Boolean).join(" "), children: o }) });
512
521
  }
513
- const H = x(null);
514
- function xe({ children: e, config: o }) {
515
- const t = A(() => ne(o), [o]);
516
- return /* @__PURE__ */ g(H.Provider, { value: t, children: e });
522
+ const $ = C(null);
523
+ function Pe({ children: e, config: n }) {
524
+ const t = A(() => re(n), [n]);
525
+ return /* @__PURE__ */ w($.Provider, { value: t, children: e });
517
526
  }
518
- function De() {
519
- const e = D(H);
527
+ function ke() {
528
+ const e = D($);
520
529
  if (!e)
521
530
  throw new Error(
522
531
  "useFluigApi deve ser usado dentro de um <FluigApiProvider>"
@@ -525,15 +534,15 @@ function De() {
525
534
  }
526
535
  export {
527
536
  Me as DebugLogger,
528
- xe as FluigApiProvider,
529
- Ve as FluigRuntimeProvider,
530
- Fe as FluigWorkflowForm,
531
- Ie as SchemaRegistryProvider,
532
- Te as Section,
533
- ke as createFluigClient,
534
- Oe as parentProxy,
535
- De as useFluigApi,
537
+ Pe as FluigApiProvider,
538
+ Ce as FluigRuntimeProvider,
539
+ De as FluigWorkflowForm,
540
+ Te as SchemaRegistryProvider,
541
+ Ne as Section,
542
+ qe as createFluigClient,
543
+ Ye as parentProxy,
544
+ ke as useFluigApi,
536
545
  R as useFluigRuntime,
537
- z as useSchemaRegistry,
538
- Ce as useSection
546
+ W as useSchemaRegistry,
547
+ Re as useSection
539
548
  };
package/dist/node.cjs CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("chalk");function f(t){var e;return((e=t._def)==null?void 0:e.schema)??t}function p(t){var l,o,s;let e=(l=t._def)==null?void 0:l.fluig;if(e!=null&&e.values)return e.values;const i=f(t);if(i!==t&&(e=(o=i._def)==null?void 0:o.fluig,e!=null&&e.values))return e.values;const n=i._def,r=(n==null?void 0:n.meta)??(n==null?void 0:n.metadata);return((s=r==null?void 0:r.fluig)==null?void 0:s.values)??null}function m(t){var e;return((e=t==null?void 0:t._def)==null?void 0:e.typeName)!=="ZodObject"?[]:Object.entries(t.shape)}function h(t){const e=new Set;return(Array.isArray(t)?t:Object.values(t).map(n=>n.schema).filter(Boolean)).forEach(n=>{var l,o;let r=n;for(;(l=r._def)!=null&&l.schema;)r=r._def.schema;((o=r._def)==null?void 0:o.typeName)==="ZodObject"&&m(r).forEach(([s,c])=>{e.add(s);const a=p(c);a!=null&&a.length&&a.forEach(u=>e.add(u))})}),Array.from(e)}function g(t){const e=h(t),i=e.map(n=>`<input type="hidden" name="${n}" />`).join(`
2
- `);return console.log(d.blue.bold(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("chalk");function f(t){var e;return((e=t._def)==null?void 0:e.schema)??t}function p(t){var o,i,s;let e=(o=t._def)==null?void 0:o.fluig;if(e!=null&&e.values)return e.values;const l=f(t);if(l!==t&&(e=(i=l._def)==null?void 0:i.fluig,e!=null&&e.values))return e.values;const r=l._def,n=(r==null?void 0:r.meta)??(r==null?void 0:r.metadata);return((s=n==null?void 0:n.fluig)==null?void 0:s.values)??null}function m(t){var e;return((e=t==null?void 0:t._def)==null?void 0:e.typeName)!=="ZodObject"?[]:Object.entries(t.shape)}function g(t){const e=new Set;return(Array.isArray(t)?t:Object.values(t).map(r=>r.schema).filter(Boolean)).forEach(r=>{var o,i;let n=r;for(;(o=n._def)!=null&&o.schema;)n=n._def.schema;((i=n._def)==null?void 0:i.typeName)==="ZodObject"&&m(n).forEach(([s,d])=>{e.add(s);const a=p(d);a!=null&&a.length&&a.forEach(u=>e.add(u))})}),Array.from(e)}function h(t){const e=g(t),l=e.map(r=>`<input type="hidden" name="${r}" />`).join(`
2
+ `);return console.log(c.blue.bold(`
3
3
  === Inputs gerados (Build Script) ===
4
- `)),e.forEach((n,r)=>{console.log(`${d.yellow(r+1+".")} ${d.green(n)}`)}),console.log(d.blue.bold(`
4
+ `)),e.forEach((r,n)=>{console.log(`${c.yellow(n+1+".")} ${c.green(r)}`)}),console.log(c.blue.bold(`
5
5
  =====================================
6
6
  `)),`<!DOCTYPE html>
7
7
  <html lang="pt-br">
@@ -16,19 +16,11 @@
16
16
  <body>
17
17
  <form id="form" name="form">
18
18
  <div id="root">
19
- <!-- IMPUTS DE CONTROLE -->
20
-
21
- <input type="hidden" name="LASTACTIVITYID" />
22
- <input type="hidden" name="CURRENTACTIVITYID" />
23
- <input type="hidden" name="FORM_MODE" />
24
-
25
- <!-- ////////////////// -->
26
-
27
- ${i}
19
+ ${l}
28
20
  </div>
29
21
  </form>
30
22
 
31
23
  <script src="./bridge.js"><\/script>
32
24
  <script src="./bundle.js"><\/script>
33
25
  </body>
34
- </html>`}exports.generateHtmlTemplate=g;
26
+ </html>`}exports.generateHtmlTemplate=h;
package/dist/node.js CHANGED
@@ -1,17 +1,17 @@
1
- import d from "chalk";
1
+ import c from "chalk";
2
2
  function f(t) {
3
3
  var e;
4
4
  return ((e = t._def) == null ? void 0 : e.schema) ?? t;
5
5
  }
6
6
  function p(t) {
7
- var o, l, s;
8
- let e = (o = t._def) == null ? void 0 : o.fluig;
7
+ var l, i, s;
8
+ let e = (l = t._def) == null ? void 0 : l.fluig;
9
9
  if (e != null && e.values) return e.values;
10
- const i = f(t);
11
- if (i !== t && (e = (l = i._def) == null ? void 0 : l.fluig, e != null && e.values))
10
+ const o = f(t);
11
+ if (o !== t && (e = (i = o._def) == null ? void 0 : i.fluig, e != null && e.values))
12
12
  return e.values;
13
- const n = i._def, r = (n == null ? void 0 : n.meta) ?? (n == null ? void 0 : n.metadata);
14
- return ((s = r == null ? void 0 : r.fluig) == null ? void 0 : s.values) ?? null;
13
+ const r = o._def, n = (r == null ? void 0 : r.meta) ?? (r == null ? void 0 : r.metadata);
14
+ return ((s = n == null ? void 0 : n.fluig) == null ? void 0 : s.values) ?? null;
15
15
  }
16
16
  function m(t) {
17
17
  var e;
@@ -19,28 +19,28 @@ function m(t) {
19
19
  }
20
20
  function h(t) {
21
21
  const e = /* @__PURE__ */ new Set();
22
- return (Array.isArray(t) ? t : Object.values(t).map((n) => n.schema).filter(Boolean)).forEach((n) => {
23
- var o, l;
24
- let r = n;
25
- for (; (o = r._def) != null && o.schema; )
26
- r = r._def.schema;
27
- ((l = r._def) == null ? void 0 : l.typeName) === "ZodObject" && m(r).forEach(([s, c]) => {
22
+ return (Array.isArray(t) ? t : Object.values(t).map((r) => r.schema).filter(Boolean)).forEach((r) => {
23
+ var l, i;
24
+ let n = r;
25
+ for (; (l = n._def) != null && l.schema; )
26
+ n = n._def.schema;
27
+ ((i = n._def) == null ? void 0 : i.typeName) === "ZodObject" && m(n).forEach(([s, d]) => {
28
28
  e.add(s);
29
- const a = p(c);
29
+ const a = p(d);
30
30
  a != null && a.length && a.forEach((u) => e.add(u));
31
31
  });
32
32
  }), Array.from(e);
33
33
  }
34
- function y(t) {
35
- const e = h(t), i = e.map(
36
- (n) => `<input type="hidden" name="${n}" />`
34
+ function b(t) {
35
+ const e = h(t), o = e.map(
36
+ (r) => `<input type="hidden" name="${r}" />`
37
37
  ).join(`
38
38
  `);
39
- return console.log(d.blue.bold(`
39
+ return console.log(c.blue.bold(`
40
40
  === Inputs gerados (Build Script) ===
41
- `)), e.forEach((n, r) => {
42
- console.log(`${d.yellow(r + 1 + ".")} ${d.green(n)}`);
43
- }), console.log(d.blue.bold(`
41
+ `)), e.forEach((r, n) => {
42
+ console.log(`${c.yellow(n + 1 + ".")} ${c.green(r)}`);
43
+ }), console.log(c.blue.bold(`
44
44
  =====================================
45
45
  `)), `<!DOCTYPE html>
46
46
  <html lang="pt-br">
@@ -55,15 +55,7 @@ function y(t) {
55
55
  <body>
56
56
  <form id="form" name="form">
57
57
  <div id="root">
58
- <!-- IMPUTS DE CONTROLE -->
59
-
60
- <input type="hidden" name="LASTACTIVITYID" />
61
- <input type="hidden" name="CURRENTACTIVITYID" />
62
- <input type="hidden" name="FORM_MODE" />
63
-
64
- <!-- ////////////////// -->
65
-
66
- ${i}
58
+ ${o}
67
59
  </div>
68
60
  </form>
69
61
 
@@ -73,5 +65,5 @@ function y(t) {
73
65
  </html>`;
74
66
  }
75
67
  export {
76
- y as generateHtmlTemplate
68
+ b as generateHtmlTemplate
77
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluig-kit/ecm",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",