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