@fluig-kit/ecm 1.0.21 → 1.0.23

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