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