@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 +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +306 -286
- package/dist/node.cjs +5 -13
- package/dist/node.js +23 -31
- package/package.json +1 -1
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
package/dist/index.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { appendErrors as
|
|
4
|
-
import { validateFieldsNatively as
|
|
5
|
-
import { z as
|
|
6
|
-
import { parentProxy as
|
|
7
|
-
import { DebugLogger as
|
|
8
|
-
var
|
|
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(
|
|
16
|
-
return
|
|
17
|
-
return e.push(
|
|
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
|
-
}),
|
|
20
|
-
var u = t[c].types,
|
|
21
|
-
t[c] =
|
|
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
|
-
},
|
|
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,
|
|
32
|
-
return a.shouldUseNativeValidation &&
|
|
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 (
|
|
35
|
-
return s(
|
|
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:
|
|
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
|
|
49
|
+
const O = T(
|
|
50
50
|
null
|
|
51
51
|
);
|
|
52
|
-
function
|
|
52
|
+
function Te({
|
|
53
53
|
children: e,
|
|
54
|
-
baseSchema:
|
|
54
|
+
baseSchema: n
|
|
55
55
|
}) {
|
|
56
|
-
const [t, r] =
|
|
57
|
-
r((
|
|
58
|
-
}, []), c =
|
|
59
|
-
r((
|
|
60
|
-
}, []), s = A(() => t.length ? t.map((
|
|
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__ */
|
|
68
|
+
return /* @__PURE__ */ w(O.Provider, { value: u, children: e });
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
const e =
|
|
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
|
|
78
|
+
function M(e) {
|
|
79
79
|
return typeof e == "number" ? e : isNaN(Number(e)) ? null : Number(e);
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function B(e, n, t) {
|
|
82
82
|
if (!e) return !0;
|
|
83
|
-
const r = Array.isArray(
|
|
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
|
|
87
|
-
const a = new Set(e), c = new Set(
|
|
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
|
|
91
|
-
if (r === null || !
|
|
90
|
+
const o = Array.isArray(s.from) ? s.from : [s.from];
|
|
91
|
+
if (r === null || !o.includes(r)) return;
|
|
92
92
|
}
|
|
93
|
-
if (!
|
|
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((
|
|
98
|
-
c.add(
|
|
97
|
+
u.forEach((o) => {
|
|
98
|
+
c.add(o), a.delete(o);
|
|
99
99
|
});
|
|
100
100
|
break;
|
|
101
101
|
case "active":
|
|
102
|
-
u.forEach((
|
|
103
|
-
a.add(
|
|
102
|
+
u.forEach((o) => {
|
|
103
|
+
a.add(o), c.delete(o);
|
|
104
104
|
});
|
|
105
105
|
break;
|
|
106
106
|
case "hidden":
|
|
107
|
-
u.forEach((
|
|
108
|
-
a.delete(
|
|
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
|
|
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
|
|
116
|
+
return n == null || n.forEach((s) => {
|
|
117
117
|
if (s.from !== void 0) {
|
|
118
|
-
const
|
|
119
|
-
if (t === null || !
|
|
118
|
+
const o = Array.isArray(s.from) ? s.from : [s.from];
|
|
119
|
+
if (t === null || !o.includes(t)) return;
|
|
120
120
|
}
|
|
121
|
-
if (!
|
|
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((
|
|
126
|
-
c.add(
|
|
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((
|
|
131
|
-
i.add(
|
|
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((
|
|
136
|
-
a.add(
|
|
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
|
|
147
|
-
if (!(e != null && e.length)) return
|
|
148
|
-
const t = new Map(
|
|
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
|
|
153
|
+
function ue(e) {
|
|
154
154
|
var r, i;
|
|
155
|
-
const
|
|
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((
|
|
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(
|
|
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
|
|
163
|
+
function le({
|
|
164
164
|
activityId: e,
|
|
165
|
-
previousActivityId:
|
|
165
|
+
previousActivityId: n,
|
|
166
166
|
control: t,
|
|
167
167
|
workflowStructure: r,
|
|
168
168
|
sectionsRegistry: i
|
|
169
169
|
}) {
|
|
170
|
-
const { registerSchema: a, unregisterSchema: c } =
|
|
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:
|
|
172
|
+
name: m,
|
|
173
173
|
defaultValue: {}
|
|
174
|
-
}),
|
|
175
|
-
const
|
|
176
|
-
return
|
|
177
|
-
|
|
178
|
-
}),
|
|
179
|
-
}, [
|
|
180
|
-
if (!
|
|
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
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
const d = ae(
|
|
186
|
+
o.sections.active,
|
|
187
|
+
o.sections.readonly,
|
|
188
|
+
o.sections.rules,
|
|
189
189
|
u,
|
|
190
|
-
|
|
190
|
+
v
|
|
191
191
|
);
|
|
192
|
-
let
|
|
193
|
-
...
|
|
194
|
-
name:
|
|
192
|
+
let y = [
|
|
193
|
+
...d.readonly.map((g) => ({
|
|
194
|
+
name: g,
|
|
195
195
|
mode: "readonly"
|
|
196
196
|
})),
|
|
197
|
-
...
|
|
198
|
-
name:
|
|
197
|
+
...d.active.map((g) => ({
|
|
198
|
+
name: g,
|
|
199
199
|
mode: "active"
|
|
200
200
|
}))
|
|
201
201
|
];
|
|
202
|
-
|
|
203
|
-
const
|
|
202
|
+
y = ce(o.sections.order, y);
|
|
203
|
+
const p = se(
|
|
204
204
|
{
|
|
205
|
-
active:
|
|
206
|
-
readonly:
|
|
207
|
-
hidden:
|
|
205
|
+
active: o.fields.active,
|
|
206
|
+
readonly: o.fields.readonly,
|
|
207
|
+
hidden: o.fields.hidden
|
|
208
208
|
},
|
|
209
|
-
|
|
209
|
+
o.fields.rules,
|
|
210
210
|
u,
|
|
211
|
-
|
|
211
|
+
v
|
|
212
212
|
);
|
|
213
|
-
return { sections:
|
|
214
|
-
}, [
|
|
213
|
+
return { sections: y, fields: p };
|
|
214
|
+
}, [o, u, v, i]);
|
|
215
215
|
return E(() => {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
var
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
}), Object.keys(i ?? {}).filter((
|
|
222
|
-
}, [
|
|
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
|
|
224
|
+
function de() {
|
|
225
225
|
if (typeof document > "u") return {};
|
|
226
226
|
const e = {};
|
|
227
|
-
return document.querySelectorAll("input[type='radio'][name]").forEach((
|
|
228
|
-
const t =
|
|
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((
|
|
231
|
-
const t =
|
|
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((
|
|
235
|
+
}), document.querySelectorAll("span[name]").forEach((n) => {
|
|
236
236
|
var i;
|
|
237
|
-
const t =
|
|
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
|
|
245
|
-
|
|
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:
|
|
267
|
+
devConfig: n
|
|
248
268
|
}) {
|
|
249
|
-
const [t, r] =
|
|
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
|
|
271
|
+
let a = !0;
|
|
256
272
|
return (async () => {
|
|
257
|
-
|
|
258
|
-
|
|
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
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
|
270
|
-
isView:
|
|
271
|
-
isReadOnly:
|
|
272
|
-
activityId:
|
|
273
|
-
|
|
274
|
-
|
|
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
|
|
280
|
-
if (
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
...
|
|
284
|
-
...
|
|
285
|
-
isView:
|
|
286
|
-
isReadOnly:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
312
|
+
a = !1;
|
|
294
313
|
};
|
|
295
|
-
}, [
|
|
314
|
+
}, [n, i]), t ? /* @__PURE__ */ w(G.Provider, { value: t, children: e }) : null;
|
|
296
315
|
}
|
|
297
|
-
function
|
|
298
|
-
const e =
|
|
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
|
|
306
|
-
const { activityId:
|
|
324
|
+
function he(e) {
|
|
325
|
+
const { activityId: n, previousActivityId: t } = N();
|
|
307
326
|
E(() => {
|
|
308
|
-
|
|
309
|
-
}, [
|
|
310
|
-
|
|
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 = ((
|
|
323
|
-
if (!r)
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
-
}
|
|
351
|
+
}
|
|
332
352
|
},
|
|
333
|
-
(
|
|
334
|
-
var u,
|
|
335
|
-
console.error("[Validation Errors]",
|
|
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
|
|
365
|
+
const we = ({
|
|
345
366
|
workflowStructure: e,
|
|
346
|
-
sectionsRegistry:
|
|
367
|
+
sectionsRegistry: n,
|
|
347
368
|
className: t
|
|
348
369
|
}) => {
|
|
349
|
-
const { control: r, handleSubmit: i, register: a, setValue: c,
|
|
370
|
+
const { control: r, handleSubmit: i, register: a, setValue: c, getValues: s } = Y(), u = N(), o = K(!1);
|
|
350
371
|
E(() => {
|
|
351
|
-
|
|
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:
|
|
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:
|
|
379
|
+
sectionsRegistry: n
|
|
359
380
|
});
|
|
360
|
-
return /* @__PURE__ */
|
|
381
|
+
return /* @__PURE__ */ R(
|
|
361
382
|
"form",
|
|
362
383
|
{
|
|
363
384
|
id: "fluig-react-form",
|
|
364
385
|
className: t,
|
|
365
|
-
onSubmit: i((
|
|
366
|
-
console.log("✅ [FluigWorkflowForm] Dados válidos:",
|
|
386
|
+
onSubmit: i((l) => {
|
|
387
|
+
console.log("✅ [FluigWorkflowForm] Dados válidos:", l);
|
|
367
388
|
}),
|
|
368
389
|
noValidate: !0,
|
|
369
390
|
children: [
|
|
370
|
-
/* @__PURE__ */
|
|
371
|
-
/* @__PURE__ */
|
|
372
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
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
|
-
|
|
399
|
+
m.map(({ name: l, mode: d }) => {
|
|
380
400
|
if (d === "hidden") return null;
|
|
381
|
-
const
|
|
382
|
-
if (!
|
|
383
|
-
const
|
|
384
|
-
return /* @__PURE__ */
|
|
385
|
-
|
|
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:
|
|
388
|
-
fields:
|
|
389
|
-
readOnly: d === "readonly"
|
|
407
|
+
id: l,
|
|
408
|
+
fields: f,
|
|
409
|
+
readOnly: d === "readonly"
|
|
390
410
|
},
|
|
391
|
-
|
|
411
|
+
l
|
|
392
412
|
);
|
|
393
413
|
}),
|
|
394
|
-
u.isDev && u.showDebugSubmit && /* @__PURE__ */
|
|
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
|
-
},
|
|
399
|
-
const { mergedSchema:
|
|
400
|
-
resolver:
|
|
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
|
|
405
|
-
t.showDebugLogs && (
|
|
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
|
-
),
|
|
409
|
-
}, [t.showDebugLogs, t.prefilledValues, r]), /* @__PURE__ */
|
|
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
|
|
431
|
+
async function pe(e) {
|
|
412
432
|
if (!e)
|
|
413
433
|
return console.warn("[setFluigNextActivity] Nenhuma atividade informada."), !1;
|
|
414
|
-
const { wfView:
|
|
415
|
-
if (!
|
|
416
|
-
|
|
417
|
-
const r = Number(e), i =
|
|
418
|
-
return i ? (
|
|
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
|
|
421
|
-
const e = await
|
|
422
|
-
return !e || !
|
|
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
|
|
444
|
+
function Ae(e) {
|
|
425
445
|
e.availableStatesCOPY || (e.availableStatesCOPY = e.availableStates);
|
|
426
446
|
}
|
|
427
|
-
function
|
|
447
|
+
function be(e, n) {
|
|
428
448
|
const t = e.availableStatesCOPY || e.availableStates;
|
|
429
|
-
return t == null ? void 0 : t.find((r) => r.sequence ===
|
|
449
|
+
return t == null ? void 0 : t.find((r) => r.sequence === n);
|
|
430
450
|
}
|
|
431
|
-
function
|
|
432
|
-
e.availableUsers.users = [], e.availableStates = [t],
|
|
451
|
+
function Se(e, n, t, r) {
|
|
452
|
+
e.availableUsers.users = [], e.availableStates = [t], n.selectActivity = () => r;
|
|
433
453
|
}
|
|
434
|
-
const
|
|
435
|
-
function
|
|
436
|
-
const e =
|
|
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
|
|
463
|
+
function ke({
|
|
444
464
|
id: e,
|
|
445
|
-
className:
|
|
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:
|
|
455
|
-
if (!
|
|
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
|
|
461
|
-
(
|
|
462
|
-
var S,
|
|
463
|
-
return (S = s.hidden) != null && S.includes(
|
|
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
|
-
),
|
|
467
|
-
(
|
|
468
|
-
[
|
|
469
|
-
),
|
|
470
|
-
(
|
|
471
|
-
[
|
|
472
|
-
),
|
|
473
|
-
(
|
|
474
|
-
if (!
|
|
475
|
-
const S =
|
|
476
|
-
|
|
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
|
-
[
|
|
498
|
+
[l, f]
|
|
479
499
|
);
|
|
480
500
|
E(() => {
|
|
481
|
-
if (!
|
|
482
|
-
const
|
|
483
|
-
S && Object.entries(S).forEach(([
|
|
484
|
-
var
|
|
485
|
-
let
|
|
486
|
-
for (; (
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
if ((
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}),
|
|
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
|
-
}, [
|
|
499
|
-
const
|
|
518
|
+
}, [o, a, t, l]);
|
|
519
|
+
const H = A(
|
|
500
520
|
() => ({
|
|
501
521
|
id: e,
|
|
502
|
-
form:
|
|
503
|
-
isHidden:
|
|
504
|
-
isReadOnly:
|
|
505
|
-
isView:
|
|
506
|
-
next:
|
|
507
|
-
wf_activity_id:
|
|
522
|
+
form: l,
|
|
523
|
+
isHidden: y,
|
|
524
|
+
isReadOnly: p,
|
|
525
|
+
isView: o,
|
|
526
|
+
next: g,
|
|
527
|
+
wf_activity_id: f
|
|
508
528
|
}),
|
|
509
|
-
[e,
|
|
529
|
+
[e, l, y, p, o, g, f]
|
|
510
530
|
);
|
|
511
|
-
return /* @__PURE__ */
|
|
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
|
|
514
|
-
function
|
|
515
|
-
const t = A(() =>
|
|
516
|
-
return /* @__PURE__ */
|
|
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
|
|
519
|
-
const e =
|
|
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
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
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
|
|
2
|
-
`);return console.log(
|
|
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
|
|
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
|
-
|
|
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=
|
|
26
|
+
</html>`}exports.generateHtmlTemplate=h;
|
package/dist/node.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
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
|
|
8
|
-
let e = (
|
|
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
|
|
11
|
-
if (
|
|
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
|
|
14
|
-
return ((s =
|
|
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((
|
|
23
|
-
var
|
|
24
|
-
let
|
|
25
|
-
for (; (
|
|
26
|
-
|
|
27
|
-
((
|
|
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(
|
|
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
|
|
35
|
-
const e = h(t),
|
|
36
|
-
(
|
|
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(
|
|
39
|
+
return console.log(c.blue.bold(`
|
|
40
40
|
=== Inputs gerados (Build Script) ===
|
|
41
|
-
`)), e.forEach((
|
|
42
|
-
console.log(`${
|
|
43
|
-
}), console.log(
|
|
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
|
-
|
|
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
|
-
|
|
68
|
+
b as generateHtmlTemplate
|
|
77
69
|
};
|