Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fox-js/flow

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fox-js/flow - npm Package Compare versions

Comparing version 4.0.1-25 to 4.0.1-26

4

dist/index.cjs.js
"use strict";/*!
* @fox-js/flow v4.0.1-24 Fri Nov 10 2023 10:39:46 GMT+0800 (中国标准时间)
*/Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("vue"),u=require("@fox-js/fox");function he(o){return Object.prototype.toString.call(o)==="[object RegExp]"}const L=Symbol.for("BroadcastKey");class pe{parent;children=[];callbacks=new Map;proxy=null;name;constructor(e,t,s){this.parent=e,this.proxy=t,this.name=s,e!==null&&e.addChild(this)}addChild(e){this.children.push(e)}removeChild(e){const t=this.children.findIndex(s=>e===s);t!==-1&&this.children.splice(t,1)}destroy(){this.parent!==null&&this.parent.removeChild(this),this.parent=null,this.proxy=null}emit(e,t,...s){if(e.maxLevel!==void 0&&e.maxLevel!==null&&e.maxLevel>0){if(e.level=e.level??0,e.level>e.maxLevel)return[];e.level++}let n=!1;!e.name||e.name==="*"?n=!0:!e.name||e.name==="+"?(n=!1,e.name="*"):he(e.name)&&this.name&&e.name.test(this.name)?n=!0:typeof e.name=="function"?n=Reflect.apply(e.name,null,[this.name]):e.name===this.name&&(n=!0);const r=[];if(n){const l=this.callbacks.get(t);if(typeof l=="function"){const a=Reflect.apply(l,this.proxy,[...s]);a!=null&&r.push(a)}const i=this.proxy??{};if(typeof i[t]=="function"){const a=Reflect.apply(i[t],i,[...s]);a!=null&&r.push(a)}}return this.children.forEach(l=>{const i=Reflect.apply(l.emit,l,[{...e},t,...s]);i!=null&&Array.isArray(i)&&Reflect.apply([].push,r,[...i])}),r}emitToChildren(e,t,...s){const n=[];return this.children.forEach(r=>{const l=Reflect.apply(r.emit,r,[{...e},t,...s]);l!=null&&Array.isArray(l)&&Reflect.apply([].push,n,[...l])}),n}on(e,t){this.callbacks.set(e,t)}}function me(o,e,t,s){const n=new pe(e,o,t);if(s&&typeof s=="object")for(const r in s)n.on(r,s[r]);return n}const y="",X=new Map;function xe(o,e=y){X.set(e,o)}function be(o=y){return X.get(o)??null}const S=new WeakMap;function we(o,e,t=y){let s=S.get(o);s||(s=new Map,S.set(o,s)),s.set(t,e)}function ve(o){const e=[],t=S.get(o);return t&&t.forEach((s,n)=>{e.push(s)}),e}function ge(o,e=y){const t=S.get(o);return t?t.get(e)??null:null}function Fe(o,e=y){const t=S.get(o);return t?t.has(e):!1}function Se(o){S.delete(o)}const Y=new Map,T=new WeakMap,k=o=>{let e=T.get(o);if(!e){const t=f.inject(L,null);e=me(o,t),T.set(o,e);const s=o;s[L]=e,f.provide(L,e)}return e},ke=o=>{const e=o;e[L]=null,T.delete(o)},Ce=Symbol.for("SyncDataKey");function Z(o){const e=u.useRoute(o);return e&&e.params?e.params[Ce]??{}:{}}const K="FoxFlow";class Re{data={}}const $=Symbol("nameKey"),O=Symbol("dataKey"),I=Symbol("originalDataKey"),N=Symbol("allDataListKey"),W=Symbol("dataListKey"),U=Symbol("proxyKey");class Ke{[$]=y;[I]={};[O]={};[N]=[];[W]=[];[U]=null;get name(){return this[$]}get originalData(){return this[I]}get data(){return this[O]}get allDataList(){return this[N]}get dataList(){return this[W]}get proxy(){return this[U]}get route(){return u.useRoute(this.proxy??void 0)}}function Ee(o,e){const t=Y.get(e);if(t){let s=o;const n=new t;s.__proto__=n}return o}function De(o,e,t){const s=ve(e);let n=[];!t||t===y?n=[]:Array.isArray(t)?n=t:n=[String(t??"")];const r=[],l={},i={};s.forEach(a=>{const c=String(a.name??"");(n.length===0||n.includes(c))&&(r.push(a),Object.assign(l,a.original),Object.assign(i,a.last))}),o[N]=s,o[W]=r,o[I]=l,o[O]=i,o[U]=e,o[$]=t??y}function ee(o,e,t,...s){const n=k(o);return Reflect.apply(n.emit,n,[e,t,...s])}function te(o,e=!0,t){const s=k(o);let n=null;if(!t||t===y)t=void 0,n={maxLevel:1,level:1};else if(Array.isArray(t)){const l=t;n={name:i=>l.includes(i)}}else n={name:String(t)};const r=s.emitToChildren(n,"validate",e);return r.length==1?r[0]:r.length>1?Promise.all(r).then(l=>{let i=[];return l.forEach(a=>{a.pass===!1&&Array.isArray(a.errors)&&(i=[...i,...a.errors])}),i.length>0?{pass:!1,errors:i}:{pass:!0}}):Promise.resolve({pass:!0})}function oe(o,e=!0,t){const s=k(o);let n=null;if(!t||t===y)t=void 0,n={maxLevel:1,level:1};else if(Array.isArray(t)){const r=t;n={name:l=>r.includes(l)}}else n={name:String(t)};s.emitToChildren(n,"clearValidate",e)}function ne(o,e,t=!0){const s=k(o),n={maxLevel:1,level:1};s.emitToChildren(n,"setNameValidateRules",e,t)}const Ae=o=>`_fox_ctrl_${o.path}_${o.root}`,Le=["beforeBack","back"],z="getShareBus",J="havePermission",Me=["beforeExit","exit"],Pe=["setCheckConditions","check"],je="cancelSubmit",Ve="endSubmit";let se=["preSubmit","commit","submit","postSubmit"],M=[];function re(o){se=[...o]}function le(o){M=[...o]}let P=null;function ie(o){P=o}const Be="foxOpenType";let He=o=>{const e=u.useRoute(o);return e&&e.params?e.params[Be]??"normal":"normal"};const b=Symbol("eventChainKey"),w=Symbol("sessionKey"),h=Symbol("proxyKey"),D=Symbol("userFlowKey"),v=Symbol("flowKey"),g=Symbol("stateKey"),V=Symbol("flowNameKey"),A=Symbol("allowResubmit"),F=Symbol("_getFlowEventChain"),p=Symbol("_getFlow"),B=Symbol("_reset"),ae=Symbol("_destroy"),m=Symbol("_execHook");function _e(o){return o==null?!1:o===!1?!0:typeof o=="object"&&Reflect.has(o,"pass")?!o.pass:!1}const R=function(o,e){return(s,...n)=>{try{const r=Reflect.apply(o,e,[s,...n]);u.isPromise(r)&&r.then(l=>{_e(l)?s.reject(l):s.resolve(l)}).catch(l=>{s.reject(l)})}catch(r){console.error(`[${K}] exec hook error`,r),s.reject(r)}}};class ce{[b]=null;[w]=new Re;[h];[D];[v]=null;[g]="none";[V]="";[A]=!1;constructor(e,t){this[D]=e,this[h]=t}[F](e=!1){return e?new u.EventChain(this[w],!0):this[b]?this[b]:(this[b]=new u.EventChain(this[w],!0),this[b])}[p](e){if(!this[v]){const t=He(this[h]);this[v]=Ee(this[D],t)}return De(this[v],this[h],e),this[v]}[B](){this[b]=null,this[g]="none"}[m](e,t){const s=this[p](t);if(Array.isArray(e)){const n=this[F](!0);e.forEach(r=>{const l=s[r];if(typeof l=="function"){const i=R(l,s);n?.post(i)}})}else{const n=s[e];if(typeof n=="function")return Reflect.apply(n,s,[this[w]])}}pretreat(e){return this[g]==="submit"?(console.warn(`[${K}]流程已经处于提交状态,无法加入预处理任务`),!1):(this[F]()?.post(e),this[g]="pretreat",!0)}[ae](){const e=this;e[b]=null,e[w]=null,e[h]=null,e[D]=null,e[v]=null}get name(){return this[V]??""}set allowResubmit(e){this[A]=e}get allowResubmit(){return this[A]}submit(e,t){if(typeof e=="string"&&(t=e,e=void 0),this[V]=t??"",!this[A]&&this[g]==="submit")return console.warn(`[${K}]流程已经处于提交状态,无法重复提交`),!1;e&&typeof e=="object"&&Object.assign(this[w].data,e);const s=this[F]();if(this[g]==="pretreat"&&P){try{P.lock()}catch{}s?.post(r=>{P?.unlock(),r.resolve()})}const n=this[p](t);Pe.forEach(r=>{const l=n[r];typeof l=="function"&&s?.post(R(l,n))}),se.forEach(r=>{const l=n[r];typeof l=="function"&&s?.post(R(l,n))}),s?.wait((r,...l)=>{this[B]();const i=n[Ve];typeof i=="function"&&Reflect.apply(i,n,[r,...l])},(r,...l)=>{this[B]();const i=()=>{const a=n[je];typeof a=="function"&&Reflect.apply(a,n,[r,...l])};if(Array.isArray(M)&&M.length>0){const a=this[F](!0);M.forEach(c=>{const C=n[c];typeof C=="function"&&a?.post(R(C,n))}),a?.wait(()=>i,()=>i)}else i()})}exit(e){return new Promise((t,s)=>{const n=this[F](!0),r=this[p](e);Me.forEach(l=>{const i=r[l];typeof i=="function"&&n?.post(R(i,r))}),n?.wait((l,...i)=>{t(!0)},(l,...i)=>{t(!0)})})}back(e){return this[m](Le,e),!0}exec(e,t){return this[m](e,t)}getShareBus(e){const t=this[p](e);return typeof t[z]=="function"?Reflect.apply(t[z],t,[]):null}havePermission(e){const t=this[p]();return typeof t[J]=="function"?Reflect.apply(t[J],t,[e]):!0}setValue(e,t,s){const n=this[p](s??"");if(Array.isArray(n.allDataList)){for(let r of n.allDataList)if(r.name===s){r.last[e]=t;break}}}getValue(e,t){let s=null;const n=this[p](t??"");if(Array.isArray(n.allDataList)){for(let r of n.allDataList)if(r.name===t){s=r.last[e];break}}return s}get allDataList(){return this[p]().allDataList}get dataList(){return this[p]().dataList}getDataRecordByFieldName(e){return this.allDataList.find(n=>Reflect.ownKeys(n.last).includes(e))??null}broadcast(e,t,...s){return Reflect.apply(ee,null,[this[h],e,t,...s])}resetFields(e,t){let s=[];Array.isArray(t)?s=t:typeof t=="string"?s=[t]:s=[y];const n=this[h];s.forEach(r=>{const l=ge(n,r)??{original:{},last:{}},i={};if(u.extend(!0,i,l.original),Array.isArray(e))e.forEach(a=>{l.last[a]=i[a]});else if(e&&Array.isArray(e.include))(e.include??[]).forEach(c=>{l.last[c]=i[c]});else if(e&&Array.isArray(e.exclude)){let a=e.exclude??[];Reflect.ownKeys(i).forEach(c=>{typeof c=="string"&&(a.includes(c)||(l.last[c]=i[c]))})}else Object.assign(l.last,i)}),this.clearValidate(e,t)}validate(e=!0,t){return te(this[h],e,t)}clearValidate(e=!0,t){return oe(this[h],e,t)}setNameValidateRules(e,t=!0){return ne(this[h],e,t)}}const ue=Symbol.for("FoxControllerKey"),Te=Symbol.for("PageWrapperKey"),G=new WeakMap;let x=[];function $e(o,e){const t=f.toRaw(o);xe(t,e)}function Oe(o,e,t){let s=t,n,r;const l={};if(typeof e=="string"?n=e:e&&typeof e=="object"&&(n=e.name,r=e.mixin,Object.assign(l,e)),!s){const d=f.getCurrentInstance();if(d===null)throw new Error("defineData must in setup hook");if(d.proxy==null)throw new Error("proxy is null");s=d.proxy}if(Fe(s,n))throw new Error("duplicate definitions are not allowed, please Set different name!");const i=f.toRaw(o),a=be(r);a&&u.extend(!0,i,a);const c=Z(s);if(!n)u.extend(!0,i,c);else{const d=c[n];d&&typeof d=="object"&&u.extend(!0,i,d)}const C={};u.extend(!0,C,i);const E=f.reactive(i);if(we(s,{name:n??y,metadata:l,original:C,last:E},n),s){const d=k(s),q=()=>{n?d?.emitToChildren({name:n},"setModelValue",E):d?.emitToChildren({maxLevel:1,level:1},"setModelValue",E)};s.$.isMounted?q():f.onMounted(q)}return E}function Ie(o={},e){if(!e){const a=f.getCurrentInstance();if(a===null)throw new Error("defineData must in setup hook");if(a.proxy===null)throw new Error("proxy is null");e=a.proxy}k(e);const t=new ce(o,e);x.push({proxy:e,controller:t,state:"create"});const s=u.useEventProxy(e);let n=null,r=null;const l=u.useRoute(e);l&&l.path&&(r=Ae(l),n=(a,c)=>{a==="exit"?t.exit(c):a==="submit"&&t.submit(c)},s.on(r,n)),f.onBeforeMount(()=>{t[m]("beforeMount")}),f.onMounted(()=>{e&&We(e,"mounted"),t[m](["mounted","endMounted"])}),f.onBeforeUnmount(()=>{t[m]("beforeUnmount")}),f.onUnmounted(()=>{t[m]("unmounted"),t[ae](),e&&(Ue(e),ke(e),G.delete(e),Se(e)),r&&n&&s.off(r,n)}),u.onFoxActivated(()=>{t[m]("activated")}),u.onFoxInactivated(()=>{t[m]("inactivated")});const i=f.inject(Te,null);i&&typeof i.beforeClose!="function"&&(i.used||(i.used=!0,i.beforeClose=async a=>{await t.exit(),typeof a=="function"&&a()}));try{t[m]("created")}catch(a){console.error(`[${K}] created error`,a)}return G.set(e,t),u.provideContextValue(e,ue,t),t}function Ne(o){let e=null;return o&&(e=G.get(o)??null),e||(o||(o=f.getCurrentInstance()?.proxy??void 0),o&&(e=u.injectContextValue(o,ue))),e}function We(o,e){for(let t=x.length-1;t>=0;t--){const s=x[t];if(s.proxy===o){s.state=e;break}}}function Ue(o){const e=x.findIndex(t=>t.proxy===o);e!==-1&&x.splice(e,1)}function j(o){if(!o){const e=x.length-1;if(e>=0){const t=x[e];if(t.state==="create")return t}return null}for(let e=x.length-1;e>=0;e--){const t=x[e];if(t.proxy&&t.proxy.$el){const s=t.proxy.$el;if(s===o||s.contains(o))return t}}return null}function Ge(o){if(!o){const e=f.getCurrentInstance();if(e===null)throw new Error("getSyncData must in setup hook");if(e.proxy===null)throw new Error("proxy is null");o=e.proxy}return Z(o)}const fe=o=>{let{key:e,shiftKey:t,altKey:s,ctrlKey:n}=o,r=[];return t&&r.push("Shift"),s&&r.push("Alt"),n&&r.push("Ctrl"),r.push(e),r.join("+").toLocaleUpperCase()},ye=(o,e="Enter")=>{let t=[o.arg??e];return o.modifiers.Shift?t.splice(0,0,"Shift"):o.modifiers.Alt?t.splice(0,0,"Alt"):o.modifiers.Ctrl&&t.splice(0,0,"Ctrl"),t.join("+").toLocaleUpperCase()},H=new WeakMap,qe={mounted(o,e,t,s){const n=ye(e,"ENTER"),r=j(o),l=e.value??{},i=a=>{const c=fe(a);r&&r.controller&&c===n&&r.controller.submit(l)};o.addEventListener("keyup",i),H.set(o,i)},beforeUnmount(o,e,t,s){const n=H.get(o);H.delete(o),n&&o.removeEventListener("keyup",n)}},_=new WeakMap,ze={mounted(o,e,t,s){const n=ye(e,"ESCAPE"),r=j(o),l=e.value??{},i=a=>{const c=fe(a);r&&r.controller&&c===n&&r.controller.exit(l)};o.addEventListener("keyup",i),_.set(o,i)},beforeUnmount(o,e,t,s){const n=_.get(o);_.delete(o),n&&o.removeEventListener("keyup",n)}},Q=(o,e,t)=>{t?e==="disabled"&&o.hasAttribute("disabled")?o.removeAttribute("disbaled"):o.style.display==="none"&&(o.style.display="block"):e==="disabled"?o.setAttribute("disabled",!0):o.style.display="none"},Je={mounted(o,e,t,s){const n=e.arg??"show";let r=e.value;r||(r=o.dataset.permission??[]),f.watchEffect(()=>{const l=j(o);if(l&&l.controller){const i=l.controller.havePermission(r);u.isPromise(i)?i.then(a=>{Q(o,n,a)}):Q(o,n,i)}})}},Qe={install(o){o.directive("submit",qe),o.directive("exit",ze),o.directive("permission",Je)}};function de(o,e){Y.set(o,e)}const Xe={install(o,e={}){if(e.pretreatLocker&&ie(e.pretreatLocker),e.customSubmitFlowHooks&&re(e.customSubmitFlowHooks),e.customCancelSubmitFlowHooks&&le(e.customCancelSubmitFlowHooks),e.systemFlows)for(let t in e.systemFlows){let s=e.systemFlows[t];de(t,s)}Qe.install(o)}};exports.BaseFlow=Ke;exports.DefaultKey=y;exports.FoxController=ce;exports.TAG=K;exports.default=Xe;exports.defineFoxController=Ie;exports.defineFoxData=Oe;exports.defineFoxMixinData=$e;exports.execBroadcast=ee;exports.execClearValidate=oe;exports.execSetNameValidateRules=ne;exports.execValidate=te;exports.setCustomCancelSubmitFlowHooks=le;exports.setCustomSubmitFlowHooks=re;exports.setFoxSystemFlow=de;exports.setPretreatLocker=ie;exports.useFoxContext=j;exports.useFoxController=Ne;exports.useFoxSyncData=Ge;
* @fox-js/flow v4.0.1-25 Fri Nov 24 2023 13:56:02 GMT+0800 (中国标准时间)
*/Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("vue"),u=require("@fox-js/fox");function pe(o){return Object.prototype.toString.call(o)==="[object RegExp]"}const L=Symbol.for("BroadcastKey");class me{parent;children=[];callbacks=new Map;proxy=null;name;constructor(e,t,s){this.parent=e,this.proxy=t,this.name=s,e!==null&&e.addChild(this)}addChild(e){this.children.push(e)}removeChild(e){const t=this.children.findIndex(s=>e===s);t!==-1&&this.children.splice(t,1)}destroy(){this.parent!==null&&this.parent.removeChild(this),this.parent=null,this.proxy=null}emit(e,t,...s){if(e.maxLevel!==void 0&&e.maxLevel!==null&&e.maxLevel>0){if(e.level=e.level??0,e.level>e.maxLevel)return[];e.level++}let n=!1;!e.name||e.name==="*"?n=!0:!e.name||e.name==="+"?(n=!1,e.name="*"):pe(e.name)&&this.name&&e.name.test(this.name)?n=!0:typeof e.name=="function"?n=Reflect.apply(e.name,null,[this.name]):e.name===this.name&&(n=!0);const r=[];if(n){const l=this.callbacks.get(t);if(typeof l=="function"){const a=Reflect.apply(l,this.proxy,[...s]);a!=null&&r.push(a)}const i=this.proxy??{};if(typeof i[t]=="function"){const a=Reflect.apply(i[t],i,[...s]);a!=null&&r.push(a)}}return this.children.forEach(l=>{const i=Reflect.apply(l.emit,l,[{...e},t,...s]);i!=null&&Array.isArray(i)&&Reflect.apply([].push,r,[...i])}),r}emitToChildren(e,t,...s){const n=[];return this.children.forEach(r=>{const l=Reflect.apply(r.emit,r,[{...e},t,...s]);l!=null&&Array.isArray(l)&&Reflect.apply([].push,n,[...l])}),n}on(e,t){this.callbacks.set(e,t)}}function xe(o,e,t,s){const n=new me(e,o,t);if(s&&typeof s=="object")for(const r in s)n.on(r,s[r]);return n}const y="",X=new Map;function be(o,e=y){X.set(e,o)}function we(o=y){return X.get(o)??null}const S=new WeakMap;function ve(o,e,t=y){let s=S.get(o);s||(s=new Map,S.set(o,s)),s.set(t,e)}function ge(o){const e=[],t=S.get(o);return t&&t.forEach((s,n)=>{e.push(s)}),e}function Fe(o,e=y){const t=S.get(o);return t?t.get(e)??null:null}function Se(o,e=y){const t=S.get(o);return t?t.has(e):!1}function ke(o){S.delete(o)}const Y=new Map,T=new WeakMap,k=o=>{let e=T.get(o);if(!e){const t=f.inject(L,null);e=xe(o,t),T.set(o,e);const s=o;s[L]=e,f.provide(L,e)}return e},Ce=o=>{const e=o;e[L]=null,T.delete(o)},Re=Symbol.for("SyncDataKey");function Z(o){const e=u.useRoute(o);return e&&e.params?e.params[Re]??{}:{}}const E="FoxFlow";class Ee{data={}}const $=Symbol("nameKey"),N=Symbol("dataKey"),O=Symbol("originalDataKey"),I=Symbol("allDataListKey"),W=Symbol("dataListKey"),U=Symbol("proxyKey");class Ke{[$]=y;[O]={};[N]={};[I]=[];[W]=[];[U]=null;get name(){return this[$]}get originalData(){return this[O]}get data(){return this[N]}get allDataList(){return this[I]}get dataList(){return this[W]}get proxy(){return this[U]}get route(){return u.useRoute(this.proxy??void 0)}}function De(o,e){const t=Y.get(e);if(t){let s=o;const n=new t;s.__proto__=n}return o}function Ae(o,e,t){const s=ge(e);let n=[];!t||t===y?n=[]:Array.isArray(t)?n=t:n=[String(t??"")];const r=[],l={},i={};s.forEach(a=>{const c=String(a.name??"");(n.length===0||n.includes(c))&&(r.push(a),Object.assign(l,a.original),Object.assign(i,a.last))}),o[I]=s,o[W]=r,o[O]=l,o[N]=i,o[U]=e,o[$]=t??y}function ee(o,e,t,...s){const n=k(o);return Reflect.apply(n.emit,n,[e,t,...s])}function te(o,e=!0,t){const s=k(o);let n=null;if(!t||t===y)t=void 0,n={maxLevel:1,level:1};else if(Array.isArray(t)){const l=t;n={name:i=>l.includes(i)}}else n={name:String(t)};const r=s.emitToChildren(n,"validate",e);return r.length==1?r[0]:r.length>1?Promise.all(r).then(l=>{let i=[];return l.forEach(a=>{a.pass===!1&&Array.isArray(a.errors)&&(i=[...i,...a.errors])}),i.length>0?{pass:!1,errors:i}:{pass:!0}}):Promise.resolve({pass:!0})}function oe(o,e=!0,t){const s=k(o);let n=null;if(!t||t===y)t=void 0,n={maxLevel:1,level:1};else if(Array.isArray(t)){const r=t;n={name:l=>r.includes(l)}}else n={name:String(t)};s.emitToChildren(n,"clearValidate",e)}function ne(o,e,t=!0){const s=k(o),n={maxLevel:1,level:1};s.emitToChildren(n,"setNameValidateRules",e,t)}const se=o=>`_fox_ctrl_${o.path??o.name??""}_${o.root??"default"}`,Le=["beforeBack","back"],z="getShareBus",J="havePermission",Me=["beforeExit","exit"],Pe=["setCheckConditions","check"],je="cancelSubmit",Ve="endSubmit";let re=["preSubmit","commit","submit","postSubmit"],M=[];function le(o){re=[...o]}function ie(o){M=[...o]}let P=null;function ae(o){P=o}const He="foxOpenType";let Be=o=>{const e=u.useRoute(o);return e&&e.params?e.params[He]??"normal":"normal"};const b=Symbol("eventChainKey"),w=Symbol("sessionKey"),p=Symbol("proxyKey"),D=Symbol("userFlowKey"),v=Symbol("flowKey"),g=Symbol("stateKey"),V=Symbol("flowNameKey"),A=Symbol("allowResubmit"),F=Symbol("_getFlowEventChain"),m=Symbol("_getFlow"),H=Symbol("_reset"),ce=Symbol("_destroy"),d=Symbol("_execHook");function _e(o){return o==null?!1:o===!1?!0:typeof o=="object"&&Reflect.has(o,"pass")?!o.pass:!1}const R=function(o,e){return(s,...n)=>{try{const r=Reflect.apply(o,e,[s,...n]);u.isPromise(r)&&r.then(l=>{_e(l)?s.reject(l):s.resolve(l)}).catch(l=>{s.reject(l)})}catch(r){console.error(`[${E}] exec hook error`,r),s.reject(r)}}};class ue{[b]=null;[w]=new Ee;[p];[D];[v]=null;[g]="none";[V]="";[A]=!1;constructor(e,t){this[D]=e,this[p]=t}[F](e=!1){return e?new u.EventChain(this[w],!0):this[b]?this[b]:(this[b]=new u.EventChain(this[w],!0),this[b])}[m](e){if(!this[v]){const t=Be(this[p]);this[v]=De(this[D],t)}return Ae(this[v],this[p],e),this[v]}[H](){this[b]=null,this[g]="none"}[d](e,t){const s=this[m](t);if(Array.isArray(e)){const n=this[F](!0);e.forEach(r=>{const l=s[r];if(typeof l=="function"){const i=R(l,s);n?.post(i)}})}else{const n=s[e];if(typeof n=="function")return Reflect.apply(n,s,[this[w]])}}pretreat(e){return this[g]==="submit"?(console.warn(`[${E}]流程已经处于提交状态,无法加入预处理任务`),!1):(this[F]()?.post(e),this[g]="pretreat",!0)}[ce](){const e=this;e[b]=null,e[w]=null,e[p]=null,e[D]=null,e[v]=null}get name(){return this[V]??""}set allowResubmit(e){this[A]=e}get allowResubmit(){return this[A]}submit(e,t){if(typeof e=="string"&&(t=e,e=void 0),this[V]=t??"",!this[A]&&this[g]==="submit")return console.warn(`[${E}]流程已经处于提交状态,无法重复提交`),!1;e&&typeof e=="object"&&Object.assign(this[w].data,e);const s=this[F]();if(this[g]==="pretreat"&&P){try{P.lock()}catch{}s?.post(r=>{P?.unlock(),r.resolve()})}const n=this[m](t);Pe.forEach(r=>{const l=n[r];typeof l=="function"&&s?.post(R(l,n))}),re.forEach(r=>{const l=n[r];typeof l=="function"&&s?.post(R(l,n))}),s?.wait((r,...l)=>{this[H]();const i=n[Ve];typeof i=="function"&&Reflect.apply(i,n,[r,...l])},(r,...l)=>{this[H]();const i=()=>{const a=n[je];typeof a=="function"&&Reflect.apply(a,n,[r,...l])};if(Array.isArray(M)&&M.length>0){const a=this[F](!0);M.forEach(c=>{const C=n[c];typeof C=="function"&&a?.post(R(C,n))}),a?.wait(()=>i,()=>i)}else i()})}exit(e){return new Promise((t,s)=>{const n=this[F](!0),r=this[m](e);Me.forEach(l=>{const i=r[l];typeof i=="function"&&n?.post(R(i,r))}),n?.wait((l,...i)=>{t(!0)},(l,...i)=>{t(!0)})})}back(e){return this[d](Le,e),!0}exec(e,t){return this[d](e,t)}getShareBus(e){const t=this[m](e);return typeof t[z]=="function"?Reflect.apply(t[z],t,[]):null}havePermission(e){const t=this[m]();return typeof t[J]=="function"?Reflect.apply(t[J],t,[e]):!0}setValue(e,t,s){const n=this[m](s??"");if(Array.isArray(n.allDataList)){for(let r of n.allDataList)if(r.name===s){r.last[e]=t;break}}}getValue(e,t){let s=null;const n=this[m](t??"");if(Array.isArray(n.allDataList)){for(let r of n.allDataList)if(r.name===t){s=r.last[e];break}}return s}get allDataList(){return this[m]().allDataList}get dataList(){return this[m]().dataList}getDataRecordByFieldName(e){return this.allDataList.find(n=>Reflect.ownKeys(n.last).includes(e))??null}broadcast(e,t,...s){return Reflect.apply(ee,null,[this[p],e,t,...s])}resetFields(e,t){let s=[];Array.isArray(t)?s=t:typeof t=="string"?s=[t]:s=[y];const n=this[p];s.forEach(r=>{const l=Fe(n,r)??{original:{},last:{}},i={};if(u.extend(!0,i,l.original),Array.isArray(e))e.forEach(a=>{l.last[a]=i[a]});else if(e&&Array.isArray(e.include))(e.include??[]).forEach(c=>{l.last[c]=i[c]});else if(e&&Array.isArray(e.exclude)){let a=e.exclude??[];Reflect.ownKeys(i).forEach(c=>{typeof c=="string"&&(a.includes(c)||(l.last[c]=i[c]))})}else Object.assign(l.last,i)}),this.clearValidate(e,t)}validate(e=!0,t){return te(this[p],e,t)}clearValidate(e=!0,t){return oe(this[p],e,t)}setNameValidateRules(e,t=!0){return ne(this[p],e,t)}}const fe=Symbol.for("FoxControllerKey"),Te=Symbol.for("PageWrapperKey"),G=new WeakMap;let x=[];function $e(o,e){const t=f.toRaw(o);be(t,e)}function Ne(o,e,t){let s=t,n,r;const l={};if(typeof e=="string"?n=e:e&&typeof e=="object"&&(n=e.name,r=e.mixin,Object.assign(l,e)),!s){const h=f.getCurrentInstance();if(h===null)throw new Error("defineData must in setup hook");if(h.proxy==null)throw new Error("proxy is null");s=h.proxy}if(Se(s,n))throw new Error("duplicate definitions are not allowed, please Set different name!");const i=f.toRaw(o),a=we(r);a&&u.extend(!0,i,a);const c=Z(s);if(!n)u.extend(!0,i,c);else{const h=c[n];h&&typeof h=="object"&&u.extend(!0,i,h)}const C={};u.extend(!0,C,i);const K=f.reactive(i);if(ve(s,{name:n??y,metadata:l,original:C,last:K},n),s){const h=k(s),q=()=>{n?h?.emitToChildren({name:n},"setModelValue",K):h?.emitToChildren({maxLevel:1,level:1},"setModelValue",K)};s.$.isMounted?q():f.onMounted(q)}return K}function Oe(o={},e){if(!e){const a=f.getCurrentInstance();if(a===null)throw new Error("defineData must in setup hook");if(a.proxy===null)throw new Error("proxy is null");e=a.proxy}k(e);const t=new ue(o,e);x.push({proxy:e,controller:t,state:"create"});const s=u.useEventProxy(e);let n=null,r=null;const l=u.useRoute(e);l&&l.path&&l.root&&(r=se(l),n=(a,c)=>{a==="exit"?t.exit(c):a==="submit"?t.submit(c):a==="execHook"&&typeof c=="string"&&t[d](c)},s.on(r,n)),f.onBeforeMount(()=>{t[d]("beforeMount")}),f.onMounted(()=>{e&&We(e,"mounted"),t[d](["mounted","endMounted"])}),f.onBeforeUnmount(()=>{t[d]("beforeUnmount")}),f.onUnmounted(()=>{t[d]("unmounted"),t[ce](),e&&(Ue(e),Ce(e),G.delete(e),ke(e)),r&&n&&s.off(r,n)}),u.onFoxActivated(()=>{t[d]("activated")}),u.onFoxInactivated(()=>{t[d]("inactivated")});const i=f.inject(Te,null);i&&typeof i.beforeClose!="function"&&(i.used||(i.used=!0,i.beforeClose=async a=>{await t.exit(),typeof a=="function"&&a()}));try{t[d]("created")}catch(a){console.error(`[${E}] created error`,a)}return G.set(e,t),u.provideContextValue(e,fe,t),t}function Ie(o){let e=null;return o&&(e=G.get(o)??null),e||(o||(o=f.getCurrentInstance()?.proxy??void 0),o&&(e=u.injectContextValue(o,fe))),e}function We(o,e){for(let t=x.length-1;t>=0;t--){const s=x[t];if(s.proxy===o){s.state=e;break}}}function Ue(o){const e=x.findIndex(t=>t.proxy===o);e!==-1&&x.splice(e,1)}function j(o){if(!o){const e=x.length-1;if(e>=0){const t=x[e];if(t.state==="create")return t}return null}for(let e=x.length-1;e>=0;e--){const t=x[e];if(t.proxy&&t.proxy.$el){const s=t.proxy.$el;if(s===o||s.contains(o))return t}}return null}function Ge(o){if(!o){const e=f.getCurrentInstance();if(e===null)throw new Error("getSyncData must in setup hook");if(e.proxy===null)throw new Error("proxy is null");o=e.proxy}return Z(o)}const ye=o=>{let{key:e,shiftKey:t,altKey:s,ctrlKey:n}=o,r=[];return t&&r.push("Shift"),s&&r.push("Alt"),n&&r.push("Ctrl"),r.push(e),r.join("+").toLocaleUpperCase()},de=(o,e="Enter")=>{let t=[o.arg??e];return o.modifiers.Shift?t.splice(0,0,"Shift"):o.modifiers.Alt?t.splice(0,0,"Alt"):o.modifiers.Ctrl&&t.splice(0,0,"Ctrl"),t.join("+").toLocaleUpperCase()},B=new WeakMap,qe={mounted(o,e,t,s){const n=de(e,"ENTER"),r=j(o),l=e.value??{},i=a=>{const c=ye(a);r&&r.controller&&c===n&&r.controller.submit(l)};o.addEventListener("keyup",i),B.set(o,i)},beforeUnmount(o,e,t,s){const n=B.get(o);B.delete(o),n&&o.removeEventListener("keyup",n)}},_=new WeakMap,ze={mounted(o,e,t,s){const n=de(e,"ESCAPE"),r=j(o),l=e.value??{},i=a=>{const c=ye(a);r&&r.controller&&c===n&&r.controller.exit(l)};o.addEventListener("keyup",i),_.set(o,i)},beforeUnmount(o,e,t,s){const n=_.get(o);_.delete(o),n&&o.removeEventListener("keyup",n)}},Q=(o,e,t)=>{t?e==="disabled"&&o.hasAttribute("disabled")?o.removeAttribute("disbaled"):o.style.display==="none"&&(o.style.display="block"):e==="disabled"?o.setAttribute("disabled",!0):o.style.display="none"},Je={mounted(o,e,t,s){const n=e.arg??"show";let r=e.value;r||(r=o.dataset.permission??[]),f.watchEffect(()=>{const l=j(o);if(l&&l.controller){const i=l.controller.havePermission(r);u.isPromise(i)?i.then(a=>{Q(o,n,a)}):Q(o,n,i)}})}},Qe={install(o){o.directive("submit",qe),o.directive("exit",ze),o.directive("permission",Je)}};function he(o,e){Y.set(o,e)}const Xe={install(o,e={}){if(e.pretreatLocker&&ae(e.pretreatLocker),e.customSubmitFlowHooks&&le(e.customSubmitFlowHooks),e.customCancelSubmitFlowHooks&&ie(e.customCancelSubmitFlowHooks),e.systemFlows)for(let t in e.systemFlows){let s=e.systemFlows[t];he(t,s)}Qe.install(o)}};exports.BaseFlow=Ke;exports.DefaultKey=y;exports.FoxController=ue;exports.TAG=E;exports.createEventProxyName=se;exports.default=Xe;exports.defineFoxController=Oe;exports.defineFoxData=Ne;exports.defineFoxMixinData=$e;exports.execBroadcast=ee;exports.execClearValidate=oe;exports.execSetNameValidateRules=ne;exports.execValidate=te;exports.setCustomCancelSubmitFlowHooks=ie;exports.setCustomSubmitFlowHooks=le;exports.setFoxSystemFlow=he;exports.setPretreatLocker=ae;exports.useFoxContext=j;exports.useFoxController=Ie;exports.useFoxSyncData=Ge;

@@ -75,2 +75,7 @@ import { App } from 'vue';

/**
* 创建event proxy 名称
*/
export declare const createEventProxyName: (route: EventProxyRoute) => string;
/**
* data key

@@ -138,2 +143,9 @@ */

declare type EventProxyRoute = {
path?: string;
name?: string;
root?: string;
[propName: string]: any;
};
/**

@@ -140,0 +152,0 @@ * 广播

import { inject as Z, provide as fe, toRaw as ee, getCurrentInstance as P, reactive as ye, onMounted as te, onBeforeMount as he, onBeforeUnmount as de, onUnmounted as pe, watchEffect as me } from "vue";
import { useRoute as j, EventChain as J, extend as C, isPromise as oe, useEventProxy as be, onFoxActivated as we, onFoxInactivated as xe, provideContextValue as ve, injectContextValue as ge } from "@fox-js/fox";
/*!
* @fox-js/flow v4.0.1-24 Fri Nov 10 2023 10:39:46 GMT+0800 (中国标准时间)
* @fox-js/flow v4.0.1-25 Fri Nov 24 2023 13:56:02 GMT+0800 (中国标准时间)
*/
function Se(o) {
function ke(o) {
return Object.prototype.toString.call(o) === "[object RegExp]";
}
const D = Symbol.for("BroadcastKey");
class ke {
class Se {
/**

@@ -74,3 +74,3 @@ * parent

let n = !1;
!e.name || e.name === "*" ? n = !0 : !e.name || e.name === "+" ? (n = !1, e.name = "*") : Se(e.name) && this.name && e.name.test(this.name) ? n = !0 : typeof e.name == "function" ? n = Reflect.apply(e.name, null, [this.name]) : e.name === this.name && (n = !0);
!e.name || e.name === "*" ? n = !0 : !e.name || e.name === "+" ? (n = !1, e.name = "*") : ke(e.name) && this.name && e.name.test(this.name) ? n = !0 : typeof e.name == "function" ? n = Reflect.apply(e.name, null, [this.name]) : e.name === this.name && (n = !0);
const r = [];

@@ -118,3 +118,3 @@ if (n) {

function Fe(o, e, t, s) {
const n = new ke(e, o, t);
const n = new Se(e, o, t);
if (s && typeof s == "object")

@@ -154,3 +154,3 @@ for (const r in s)

}
const se = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new WeakMap(), S = (o) => {
const se = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new WeakMap(), k = (o) => {
let e = T.get(o);

@@ -248,3 +248,3 @@ if (!e) {

}
function Ve(o, e) {
function He(o, e) {
const t = se.get(e);

@@ -258,3 +258,3 @@ if (t) {

}
function Be(o, e, t) {
function Ve(o, e, t) {
const s = Re(e);

@@ -269,8 +269,8 @@ let n = [];

}
function He(o, e, t, ...s) {
const n = S(o);
function Be(o, e, t, ...s) {
const n = k(o);
return Reflect.apply(n.emit, n, [e, t, ...s]);
}
function _e(o, e = !0, t) {
const s = S(o);
const s = k(o);
let n = null;

@@ -305,3 +305,3 @@ if (!t || t === u)

function Te(o, e = !0, t) {
const s = S(o);
const s = k(o);
let n = null;

@@ -323,3 +323,3 @@ if (!t || t === u)

function $e(o, e, t = !0) {
const s = S(o), n = {
const s = k(o), n = {
maxLevel: 1,

@@ -330,3 +330,3 @@ level: 1

}
const Oe = (o) => `_fox_ctrl_${o.path}_${o.root}`, We = ["beforeBack", "back"], Q = "getShareBus", X = "havePermission", Ne = ["beforeExit", "exit"], Ue = ["setCheckConditions", "check"], Ie = "cancelSubmit", Ge = "endSubmit";
const Oe = (o) => `_fox_ctrl_${o.path ?? o.name ?? ""}_${o.root ?? "default"}`, We = ["beforeBack", "back"], Q = "getShareBus", X = "havePermission", Ne = ["beforeExit", "exit"], Ue = ["setCheckConditions", "check"], Ie = "cancelSubmit", Ge = "endSubmit";
let le = ["preSubmit", "commit", "submit", "postSubmit"], A = [];

@@ -348,3 +348,3 @@ function qe(o) {

};
const m = Symbol("eventChainKey"), b = Symbol("sessionKey"), y = Symbol("proxyKey"), E = Symbol("userFlowKey"), w = Symbol("flowKey"), x = Symbol("stateKey"), V = Symbol("flowNameKey"), R = Symbol("allowResubmit"), v = Symbol("_getFlowEventChain"), h = Symbol("_getFlow"), B = Symbol("_reset"), ie = Symbol("_destroy"), d = Symbol("_execHook");
const m = Symbol("eventChainKey"), b = Symbol("sessionKey"), h = Symbol("proxyKey"), E = Symbol("userFlowKey"), w = Symbol("flowKey"), x = Symbol("stateKey"), H = Symbol("flowNameKey"), R = Symbol("allowResubmit"), v = Symbol("_getFlowEventChain"), d = Symbol("_getFlow"), V = Symbol("_reset"), ie = Symbol("_destroy"), f = Symbol("_execHook");
function Ye(o) {

@@ -379,3 +379,3 @@ return o == null ? !1 : o === !1 ? !0 : typeof o == "object" && Reflect.has(o, "pass") ? !o.pass : !1;

*/
[y];
[h];
/**

@@ -396,3 +396,3 @@ * user flow

*/
[V] = "";
[H] = "";
/**

@@ -409,3 +409,3 @@ * 是否允许重复提交

constructor(e, t) {
this[E] = e, this[y] = t;
this[E] = e, this[h] = t;
}

@@ -424,8 +424,8 @@ /**

*/
[h](e) {
[d](e) {
if (!this[w]) {
const t = Xe(this[y]);
this[w] = Ve(this[E], t);
const t = Xe(this[h]);
this[w] = He(this[E], t);
}
return Be(this[w], this[y], e), this[w];
return Ve(this[w], this[h], e), this[w];
}

@@ -435,3 +435,3 @@ /**

*/
[B]() {
[V]() {
this[m] = null, this[x] = "none";

@@ -445,4 +445,4 @@ }

*/
[d](e, t) {
const s = this[h](t);
[f](e, t) {
const s = this[d](t);
if (Array.isArray(e)) {

@@ -476,3 +476,3 @@ const n = this[v](!0);

const e = this;
e[m] = null, e[b] = null, e[y] = null, e[E] = null, e[w] = null;
e[m] = null, e[b] = null, e[h] = null, e[E] = null, e[w] = null;
}

@@ -483,3 +483,3 @@ /**

get name() {
return this[V] ?? "";
return this[H] ?? "";
}

@@ -505,3 +505,3 @@ /**

submit(e, t) {
if (typeof e == "string" && (t = e, e = void 0), this[V] = t ?? "", !this[R] && this[x] === "submit")
if (typeof e == "string" && (t = e, e = void 0), this[H] = t ?? "", !this[R] && this[x] === "submit")
return console.warn(`[${M}]流程已经处于提交状态,无法重复提交`), !1;

@@ -519,3 +519,3 @@ e && typeof e == "object" && Object.assign(this[b].data, e);

}
const n = this[h](t);
const n = this[d](t);
Ue.forEach((r) => {

@@ -529,3 +529,3 @@ const l = n[r];

(r, ...l) => {
this[B]();
this[V]();
const i = n[Ge];

@@ -535,3 +535,3 @@ typeof i == "function" && Reflect.apply(i, n, [r, ...l]);

(r, ...l) => {
this[B]();
this[V]();
const i = () => {

@@ -544,4 +544,4 @@ const a = n[Ie];

A.forEach((c) => {
const k = n[c];
typeof k == "function" && a?.post(F(k, n));
const S = n[c];
typeof S == "function" && a?.post(F(S, n));
}), a?.wait(

@@ -562,3 +562,3 @@ () => i,

return new Promise((t, s) => {
const n = this[v](!0), r = this[h](e);
const n = this[v](!0), r = this[d](e);
Ne.forEach((l) => {

@@ -582,3 +582,3 @@ const i = r[l];

back(e) {
return this[d](We, e), !0;
return this[f](We, e), !0;
}

@@ -591,3 +591,3 @@ /**

exec(e, t) {
return this[d](e, t);
return this[f](e, t);
}

@@ -600,3 +600,3 @@ /**

getShareBus(e) {
const t = this[h](e);
const t = this[d](e);
return typeof t[Q] == "function" ? Reflect.apply(t[Q], t, []) : null;

@@ -610,3 +610,3 @@ }

havePermission(e) {
const t = this[h]();
const t = this[d]();
return typeof t[X] == "function" ? Reflect.apply(t[X], t, [e]) : !0;

@@ -621,3 +621,3 @@ }

setValue(e, t, s) {
const n = this[h](s ?? "");
const n = this[d](s ?? "");
if (Array.isArray(n.allDataList)) {

@@ -638,3 +638,3 @@ for (let r of n.allDataList)

let s = null;
const n = this[h](t ?? "");
const n = this[d](t ?? "");
if (Array.isArray(n.allDataList)) {

@@ -653,3 +653,3 @@ for (let r of n.allDataList)

get allDataList() {
return this[h]().allDataList;
return this[d]().allDataList;
}

@@ -660,3 +660,3 @@ /**

get dataList() {
return this[h]().dataList;
return this[d]().dataList;
}

@@ -678,3 +678,3 @@ /**

broadcast(e, t, ...s) {
return Reflect.apply(He, null, [this[y], e, t, ...s]);
return Reflect.apply(Be, null, [this[h], e, t, ...s]);
}

@@ -689,3 +689,3 @@ /**

Array.isArray(t) ? s = t : typeof t == "string" ? s = [t] : s = [u];
const n = this[y];
const n = this[h];
s.forEach((r) => {

@@ -717,3 +717,3 @@ const l = De(n, r) ?? { original: {}, last: {} }, i = {};

validate(e = !0, t) {
return _e(this[y], e, t);
return _e(this[h], e, t);
}

@@ -726,3 +726,3 @@ /**

clearValidate(e = !0, t) {
return Te(this[y], e, t);
return Te(this[h], e, t);
}

@@ -735,3 +735,3 @@ /**

setNameValidateRules(e, t = !0) {
return $e(this[y], e, t);
return $e(this[h], e, t);
}

@@ -749,8 +749,8 @@ }

if (typeof e == "string" ? n = e : e && typeof e == "object" && (n = e.name, r = e.mixin, Object.assign(l, e)), !s) {
const f = P();
if (f === null)
const y = P();
if (y === null)
throw new Error("defineData must in setup hook");
if (f.proxy == null)
if (y.proxy == null)
throw new Error("proxy is null");
s = f.proxy;
s = y.proxy;
}

@@ -765,7 +765,7 @@ if (Ae(s, n))

else {
const f = c[n];
f && typeof f == "object" && C(!0, i, f);
const y = c[n];
y && typeof y == "object" && C(!0, i, y);
}
const k = {};
C(!0, k, i);
const S = {};
C(!0, S, i);
const K = ye(i);

@@ -777,3 +777,3 @@ if (Ee(

metadata: l,
original: k,
original: S,
last: K

@@ -783,4 +783,4 @@ },

), s) {
const f = S(s), z = () => {
n ? f?.emitToChildren({ name: n }, "setModelValue", K) : f?.emitToChildren({ maxLevel: 1, level: 1 }, "setModelValue", K);
const y = k(s), z = () => {
n ? y?.emitToChildren({ name: n }, "setModelValue", K) : y?.emitToChildren({ maxLevel: 1, level: 1 }, "setModelValue", K);
};

@@ -800,3 +800,3 @@ s.$.isMounted ? z() : te(z);

}
S(e);
k(e);
const t = new Ze(o, e);

@@ -811,16 +811,16 @@ p.push({

const l = j(e);
l && l.path && (r = Oe(l), n = (a, c) => {
a === "exit" ? t.exit(c) : a === "submit" && t.submit(c);
l && l.path && l.root && (r = Oe(l), n = (a, c) => {
a === "exit" ? t.exit(c) : a === "submit" ? t.submit(c) : a === "execHook" && typeof c == "string" && t[f](c);
}, s.on(r, n)), he(() => {
t[d]("beforeMount");
t[f]("beforeMount");
}), te(() => {
e && tt(e, "mounted"), t[d](["mounted", "endMounted"]);
e && tt(e, "mounted"), t[f](["mounted", "endMounted"]);
}), de(() => {
t[d]("beforeUnmount");
t[f]("beforeUnmount");
}), pe(() => {
t[d]("unmounted"), t[ie](), e && (ot(e), Me(e), G.delete(e), Le(e)), r && n && s.off(r, n);
t[f]("unmounted"), t[ie](), e && (ot(e), Me(e), G.delete(e), Le(e)), r && n && s.off(r, n);
}), we(() => {
t[d]("activated");
t[f]("activated");
}), xe(() => {
t[d]("inactivated");
t[f]("inactivated");
});

@@ -832,3 +832,3 @@ const i = Z(et, null);

try {
t[d]("created");
t[f]("created");
} catch (a) {

@@ -893,3 +893,3 @@ console.error(`[${M}] created error`, a);

return o.modifiers.Shift ? t.splice(0, 0, "Shift") : o.modifiers.Alt ? t.splice(0, 0, "Alt") : o.modifiers.Ctrl && t.splice(0, 0, "Ctrl"), t.join("+").toLocaleUpperCase();
}, H = /* @__PURE__ */ new WeakMap(), nt = {
}, B = /* @__PURE__ */ new WeakMap(), nt = {
// 在绑定元素的父组件

@@ -902,8 +902,8 @@ // 及他自己的所有子节点都挂载完成后调用

};
o.addEventListener("keyup", i), H.set(o, i);
o.addEventListener("keyup", i), B.set(o, i);
},
// 绑定元素的父组件卸载后调用
beforeUnmount(o, e, t, s) {
const n = H.get(o);
H.delete(o), n && o.removeEventListener("keyup", n);
const n = B.get(o);
B.delete(o), n && o.removeEventListener("keyup", n);
}

@@ -975,2 +975,3 @@ }, _ = /* @__PURE__ */ new WeakMap(), st = {

M as TAG,
Oe as createEventProxyName,
mt as default,

@@ -980,3 +981,3 @@ ht as defineFoxController,

ft as defineFoxMixinData,
He as execBroadcast,
Be as execBroadcast,
Te as execClearValidate,

@@ -983,0 +984,0 @@ $e as execSetNameValidateRules,

(function(c,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue"),require("@fox-js/fox")):typeof define=="function"&&define.amd?define(["exports","vue","@fox-js/fox"],f):(c=typeof globalThis<"u"?globalThis:c||self,f(c.FoxFlow={},c.Vue,c.Fox))})(this,function(c,f,y){"use strict";/*!
* @fox-js/flow v4.0.1-24 Fri Nov 10 2023 10:39:46 GMT+0800 (中国标准时间)
*/function me(n){return Object.prototype.toString.call(n)==="[object RegExp]"}const D=Symbol.for("BroadcastKey");class pe{parent;children=[];callbacks=new Map;proxy=null;name;constructor(e,t,s){this.parent=e,this.proxy=t,this.name=s,e!==null&&e.addChild(this)}addChild(e){this.children.push(e)}removeChild(e){const t=this.children.findIndex(s=>e===s);t!==-1&&this.children.splice(t,1)}destroy(){this.parent!==null&&this.parent.removeChild(this),this.parent=null,this.proxy=null}emit(e,t,...s){if(e.maxLevel!==void 0&&e.maxLevel!==null&&e.maxLevel>0){if(e.level=e.level??0,e.level>e.maxLevel)return[];e.level++}let o=!1;!e.name||e.name==="*"?o=!0:!e.name||e.name==="+"?(o=!1,e.name="*"):me(e.name)&&this.name&&e.name.test(this.name)?o=!0:typeof e.name=="function"?o=Reflect.apply(e.name,null,[this.name]):e.name===this.name&&(o=!0);const r=[];if(o){const i=this.callbacks.get(t);if(typeof i=="function"){const a=Reflect.apply(i,this.proxy,[...s]);a!=null&&r.push(a)}const l=this.proxy??{};if(typeof l[t]=="function"){const a=Reflect.apply(l[t],l,[...s]);a!=null&&r.push(a)}}return this.children.forEach(i=>{const l=Reflect.apply(i.emit,i,[{...e},t,...s]);l!=null&&Array.isArray(l)&&Reflect.apply([].push,r,[...l])}),r}emitToChildren(e,t,...s){const o=[];return this.children.forEach(r=>{const i=Reflect.apply(r.emit,r,[{...e},t,...s]);i!=null&&Array.isArray(i)&&Reflect.apply([].push,o,[...i])}),o}on(e,t){this.callbacks.set(e,t)}}function be(n,e,t,s){const o=new pe(e,n,t);if(s&&typeof s=="object")for(const r in s)o.on(r,s[r]);return o}const d="",z=new Map;function we(n,e=d){z.set(e,n)}function ge(n=d){return z.get(n)??null}const x=new WeakMap;function xe(n,e,t=d){let s=x.get(n);s||(s=new Map,x.set(n,s)),s.set(t,e)}function ve(n){const e=[],t=x.get(n);return t&&t.forEach((s,o)=>{e.push(s)}),e}function Fe(n,e=d){const t=x.get(n);return t?t.get(e)??null:null}function Se(n,e=d){const t=x.get(n);return t?t.has(e):!1}function ke(n){x.delete(n)}const J=new Map,B=new WeakMap,v=n=>{let e=B.get(n);if(!e){const t=f.inject(D,null);e=be(n,t),B.set(n,e);const s=n;s[D]=e,f.provide(D,e)}return e},Ce=n=>{const e=n;e[D]=null,B.delete(n)},Re=Symbol.for("SyncDataKey");function Q(n){const e=y.useRoute(n);return e&&e.params?e.params[Re]??{}:{}}const R="FoxFlow";class Ke{data={}}const H=Symbol("nameKey"),T=Symbol("dataKey"),_=Symbol("originalDataKey"),$=Symbol("allDataListKey"),O=Symbol("dataListKey"),I=Symbol("proxyKey");class Ee{[H]=d;[_]={};[T]={};[$]=[];[O]=[];[I]=null;get name(){return this[H]}get originalData(){return this[_]}get data(){return this[T]}get allDataList(){return this[$]}get dataList(){return this[O]}get proxy(){return this[I]}get route(){return y.useRoute(this.proxy??void 0)}}function De(n,e){const t=J.get(e);if(t){let s=n;const o=new t;s.__proto__=o}return n}function Ae(n,e,t){const s=ve(e);let o=[];!t||t===d?o=[]:Array.isArray(t)?o=t:o=[String(t??"")];const r=[],i={},l={};s.forEach(a=>{const u=String(a.name??"");(o.length===0||o.includes(u))&&(r.push(a),Object.assign(i,a.original),Object.assign(l,a.last))}),n[$]=s,n[O]=r,n[_]=i,n[T]=l,n[I]=e,n[H]=t??d}function X(n,e,t,...s){const o=v(n);return Reflect.apply(o.emit,o,[e,t,...s])}function Y(n,e=!0,t){const s=v(n);let o=null;if(!t||t===d)t=void 0,o={maxLevel:1,level:1};else if(Array.isArray(t)){const i=t;o={name:l=>i.includes(l)}}else o={name:String(t)};const r=s.emitToChildren(o,"validate",e);return r.length==1?r[0]:r.length>1?Promise.all(r).then(i=>{let l=[];return i.forEach(a=>{a.pass===!1&&Array.isArray(a.errors)&&(l=[...l,...a.errors])}),l.length>0?{pass:!1,errors:l}:{pass:!0}}):Promise.resolve({pass:!0})}function Z(n,e=!0,t){const s=v(n);let o=null;if(!t||t===d)t=void 0,o={maxLevel:1,level:1};else if(Array.isArray(t)){const r=t;o={name:i=>r.includes(i)}}else o={name:String(t)};s.emitToChildren(o,"clearValidate",e)}function ee(n,e,t=!0){const s=v(n),o={maxLevel:1,level:1};s.emitToChildren(o,"setNameValidateRules",e,t)}const Le=n=>`_fox_ctrl_${n.path}_${n.root}`,Me=["beforeBack","back"],te="getShareBus",ne="havePermission",je=["beforeExit","exit"],Pe=["setCheckConditions","check"],Ve="cancelSubmit",Be="endSubmit";let oe=["preSubmit","commit","submit","postSubmit"],A=[];function se(n){oe=[...n]}function re(n){A=[...n]}let L=null;function ie(n){L=n}const He="foxOpenType";let Te=n=>{const e=y.useRoute(n);return e&&e.params?e.params[He]??"normal":"normal"};const g=Symbol("eventChainKey"),F=Symbol("sessionKey"),h=Symbol("proxyKey"),M=Symbol("userFlowKey"),S=Symbol("flowKey"),k=Symbol("stateKey"),N=Symbol("flowNameKey"),j=Symbol("allowResubmit"),C=Symbol("_getFlowEventChain"),m=Symbol("_getFlow"),W=Symbol("_reset"),le=Symbol("_destroy"),p=Symbol("_execHook");function _e(n){return n==null?!1:n===!1?!0:typeof n=="object"&&Reflect.has(n,"pass")?!n.pass:!1}const K=function(n,e){return(s,...o)=>{try{const r=Reflect.apply(n,e,[s,...o]);y.isPromise(r)&&r.then(i=>{_e(i)?s.reject(i):s.resolve(i)}).catch(i=>{s.reject(i)})}catch(r){console.error(`[${R}] exec hook error`,r),s.reject(r)}}};class ae{[g]=null;[F]=new Ke;[h];[M];[S]=null;[k]="none";[N]="";[j]=!1;constructor(e,t){this[M]=e,this[h]=t}[C](e=!1){return e?new y.EventChain(this[F],!0):this[g]?this[g]:(this[g]=new y.EventChain(this[F],!0),this[g])}[m](e){if(!this[S]){const t=Te(this[h]);this[S]=De(this[M],t)}return Ae(this[S],this[h],e),this[S]}[W](){this[g]=null,this[k]="none"}[p](e,t){const s=this[m](t);if(Array.isArray(e)){const o=this[C](!0);e.forEach(r=>{const i=s[r];if(typeof i=="function"){const l=K(i,s);o?.post(l)}})}else{const o=s[e];if(typeof o=="function")return Reflect.apply(o,s,[this[F]])}}pretreat(e){return this[k]==="submit"?(console.warn(`[${R}]流程已经处于提交状态,无法加入预处理任务`),!1):(this[C]()?.post(e),this[k]="pretreat",!0)}[le](){const e=this;e[g]=null,e[F]=null,e[h]=null,e[M]=null,e[S]=null}get name(){return this[N]??""}set allowResubmit(e){this[j]=e}get allowResubmit(){return this[j]}submit(e,t){if(typeof e=="string"&&(t=e,e=void 0),this[N]=t??"",!this[j]&&this[k]==="submit")return console.warn(`[${R}]流程已经处于提交状态,无法重复提交`),!1;e&&typeof e=="object"&&Object.assign(this[F].data,e);const s=this[C]();if(this[k]==="pretreat"&&L){try{L.lock()}catch{}s?.post(r=>{L?.unlock(),r.resolve()})}const o=this[m](t);Pe.forEach(r=>{const i=o[r];typeof i=="function"&&s?.post(K(i,o))}),oe.forEach(r=>{const i=o[r];typeof i=="function"&&s?.post(K(i,o))}),s?.wait((r,...i)=>{this[W]();const l=o[Be];typeof l=="function"&&Reflect.apply(l,o,[r,...i])},(r,...i)=>{this[W]();const l=()=>{const a=o[Ve];typeof a=="function"&&Reflect.apply(a,o,[r,...i])};if(Array.isArray(A)&&A.length>0){const a=this[C](!0);A.forEach(u=>{const E=o[u];typeof E=="function"&&a?.post(K(E,o))}),a?.wait(()=>l,()=>l)}else l()})}exit(e){return new Promise((t,s)=>{const o=this[C](!0),r=this[m](e);je.forEach(i=>{const l=r[i];typeof l=="function"&&o?.post(K(l,r))}),o?.wait((i,...l)=>{t(!0)},(i,...l)=>{t(!0)})})}back(e){return this[p](Me,e),!0}exec(e,t){return this[p](e,t)}getShareBus(e){const t=this[m](e);return typeof t[te]=="function"?Reflect.apply(t[te],t,[]):null}havePermission(e){const t=this[m]();return typeof t[ne]=="function"?Reflect.apply(t[ne],t,[e]):!0}setValue(e,t,s){const o=this[m](s??"");if(Array.isArray(o.allDataList)){for(let r of o.allDataList)if(r.name===s){r.last[e]=t;break}}}getValue(e,t){let s=null;const o=this[m](t??"");if(Array.isArray(o.allDataList)){for(let r of o.allDataList)if(r.name===t){s=r.last[e];break}}return s}get allDataList(){return this[m]().allDataList}get dataList(){return this[m]().dataList}getDataRecordByFieldName(e){return this.allDataList.find(o=>Reflect.ownKeys(o.last).includes(e))??null}broadcast(e,t,...s){return Reflect.apply(X,null,[this[h],e,t,...s])}resetFields(e,t){let s=[];Array.isArray(t)?s=t:typeof t=="string"?s=[t]:s=[d];const o=this[h];s.forEach(r=>{const i=Fe(o,r)??{original:{},last:{}},l={};if(y.extend(!0,l,i.original),Array.isArray(e))e.forEach(a=>{i.last[a]=l[a]});else if(e&&Array.isArray(e.include))(e.include??[]).forEach(u=>{i.last[u]=l[u]});else if(e&&Array.isArray(e.exclude)){let a=e.exclude??[];Reflect.ownKeys(l).forEach(u=>{typeof u=="string"&&(a.includes(u)||(i.last[u]=l[u]))})}else Object.assign(i.last,l)}),this.clearValidate(e,t)}validate(e=!0,t){return Y(this[h],e,t)}clearValidate(e=!0,t){return Z(this[h],e,t)}setNameValidateRules(e,t=!0){return ee(this[h],e,t)}}const ce=Symbol.for("FoxControllerKey"),$e=Symbol.for("PageWrapperKey"),U=new WeakMap;let w=[];function Oe(n,e){const t=f.toRaw(n);we(t,e)}function Ie(n,e,t){let s=t,o,r;const i={};if(typeof e=="string"?o=e:e&&typeof e=="object"&&(o=e.name,r=e.mixin,Object.assign(i,e)),!s){const b=f.getCurrentInstance();if(b===null)throw new Error("defineData must in setup hook");if(b.proxy==null)throw new Error("proxy is null");s=b.proxy}if(Se(s,o))throw new Error("duplicate definitions are not allowed, please Set different name!");const l=f.toRaw(n),a=ge(r);a&&y.extend(!0,l,a);const u=Q(s);if(!o)y.extend(!0,l,u);else{const b=u[o];b&&typeof b=="object"&&y.extend(!0,l,b)}const E={};y.extend(!0,E,l);const V=f.reactive(l);if(xe(s,{name:o??d,metadata:i,original:E,last:V},o),s){const b=v(s),he=()=>{o?b?.emitToChildren({name:o},"setModelValue",V):b?.emitToChildren({maxLevel:1,level:1},"setModelValue",V)};s.$.isMounted?he():f.onMounted(he)}return V}function Ne(n={},e){if(!e){const a=f.getCurrentInstance();if(a===null)throw new Error("defineData must in setup hook");if(a.proxy===null)throw new Error("proxy is null");e=a.proxy}v(e);const t=new ae(n,e);w.push({proxy:e,controller:t,state:"create"});const s=y.useEventProxy(e);let o=null,r=null;const i=y.useRoute(e);i&&i.path&&(r=Le(i),o=(a,u)=>{a==="exit"?t.exit(u):a==="submit"&&t.submit(u)},s.on(r,o)),f.onBeforeMount(()=>{t[p]("beforeMount")}),f.onMounted(()=>{e&&Ue(e,"mounted"),t[p](["mounted","endMounted"])}),f.onBeforeUnmount(()=>{t[p]("beforeUnmount")}),f.onUnmounted(()=>{t[p]("unmounted"),t[le](),e&&(Ge(e),Ce(e),U.delete(e),ke(e)),r&&o&&s.off(r,o)}),y.onFoxActivated(()=>{t[p]("activated")}),y.onFoxInactivated(()=>{t[p]("inactivated")});const l=f.inject($e,null);l&&typeof l.beforeClose!="function"&&(l.used||(l.used=!0,l.beforeClose=async a=>{await t.exit(),typeof a=="function"&&a()}));try{t[p]("created")}catch(a){console.error(`[${R}] created error`,a)}return U.set(e,t),y.provideContextValue(e,ce,t),t}function We(n){let e=null;return n&&(e=U.get(n)??null),e||(n||(n=f.getCurrentInstance()?.proxy??void 0),n&&(e=y.injectContextValue(n,ce))),e}function Ue(n,e){for(let t=w.length-1;t>=0;t--){const s=w[t];if(s.proxy===n){s.state=e;break}}}function Ge(n){const e=w.findIndex(t=>t.proxy===n);e!==-1&&w.splice(e,1)}function P(n){if(!n){const e=w.length-1;if(e>=0){const t=w[e];if(t.state==="create")return t}return null}for(let e=w.length-1;e>=0;e--){const t=w[e];if(t.proxy&&t.proxy.$el){const s=t.proxy.$el;if(s===n||s.contains(n))return t}}return null}function qe(n){if(!n){const e=f.getCurrentInstance();if(e===null)throw new Error("getSyncData must in setup hook");if(e.proxy===null)throw new Error("proxy is null");n=e.proxy}return Q(n)}const ue=n=>{let{key:e,shiftKey:t,altKey:s,ctrlKey:o}=n,r=[];return t&&r.push("Shift"),s&&r.push("Alt"),o&&r.push("Ctrl"),r.push(e),r.join("+").toLocaleUpperCase()},fe=(n,e="Enter")=>{let t=[n.arg??e];return n.modifiers.Shift?t.splice(0,0,"Shift"):n.modifiers.Alt?t.splice(0,0,"Alt"):n.modifiers.Ctrl&&t.splice(0,0,"Ctrl"),t.join("+").toLocaleUpperCase()},G=new WeakMap,ze={mounted(n,e,t,s){const o=fe(e,"ENTER"),r=P(n),i=e.value??{},l=a=>{const u=ue(a);r&&r.controller&&u===o&&r.controller.submit(i)};n.addEventListener("keyup",l),G.set(n,l)},beforeUnmount(n,e,t,s){const o=G.get(n);G.delete(n),o&&n.removeEventListener("keyup",o)}},q=new WeakMap,Je={mounted(n,e,t,s){const o=fe(e,"ESCAPE"),r=P(n),i=e.value??{},l=a=>{const u=ue(a);r&&r.controller&&u===o&&r.controller.exit(i)};n.addEventListener("keyup",l),q.set(n,l)},beforeUnmount(n,e,t,s){const o=q.get(n);q.delete(n),o&&n.removeEventListener("keyup",o)}},ye=(n,e,t)=>{t?e==="disabled"&&n.hasAttribute("disabled")?n.removeAttribute("disbaled"):n.style.display==="none"&&(n.style.display="block"):e==="disabled"?n.setAttribute("disabled",!0):n.style.display="none"},Qe={mounted(n,e,t,s){const o=e.arg??"show";let r=e.value;r||(r=n.dataset.permission??[]),f.watchEffect(()=>{const i=P(n);if(i&&i.controller){const l=i.controller.havePermission(r);y.isPromise(l)?l.then(a=>{ye(n,o,a)}):ye(n,o,l)}})}},Xe={install(n){n.directive("submit",ze),n.directive("exit",Je),n.directive("permission",Qe)}};function de(n,e){J.set(n,e)}const Ye={install(n,e={}){if(e.pretreatLocker&&ie(e.pretreatLocker),e.customSubmitFlowHooks&&se(e.customSubmitFlowHooks),e.customCancelSubmitFlowHooks&&re(e.customCancelSubmitFlowHooks),e.systemFlows)for(let t in e.systemFlows){let s=e.systemFlows[t];de(t,s)}Xe.install(n)}};c.BaseFlow=Ee,c.DefaultKey=d,c.FoxController=ae,c.TAG=R,c.default=Ye,c.defineFoxController=Ne,c.defineFoxData=Ie,c.defineFoxMixinData=Oe,c.execBroadcast=X,c.execClearValidate=Z,c.execSetNameValidateRules=ee,c.execValidate=Y,c.setCustomCancelSubmitFlowHooks=re,c.setCustomSubmitFlowHooks=se,c.setFoxSystemFlow=de,c.setPretreatLocker=ie,c.useFoxContext=P,c.useFoxController=We,c.useFoxSyncData=qe,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
* @fox-js/flow v4.0.1-25 Fri Nov 24 2023 13:56:02 GMT+0800 (中国标准时间)
*/function pe(n){return Object.prototype.toString.call(n)==="[object RegExp]"}const D=Symbol.for("BroadcastKey");class be{parent;children=[];callbacks=new Map;proxy=null;name;constructor(e,t,s){this.parent=e,this.proxy=t,this.name=s,e!==null&&e.addChild(this)}addChild(e){this.children.push(e)}removeChild(e){const t=this.children.findIndex(s=>e===s);t!==-1&&this.children.splice(t,1)}destroy(){this.parent!==null&&this.parent.removeChild(this),this.parent=null,this.proxy=null}emit(e,t,...s){if(e.maxLevel!==void 0&&e.maxLevel!==null&&e.maxLevel>0){if(e.level=e.level??0,e.level>e.maxLevel)return[];e.level++}let o=!1;!e.name||e.name==="*"?o=!0:!e.name||e.name==="+"?(o=!1,e.name="*"):pe(e.name)&&this.name&&e.name.test(this.name)?o=!0:typeof e.name=="function"?o=Reflect.apply(e.name,null,[this.name]):e.name===this.name&&(o=!0);const r=[];if(o){const i=this.callbacks.get(t);if(typeof i=="function"){const a=Reflect.apply(i,this.proxy,[...s]);a!=null&&r.push(a)}const l=this.proxy??{};if(typeof l[t]=="function"){const a=Reflect.apply(l[t],l,[...s]);a!=null&&r.push(a)}}return this.children.forEach(i=>{const l=Reflect.apply(i.emit,i,[{...e},t,...s]);l!=null&&Array.isArray(l)&&Reflect.apply([].push,r,[...l])}),r}emitToChildren(e,t,...s){const o=[];return this.children.forEach(r=>{const i=Reflect.apply(r.emit,r,[{...e},t,...s]);i!=null&&Array.isArray(i)&&Reflect.apply([].push,o,[...i])}),o}on(e,t){this.callbacks.set(e,t)}}function we(n,e,t,s){const o=new be(e,n,t);if(s&&typeof s=="object")for(const r in s)o.on(r,s[r]);return o}const d="",z=new Map;function xe(n,e=d){z.set(e,n)}function ge(n=d){return z.get(n)??null}const g=new WeakMap;function ve(n,e,t=d){let s=g.get(n);s||(s=new Map,g.set(n,s)),s.set(t,e)}function Fe(n){const e=[],t=g.get(n);return t&&t.forEach((s,o)=>{e.push(s)}),e}function Se(n,e=d){const t=g.get(n);return t?t.get(e)??null:null}function ke(n,e=d){const t=g.get(n);return t?t.has(e):!1}function Ce(n){g.delete(n)}const J=new Map,H=new WeakMap,v=n=>{let e=H.get(n);if(!e){const t=f.inject(D,null);e=we(n,t),H.set(n,e);const s=n;s[D]=e,f.provide(D,e)}return e},Re=n=>{const e=n;e[D]=null,H.delete(n)},Ee=Symbol.for("SyncDataKey");function Q(n){const e=y.useRoute(n);return e&&e.params?e.params[Ee]??{}:{}}const R="FoxFlow";class Ke{data={}}const B=Symbol("nameKey"),T=Symbol("dataKey"),_=Symbol("originalDataKey"),$=Symbol("allDataListKey"),N=Symbol("dataListKey"),O=Symbol("proxyKey");class De{[B]=d;[_]={};[T]={};[$]=[];[N]=[];[O]=null;get name(){return this[B]}get originalData(){return this[_]}get data(){return this[T]}get allDataList(){return this[$]}get dataList(){return this[N]}get proxy(){return this[O]}get route(){return y.useRoute(this.proxy??void 0)}}function Ae(n,e){const t=J.get(e);if(t){let s=n;const o=new t;s.__proto__=o}return n}function Le(n,e,t){const s=Fe(e);let o=[];!t||t===d?o=[]:Array.isArray(t)?o=t:o=[String(t??"")];const r=[],i={},l={};s.forEach(a=>{const u=String(a.name??"");(o.length===0||o.includes(u))&&(r.push(a),Object.assign(i,a.original),Object.assign(l,a.last))}),n[$]=s,n[N]=r,n[_]=i,n[T]=l,n[O]=e,n[B]=t??d}function X(n,e,t,...s){const o=v(n);return Reflect.apply(o.emit,o,[e,t,...s])}function Y(n,e=!0,t){const s=v(n);let o=null;if(!t||t===d)t=void 0,o={maxLevel:1,level:1};else if(Array.isArray(t)){const i=t;o={name:l=>i.includes(l)}}else o={name:String(t)};const r=s.emitToChildren(o,"validate",e);return r.length==1?r[0]:r.length>1?Promise.all(r).then(i=>{let l=[];return i.forEach(a=>{a.pass===!1&&Array.isArray(a.errors)&&(l=[...l,...a.errors])}),l.length>0?{pass:!1,errors:l}:{pass:!0}}):Promise.resolve({pass:!0})}function Z(n,e=!0,t){const s=v(n);let o=null;if(!t||t===d)t=void 0,o={maxLevel:1,level:1};else if(Array.isArray(t)){const r=t;o={name:i=>r.includes(i)}}else o={name:String(t)};s.emitToChildren(o,"clearValidate",e)}function ee(n,e,t=!0){const s=v(n),o={maxLevel:1,level:1};s.emitToChildren(o,"setNameValidateRules",e,t)}const te=n=>`_fox_ctrl_${n.path??n.name??""}_${n.root??"default"}`,Me=["beforeBack","back"],ne="getShareBus",oe="havePermission",Pe=["beforeExit","exit"],je=["setCheckConditions","check"],Ve="cancelSubmit",He="endSubmit";let se=["preSubmit","commit","submit","postSubmit"],A=[];function re(n){se=[...n]}function ie(n){A=[...n]}let L=null;function le(n){L=n}const Be="foxOpenType";let Te=n=>{const e=y.useRoute(n);return e&&e.params?e.params[Be]??"normal":"normal"};const x=Symbol("eventChainKey"),F=Symbol("sessionKey"),m=Symbol("proxyKey"),M=Symbol("userFlowKey"),S=Symbol("flowKey"),k=Symbol("stateKey"),I=Symbol("flowNameKey"),P=Symbol("allowResubmit"),C=Symbol("_getFlowEventChain"),p=Symbol("_getFlow"),W=Symbol("_reset"),ae=Symbol("_destroy"),h=Symbol("_execHook");function _e(n){return n==null?!1:n===!1?!0:typeof n=="object"&&Reflect.has(n,"pass")?!n.pass:!1}const E=function(n,e){return(s,...o)=>{try{const r=Reflect.apply(n,e,[s,...o]);y.isPromise(r)&&r.then(i=>{_e(i)?s.reject(i):s.resolve(i)}).catch(i=>{s.reject(i)})}catch(r){console.error(`[${R}] exec hook error`,r),s.reject(r)}}};class ce{[x]=null;[F]=new Ke;[m];[M];[S]=null;[k]="none";[I]="";[P]=!1;constructor(e,t){this[M]=e,this[m]=t}[C](e=!1){return e?new y.EventChain(this[F],!0):this[x]?this[x]:(this[x]=new y.EventChain(this[F],!0),this[x])}[p](e){if(!this[S]){const t=Te(this[m]);this[S]=Ae(this[M],t)}return Le(this[S],this[m],e),this[S]}[W](){this[x]=null,this[k]="none"}[h](e,t){const s=this[p](t);if(Array.isArray(e)){const o=this[C](!0);e.forEach(r=>{const i=s[r];if(typeof i=="function"){const l=E(i,s);o?.post(l)}})}else{const o=s[e];if(typeof o=="function")return Reflect.apply(o,s,[this[F]])}}pretreat(e){return this[k]==="submit"?(console.warn(`[${R}]流程已经处于提交状态,无法加入预处理任务`),!1):(this[C]()?.post(e),this[k]="pretreat",!0)}[ae](){const e=this;e[x]=null,e[F]=null,e[m]=null,e[M]=null,e[S]=null}get name(){return this[I]??""}set allowResubmit(e){this[P]=e}get allowResubmit(){return this[P]}submit(e,t){if(typeof e=="string"&&(t=e,e=void 0),this[I]=t??"",!this[P]&&this[k]==="submit")return console.warn(`[${R}]流程已经处于提交状态,无法重复提交`),!1;e&&typeof e=="object"&&Object.assign(this[F].data,e);const s=this[C]();if(this[k]==="pretreat"&&L){try{L.lock()}catch{}s?.post(r=>{L?.unlock(),r.resolve()})}const o=this[p](t);je.forEach(r=>{const i=o[r];typeof i=="function"&&s?.post(E(i,o))}),se.forEach(r=>{const i=o[r];typeof i=="function"&&s?.post(E(i,o))}),s?.wait((r,...i)=>{this[W]();const l=o[He];typeof l=="function"&&Reflect.apply(l,o,[r,...i])},(r,...i)=>{this[W]();const l=()=>{const a=o[Ve];typeof a=="function"&&Reflect.apply(a,o,[r,...i])};if(Array.isArray(A)&&A.length>0){const a=this[C](!0);A.forEach(u=>{const K=o[u];typeof K=="function"&&a?.post(E(K,o))}),a?.wait(()=>l,()=>l)}else l()})}exit(e){return new Promise((t,s)=>{const o=this[C](!0),r=this[p](e);Pe.forEach(i=>{const l=r[i];typeof l=="function"&&o?.post(E(l,r))}),o?.wait((i,...l)=>{t(!0)},(i,...l)=>{t(!0)})})}back(e){return this[h](Me,e),!0}exec(e,t){return this[h](e,t)}getShareBus(e){const t=this[p](e);return typeof t[ne]=="function"?Reflect.apply(t[ne],t,[]):null}havePermission(e){const t=this[p]();return typeof t[oe]=="function"?Reflect.apply(t[oe],t,[e]):!0}setValue(e,t,s){const o=this[p](s??"");if(Array.isArray(o.allDataList)){for(let r of o.allDataList)if(r.name===s){r.last[e]=t;break}}}getValue(e,t){let s=null;const o=this[p](t??"");if(Array.isArray(o.allDataList)){for(let r of o.allDataList)if(r.name===t){s=r.last[e];break}}return s}get allDataList(){return this[p]().allDataList}get dataList(){return this[p]().dataList}getDataRecordByFieldName(e){return this.allDataList.find(o=>Reflect.ownKeys(o.last).includes(e))??null}broadcast(e,t,...s){return Reflect.apply(X,null,[this[m],e,t,...s])}resetFields(e,t){let s=[];Array.isArray(t)?s=t:typeof t=="string"?s=[t]:s=[d];const o=this[m];s.forEach(r=>{const i=Se(o,r)??{original:{},last:{}},l={};if(y.extend(!0,l,i.original),Array.isArray(e))e.forEach(a=>{i.last[a]=l[a]});else if(e&&Array.isArray(e.include))(e.include??[]).forEach(u=>{i.last[u]=l[u]});else if(e&&Array.isArray(e.exclude)){let a=e.exclude??[];Reflect.ownKeys(l).forEach(u=>{typeof u=="string"&&(a.includes(u)||(i.last[u]=l[u]))})}else Object.assign(i.last,l)}),this.clearValidate(e,t)}validate(e=!0,t){return Y(this[m],e,t)}clearValidate(e=!0,t){return Z(this[m],e,t)}setNameValidateRules(e,t=!0){return ee(this[m],e,t)}}const ue=Symbol.for("FoxControllerKey"),$e=Symbol.for("PageWrapperKey"),U=new WeakMap;let w=[];function Ne(n,e){const t=f.toRaw(n);xe(t,e)}function Oe(n,e,t){let s=t,o,r;const i={};if(typeof e=="string"?o=e:e&&typeof e=="object"&&(o=e.name,r=e.mixin,Object.assign(i,e)),!s){const b=f.getCurrentInstance();if(b===null)throw new Error("defineData must in setup hook");if(b.proxy==null)throw new Error("proxy is null");s=b.proxy}if(ke(s,o))throw new Error("duplicate definitions are not allowed, please Set different name!");const l=f.toRaw(n),a=ge(r);a&&y.extend(!0,l,a);const u=Q(s);if(!o)y.extend(!0,l,u);else{const b=u[o];b&&typeof b=="object"&&y.extend(!0,l,b)}const K={};y.extend(!0,K,l);const V=f.reactive(l);if(ve(s,{name:o??d,metadata:i,original:K,last:V},o),s){const b=v(s),me=()=>{o?b?.emitToChildren({name:o},"setModelValue",V):b?.emitToChildren({maxLevel:1,level:1},"setModelValue",V)};s.$.isMounted?me():f.onMounted(me)}return V}function Ie(n={},e){if(!e){const a=f.getCurrentInstance();if(a===null)throw new Error("defineData must in setup hook");if(a.proxy===null)throw new Error("proxy is null");e=a.proxy}v(e);const t=new ce(n,e);w.push({proxy:e,controller:t,state:"create"});const s=y.useEventProxy(e);let o=null,r=null;const i=y.useRoute(e);i&&i.path&&i.root&&(r=te(i),o=(a,u)=>{a==="exit"?t.exit(u):a==="submit"?t.submit(u):a==="execHook"&&typeof u=="string"&&t[h](u)},s.on(r,o)),f.onBeforeMount(()=>{t[h]("beforeMount")}),f.onMounted(()=>{e&&Ue(e,"mounted"),t[h](["mounted","endMounted"])}),f.onBeforeUnmount(()=>{t[h]("beforeUnmount")}),f.onUnmounted(()=>{t[h]("unmounted"),t[ae](),e&&(Ge(e),Re(e),U.delete(e),Ce(e)),r&&o&&s.off(r,o)}),y.onFoxActivated(()=>{t[h]("activated")}),y.onFoxInactivated(()=>{t[h]("inactivated")});const l=f.inject($e,null);l&&typeof l.beforeClose!="function"&&(l.used||(l.used=!0,l.beforeClose=async a=>{await t.exit(),typeof a=="function"&&a()}));try{t[h]("created")}catch(a){console.error(`[${R}] created error`,a)}return U.set(e,t),y.provideContextValue(e,ue,t),t}function We(n){let e=null;return n&&(e=U.get(n)??null),e||(n||(n=f.getCurrentInstance()?.proxy??void 0),n&&(e=y.injectContextValue(n,ue))),e}function Ue(n,e){for(let t=w.length-1;t>=0;t--){const s=w[t];if(s.proxy===n){s.state=e;break}}}function Ge(n){const e=w.findIndex(t=>t.proxy===n);e!==-1&&w.splice(e,1)}function j(n){if(!n){const e=w.length-1;if(e>=0){const t=w[e];if(t.state==="create")return t}return null}for(let e=w.length-1;e>=0;e--){const t=w[e];if(t.proxy&&t.proxy.$el){const s=t.proxy.$el;if(s===n||s.contains(n))return t}}return null}function qe(n){if(!n){const e=f.getCurrentInstance();if(e===null)throw new Error("getSyncData must in setup hook");if(e.proxy===null)throw new Error("proxy is null");n=e.proxy}return Q(n)}const fe=n=>{let{key:e,shiftKey:t,altKey:s,ctrlKey:o}=n,r=[];return t&&r.push("Shift"),s&&r.push("Alt"),o&&r.push("Ctrl"),r.push(e),r.join("+").toLocaleUpperCase()},ye=(n,e="Enter")=>{let t=[n.arg??e];return n.modifiers.Shift?t.splice(0,0,"Shift"):n.modifiers.Alt?t.splice(0,0,"Alt"):n.modifiers.Ctrl&&t.splice(0,0,"Ctrl"),t.join("+").toLocaleUpperCase()},G=new WeakMap,ze={mounted(n,e,t,s){const o=ye(e,"ENTER"),r=j(n),i=e.value??{},l=a=>{const u=fe(a);r&&r.controller&&u===o&&r.controller.submit(i)};n.addEventListener("keyup",l),G.set(n,l)},beforeUnmount(n,e,t,s){const o=G.get(n);G.delete(n),o&&n.removeEventListener("keyup",o)}},q=new WeakMap,Je={mounted(n,e,t,s){const o=ye(e,"ESCAPE"),r=j(n),i=e.value??{},l=a=>{const u=fe(a);r&&r.controller&&u===o&&r.controller.exit(i)};n.addEventListener("keyup",l),q.set(n,l)},beforeUnmount(n,e,t,s){const o=q.get(n);q.delete(n),o&&n.removeEventListener("keyup",o)}},de=(n,e,t)=>{t?e==="disabled"&&n.hasAttribute("disabled")?n.removeAttribute("disbaled"):n.style.display==="none"&&(n.style.display="block"):e==="disabled"?n.setAttribute("disabled",!0):n.style.display="none"},Qe={mounted(n,e,t,s){const o=e.arg??"show";let r=e.value;r||(r=n.dataset.permission??[]),f.watchEffect(()=>{const i=j(n);if(i&&i.controller){const l=i.controller.havePermission(r);y.isPromise(l)?l.then(a=>{de(n,o,a)}):de(n,o,l)}})}},Xe={install(n){n.directive("submit",ze),n.directive("exit",Je),n.directive("permission",Qe)}};function he(n,e){J.set(n,e)}const Ye={install(n,e={}){if(e.pretreatLocker&&le(e.pretreatLocker),e.customSubmitFlowHooks&&re(e.customSubmitFlowHooks),e.customCancelSubmitFlowHooks&&ie(e.customCancelSubmitFlowHooks),e.systemFlows)for(let t in e.systemFlows){let s=e.systemFlows[t];he(t,s)}Xe.install(n)}};c.BaseFlow=De,c.DefaultKey=d,c.FoxController=ce,c.TAG=R,c.createEventProxyName=te,c.default=Ye,c.defineFoxController=Ie,c.defineFoxData=Oe,c.defineFoxMixinData=Ne,c.execBroadcast=X,c.execClearValidate=Z,c.execSetNameValidateRules=ee,c.execValidate=Y,c.setCustomCancelSubmitFlowHooks=ie,c.setCustomSubmitFlowHooks=re,c.setFoxSystemFlow=he,c.setPretreatLocker=le,c.useFoxContext=j,c.useFoxController=We,c.useFoxSyncData=qe,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
{
"name": "@fox-js/flow",
"type": "module",
"version": "4.0.1-25",
"version": "4.0.1-26",
"description": "fox flow",

@@ -6,0 +6,0 @@ "author": "jiangcheng",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc