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