@fluig-kit/ecm 1.0.0

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.
@@ -0,0 +1,31 @@
1
+ (function(g,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react"),require("react-hook-form"),require("@hookform/resolvers"),require("zod"),require("@fluig-kit/core"),require("chalk")):typeof define=="function"&&define.amd?define(["exports","react","react-hook-form","@hookform/resolvers","zod","@fluig-kit/core","chalk"],d):(g=typeof globalThis<"u"?globalThis:g||self,d(g.FluigKitECM={},g.React,g.reactHookForm,g.resolvers,g.zod,g.FluigKitCore,g.chalk))})(this,(function(g,d,k,H,fe,_,D){"use strict";var L={exports:{}},j={};var K;function me(){if(K)return j;K=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function n(o,a,s){var l=null;if(s!==void 0&&(l=""+s),a.key!==void 0&&(l=""+a.key),"key"in a){s={};for(var u in a)u!=="key"&&(s[u]=a[u])}else s=a;return a=s.ref,{$$typeof:e,type:o,key:l,ref:a!==void 0?a:null,props:s}}return j.Fragment=r,j.jsx=n,j.jsxs=n,j}var O={};var Q;function ve(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&(function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Je?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case R:return"Fragment";case z:return"Profiler";case x:return"StrictMode";case B:return"Suspense";case I:return"SuspenseList";case Y:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case p:return"Portal";case C:return t.displayName||"Context";case T:return(t._context.displayName||"Context")+".Consumer";case M:var f=t.render;return t=t.displayName,t||(t=f.displayName||f.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case N:return f=t.displayName||null,f!==null?f:e(t.type)||"Memo";case P:f=t._payload,t=t._init;try{return e(t(f))}catch{}}return null}function r(t){return""+t}function n(t){try{r(t);var f=!1}catch{f=!0}if(f){f=console;var h=f.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return h.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),r(t)}}function o(t){if(t===R)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===P)return"<...>";try{var f=e(t);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function a(){var t=G.A;return t===null?null:t.getOwner()}function s(){return Error("react-stack-top-frame")}function l(t){if(ie.call(t,"key")){var f=Object.getOwnPropertyDescriptor(t,"key").get;if(f&&f.isReactWarning)return!1}return t.key!==void 0}function u(t,f){function h(){se||(se=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",f))}h.isReactWarning=!0,Object.defineProperty(t,"key",{get:h,configurable:!0})}function c(){var t=e(this.type);return ue[t]||(ue[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function i(t,f,h,E,U,X){var A=h.ref;return t={$$typeof:b,type:t,key:f,props:h,_owner:E},(A!==void 0?A:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:c}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function y(t,f,h,E,U,X){var A=f.children;if(A!==void 0)if(E)if(Xe(A)){for(E=0;E<A.length;E++)v(A[E]);Object.freeze&&Object.freeze(A)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else v(A);if(ie.call(f,"key")){A=e(t);var F=Object.keys(f).filter(function(Ze){return Ze!=="key"});E=0<F.length?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}",de[A+E]||(F=0<F.length?"{"+F.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,E,A,F,A),de[A+E]=!0)}if(A=null,h!==void 0&&(n(h),A=""+h),l(f)&&(n(f.key),A=""+f.key),"key"in f){h={};for(var Z in f)Z!=="key"&&(h[Z]=f[Z])}else h=f;return A&&u(h,typeof t=="function"?t.displayName||t.name||"Unknown":t),i(t,A,h,a(),U,X)}function v(t){w(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===P&&(t._payload.status==="fulfilled"?w(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function w(t){return typeof t=="object"&&t!==null&&t.$$typeof===b}var m=d,b=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),C=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),Y=Symbol.for("react.activity"),Je=Symbol.for("react.client.reference"),G=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie=Object.prototype.hasOwnProperty,Xe=Array.isArray,J=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(t){return t()}};var se,ue={},le=m.react_stack_bottom_frame.bind(m,s)(),ce=J(o(s)),de={};O.Fragment=R,O.jsx=function(t,f,h){var E=1e4>G.recentlyCreatedOwnerStacks++;return y(t,f,h,!1,E?Error("react-stack-top-frame"):le,E?J(o(t)):ce)},O.jsxs=function(t,f,h){var E=1e4>G.recentlyCreatedOwnerStacks++;return y(t,f,h,!0,E?Error("react-stack-top-frame"):le,E?J(o(t)):ce)}})()),O}var q;function ge(){return q||(q=1,process.env.NODE_ENV==="production"?L.exports=me():L.exports=ve()),L.exports}var S=ge(),ye=function(e,r){for(var n={};e.length;){var o=e[0],a=o.code,s=o.message,l=o.path.join(".");if(!n[l])if("unionErrors"in o){var u=o.unionErrors[0].errors[0];n[l]={message:u.message,type:u.code}}else n[l]={message:s,type:a};if("unionErrors"in o&&o.unionErrors.forEach(function(y){return y.errors.forEach(function(v){return e.push(v)})}),r){var c=n[l].types,i=c&&c[o.code];n[l]=k.appendErrors(l,r,n,a,i?[].concat(i,o.message):o.message)}e.shift()}return n},pe=function(e,r,n){return n===void 0&&(n={}),function(o,a,s){try{return Promise.resolve((function(l,u){try{var c=Promise.resolve(e[n.mode==="sync"?"parse":"parseAsync"](o,r)).then(function(i){return s.shouldUseNativeValidation&&H.validateFieldsNatively({},s),{errors:{},values:n.raw?o:i}})}catch(i){return u(i)}return c&&c.then?c.then(void 0,u):c})(0,function(l){if((function(u){return Array.isArray(u?.errors)})(l))return{values:{},errors:H.toNestErrors(ye(l.errors,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw l}))}catch(l){return Promise.reject(l)}}};const $=d.createContext(null);function he({children:e,baseSchema:r}){const[n,o]=d.useState([]),a=d.useMemo(()=>r??fe.z.object({}),[r]),s=d.useCallback((i,y)=>{o(v=>v.some(w=>w.id===i)?v:[...v,{id:i,schema:y}])},[]),l=d.useCallback(i=>{o(y=>y.some(v=>v.id===i)?y.filter(v=>v.id!==i):y)},[]),u=d.useMemo(()=>n.length?n.map(i=>i.schema).reduce((i,y)=>i.and(y),a):a,[n,a]),c=d.useMemo(()=>({registerSchema:s,unregisterSchema:l,mergedSchema:u}),[s,l,u]);return S.jsx($.Provider,{value:c,children:e})}function W(){const e=d.useContext($);if(!e)throw new Error("useSchemaRegistry deve ser usado dentro de <SchemaRegistryProvider>");return e}function ee(e){return typeof e=="number"?e:isNaN(Number(e))?null:Number(e)}function te(e,r,n){if(!e)return!0;const o=Array.isArray(r)?r[0]:r,a=e.field??o,s=n?.[a];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 we(e,r,n,o,a){const s=new Set(e),l=new Set(r);return n?.forEach(u=>{if(u.from!==void 0){const i=Array.isArray(u.from)?u.from:[u.from];if(o===null||!i.includes(o))return}if(!te(u.when,u.target,a))return;const c=Array.isArray(u.target)?u.target:[u.target];switch(u.type){case"readonly":c.forEach(i=>{l.add(i),s.delete(i)});break;case"active":c.forEach(i=>{s.add(i),l.delete(i)});break;case"hidden":c.forEach(i=>{s.delete(i),l.delete(i)});break}}),{active:Array.from(s),readonly:Array.from(l)}}function be(e,r,n,o){const a=new Set(e.active),s=new Set(e.readonly),l=new Set(e.hidden??[]);return r?.forEach(u=>{if(u.from!==void 0){const i=Array.isArray(u.from)?u.from:[u.from];if(n===null||!i.includes(n))return}if(!te(u.when,u.target,o))return;const c=Array.isArray(u.target)?u.target:[u.target];switch(u.type){case"hidden":c.forEach(i=>{l.add(i),a.delete(i),s.delete(i)});break;case"active":c.forEach(i=>{a.add(i),s.delete(i),l.delete(i)});break;case"readonly":c.forEach(i=>{s.add(i),a.delete(i),l.delete(i)});break}}),{active:Array.from(a),readonly:Array.from(s),hidden:Array.from(l)}}function Ee(e,r){if(!e?.length)return r;const n=new Map(r.map(a=>[a.name,a])),o=[];return e.forEach(a=>{n.has(a)&&(o.push(n.get(a)),n.delete(a))}),n.forEach(a=>o.push(a)),o}function Ae(e){const r=new Set,n=(o=[])=>{o.forEach(a=>{a.target&&(Array.isArray(a.target)?a.target:[a.target]).forEach(l=>r.add(l)),a.when?.field&&r.add(a.when.field)})};return n(e?.fields?.rules),n(e?.sections?.rules),Array.from(r)}function Se({activityId:e,previousActivityId:r,control:n,workflowStructure:o,sectionsRegistry:a}){const{registerSchema:s,unregisterSchema:l}=W(),u=ee(e),c=ee(r),i=u!==null?o[u]:null,y=d.useMemo(()=>Ae(i),[u,i]),v=k.useWatch({control:n,name:y,defaultValue:{}}),w=d.useMemo(()=>{const b={};return y.forEach((p,R)=>{b[p]=Array.isArray(v)?v[R]:v}),b},[v,y]),m=d.useMemo(()=>{if(!i)return{sections:[],fields:{active:[],readonly:[],hidden:[]}};const b=we(i.sections.active,i.sections.readonly,i.sections.rules,c,w);let p=[...b.readonly.map(x=>({name:x,mode:"readonly"})),...b.active.map(x=>({name:x,mode:"active"}))];p=Ee(i.sections.order,p);const R=be({active:i.fields.active,readonly:i.fields.readonly,hidden:i.fields.hidden},i.fields.rules,c,w);return{sections:p,fields:R}},[i,c,w,a]);return d.useEffect(()=>{const b=m.sections.filter(p=>p.mode==="active").map(p=>p.name);b.forEach(p=>{const R=a?.[p]?.schema;R&&s(p,R)}),Object.keys(a??{}).filter(p=>!b.includes(p)).forEach(l)},[m.sections,a,s,l]),m}function Re(){if(typeof document>"u")return{};const e={};return document.querySelectorAll("input[type='radio'][name]").forEach(r=>{const n=r,o=n.getAttribute("name");o&&n.checked&&(e[o]=n.value)}),document.querySelectorAll("input[name], textarea[name], select[name]").forEach(r=>{const n=r,o=n.getAttribute("name");if(!o||e[o]!==void 0)return;const a=n.getAttribute("value")??n.value??n.textContent??"";e[o]=String(a).trim()}),document.querySelectorAll("span[name]").forEach(r=>{const n=r,o=n.getAttribute("name");if(o){const a=n.textContent?.trim()??"";a!==""&&(e[o]=a)}}),e}const re=()=>typeof window>"u"?null:new URLSearchParams(window.location.search).get("edit"),_e=()=>typeof window>"u"||!window.top?null:window.top.ECM?.workflowView?"process":"document",Te=()=>{if(_e()==="process"){const r=window.top?.ECM?.workflowView;if(!r)return!1;const n=r.newRequest??r.isNewRequest,o=r.colleagueLogin;return n===!0||!!o&&o.trim()!==""}return re()===null},xe=()=>re()==="true",ne=d.createContext(null);function ke({children:e,devConfig:r}){const[n,o]=d.useState(null),a=d.useMemo(()=>Re()??{},[]);return d.useEffect(()=>{let s=!0;return(async()=>{const u=typeof window<"u"&&window.location.hostname==="localhost",c=typeof window<"u"&&window.self!==window.top;let i=null;try{const m=await _.parentProxy.top.ECM.workflowView.sequence;m!=null&&(i=Number(m),r?.showDebugLogs&&console.log("[FluigRuntime] Atividade:",i))}catch(m){console.warn("[FluigRuntime] Falha ao detectar atividade:",m)}const y=!u&&c&&!(Te()||xe()),v={isView:y,isReadOnly:y,activityId:i,previousActivityId:null,prefilledValues:a,showDebugSubmit:!1,showDebugLogs:!1,isDev:!1};let w=v;if(r?.enabled){const m=r.isView??v.isView;w={...v,...r,isView:m,isReadOnly:m,isDev:!0,activityId:r.activityId!==void 0?r.activityId:i}}typeof window<"u"&&(window.__FLUIG_DEBUG_ENABLED__=w.showDebugLogs),w.showDebugLogs&&s&&(_.DebugLogger.header("Runtime Initialized"),_.DebugLogger.table("State",{"Detected Activity":i,"Final Activity":w.activityId,"Dev Mode":w.isDev}),_.DebugLogger.end()),s&&o(w)})(),()=>{s=!1}},[r,a]),n?S.jsx(ne.Provider,{value:n,children:e}):null}function V(){const e=d.useContext(ne);if(!e)throw new Error("useFluigRuntime deve ser usado dentro de <FluigRuntimeProvider>");return e}function Ce(e){const{activityId:r,previousActivityId:n}=V();d.useEffect(()=>{r!=null&&e.setValue("CURRENTACTIVITYID",r),n!=null&&e.setValue("LASTACTIVITYID",n)},[r,n,e]),d.useEffect(()=>{if(typeof window>"u")return;const o=window.top?.document.getElementById("send-process-button")||window.parent?.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()}},a=>{console.error("[Validation Errors]",a),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 Ie=({workflowStructure:e,sectionsRegistry:r,className:n})=>{const{control:o,handleSubmit:a,register:s,setValue:l,getValues:u}=k.useFormContext(),c=V(),i=d.useRef(!1);d.useEffect(()=>{i.current||(c.activityId!=null&&l("CURRENTACTIVITYID",c.activityId),c.previousActivityId!=null&&l("LASTACTIVITYID",c.previousActivityId),i.current=!0)},[c,l]);const{sections:y,fields:v}=Se({control:o,activityId:c.activityId,previousActivityId:c.previousActivityId,workflowStructure:e,sectionsRegistry:r}),w=m=>{console.log("✅ [FluigWorkflowForm] Dados válidos:",m)};return S.jsxs("form",{id:"fluig-react-form",className:n,onSubmit:a(w),noValidate:!0,children:[S.jsxs("div",{className:"hidden",style:{display:"none"},children:[S.jsx("input",{type:"hidden",...s("CURRENTACTIVITYID")}),S.jsx("input",{type:"hidden",...s("LASTACTIVITYID")})]}),y.length===0&&c.activityId!==null&&S.jsxs("p",{children:["Não foi possível encontrar a atividade: ",String(c.activityId)]}),y.map(({name:m,mode:b})=>{if(b==="hidden")return null;const p=r[m];if(!p)return null;const R=p.Component;return S.jsx(R,{id:m,fields:v,readOnly:b==="readonly"},m)}),c.isDev&&c.showDebugSubmit&&S.jsx("div",{style:{width:"100%",padding:"16px",paddingTop:"0"},children:S.jsx("button",{type:"submit",className:"btn btn-primary btn-lg btn-block",children:"Submit (Debug)"})})]})},Pe=e=>{const{mergedSchema:r}=W(),n=V(),o=k.useForm({resolver:r?pe(r):void 0,defaultValues:n.prefilledValues,mode:"onBlur"});return Ce(o),d.useEffect(()=>{n.showDebugLogs&&(_.DebugLogger.header("Form Initialized"),_.DebugLogger.table("Prefilled Values (DOM Capture)",n.prefilledValues),_.DebugLogger.info("RHF Current Values",o.getValues()),_.DebugLogger.end())},[n.showDebugLogs,n.prefilledValues,o]),S.jsx(k.FormProvider,{...o,children:S.jsx(Ie,{...e})})};async function Fe(e){if(!e)return console.warn("[setFluigNextActivity] Nenhuma atividade informada."),!1;const{wfView:r,wkfView:n}=await je();if(!r||!n)return!1;Oe(r);const o=Number(e),a=Ve(r,o);return a?(Ne(r,n,a,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:",r.availableStatesCOPY||r.availableStates),!1)}async function je(){const e=await _.parentProxy.top.ECM.workflowView,r=await _.parentProxy.top.ECM_WKFView;return!e||!r?(console.warn("[setFluigNextActivity] Contexto Fluig inválido ou não carregado."),{}):{wfView:e,wkfView:r}}function Oe(e){e.availableStatesCOPY||(e.availableStatesCOPY=e.availableStates)}function Ve(e,r){return(e.availableStatesCOPY||e.availableStates)?.find(o=>o.sequence===r)}function Ne(e,r,n,o){e.availableUsers.users=[],e.availableStates=[n],r.selectActivity=()=>o}const oe=d.createContext(null);function De(){const e=d.useContext(oe);if(!e)throw new Error("useSection deve ser usado dentro de um componente <Section>");return e}function Le({id:e,className:r,schema:n,children:o,form:a,prefilledValues:s,readOnly:l,fields:u={},hidden:c=!1}){const{isView:i,activityId:y}=V(),v=y,w=k.useFormContext(),m=a||w;if(!m)return console.error(`[FluigWorkflowReact] Section "${e}" não encontrou o 'form'.`),null;if(c)return null;const b=d.useCallback(T=>u.hidden?.includes(T)?"hidden":u.readonly?.includes(T)?"readonly":u.active?.includes(T)?"active":l?"readonly":"active",[u,l]),p=d.useCallback(T=>b(T)==="hidden",[b]),R=d.useCallback(T=>b(T)==="readonly",[b]),x=d.useCallback(T=>{if(!T)return;const C=m.getValues("CURRENTACTIVITYID");m.setValue("LASTACTIVITYID",C),m.setValue("CURRENTACTIVITYID",v),Fe(Number(T))},[m,v]);d.useEffect(()=>{if(!i||!s||!n||!m)return;const T=m.getValues(),C=n.shape;C&&Object.entries(C).forEach(([M,B])=>{let I=B;for(;I?._def?.schema;)I=I._def.schema;const N=I?._def?.fluig;if(N?.type!=="options"||!Array.isArray(N.values)||T[M]!==void 0)return;const P={};N.values.forEach(Y=>{P[Y]=s[Y]==="on"}),m.setValue(M,P,{shouldDirty:!1,shouldValidate:!1})})},[i,s,n,m]);const z=d.useMemo(()=>({id:e,form:m,isHidden:p,isReadOnly:R,isView:i,next:x,wf_activity_id:v}),[e,m,p,R,i,x,v]);return S.jsx(oe.Provider,{value:z,children:S.jsx("section",{id:e,className:[e,r].filter(Boolean).join(" "),children:o})})}const ae=d.createContext(null);function Me({children:e,config:r}){const n=d.useMemo(()=>_.createFluigClient(r),[r]);return S.jsx(ae.Provider,{value:n,children:e})}function Ye(){const e=d.useContext(ae);if(!e)throw new Error("useFluigApi deve ser usado dentro de um <FluigApiProvider>");return e}function Ue(e){return e._def?.schema??e}function We(e){let r=e._def?.fluig;if(r?.values)return r.values;const n=Ue(e);if(n!==e&&(r=n._def?.fluig,r?.values))return r.values;const o=n._def;return(o?.meta??o?.metadata)?.fluig?.values??null}function ze(e){return e?._def?.typeName!=="ZodObject"?[]:Object.entries(e.shape)}function Be(e){const r=new Set;return(Array.isArray(e)?e:Object.values(e).map(o=>o.schema).filter(Boolean)).forEach(o=>{let a=o;for(;a._def?.schema;)a=a._def.schema;a._def?.typeName==="ZodObject"&&ze(a).forEach(([s,l])=>{r.add(s);const u=We(l);u?.length&&u.forEach(c=>r.add(c))})}),Array.from(r)}function Ge(e){const r=Be(e),n=r.map(o=>`<input type="hidden" name="${o}" />`).join(`
7
+ `);return console.log(D.blue.bold(`
8
+ === Inputs gerados (Build Script) ===
9
+ `)),r.forEach((o,a)=>{console.log(`${D.yellow(a+1+".")} ${D.green(o)}`)}),console.log(D.blue.bold(`
10
+ =====================================
11
+ `)),`<!DOCTYPE html>
12
+ <html lang="pt-br">
13
+ <head>
14
+ <meta charset="UTF-8">
15
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
16
+ <title>Workflow Fluig</title>
17
+
18
+ <link rel="stylesheet" href="/portal/style-guide/css/fluig-style-guide.min.css">
19
+
20
+ <link rel="stylesheet" crossorigin href="./main.css">
21
+ </head>
22
+ <body>
23
+ <form id="form" name="form">
24
+ <div id="root">
25
+ ${n}
26
+ </div>
27
+ </form>
28
+
29
+ <script src="./bundle.js"><\/script>
30
+ </body>
31
+ </html>`}Object.defineProperty(g,"DebugLogger",{enumerable:!0,get:()=>_.DebugLogger}),Object.defineProperty(g,"createFluigClient",{enumerable:!0,get:()=>_.createFluigClient}),Object.defineProperty(g,"parentProxy",{enumerable:!0,get:()=>_.parentProxy}),g.FluigApiProvider=Me,g.FluigRuntimeProvider=ke,g.FluigWorkflowForm=Pe,g.SchemaRegistryProvider=he,g.Section=Le,g.generateHtmlTemplate=Ge,g.useFluigApi=Ye,g.useFluigRuntime=V,g.useSchemaRegistry=W,g.useSection=De,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,166 @@
1
+ import { createFluigClient } from '@fluig-kit/core';
2
+ import { DebugLogger } from '@fluig-kit/core';
3
+ import { default as default_2 } from 'react';
4
+ import { FluigClient } from '@fluig-kit/core';
5
+ import { FluigClientConfig } from '@fluig-kit/core';
6
+ import { JSX } from 'react/jsx-runtime';
7
+ import { parentProxy } from '@fluig-kit/core';
8
+ import { ReactNode } from 'react';
9
+ import { UseFormReturn } from 'react-hook-form';
10
+ import { ZodObject } from 'zod';
11
+ import { ZodType } from 'zod';
12
+ import { ZodTypeAny } from 'zod';
13
+
14
+ export declare interface ActivityConfig {
15
+ sections: SectionConfig;
16
+ fields: FieldConfig;
17
+ }
18
+
19
+ export { createFluigClient }
20
+
21
+ export { DebugLogger }
22
+
23
+ export declare interface FieldConfig {
24
+ active: string[];
25
+ readonly: string[];
26
+ hidden: string[];
27
+ rules?: Rule[];
28
+ }
29
+
30
+ declare type FieldModeOverrides = {
31
+ hidden?: string[];
32
+ readonly?: string[];
33
+ active?: string[];
34
+ };
35
+
36
+ export declare function FluigApiProvider({ children, config }: FluigApiProviderProps): JSX.Element;
37
+
38
+ declare interface FluigApiProviderProps {
39
+ children: ReactNode;
40
+ /** Configuração de conexão (URL base e Proxy) */
41
+ config: FluigClientConfig;
42
+ }
43
+
44
+ export { FluigClient }
45
+
46
+ export { FluigClientConfig }
47
+
48
+ export declare type FluigRuntimeDevConfig = Partial<Omit<FluigRuntimeState, "prefilledValues" | "isReadOnly">> & {
49
+ enabled?: boolean;
50
+ };
51
+
52
+ export declare function FluigRuntimeProvider({ children, devConfig, }: FluigRuntimeProviderProps): JSX.Element | null;
53
+
54
+ declare interface FluigRuntimeProviderProps {
55
+ children: ReactNode;
56
+ devConfig?: FluigRuntimeDevConfig;
57
+ }
58
+
59
+ export declare interface FluigRuntimeState {
60
+ isView: boolean;
61
+ isReadOnly: boolean;
62
+ activityId: number | null;
63
+ previousActivityId: number | null;
64
+ prefilledValues: Record<string, any>;
65
+ showDebugSubmit: boolean;
66
+ showDebugLogs: boolean;
67
+ isDev: boolean;
68
+ }
69
+
70
+ /**
71
+ * COMPONENTE PAI: Estável.
72
+ */
73
+ export declare const FluigWorkflowForm: default_2.FC<FluigWorkflowFormProps>;
74
+
75
+ declare interface FluigWorkflowFormProps {
76
+ workflowStructure: WorkflowStructure;
77
+ sectionsRegistry: Record<string, {
78
+ Component: default_2.FC<any>;
79
+ schema?: any;
80
+ }>;
81
+ className?: string;
82
+ debug?: boolean;
83
+ }
84
+
85
+ export declare function generateHtmlTemplate(sectionsRegistry: any): string;
86
+
87
+ export { parentProxy }
88
+
89
+ export declare interface Rule {
90
+ type: "active" | "hidden" | "readonly";
91
+ target: string | string[];
92
+ when?: RuleCondition;
93
+ from?: number | number[];
94
+ }
95
+
96
+ declare interface RuleCondition {
97
+ field: string;
98
+ equals?: any;
99
+ notEquals?: any;
100
+ hasValue?: boolean;
101
+ contains?: any;
102
+ }
103
+
104
+ declare interface SchemaRegistryContextType {
105
+ registerSchema: (id: string, schema: ZodTypeAny) => void;
106
+ unregisterSchema: (id: string) => void;
107
+ mergedSchema: ZodTypeAny;
108
+ }
109
+
110
+ export declare function SchemaRegistryProvider({ children, baseSchema, }: SchemaRegistryProviderProps): JSX.Element;
111
+
112
+ declare interface SchemaRegistryProviderProps {
113
+ children: ReactNode;
114
+ baseSchema?: ZodObject<any>;
115
+ }
116
+
117
+ export declare function Section({ id, className, schema, children, form: propForm, prefilledValues, readOnly, fields, hidden, }: SectionProps): JSX.Element | null;
118
+
119
+ export declare interface SectionConfig {
120
+ order?: string[];
121
+ active: string[];
122
+ readonly: string[];
123
+ rules?: Rule[];
124
+ }
125
+
126
+ declare interface SectionContextType {
127
+ id: string;
128
+ form: UseFormReturn<any>;
129
+ isHidden: (fieldName: string) => boolean;
130
+ isReadOnly: (fieldName: string) => boolean;
131
+ isView: boolean;
132
+ next: (nextActivityId: string | number) => void;
133
+ wf_activity_id: number | null;
134
+ }
135
+
136
+ declare interface SectionProps {
137
+ id: string;
138
+ className?: string;
139
+ schema?: ZodType<any>;
140
+ children?: ReactNode;
141
+ form?: UseFormReturn<any>;
142
+ prefilledValues?: Record<string, any>;
143
+ readOnly?: boolean;
144
+ fields?: FieldModeOverrides;
145
+ hidden?: boolean;
146
+ }
147
+
148
+ /**
149
+ * Hook para acessar a API do Fluig em qualquer componente.
150
+ * Exemplo de uso:
151
+ * const api = useFluigApi();
152
+ * api.get("/ecm/dataset/search", ...).then(...)
153
+ */
154
+ export declare function useFluigApi(): FluigClient;
155
+
156
+ export declare function useFluigRuntime(): FluigRuntimeState;
157
+
158
+ export declare function useSchemaRegistry(): SchemaRegistryContextType;
159
+
160
+ export declare function useSection(): SectionContextType;
161
+
162
+ export declare interface WorkflowStructure {
163
+ [activityId: number]: ActivityConfig;
164
+ }
165
+
166
+ export { }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@fluig-kit/ecm",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./dist/fluig-kit-ecm.umd.js",
6
+ "private": false,
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/fluig-kit-ecm.es.js",
17
+ "require": "./dist/fluig-kit-ecm.umd.js"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "build": "vite build && shx cp ../../README.md ."
22
+ },
23
+ "dependencies": {
24
+ "@fluig-kit/core": "*",
25
+ "chalk": "^4.1.2"
26
+ },
27
+ "peerDependencies": {
28
+ "react": "^18.0.0 || ^19.0.0",
29
+ "react-dom": "^18.0.0 || ^19.0.0",
30
+ "react-hook-form": "^7.0.0",
31
+ "@hookform/resolvers": "^3.0.0",
32
+ "zod": "^3.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@vitejs/plugin-react": "^4.2.1",
36
+ "react": "^19.0.0",
37
+ "react-dom": "^19.0.0",
38
+ "react-hook-form": "^7.54.0",
39
+ "@hookform/resolvers": "^3.10.0",
40
+ "zod": "^3.24.0",
41
+ "@types/react": "^19.0.0",
42
+ "@types/react-dom": "^19.0.0"
43
+ }
44
+ }