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