@fluig-kit/ecm 1.0.19 → 1.0.21

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