@fluig-kit/ecm 1.0.8 → 1.0.10
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 +57 -49
- package/dist/node.cjs +3 -2
- package/dist/node.js +12 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),l=require("react"),I=require("react-hook-form"),N=require("@hookform/resolvers"),_=require("zod"),h=require("@fluig-kit/core");var B=function(e,n){for(var t={};e.length;){var o=e[0],i=o.code,s=o.message,u=o.path.join(".");if(!t[u])if("unionErrors"in o){var a=o.unionErrors[0].errors[0];t[u]={message:a.message,type:a.code}}else t[u]={message:s,type:i};if("unionErrors"in o&&o.unionErrors.forEach(function(y){return y.errors.forEach(function(m){return e.push(m)})}),n){var c=t[u].types,r=c&&c[o.code];t[u]=I.appendErrors(u,n,t,i,r?[].concat(r,o.message):o.message)}e.shift()}return t},z=function(e,n,t){return t===void 0&&(t={}),function(o,i,s){try{return Promise.resolve(function(u,a){try{var c=Promise.resolve(e[t.mode==="sync"?"parse":"parseAsync"](o,n)).then(function(r){return s.shouldUseNativeValidation&&N.validateFieldsNatively({},s),{errors:{},values:t.raw?o:r}})}catch(r){return a(r)}return c&&c.then?c.then(void 0,a):c}(0,function(u){if(function(a){return Array.isArray(a==null?void 0:a.errors)}(u))return{values:{},errors:N.toNestErrors(B(u.errors,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw u}))}catch(u){return Promise.reject(u)}}};const j=l.createContext(null);function G({children:e,baseSchema:n}){const[t,o]=l.useState([]),i=l.useMemo(()=>n??_.z.object({}),[n]),s=l.useCallback((r,y)=>{o(m=>m.some(w=>w.id===r)?m:[...m,{id:r,schema:y}])},[]),u=l.useCallback(r=>{o(y=>y.some(m=>m.id===r)?y.filter(m=>m.id!==r):y)},[]),a=l.useMemo(()=>t.length?t.map(r=>r.schema).reduce((r,y)=>r.and(y),i):i,[t,i]),c=l.useMemo(()=>({registerSchema:s,unregisterSchema:u,mergedSchema:a}),[s,u,a]);return g.jsx(j.Provider,{value:c,children:e})}function D(){const e=l.useContext(j);if(!e)throw new Error("useSchemaRegistry deve ser usado dentro de <SchemaRegistryProvider>");return e}function L(e){return typeof e=="number"?e:isNaN(Number(e))?null:Number(e)}function M(e,n,t){if(!e)return!0;const o=Array.isArray(n)?n[0]:n,i=e.field??o,s=t==null?void 0:t[i];return e.hasValue!==void 0?e.hasValue?s!=null&&s!=="":s==null||s==="":e.equals!==void 0?s===e.equals:e.notEquals!==void 0?s!==e.notEquals:!0}function H(e,n,t,o,i){const s=new Set(e),u=new Set(n);return t==null||t.forEach(a=>{if(a.from!==void 0){const r=Array.isArray(a.from)?a.from:[a.from];if(o===null||!r.includes(o))return}if(!M(a.when,a.target,i))return;const c=Array.isArray(a.target)?a.target:[a.target];switch(a.type){case"readonly":c.forEach(r=>{u.add(r),s.delete(r)});break;case"active":c.forEach(r=>{s.add(r),u.delete(r)});break;case"hidden":c.forEach(r=>{s.delete(r),u.delete(r)});break}}),{active:Array.from(s),readonly:Array.from(u)}}function $(e,n,t,o){const i=new Set(e.active),s=new Set(e.readonly),u=new Set(e.hidden??[]);return n==null||n.forEach(a=>{if(a.from!==void 0){const r=Array.isArray(a.from)?a.from:[a.from];if(t===null||!r.includes(t))return}if(!M(a.when,a.target,o))return;const c=Array.isArray(a.target)?a.target:[a.target];switch(a.type){case"hidden":c.forEach(r=>{u.add(r),i.delete(r),s.delete(r)});break;case"active":c.forEach(r=>{i.add(r),s.delete(r),u.delete(r)});break;case"readonly":c.forEach(r=>{s.add(r),i.delete(r),u.delete(r)});break}}),{active:Array.from(i),readonly:Array.from(s),hidden:Array.from(u)}}function K(e,n){if(!(e!=null&&e.length))return n;const t=new Map(n.map(i=>[i.name,i])),o=[];return e.forEach(i=>{t.has(i)&&(o.push(t.get(i)),t.delete(i))}),t.forEach(i=>o.push(i)),o}function J(e){var o,i;const n=new Set,t=(s=[])=>{s.forEach(u=>{var a;u.target&&(Array.isArray(u.target)?u.target:[u.target]).forEach(r=>n.add(r)),(a=u.when)!=null&&a.field&&n.add(u.when.field)})};return t((o=e==null?void 0:e.fields)==null?void 0:o.rules),t((i=e==null?void 0:e.sections)==null?void 0:i.rules),Array.from(n)}function Q({activityId:e,previousActivityId:n,control:t,workflowStructure:o,sectionsRegistry:i}){const{registerSchema:s,unregisterSchema:u}=D(),a=L(e),c=L(n),r=a!==null?o[a]:null,y=l.useMemo(()=>J(r),[a,r]),m=I.useWatch({control:t,name:y,defaultValue:{}}),w=l.useMemo(()=>{const f={};return y.forEach((v,b)=>{f[v]=Array.isArray(m)?m[b]:m}),f},[m,y]),d=l.useMemo(()=>{if(!r)return{sections:[],fields:{active:[],readonly:[],hidden:[]}};const f=H(r.sections.active,r.sections.readonly,r.sections.rules,c,w);let v=[...f.readonly.map(A=>({name:A,mode:"readonly"})),...f.active.map(A=>({name:A,mode:"active"}))];v=K(r.sections.order,v);const b=$({active:r.fields.active,readonly:r.fields.readonly,hidden:r.fields.hidden},r.fields.rules,c,w);return{sections:v,fields:b}},[r,c,w,i]);return l.useEffect(()=>{const f=d.sections.filter(v=>v.mode==="active").map(v=>v.name);f.forEach(v=>{var A;const b=(A=i==null?void 0:i[v])==null?void 0:A.schema;b&&s(v,b)}),Object.keys(i??{}).filter(v=>!f.includes(v)).forEach(u)},[d.sections,i,s,u]),d}function X(){if(typeof document>"u")return{};const e={};return document.querySelectorAll("input[type='radio'][name]").forEach(n=>{const t=n,o=t.getAttribute("name");o&&t.checked&&(e[o]=t.value)}),document.querySelectorAll("input[name], textarea[name], select[name]").forEach(n=>{const t=n,o=t.getAttribute("name");if(!o||e[o]!==void 0)return;const i=t.getAttribute("value")??t.value??t.textContent??"";e[o]=String(i).trim()}),document.querySelectorAll("span[name]").forEach(n=>{var i;const t=n,o=t.getAttribute("name");if(o){const s=((i=t.textContent)==null?void 0:i.trim())??"";s!==""&&(e[o]=s)}}),e}const q=()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("edit"),Z=()=>{var e;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 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(O.Provider,{value:t,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:n,previousActivityId:t}=F();l.useEffect(()=>{n!=null&&e.setValue("CURRENTACTIVITYID",n),t!=null&&e.setValue("LASTACTIVITYID",t)},[n,t,e]),l.useEffect(()=>{var i,s;if(typeof window>"u")return;const 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}=I.useFormContext(),c=F(),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=F(),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 Y=l.createContext(null);function de(){const e=l.useContext(Y);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}=F(),m=y,w=I.useFormContext(),d=i||w;if(!d)return console.error(`[FluigWorkflowReact] Section "${e}" não encontrou o 'form'.`),null;if(c)return null;const f=l.useCallback(p=>{var E,x,C;return(E=a.hidden)!=null&&E.includes(p)?"hidden":(x=a.readonly)!=null&&x.includes(p)?"readonly":(C=a.active)!=null&&C.includes(p)?"active":u?"readonly":"active"},[a,u]),v=l.useCallback(p=>f(p)==="hidden",[f]),b=l.useCallback(p=>f(p)==="readonly",[f]),A=l.useCallback(p=>{if(!p)return;const E=d.getValues("CURRENTACTIVITYID");d.setValue("LASTACTIVITYID",E),d.setValue("CURRENTACTIVITYID",m),se(Number(p))},[d,m]);l.useEffect(()=>{if(!r||!s||!t||!d)return;const p=d.getValues(),E=t.shape;E&&Object.entries(E).forEach(([x,C])=>{var R,T;let S=C;for(;(R=S==null?void 0:S._def)!=null&&R.schema;)S=S._def.schema;const V=(T=S==null?void 0:S._def)==null?void 0:T.fluig;if((V==null?void 0:V.type)!=="options"||!Array.isArray(V.values)||p[x]!==void 0)return;const P={};V.values.forEach(k=>{P[k]=s[k]==="on"}),d.setValue(x,P,{shouldDirty:!1,shouldValidate:!1})})},[r,s,t,d]);const W=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(Y.Provider,{value:W,children:g.jsx("section",{id:e,className:[e,n].filter(Boolean).join(" "),children:o})})}const U=l.createContext(null);function me({children:e,config:n}){const t=l.useMemo(()=>h.createFluigClient(n),[n]);return g.jsx(U.Provider,{value:t,children:e})}function ye(){const e=l.useContext(U);if(!e)throw new Error("useFluigApi deve ser usado dentro de um <FluigApiProvider>");return e}Object.defineProperty(exports,"DebugLogger",{enumerable:!0,get:()=>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=F;exports.useSchemaRegistry=D;exports.useSection=de;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),l=require("react"),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,10 +1,10 @@
|
|
|
1
|
-
import { jsx as w, jsxs 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
6
|
import { parentProxy as P, DebugLogger as I, createFluigClient as re } from "@fluig-kit/core";
|
|
7
|
-
import { DebugLogger as
|
|
7
|
+
import { DebugLogger as qe, createFluigClient as Me, parentProxy as Ye } from "@fluig-kit/core";
|
|
8
8
|
var oe = function(e, n) {
|
|
9
9
|
for (var t = {}; e.length; ) {
|
|
10
10
|
var o = e[0], i = o.code, a = o.message, c = o.path.join(".");
|
|
@@ -46,14 +46,14 @@ var oe = function(e, n) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
-
const
|
|
49
|
+
const O = C(
|
|
50
50
|
null
|
|
51
51
|
);
|
|
52
|
-
function
|
|
52
|
+
function Te({
|
|
53
53
|
children: e,
|
|
54
54
|
baseSchema: n
|
|
55
55
|
}) {
|
|
56
|
-
const [t, o] =
|
|
56
|
+
const [t, o] = Y([]), i = A(() => n ?? ne.object({}), [n]), a = V((r, m) => {
|
|
57
57
|
o((f) => f.some((v) => v.id === r) ? f : [...f, { id: r, schema: m }]);
|
|
58
58
|
}, []), c = V((r) => {
|
|
59
59
|
o((m) => m.some((f) => f.id === r) ? m.filter((f) => f.id !== r) : m);
|
|
@@ -65,17 +65,17 @@ function Ce({
|
|
|
65
65
|
}),
|
|
66
66
|
[a, c, s]
|
|
67
67
|
);
|
|
68
|
-
return /* @__PURE__ */ w(
|
|
68
|
+
return /* @__PURE__ */ w(O.Provider, { value: u, children: e });
|
|
69
69
|
}
|
|
70
70
|
function W() {
|
|
71
|
-
const e = D(
|
|
71
|
+
const e = D(O);
|
|
72
72
|
if (!e)
|
|
73
73
|
throw new Error(
|
|
74
74
|
"useSchemaRegistry deve ser usado dentro de <SchemaRegistryProvider>"
|
|
75
75
|
);
|
|
76
76
|
return e;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function M(e) {
|
|
79
79
|
return typeof e == "number" ? e : isNaN(Number(e)) ? null : Number(e);
|
|
80
80
|
}
|
|
81
81
|
function B(e, n, t) {
|
|
@@ -167,7 +167,7 @@ function le({
|
|
|
167
167
|
workflowStructure: o,
|
|
168
168
|
sectionsRegistry: i
|
|
169
169
|
}) {
|
|
170
|
-
const { registerSchema: a, unregisterSchema: c } = W(), s =
|
|
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
171
|
control: t,
|
|
172
172
|
name: m,
|
|
173
173
|
defaultValue: {}
|
|
@@ -253,12 +253,12 @@ const j = () => typeof window > "u" ? null : new URLSearchParams(window.location
|
|
|
253
253
|
return i === !0 || !!a && a.trim() !== "";
|
|
254
254
|
}
|
|
255
255
|
return j() === null;
|
|
256
|
-
}, ye = () => j() === "true",
|
|
257
|
-
function
|
|
256
|
+
}, ye = () => j() === "true", G = C(null);
|
|
257
|
+
function Ce({
|
|
258
258
|
children: e,
|
|
259
259
|
devConfig: n
|
|
260
260
|
}) {
|
|
261
|
-
const [t, o] =
|
|
261
|
+
const [t, o] = Y(null), i = A(() => de() ?? {}, []);
|
|
262
262
|
return E(() => {
|
|
263
263
|
let a = !0;
|
|
264
264
|
return (async () => {
|
|
@@ -303,10 +303,10 @@ function Te({
|
|
|
303
303
|
})(), () => {
|
|
304
304
|
a = !1;
|
|
305
305
|
};
|
|
306
|
-
}, [n, i]), t ? /* @__PURE__ */ w(
|
|
306
|
+
}, [n, i]), t ? /* @__PURE__ */ w(G.Provider, { value: t, children: e }) : null;
|
|
307
307
|
}
|
|
308
|
-
function
|
|
309
|
-
const e = D(
|
|
308
|
+
function R() {
|
|
309
|
+
const e = D(G);
|
|
310
310
|
if (!e)
|
|
311
311
|
throw new Error(
|
|
312
312
|
"useFluigRuntime deve ser usado dentro de <FluigRuntimeProvider>"
|
|
@@ -314,7 +314,7 @@ function N() {
|
|
|
314
314
|
return e;
|
|
315
315
|
}
|
|
316
316
|
function ve(e) {
|
|
317
|
-
const { activityId: n, previousActivityId: t } =
|
|
317
|
+
const { activityId: n, previousActivityId: t } = R();
|
|
318
318
|
E(() => {
|
|
319
319
|
n != null && e.setValue("CURRENTACTIVITYID", n), t != null && e.setValue("LASTACTIVITYID", t);
|
|
320
320
|
}, [n, t, e]), E(() => {
|
|
@@ -322,14 +322,22 @@ function ve(e) {
|
|
|
322
322
|
if (typeof window > "u") return;
|
|
323
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
324
|
if (!o) {
|
|
325
|
-
console.warn(
|
|
325
|
+
console.warn(
|
|
326
|
+
"[FluigWorkflowReact] Botão de envio do Fluig não encontrado. A validação automática pode falhar."
|
|
327
|
+
);
|
|
326
328
|
return;
|
|
327
329
|
}
|
|
328
330
|
return window.beforeSendValidate = () => (e.handleSubmit(
|
|
329
331
|
() => {
|
|
330
|
-
window.beforeSendValidate = () => !0;
|
|
332
|
+
window.top.__FLUIG_REACT_FORM_DATA__ = e.getValues(), window.beforeSendValidate = () => !0;
|
|
331
333
|
try {
|
|
332
|
-
o.dispatchEvent(
|
|
334
|
+
o.dispatchEvent(
|
|
335
|
+
new MouseEvent("click", {
|
|
336
|
+
view: window,
|
|
337
|
+
bubbles: !0,
|
|
338
|
+
cancelable: !0
|
|
339
|
+
})
|
|
340
|
+
);
|
|
333
341
|
} catch {
|
|
334
342
|
o.click();
|
|
335
343
|
}
|
|
@@ -351,7 +359,7 @@ const he = ({
|
|
|
351
359
|
sectionsRegistry: n,
|
|
352
360
|
className: t
|
|
353
361
|
}) => {
|
|
354
|
-
const { control: o, handleSubmit: i, register: a, setValue: c, getValues: s } =
|
|
362
|
+
const { control: o, handleSubmit: i, register: a, setValue: c, getValues: s } = U(), u = R(), r = K(!1);
|
|
355
363
|
E(() => {
|
|
356
364
|
r.current || (u.activityId != null && c("CURRENTACTIVITYID", u.activityId), u.previousActivityId != null && c("LASTACTIVITYID", u.previousActivityId), r.current = !0);
|
|
357
365
|
}, [u, c]);
|
|
@@ -362,7 +370,7 @@ const he = ({
|
|
|
362
370
|
workflowStructure: e,
|
|
363
371
|
sectionsRegistry: n
|
|
364
372
|
});
|
|
365
|
-
return /* @__PURE__ */
|
|
373
|
+
return /* @__PURE__ */ N(
|
|
366
374
|
"form",
|
|
367
375
|
{
|
|
368
376
|
id: "fluig-react-form",
|
|
@@ -372,11 +380,11 @@ const he = ({
|
|
|
372
380
|
}),
|
|
373
381
|
noValidate: !0,
|
|
374
382
|
children: [
|
|
375
|
-
/* @__PURE__ */
|
|
383
|
+
/* @__PURE__ */ N("div", { className: "hidden", style: { display: "none" }, children: [
|
|
376
384
|
/* @__PURE__ */ w("input", { type: "hidden", ...a("CURRENTACTIVITYID") }),
|
|
377
385
|
/* @__PURE__ */ w("input", { type: "hidden", ...a("LASTACTIVITYID") })
|
|
378
386
|
] }),
|
|
379
|
-
m.length === 0 && u.activityId !== null && /* @__PURE__ */
|
|
387
|
+
m.length === 0 && u.activityId !== null && /* @__PURE__ */ N("p", { children: [
|
|
380
388
|
"Não foi possível encontrar a atividade: ",
|
|
381
389
|
String(u.activityId)
|
|
382
390
|
] }),
|
|
@@ -400,7 +408,7 @@ const he = ({
|
|
|
400
408
|
}
|
|
401
409
|
);
|
|
402
410
|
}, De = (e) => {
|
|
403
|
-
const { mergedSchema: n } = W(), t =
|
|
411
|
+
const { mergedSchema: n } = W(), t = R(), o = X({
|
|
404
412
|
resolver: n ? ie(n) : void 0,
|
|
405
413
|
defaultValues: t.prefilledValues,
|
|
406
414
|
mode: "onBlur"
|
|
@@ -435,16 +443,16 @@ function Ae(e, n) {
|
|
|
435
443
|
function be(e, n, t, o) {
|
|
436
444
|
e.availableUsers.users = [], e.availableStates = [t], n.selectActivity = () => o;
|
|
437
445
|
}
|
|
438
|
-
const
|
|
439
|
-
function
|
|
440
|
-
const e = D(
|
|
446
|
+
const z = C(null);
|
|
447
|
+
function Re() {
|
|
448
|
+
const e = D(z);
|
|
441
449
|
if (!e)
|
|
442
450
|
throw new Error(
|
|
443
451
|
"useSection deve ser usado dentro de um componente <Section>"
|
|
444
452
|
);
|
|
445
453
|
return e;
|
|
446
454
|
}
|
|
447
|
-
function
|
|
455
|
+
function Ne({
|
|
448
456
|
id: e,
|
|
449
457
|
className: n,
|
|
450
458
|
schema: t,
|
|
@@ -455,7 +463,7 @@ function Re({
|
|
|
455
463
|
fields: s = {},
|
|
456
464
|
hidden: u = !1
|
|
457
465
|
}) {
|
|
458
|
-
const { isView: r, activityId: m } =
|
|
466
|
+
const { isView: r, activityId: m } = R(), f = m, v = U(), l = i || v;
|
|
459
467
|
if (!l)
|
|
460
468
|
return console.error(
|
|
461
469
|
`[FluigWorkflowReact] Section "${e}" não encontrou o 'form'.`
|
|
@@ -463,8 +471,8 @@ function Re({
|
|
|
463
471
|
if (u) return null;
|
|
464
472
|
const d = V(
|
|
465
473
|
(h) => {
|
|
466
|
-
var S, F,
|
|
467
|
-
return (S = s.hidden) != null && S.includes(h) ? "hidden" : (F = s.readonly) != null && F.includes(h) ? "readonly" : (
|
|
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";
|
|
468
476
|
},
|
|
469
477
|
[s, c]
|
|
470
478
|
), y = V(
|
|
@@ -484,16 +492,16 @@ function Re({
|
|
|
484
492
|
E(() => {
|
|
485
493
|
if (!r || !a || !t || !l) return;
|
|
486
494
|
const h = l.getValues(), S = t.shape;
|
|
487
|
-
S && Object.entries(S).forEach(([F,
|
|
488
|
-
var L,
|
|
489
|
-
let b =
|
|
495
|
+
S && Object.entries(S).forEach(([F, T]) => {
|
|
496
|
+
var L, _;
|
|
497
|
+
let b = T;
|
|
490
498
|
for (; (L = b == null ? void 0 : b._def) != null && L.schema; )
|
|
491
499
|
b = b._def.schema;
|
|
492
|
-
const x = (
|
|
500
|
+
const x = (_ = b == null ? void 0 : b._def) == null ? void 0 : _.fluig;
|
|
493
501
|
if ((x == null ? void 0 : x.type) !== "options" || !Array.isArray(x.values) || h[F] !== void 0) return;
|
|
494
502
|
const k = {};
|
|
495
|
-
x.values.forEach((
|
|
496
|
-
k[
|
|
503
|
+
x.values.forEach((q) => {
|
|
504
|
+
k[q] = a[q] === "on";
|
|
497
505
|
}), l.setValue(F, k, {
|
|
498
506
|
shouldDirty: !1,
|
|
499
507
|
shouldValidate: !1
|
|
@@ -512,9 +520,9 @@ function Re({
|
|
|
512
520
|
}),
|
|
513
521
|
[e, l, y, p, r, g, f]
|
|
514
522
|
);
|
|
515
|
-
return /* @__PURE__ */ w(
|
|
523
|
+
return /* @__PURE__ */ w(z.Provider, { value: H, children: /* @__PURE__ */ w("section", { id: e, className: [e, n].filter(Boolean).join(" "), children: o }) });
|
|
516
524
|
}
|
|
517
|
-
const $ =
|
|
525
|
+
const $ = C(null);
|
|
518
526
|
function Pe({ children: e, config: n }) {
|
|
519
527
|
const t = A(() => re(n), [n]);
|
|
520
528
|
return /* @__PURE__ */ w($.Provider, { value: t, children: e });
|
|
@@ -528,16 +536,16 @@ function ke() {
|
|
|
528
536
|
return e;
|
|
529
537
|
}
|
|
530
538
|
export {
|
|
531
|
-
|
|
539
|
+
qe as DebugLogger,
|
|
532
540
|
Pe as FluigApiProvider,
|
|
533
|
-
|
|
541
|
+
Ce as FluigRuntimeProvider,
|
|
534
542
|
De as FluigWorkflowForm,
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
543
|
+
Te as SchemaRegistryProvider,
|
|
544
|
+
Ne as Section,
|
|
545
|
+
Me as createFluigClient,
|
|
546
|
+
Ye as parentProxy,
|
|
539
547
|
ke as useFluigApi,
|
|
540
|
-
|
|
548
|
+
R as useFluigRuntime,
|
|
541
549
|
W as useSchemaRegistry,
|
|
542
|
-
|
|
550
|
+
Re as useSection
|
|
543
551
|
};
|
package/dist/node.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("chalk");function f(t){var e;return((e=t._def)==null?void 0:e.schema)??t}function p(t){var o,i,s;let e=(o=t._def)==null?void 0:o.fluig;if(e!=null&&e.values)return e.values;const l=f(t);if(l!==t&&(e=(i=l._def)==null?void 0:i.fluig,e!=null&&e.values))return e.values;const r=l._def,n=(r==null?void 0:r.meta)??(r==null?void 0:r.metadata);return((s=n==null?void 0:n.fluig)==null?void 0:s.values)??null}function m(t){var e;return((e=t==null?void 0:t._def)==null?void 0:e.typeName)!=="ZodObject"?[]:Object.entries(t.shape)}function g(t){const e=new Set;return(Array.isArray(t)?t:Object.values(t).map(r=>r.schema).filter(Boolean)).forEach(r=>{var o,i;let n=r;for(;(o=n._def)!=null&&o.schema;)n=n._def.schema;((i=n._def)==null?void 0:i.typeName)==="ZodObject"&&m(n).forEach(([s,d])=>{e.add(s);const a=p(d);a!=null&&a.length&&a.forEach(u=>e.add(u))})}),Array.from(e)}function h(t){const e=g(t),l=e.map(r=>`<input type="hidden" name="${r}" />`).join(`
|
|
2
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(`
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<title>Workflow Fluig</title>
|
|
12
12
|
|
|
13
13
|
<link rel="stylesheet" href="/portal/style-guide/css/fluig-style-guide.min.css">
|
|
14
|
-
<link rel="stylesheet" crossorigin href="./
|
|
14
|
+
<link rel="stylesheet" crossorigin href="./bundle.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<form id="form" name="form">
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
</div>
|
|
21
21
|
</form>
|
|
22
22
|
|
|
23
|
+
<script src="./bridge.js"><\/script>
|
|
23
24
|
<script src="./bundle.js"><\/script>
|
|
24
25
|
</body>
|
|
25
26
|
</html>`}exports.generateHtmlTemplate=h;
|
package/dist/node.js
CHANGED
|
@@ -3,17 +3,17 @@ function f(t) {
|
|
|
3
3
|
var e;
|
|
4
4
|
return ((e = t._def) == null ? void 0 : e.schema) ?? t;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
var l, i,
|
|
6
|
+
function p(t) {
|
|
7
|
+
var l, i, s;
|
|
8
8
|
let e = (l = t._def) == null ? void 0 : l.fluig;
|
|
9
9
|
if (e != null && e.values) return e.values;
|
|
10
10
|
const o = f(t);
|
|
11
11
|
if (o !== t && (e = (i = o._def) == null ? void 0 : i.fluig, e != null && e.values))
|
|
12
12
|
return e.values;
|
|
13
13
|
const r = o._def, n = (r == null ? void 0 : r.meta) ?? (r == null ? void 0 : r.metadata);
|
|
14
|
-
return ((
|
|
14
|
+
return ((s = n == null ? void 0 : n.fluig) == null ? void 0 : s.values) ?? null;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function m(t) {
|
|
17
17
|
var e;
|
|
18
18
|
return ((e = t == null ? void 0 : t._def) == null ? void 0 : e.typeName) !== "ZodObject" ? [] : Object.entries(t.shape);
|
|
19
19
|
}
|
|
@@ -24,14 +24,14 @@ function h(t) {
|
|
|
24
24
|
let n = r;
|
|
25
25
|
for (; (l = n._def) != null && l.schema; )
|
|
26
26
|
n = n._def.schema;
|
|
27
|
-
((i = n._def) == null ? void 0 : i.typeName) === "ZodObject" &&
|
|
28
|
-
e.add(
|
|
29
|
-
const
|
|
30
|
-
|
|
27
|
+
((i = n._def) == null ? void 0 : i.typeName) === "ZodObject" && m(n).forEach(([s, d]) => {
|
|
28
|
+
e.add(s);
|
|
29
|
+
const a = p(d);
|
|
30
|
+
a != null && a.length && a.forEach((u) => e.add(u));
|
|
31
31
|
});
|
|
32
32
|
}), Array.from(e);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function b(t) {
|
|
35
35
|
const e = h(t), o = e.map(
|
|
36
36
|
(r) => `<input type="hidden" name="${r}" />`
|
|
37
37
|
).join(`
|
|
@@ -50,7 +50,7 @@ function y(t) {
|
|
|
50
50
|
<title>Workflow Fluig</title>
|
|
51
51
|
|
|
52
52
|
<link rel="stylesheet" href="/portal/style-guide/css/fluig-style-guide.min.css">
|
|
53
|
-
<link rel="stylesheet" crossorigin href="./
|
|
53
|
+
<link rel="stylesheet" crossorigin href="./bundle.css">
|
|
54
54
|
</head>
|
|
55
55
|
<body>
|
|
56
56
|
<form id="form" name="form">
|
|
@@ -59,10 +59,11 @@ function y(t) {
|
|
|
59
59
|
</div>
|
|
60
60
|
</form>
|
|
61
61
|
|
|
62
|
+
<script src="./bridge.js"><\/script>
|
|
62
63
|
<script src="./bundle.js"><\/script>
|
|
63
64
|
</body>
|
|
64
65
|
</html>`;
|
|
65
66
|
}
|
|
66
67
|
export {
|
|
67
|
-
|
|
68
|
+
b as generateHtmlTemplate
|
|
68
69
|
};
|