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-28 to 4.0.1-29

4

dist/index.cjs.js
"use strict";/*!
* @fox-js/flow v4.0.1-27 Sat Mar 09 2024 10:12:21 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 d="",X=new Map;function be(o,e=d){X.set(e,o)}function we(o=d){return X.get(o)??null}const S=new WeakMap;function ve(o,e,t=d){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=d){const t=S.get(o);return t?t.get(e)??null:null}function Se(o,e=d){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{[$]=d;[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===d?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??d}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===d)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===d)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",He="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 Ve="foxOpenType";let Be=o=>{const e=u.useRoute(o);return e&&e.params?e.params[Ve]??"normal":"normal"};const b=Symbol("eventChainKey"),w=Symbol("sessionKey"),h=Symbol("proxyKey"),D=Symbol("userFlowKey"),v=Symbol("flowKey"),g=Symbol("stateKey"),H=Symbol("flowNameKey"),A=Symbol("allowResubmit"),F=Symbol("_getFlowEventChain"),m=Symbol("_getFlow"),V=Symbol("_reset"),ce=Symbol("_destroy"),y=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;[h];[D];[v]=null;[g]="none";[H]="";[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])}[m](e){if(!this[v]){const t=Be(this[h]);this[v]=De(this[D],t)}return Ae(this[v],this[h],e),this[v]}[V](){this[b]=null,this[g]="none"}[y](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[h]=null,e[D]=null,e[v]=null}get name(){return this[H]??""}get proxy(){return this[h]}set allowResubmit(e){this[A]=e}get allowResubmit(){return this[A]}submit(e,t){if(typeof e=="string"&&(t=e,e=void 0),this[H]=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[V]();const i=n[He];typeof i=="function"&&Reflect.apply(i,n,[r,...l])},(r,...l)=>{this[V]();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[y](Le,e),!0}exec(e,t){return this[y](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[h],e,t,...s])}resetFields(e,t){let s=[];Array.isArray(t)?s=t:typeof t=="string"?s=[t]:s=[d];const n=this[h];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[h],e,t)}clearValidate(e=!0,t){return oe(this[h],e,t)}setNameValidateRules(e,t=!0){return ne(this[h],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 p=f.getCurrentInstance();if(p===null)throw new Error("defineData must in setup hook");if(p.proxy==null)throw new Error("proxy is null");s=p.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 p=c[n];p&&typeof p=="object"&&u.extend(!0,i,p)}const C={};u.extend(!0,C,i);const K=f.reactive(i);if(ve(s,{name:n??d,metadata:l,original:C,last:K},n),s){const p=k(s),q=()=>{n?p?.emitToChildren({name:n},"setModelValue",K):p?.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[y](c)},s.on(r,n)),f.onBeforeMount(()=>{t[y]("beforeMount")}),f.onMounted(()=>{e&&We(e,"mounted"),t[y](["mounted","endMounted"])}),f.onBeforeUnmount(()=>{t[y]("beforeUnmount")}),f.onUnmounted(()=>{t[y]("unmounted"),t[ce](),e&&(Ue(e),Ce(e),G.delete(e),ke(e)),r&&n&&s.off(r,n)}),u.onFoxActivated(()=>{t[y]("activated")}),u.onFoxInactivated(()=>{t[y]("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()},i.onShow=()=>{t[y]("activated")},i.onHide=()=>{t[y]("inactivated")}));try{t[y]("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=d;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;
* @fox-js/flow v4.0.1-28 Mon Mar 25 2024 00:13:18 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,n){this.parent=e,this.proxy=t,this.name=n,e!==null&&e.addChild(this)}addChild(e){this.children.push(e)}removeChild(e){const t=this.children.findIndex(n=>e===n);t!==-1&&this.children.splice(t,1)}destroy(){this.parent!==null&&this.parent.removeChild(this),this.parent=null,this.proxy=null}emit(e,t,...n){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 s=!1;!e.name||e.name==="*"?s=!0:!e.name||e.name==="+"?(s=!1,e.name="*"):pe(e.name)&&this.name&&e.name.test(this.name)?s=!0:typeof e.name=="function"?s=Reflect.apply(e.name,null,[this.name]):e.name===this.name&&(s=!0);const r=[];if(s){const l=this.callbacks.get(t);if(typeof l=="function"){const a=Reflect.apply(l,this.proxy,[...n]);a!=null&&r.push(a)}const i=this.proxy??{};if(typeof i[t]=="function"){const a=Reflect.apply(i[t],i,[...n]);a!=null&&r.push(a)}}return this.children.forEach(l=>{const i=Reflect.apply(l.emit,l,[{...e},t,...n]);i!=null&&Array.isArray(i)&&Reflect.apply([].push,r,[...i])}),r}emitToChildren(e,t,...n){const s=[];return this.children.forEach(r=>{const l=Reflect.apply(r.emit,r,[{...e},t,...n]);l!=null&&Array.isArray(l)&&Reflect.apply([].push,s,[...l])}),s}on(e,t){this.callbacks.set(e,t)}}function xe(o,e,t,n){const s=new me(e,o,t);if(n&&typeof n=="object")for(const r in n)s.on(r,n[r]);return s}const d="",X=new Map;function be(o,e=d){X.set(e,o)}function we(o=d){return X.get(o)??null}const S=new WeakMap;function ve(o,e,t=d){let n=S.get(o);n||(n=new Map,S.set(o,n)),n.set(t,e)}function ge(o){const e=[],t=S.get(o);return t&&t.forEach((n,s)=>{e.push(n)}),e}function Fe(o,e=d){const t=S.get(o);return t?t.get(e)??null:null}function Se(o,e=d){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 n=o;n[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{[$]=d;[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 n=o;const s=new t;n.__proto__=s}return o}function Ae(o,e,t){const n=ge(e);let s=[];!t||t===d?s=[]:Array.isArray(t)?s=t:s=[String(t??"")];const r=[],l={},i={};n.forEach(a=>{const c=String(a.name??"");(s.length===0||s.includes(c))&&(r.push(a),Object.assign(l,a.original),Object.assign(i,a.last))}),o[I]=n,o[W]=r,o[O]=l,o[N]=i,o[U]=e,o[$]=t??d}function ee(o,e,t,...n){const s=k(o);return Reflect.apply(s.emit,s,[e,t,...n])}function te(o,e=!0,t){const n=k(o);let s=null;if(!t||t===d)t=void 0,s={maxLevel:1,level:1};else if(Array.isArray(t)){const l=t;s={name:i=>l.includes(i)}}else s={name:String(t)};const r=n.emitToChildren(s,"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 n=k(o);let s=null;if(!t||t===d)t=void 0,s={maxLevel:1,level:1};else if(Array.isArray(t)){const r=t;s={name:l=>r.includes(l)}}else s={name:String(t)};n.emitToChildren(s,"clearValidate",e)}function ne(o,e,t=!0){const n=k(o),s={maxLevel:1,level:1};n.emitToChildren(s,"setNameValidateRules",e,t)}const se=o=>`_fox_ctrl_${o.path??o.name??""}_${o.root??"default"}`;function Le(o,e,t){if(o==null||typeof o!="object")return;let n=o;const s=e.split(".");for(let r=0;r<s.length&&Reflect.has(n,s[r]);r++){if(r===s.length-1){n[s[r]]=t;return}if(n=n[s[r]],n==null||typeof n!="object")break}}const Me=["beforeBack","back"],z="getShareBus",J="havePermission",Pe=["beforeExit","exit"],je=["setCheckConditions","check"],Ve="cancelSubmit",He="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 Be="foxOpenType";let _e=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"),m=Symbol("_getFlow"),H=Symbol("_reset"),ce=Symbol("_destroy"),y=Symbol("_execHook");function Te(o){return o==null?!1:o===!1?!0:typeof o=="object"&&Reflect.has(o,"pass")?!o.pass:!1}const R=function(o,e){return(n,...s)=>{try{const r=Reflect.apply(o,e,[n,...s]);u.isPromise(r)&&r.then(l=>{Te(l)?n.reject(l):n.resolve(l)}).catch(l=>{n.reject(l)})}catch(r){console.error(`[${E}] exec hook error`,r),n.reject(r)}}};class ue{[b]=null;[w]=new Ee;[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])}[m](e){if(!this[v]){const t=_e(this[h]);this[v]=De(this[D],t)}return Ae(this[v],this[h],e),this[v]}[H](){this[b]=null,this[g]="none"}[y](e,t){const n=this[m](t);if(Array.isArray(e)){const s=this[F](!0);e.forEach(r=>{const l=n[r];if(typeof l=="function"){const i=R(l,n);s?.post(i)}})}else{const s=n[e];if(typeof s=="function")return Reflect.apply(s,n,[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[h]=null,e[D]=null,e[v]=null}get name(){return this[V]??""}get proxy(){return this[h]}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 n=this[F]();if(this[g]==="pretreat"&&P){try{P.lock()}catch{}n?.post(r=>{P?.unlock(),r.resolve()})}const s=this[m](t);je.forEach(r=>{const l=s[r];typeof l=="function"&&n?.post(R(l,s))}),re.forEach(r=>{const l=s[r];typeof l=="function"&&n?.post(R(l,s))}),n?.wait((r,...l)=>{this[H]();const i=s[He];typeof i=="function"&&Reflect.apply(i,s,[r,...l])},(r,...l)=>{this[H]();const i=()=>{const a=s[Ve];typeof a=="function"&&Reflect.apply(a,s,[r,...l])};if(Array.isArray(M)&&M.length>0){const a=this[F](!0);M.forEach(c=>{const C=s[c];typeof C=="function"&&a?.post(R(C,s))}),a?.wait(()=>i,()=>i)}else i()})}exit(e){return new Promise((t,n)=>{const s=this[F](!0),r=this[m](e);Pe.forEach(l=>{const i=r[l];typeof i=="function"&&s?.post(R(i,r))}),s?.wait((l,...i)=>{t(!0)},(l,...i)=>{t(!0)})})}back(e){return this[y](Me,e),!0}exec(e,t){return this[y](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,n){const s=this[m](n??"");if(Array.isArray(s.allDataList)){for(let r of s.allDataList)if(r.name===n){Le(r.last,e,t),r.last[e]=t;break}}}getValue(e,t){let n=null;const s=this[m](t??"");if(Array.isArray(s.allDataList)){for(let r of s.allDataList)if(r.name===t){n=r.last[e];break}}return n}get allDataList(){return this[m]().allDataList}get dataList(){return this[m]().dataList}getDataRecordByFieldName(e){return this.allDataList.find(s=>Reflect.ownKeys(s.last).includes(e))??null}broadcast(e,t,...n){return Reflect.apply(ee,null,[this[h],e,t,...n])}resetFields(e,t){let n=[];Array.isArray(t)?n=t:typeof t=="string"?n=[t]:n=[d];const s=this[h];n.forEach(r=>{const l=Fe(s,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 fe=Symbol.for("FoxControllerKey"),$e=Symbol.for("PageWrapperKey"),G=new WeakMap;let x=[];function Ne(o,e){const t=f.toRaw(o);be(t,e)}function Oe(o,e,t){let n=t,s,r;const l={};if(typeof e=="string"?s=e:e&&typeof e=="object"&&(s=e.name,r=e.mixin,Object.assign(l,e)),!n){const p=f.getCurrentInstance();if(p===null)throw new Error("defineData must in setup hook");if(p.proxy==null)throw new Error("proxy is null");n=p.proxy}if(Se(n,s))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(n);if(!s)u.extend(!0,i,c);else{const p=c[s];p&&typeof p=="object"&&u.extend(!0,i,p)}const C={};u.extend(!0,C,i);const K=f.reactive(i);if(ve(n,{name:s??d,metadata:l,original:C,last:K},s),n){const p=k(n),q=()=>{s?p?.emitToChildren({name:s},"setModelValue",K):p?.emitToChildren({maxLevel:1,level:1},"setModelValue",K)};n.$.isMounted?q():f.onMounted(q)}return K}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 ue(o,e);x.push({proxy:e,controller:t,state:"create"});const n=u.useEventProxy(e);let s=null,r=null;const l=u.useRoute(e);l&&l.path&&l.root&&(r=se(l),s=(a,c)=>{a==="exit"?t.exit(c):a==="submit"?t.submit(c):a==="execHook"&&typeof c=="string"&&t[y](c)},n.on(r,s)),f.onBeforeMount(()=>{t[y]("beforeMount")}),f.onMounted(()=>{e&&Ue(e,"mounted"),t[y](["mounted","endMounted"])}),f.onBeforeUnmount(()=>{t[y]("beforeUnmount")}),f.onUnmounted(()=>{t[y]("unmounted"),t[ce](),e&&(Ge(e),Ce(e),G.delete(e),ke(e)),r&&s&&n.off(r,s)}),u.onFoxActivated(()=>{t[y]("activated")}),u.onFoxInactivated(()=>{t[y]("inactivated")});const i=f.inject($e,null);i&&typeof i.beforeClose!="function"&&(i.used||(i.used=!0,i.beforeClose=async a=>{await t.exit(),typeof a=="function"&&a()},i.onShow=()=>{t[y]("activated")},i.onHide=()=>{t[y]("inactivated")}));try{t[y]("created")}catch(a){console.error(`[${E}] created error`,a)}return G.set(e,t),u.provideContextValue(e,fe,t),t}function We(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 Ue(o,e){for(let t=x.length-1;t>=0;t--){const n=x[t];if(n.proxy===o){n.state=e;break}}}function Ge(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 n=t.proxy.$el;if(n===o||n.contains(o))return t}}return null}function qe(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:n,ctrlKey:s}=o,r=[];return t&&r.push("Shift"),n&&r.push("Alt"),s&&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,ze={mounted(o,e,t,n){const s=de(e,"ENTER"),r=j(o),l=e.value??{},i=a=>{const c=ye(a);r&&r.controller&&c===s&&r.controller.submit(l)};o.addEventListener("keyup",i),B.set(o,i)},beforeUnmount(o,e,t,n){const s=B.get(o);B.delete(o),s&&o.removeEventListener("keyup",s)}},_=new WeakMap,Je={mounted(o,e,t,n){const s=de(e,"ESCAPE"),r=j(o),l=e.value??{},i=a=>{const c=ye(a);r&&r.controller&&c===s&&r.controller.exit(l)};o.addEventListener("keyup",i),_.set(o,i)},beforeUnmount(o,e,t,n){const s=_.get(o);_.delete(o),s&&o.removeEventListener("keyup",s)}},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"},Qe={mounted(o,e,t,n){const s=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,s,a)}):Q(o,s,i)}})}},Xe={install(o){o.directive("submit",ze),o.directive("exit",Je),o.directive("permission",Qe)}};function he(o,e){Y.set(o,e)}const Ye={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 n=e.systemFlows[t];he(t,n)}Xe.install(o)}};exports.BaseFlow=Ke;exports.DefaultKey=d;exports.FoxController=ue;exports.TAG=E;exports.createEventProxyName=se;exports.default=Ye;exports.defineFoxController=Ie;exports.defineFoxData=Oe;exports.defineFoxMixinData=Ne;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=We;exports.useFoxSyncData=qe;

@@ -1,11 +0,11 @@

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";
import { inject as Z, provide as fe, toRaw as ee, getCurrentInstance as M, reactive as ye, onMounted as te, onBeforeMount as he, onBeforeUnmount as de, onUnmounted as pe, watchEffect as me } from "vue";
import { useRoute as P, 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-27 Sat Mar 09 2024 10:12:21 GMT+0800 (中国标准时间)
* @fox-js/flow v4.0.1-28 Mon Mar 25 2024 00:13:18 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 {
/**

@@ -37,4 +37,4 @@ * parent

*/
constructor(e, t, s) {
this.parent = e, this.proxy = t, this.name = s, e !== null && e.addChild(this);
constructor(e, t, n) {
this.parent = e, this.proxy = t, this.name = n, e !== null && e.addChild(this);
}

@@ -53,3 +53,3 @@ /**

removeChild(e) {
const t = this.children.findIndex((s) => e === s);
const t = this.children.findIndex((n) => e === n);
t !== -1 && this.children.splice(t, 1);

@@ -69,3 +69,3 @@ }

*/
emit(e, t, ...s) {
emit(e, t, ...n) {
if (e.maxLevel !== void 0 && e.maxLevel !== null && e.maxLevel > 0) {

@@ -76,20 +76,20 @@ if (e.level = e.level ?? 0, e.level > e.maxLevel)

}
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);
let s = !1;
!e.name || e.name === "*" ? s = !0 : !e.name || e.name === "+" ? (s = !1, e.name = "*") : ke(e.name) && this.name && e.name.test(this.name) ? s = !0 : typeof e.name == "function" ? s = Reflect.apply(e.name, null, [this.name]) : e.name === this.name && (s = !0);
const r = [];
if (n) {
const i = this.callbacks.get(t);
if (typeof i == "function") {
const a = Reflect.apply(i, this.proxy, [...s]);
if (s) {
const l = this.callbacks.get(t);
if (typeof l == "function") {
const a = Reflect.apply(l, this.proxy, [...n]);
a != null && r.push(a);
}
const l = this.proxy ?? {};
if (typeof l[t] == "function") {
const a = Reflect.apply(l[t], l, [...s]);
const i = this.proxy ?? {};
if (typeof i[t] == "function") {
const a = Reflect.apply(i[t], i, [...n]);
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]);
return this.children.forEach((l) => {
const i = Reflect.apply(l.emit, l, [{ ...e }, t, ...n]);
i != null && Array.isArray(i) && Reflect.apply([].push, r, [...i]);
}), r;

@@ -103,8 +103,8 @@ }

*/
emitToChildren(e, t, ...s) {
const n = [];
emitToChildren(e, t, ...n) {
const s = [];
return this.children.forEach((r) => {
const i = Reflect.apply(r.emit, r, [{ ...e }, t, ...s]);
i != null && Array.isArray(i) && Reflect.apply([].push, n, [...i]);
}), n;
const l = Reflect.apply(r.emit, r, [{ ...e }, t, ...n]);
l != null && Array.isArray(l) && Reflect.apply([].push, s, [...l]);
}), s;
}

@@ -121,8 +121,8 @@ /**

}
function Fe(o, e, t, s) {
const n = new ke(e, o, t);
if (s && typeof s == "object")
for (const r in s)
n.on(r, s[r]);
return n;
function Fe(o, e, t, n) {
const s = new Se(e, o, t);
if (n && typeof n == "object")
for (const r in n)
s.on(r, n[r]);
return s;
}

@@ -138,9 +138,9 @@ const f = "", ne = /* @__PURE__ */ new Map();

function Ee(o, e, t = f) {
let s = g.get(o);
s || (s = /* @__PURE__ */ new Map(), g.set(o, s)), s.set(t, e);
let n = g.get(o);
n || (n = /* @__PURE__ */ new Map(), g.set(o, n)), n.set(t, e);
}
function Re(o) {
const e = [], t = g.get(o);
return t && t.forEach((s, n) => {
e.push(s);
return t && t.forEach((n, s) => {
e.push(n);
}), e;

@@ -159,3 +159,3 @@ }

}
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);

@@ -165,16 +165,16 @@ if (!e) {

e = Fe(o, t), T.set(o, e);
const s = o;
s[D] = e, fe(D, e);
const n = o;
n[D] = e, fe(D, e);
}
return e;
}, Me = (o) => {
}, je = (o) => {
const e = o;
e[D] = null, T.delete(o);
}, Pe = Symbol.for("SyncDataKey");
}, Me = Symbol.for("SyncDataKey");
function re(o) {
const e = j(o);
return e && e.params ? e.params[Pe] ?? {} : {};
const e = P(o);
return e && e.params ? e.params[Me] ?? {} : {};
}
const M = "FoxFlow";
class je {
const j = "FoxFlow";
class Pe {
/**

@@ -186,3 +186,3 @@ * session数据

const $ = Symbol("nameKey"), O = Symbol("dataKey"), W = Symbol("originalDataKey"), N = Symbol("allDataListKey"), U = Symbol("dataListKey"), I = Symbol("proxyKey");
class ut {
class ft {
/**

@@ -252,3 +252,3 @@ * Flow名称

get route() {
return j(this.proxy ?? void 0);
return P(this.proxy ?? void 0);
}

@@ -259,5 +259,5 @@ }

if (t) {
let s = o;
const n = new t();
s.__proto__ = n;
let n = o;
const s = new t();
n.__proto__ = s;
}

@@ -267,20 +267,20 @@ return o;

function Ve(o, e, t) {
const s = Re(e);
let n = [];
!t || t === f ? n = [] : Array.isArray(t) ? n = t : n = [String(t ?? "")];
const r = [], i = {}, l = {};
s.forEach((a) => {
const n = Re(e);
let s = [];
!t || t === f ? s = [] : Array.isArray(t) ? s = t : s = [String(t ?? "")];
const r = [], l = {}, i = {};
n.forEach((a) => {
const c = String(a.name ?? "");
(n.length === 0 || n.includes(c)) && (r.push(a), Object.assign(i, a.original), Object.assign(l, a.last));
}), o[N] = s, o[U] = r, o[W] = i, o[O] = l, o[I] = e, o[$] = t ?? f;
(s.length === 0 || s.includes(c)) && (r.push(a), Object.assign(l, a.original), Object.assign(i, a.last));
}), o[N] = n, o[U] = r, o[W] = l, o[O] = i, o[I] = e, o[$] = t ?? f;
}
function Be(o, e, t, ...s) {
const n = S(o);
return Reflect.apply(n.emit, n, [e, t, ...s]);
function Be(o, e, t, ...n) {
const s = k(o);
return Reflect.apply(s.emit, s, [e, t, ...n]);
}
function _e(o, e = !0, t) {
const s = S(o);
let n = null;
const n = k(o);
let s = null;
if (!t || t === f)
t = void 0, n = {
t = void 0, s = {
maxLevel: 1,

@@ -290,16 +290,16 @@ level: 1

else if (Array.isArray(t)) {
const i = t;
n = {
name: (l) => i.includes(l)
const l = t;
s = {
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((i) => {
let l = [];
return i.forEach((a) => {
a.pass === !1 && Array.isArray(a.errors) && (l = [...l, ...a.errors]);
}), l.length > 0 ? {
s = { name: String(t) };
const r = n.emitToChildren(s, "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: l
errors: i
} : {

@@ -313,6 +313,6 @@ pass: !0

function Te(o, e = !0, t) {
const s = S(o);
let n = null;
const n = k(o);
let s = null;
if (!t || t === f)
t = void 0, n = {
t = void 0, s = {
maxLevel: 1,

@@ -323,52 +323,67 @@ level: 1

const r = t;
n = {
name: (i) => r.includes(i)
s = {
name: (l) => r.includes(l)
};
} else
n = { name: String(t) };
s.emitToChildren(n, "clearValidate", e);
s = { name: String(t) };
n.emitToChildren(s, "clearValidate", e);
}
function $e(o, e, t = !0) {
const s = S(o), n = {
const n = k(o), s = {
maxLevel: 1,
level: 1
};
s.emitToChildren(n, "setNameValidateRules", e, t);
n.emitToChildren(s, "setNameValidateRules", e, t);
}
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 ie = ["preSubmit", "commit", "submit", "postSubmit"], A = [];
function qe(o) {
ie = [...o];
const Oe = (o) => `_fox_ctrl_${o.path ?? o.name ?? ""}_${o.root ?? "default"}`;
function We(o, e, t) {
if (o == null || typeof o != "object")
return;
let n = o;
const s = e.split(".");
for (let r = 0; r < s.length && Reflect.has(n, s[r]); r++) {
if (r === s.length - 1) {
n[s[r]] = t;
return;
}
if (n = n[s[r]], n == null || typeof n != "object")
break;
}
}
const Ne = ["beforeBack", "back"], Q = "getShareBus", X = "havePermission", Ue = ["beforeExit", "exit"], Ie = ["setCheckConditions", "check"], Ge = "cancelSubmit", qe = "endSubmit";
let le = ["preSubmit", "commit", "submit", "postSubmit"], A = [];
function ze(o) {
le = [...o];
}
function Je(o) {
A = [...o];
}
let L = null;
function Je(o) {
function Qe(o) {
L = o;
}
const Qe = "foxOpenType";
let Xe = (o) => {
const e = j(o);
return e && e.params ? e.params[Qe] ?? "normal" : "normal";
const Xe = "foxOpenType";
let Ye = (o) => {
const e = P(o);
return e && e.params ? e.params[Xe] ?? "normal" : "normal";
};
const m = Symbol("eventChainKey"), b = Symbol("sessionKey"), y = 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"), le = Symbol("_destroy"), u = Symbol("_execHook");
function Ye(o) {
const m = Symbol("eventChainKey"), b = Symbol("sessionKey"), y = 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"), u = Symbol("_execHook");
function Ze(o) {
return o == null ? !1 : o === !1 ? !0 : typeof o == "object" && Reflect.has(o, "pass") ? !o.pass : !1;
}
const F = function(o, e) {
return (s, ...n) => {
return (n, ...s) => {
try {
const r = Reflect.apply(o, e, [s, ...n]);
oe(r) && r.then((i) => {
Ye(i) ? s.reject(i) : s.resolve(i);
}).catch((i) => {
s.reject(i);
const r = Reflect.apply(o, e, [n, ...s]);
oe(r) && r.then((l) => {
Ze(l) ? n.reject(l) : n.resolve(l);
}).catch((l) => {
n.reject(l);
});
} catch (r) {
console.error(`[${M}] exec hook error`, r), s.reject(r);
console.error(`[${j}] exec hook error`, r), n.reject(r);
}
};
};
class Ze {
class et {
/**

@@ -381,3 +396,3 @@ * event chain

*/
[b] = new je();
[b] = new Pe();
/**

@@ -430,3 +445,3 @@ * proxy属性

if (!this[w]) {
const t = Xe(this[y]);
const t = Ye(this[y]);
this[w] = He(this[E], t);

@@ -449,16 +464,16 @@ }

[u](e, t) {
const s = this[d](t);
const n = this[d](t);
if (Array.isArray(e)) {
const n = this[v](!0);
const s = this[v](!0);
e.forEach((r) => {
const i = s[r];
if (typeof i == "function") {
const l = F(i, s);
n?.post(l);
const l = n[r];
if (typeof l == "function") {
const i = F(l, n);
s?.post(i);
}
});
} else {
const n = s[e];
if (typeof n == "function")
return Reflect.apply(n, s, [this[b]]);
const s = n[e];
if (typeof s == "function")
return Reflect.apply(s, n, [this[b]]);
}

@@ -472,3 +487,3 @@ }

pretreat(e) {
return this[x] === "submit" ? (console.warn(`[${M}]流程已经处于提交状态,无法加入预处理任务`), !1) : (this[v]()?.post(e), this[x] = "pretreat", !0);
return this[x] === "submit" ? (console.warn(`[${j}]流程已经处于提交状态,无法加入预处理任务`), !1) : (this[v]()?.post(e), this[x] = "pretreat", !0);
}

@@ -478,3 +493,3 @@ /**

*/
[le]() {
[ie]() {
const e = this;

@@ -515,5 +530,5 @@ e[m] = null, e[b] = null, e[y] = null, e[E] = null, e[w] = null;

if (typeof e == "string" && (t = e, e = void 0), this[H] = t ?? "", !this[R] && this[x] === "submit")
return console.warn(`[${M}]流程已经处于提交状态,无法重复提交`), !1;
return console.warn(`[${j}]流程已经处于提交状态,无法重复提交`), !1;
e && typeof e == "object" && Object.assign(this[b].data, e);
const s = this[v]();
const n = this[v]();
if (this[x] === "pretreat" && L) {

@@ -524,24 +539,24 @@ try {

}
s?.post((r) => {
n?.post((r) => {
L?.unlock(), r.resolve();
});
}
const n = this[d](t);
Ue.forEach((r) => {
const i = n[r];
typeof i == "function" && s?.post(F(i, n));
}), ie.forEach((r) => {
const i = n[r];
typeof i == "function" && s?.post(F(i, n));
}), s?.wait(
(r, ...i) => {
const s = this[d](t);
Ie.forEach((r) => {
const l = s[r];
typeof l == "function" && n?.post(F(l, s));
}), le.forEach((r) => {
const l = s[r];
typeof l == "function" && n?.post(F(l, s));
}), n?.wait(
(r, ...l) => {
this[V]();
const l = n[Ge];
typeof l == "function" && Reflect.apply(l, n, [r, ...i]);
const i = s[qe];
typeof i == "function" && Reflect.apply(i, s, [r, ...l]);
},
(r, ...i) => {
(r, ...l) => {
this[V]();
const l = () => {
const a = n[Ie];
typeof a == "function" && Reflect.apply(a, n, [r, ...i]);
const i = () => {
const a = s[Ge];
typeof a == "function" && Reflect.apply(a, s, [r, ...l]);
};

@@ -551,10 +566,10 @@ if (Array.isArray(A) && A.length > 0) {

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

@@ -568,12 +583,12 @@ );

exit(e) {
return new Promise((t, s) => {
const n = this[v](!0), r = this[d](e);
Ne.forEach((i) => {
const l = r[i];
typeof l == "function" && n?.post(F(l, r));
}), n?.wait(
(i, ...l) => {
return new Promise((t, n) => {
const s = this[v](!0), r = this[d](e);
Ue.forEach((l) => {
const i = r[l];
typeof i == "function" && s?.post(F(i, r));
}), s?.wait(
(l, ...i) => {
t(!0);
},
(i, ...l) => {
(l, ...i) => {
t(!0);

@@ -589,3 +604,3 @@ }

back(e) {
return this[u](We, e), !0;
return this[u](Ne, e), !0;
}

@@ -624,8 +639,8 @@ /**

*/
setValue(e, t, s) {
const n = this[d](s ?? "");
if (Array.isArray(n.allDataList)) {
for (let r of n.allDataList)
if (r.name === s) {
r.last[e] = t;
setValue(e, t, n) {
const s = this[d](n ?? "");
if (Array.isArray(s.allDataList)) {
for (let r of s.allDataList)
if (r.name === n) {
We(r.last, e, t), r.last[e] = t;
break;

@@ -641,12 +656,12 @@ }

getValue(e, t) {
let s = null;
const n = this[d](t ?? "");
if (Array.isArray(n.allDataList)) {
for (let r of n.allDataList)
let n = null;
const s = this[d](t ?? "");
if (Array.isArray(s.allDataList)) {
for (let r of s.allDataList)
if (r.name === t) {
s = r.last[e];
n = r.last[e];
break;
}
}
return s;
return n;
}

@@ -671,3 +686,3 @@ /**

getDataRecordByFieldName(e) {
return this.allDataList.find((n) => Reflect.ownKeys(n.last).includes(e)) ?? null;
return this.allDataList.find((s) => Reflect.ownKeys(s.last).includes(e)) ?? null;
}

@@ -680,4 +695,4 @@ /**

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

@@ -690,22 +705,22 @@ /**

resetFields(e, t) {
let s = [];
Array.isArray(t) ? s = t : typeof t == "string" ? s = [t] : s = [f];
const n = this[y];
s.forEach((r) => {
const i = De(n, r) ?? { original: {}, last: {} }, l = {};
if (C(!0, l, i.original), Array.isArray(e))
let n = [];
Array.isArray(t) ? n = t : typeof t == "string" ? n = [t] : n = [f];
const s = this[y];
n.forEach((r) => {
const l = De(s, r) ?? { original: {}, last: {} }, i = {};
if (C(!0, i, l.original), Array.isArray(e))
e.forEach((a) => {
i.last[a] = l[a];
l.last[a] = i[a];
});
else if (e && Array.isArray(e.include))
(e.include ?? []).forEach((c) => {
i.last[c] = l[c];
l.last[c] = i[c];
});
else if (e && Array.isArray(e.exclude)) {
let a = e.exclude ?? [];
Reflect.ownKeys(l).forEach((c) => {
typeof c == "string" && (a.includes(c) || (i.last[c] = l[c]));
Reflect.ownKeys(i).forEach((c) => {
typeof c == "string" && (a.includes(c) || (l.last[c] = i[c]));
});
} else
Object.assign(i.last, l);
Object.assign(l.last, i);
}), this.clearValidate(e, t);

@@ -739,13 +754,13 @@ }

}
const ae = Symbol.for("FoxControllerKey"), et = Symbol.for("PageWrapperKey"), G = /* @__PURE__ */ new WeakMap();
const ae = Symbol.for("FoxControllerKey"), tt = Symbol.for("PageWrapperKey"), G = /* @__PURE__ */ new WeakMap();
let p = [];
function ft(o, e) {
function yt(o, e) {
const t = ee(o);
Ce(t, e);
}
function yt(o, e, t) {
let s = t, n, r;
const i = {};
if (typeof e == "string" ? n = e : e && typeof e == "object" && (n = e.name, r = e.mixin, Object.assign(i, e)), !s) {
const h = P();
function ht(o, e, t) {
let n = t, s, r;
const l = {};
if (typeof e == "string" ? s = e : e && typeof e == "object" && (s = e.name, r = e.mixin, Object.assign(l, e)), !n) {
const h = M();
if (h === null)

@@ -755,38 +770,38 @@ throw new Error("defineData must in setup hook");

throw new Error("proxy is null");
s = h.proxy;
n = h.proxy;
}
if (Ae(s, n))
if (Ae(n, s))
throw new Error("duplicate definitions are not allowed, please Set different name!");
const l = ee(o), a = Ke(r);
a && C(!0, l, a);
const c = re(s);
if (!n)
C(!0, l, c);
const i = ee(o), a = Ke(r);
a && C(!0, i, a);
const c = re(n);
if (!s)
C(!0, i, c);
else {
const h = c[n];
h && typeof h == "object" && C(!0, l, h);
const h = c[s];
h && typeof h == "object" && C(!0, i, h);
}
const k = {};
C(!0, k, l);
const K = ye(l);
const S = {};
C(!0, S, i);
const K = ye(i);
if (Ee(
s,
n,
{
name: n ?? f,
metadata: i,
original: k,
name: s ?? f,
metadata: l,
original: S,
last: K
},
n
), s) {
const h = S(s), z = () => {
n ? h?.emitToChildren({ name: n }, "setModelValue", K) : h?.emitToChildren({ maxLevel: 1, level: 1 }, "setModelValue", K);
s
), n) {
const h = k(n), z = () => {
s ? h?.emitToChildren({ name: s }, "setModelValue", K) : h?.emitToChildren({ maxLevel: 1, level: 1 }, "setModelValue", K);
};
s.$.isMounted ? z() : te(z);
n.$.isMounted ? z() : te(z);
}
return K;
}
function ht(o = {}, e) {
function dt(o = {}, e) {
if (!e) {
const a = P();
const a = M();
if (a === null)

@@ -798,4 +813,4 @@ throw new Error("defineData must in setup hook");

}
S(e);
const t = new Ze(o, e);
k(e);
const t = new et(o, e);
p.push({

@@ -806,15 +821,15 @@ proxy: e,

});
const s = be(e);
let n = null, r = null;
const i = j(e);
i && i.path && i.root && (r = Oe(i), n = (a, c) => {
const n = be(e);
let s = null, r = null;
const l = P(e);
l && l.path && l.root && (r = Oe(l), s = (a, c) => {
a === "exit" ? t.exit(c) : a === "submit" ? t.submit(c) : a === "execHook" && typeof c == "string" && t[u](c);
}, s.on(r, n)), he(() => {
}, n.on(r, s)), he(() => {
t[u]("beforeMount");
}), te(() => {
e && tt(e, "mounted"), t[u](["mounted", "endMounted"]);
e && ot(e, "mounted"), t[u](["mounted", "endMounted"]);
}), de(() => {
t[u]("beforeUnmount");
}), pe(() => {
t[u]("unmounted"), t[le](), e && (ot(e), Me(e), G.delete(e), Le(e)), r && n && s.off(r, n);
t[u]("unmounted"), t[ie](), e && (nt(e), je(e), G.delete(e), Le(e)), r && s && n.off(r, s);
}), we(() => {

@@ -825,8 +840,8 @@ t[u]("activated");

});
const l = Z(et, null);
l && typeof l.beforeClose != "function" && (l.used || (l.used = !0, l.beforeClose = async (a) => {
const i = Z(tt, null);
i && typeof i.beforeClose != "function" && (i.used || (i.used = !0, i.beforeClose = async (a) => {
await t.exit(), typeof a == "function" && a();
}, l.onShow = () => {
}, i.onShow = () => {
t[u]("activated");
}, l.onHide = () => {
}, i.onHide = () => {
t[u]("inactivated");

@@ -837,15 +852,15 @@ }));

} catch (a) {
console.error(`[${M}] created error`, a);
console.error(`[${j}] created error`, a);
}
return G.set(e, t), ve(e, ae, t), t;
}
function dt(o) {
function pt(o) {
let e = null;
return o && (e = G.get(o) ?? null), e || (o || (o = P()?.proxy ?? void 0), o && (e = ge(o, ae))), e;
return o && (e = G.get(o) ?? null), e || (o || (o = M()?.proxy ?? void 0), o && (e = ge(o, ae))), e;
}
function tt(o, e) {
function ot(o, e) {
for (let t = p.length - 1; t >= 0; t--) {
const s = p[t];
if (s.proxy === o) {
s.state = e;
const n = p[t];
if (n.proxy === o) {
n.state = e;
break;

@@ -855,3 +870,3 @@ }

}
function ot(o) {
function nt(o) {
const e = p.findIndex((t) => t.proxy === o);

@@ -873,4 +888,4 @@ e !== -1 && p.splice(e, 1);

if (t.proxy && t.proxy.$el) {
const s = t.proxy.$el;
if (s === o || s.contains(o))
const n = t.proxy.$el;
if (n === o || n.contains(o))
return t;

@@ -881,5 +896,5 @@ }

}
function pt(o) {
function mt(o) {
if (!o) {
const e = P();
const e = M();
if (e === null)

@@ -894,52 +909,52 @@ throw new Error("getSyncData must in setup hook");

const ce = (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();
let { key: e, shiftKey: t, altKey: n, ctrlKey: s } = o, r = [];
return t && r.push("Shift"), n && r.push("Alt"), s && r.push("Ctrl"), r.push(e), r.join("+").toLocaleUpperCase();
}, ue = (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 = /* @__PURE__ */ new WeakMap(), nt = {
}, B = /* @__PURE__ */ new WeakMap(), st = {
// 在绑定元素的父组件
// 及他自己的所有子节点都挂载完成后调用
mounted(o, e, t, s) {
const n = ue(e, "ENTER"), r = q(o), i = e.value ?? {}, l = (a) => {
mounted(o, e, t, n) {
const s = ue(e, "ENTER"), r = q(o), l = e.value ?? {}, i = (a) => {
const c = ce(a);
r && r.controller && c === n && r.controller.submit(i);
r && r.controller && c === s && r.controller.submit(l);
};
o.addEventListener("keyup", l), B.set(o, 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);
beforeUnmount(o, e, t, n) {
const s = B.get(o);
B.delete(o), s && o.removeEventListener("keyup", s);
}
}, _ = /* @__PURE__ */ new WeakMap(), st = {
}, _ = /* @__PURE__ */ new WeakMap(), rt = {
// 在绑定元素的父组件
// 及他自己的所有子节点都挂载完成后调用
mounted(o, e, t, s) {
const n = ue(e, "ESCAPE"), r = q(o), i = e.value ?? {}, l = (a) => {
mounted(o, e, t, n) {
const s = ue(e, "ESCAPE"), r = q(o), l = e.value ?? {}, i = (a) => {
const c = ce(a);
r && r.controller && c === n && r.controller.exit(i);
r && r.controller && c === s && r.controller.exit(l);
};
o.addEventListener("keyup", l), _.set(o, l);
o.addEventListener("keyup", i), _.set(o, i);
},
// 绑定元素的父组件卸载后调用
beforeUnmount(o, e, t, s) {
const n = _.get(o);
_.delete(o), n && o.removeEventListener("keyup", n);
beforeUnmount(o, e, t, n) {
const s = _.get(o);
_.delete(o), s && o.removeEventListener("keyup", s);
}
}, Y = (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";
}, rt = {
}, lt = {
// 在绑定元素的父组件
// 及他自己的所有子节点都挂载完成后调用
mounted(o, e, t, s) {
const n = e.arg ?? "show";
mounted(o, e, t, n) {
const s = e.arg ?? "show";
let r = e.value;
r || (r = o.dataset.permission ?? []), me(() => {
const i = q(o);
if (i && i.controller) {
const l = i.controller.havePermission(r);
oe(l) ? l.then((a) => {
Y(o, n, a);
}) : Y(o, n, l);
const l = q(o);
if (l && l.controller) {
const i = l.controller.havePermission(r);
oe(i) ? i.then((a) => {
Y(o, s, a);
}) : Y(o, s, i);
}

@@ -954,9 +969,9 @@ });

install(o) {
o.directive("submit", nt), o.directive("exit", st), o.directive("permission", rt);
o.directive("submit", st), o.directive("exit", rt), o.directive("permission", lt);
}
};
function lt(o, e) {
function at(o, e) {
se.set(o, e);
}
const mt = {
const bt = {
/**

@@ -968,6 +983,6 @@ * 安装

install(o, e = {}) {
if (e.pretreatLocker && Je(e.pretreatLocker), e.customSubmitFlowHooks && qe(e.customSubmitFlowHooks), e.customCancelSubmitFlowHooks && ze(e.customCancelSubmitFlowHooks), e.systemFlows)
if (e.pretreatLocker && Qe(e.pretreatLocker), e.customSubmitFlowHooks && ze(e.customSubmitFlowHooks), e.customCancelSubmitFlowHooks && Je(e.customCancelSubmitFlowHooks), e.systemFlows)
for (let t in e.systemFlows) {
let s = e.systemFlows[t];
lt(t, s);
let n = e.systemFlows[t];
at(t, n);
}

@@ -978,11 +993,11 @@ it.install(o);

export {
ut as BaseFlow,
ft as BaseFlow,
f as DefaultKey,
Ze as FoxController,
M as TAG,
et as FoxController,
j as TAG,
Oe as createEventProxyName,
mt as default,
ht as defineFoxController,
yt as defineFoxData,
ft as defineFoxMixinData,
bt as default,
dt as defineFoxController,
ht as defineFoxData,
yt as defineFoxMixinData,
Be as execBroadcast,

@@ -992,9 +1007,9 @@ Te as execClearValidate,

_e as execValidate,
ze as setCustomCancelSubmitFlowHooks,
qe as setCustomSubmitFlowHooks,
lt as setFoxSystemFlow,
Je as setPretreatLocker,
Je as setCustomCancelSubmitFlowHooks,
ze as setCustomSubmitFlowHooks,
at as setFoxSystemFlow,
Qe as setPretreatLocker,
q as useFoxContext,
dt as useFoxController,
pt as useFoxSyncData
pt as useFoxController,
mt as useFoxSyncData
};
(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-27 Sat Mar 09 2024 10:12:21 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]??""}get proxy(){return this[m]}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()},l.onShow=()=>{t[h]("activated")},l.onHide=()=>{t[h]("inactivated")}));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"}})});
* @fox-js/flow v4.0.1-28 Mon Mar 25 2024 00:13:18 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,o){this.parent=e,this.proxy=t,this.name=o,e!==null&&e.addChild(this)}addChild(e){this.children.push(e)}removeChild(e){const t=this.children.findIndex(o=>e===o);t!==-1&&this.children.splice(t,1)}destroy(){this.parent!==null&&this.parent.removeChild(this),this.parent=null,this.proxy=null}emit(e,t,...o){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 s=!1;!e.name||e.name==="*"?s=!0:!e.name||e.name==="+"?(s=!1,e.name="*"):pe(e.name)&&this.name&&e.name.test(this.name)?s=!0:typeof e.name=="function"?s=Reflect.apply(e.name,null,[this.name]):e.name===this.name&&(s=!0);const r=[];if(s){const i=this.callbacks.get(t);if(typeof i=="function"){const a=Reflect.apply(i,this.proxy,[...o]);a!=null&&r.push(a)}const l=this.proxy??{};if(typeof l[t]=="function"){const a=Reflect.apply(l[t],l,[...o]);a!=null&&r.push(a)}}return this.children.forEach(i=>{const l=Reflect.apply(i.emit,i,[{...e},t,...o]);l!=null&&Array.isArray(l)&&Reflect.apply([].push,r,[...l])}),r}emitToChildren(e,t,...o){const s=[];return this.children.forEach(r=>{const i=Reflect.apply(r.emit,r,[{...e},t,...o]);i!=null&&Array.isArray(i)&&Reflect.apply([].push,s,[...i])}),s}on(e,t){this.callbacks.set(e,t)}}function we(n,e,t,o){const s=new be(e,n,t);if(o&&typeof o=="object")for(const r in o)s.on(r,o[r]);return s}const d="",z=new Map;function ge(n,e=d){z.set(e,n)}function xe(n=d){return z.get(n)??null}const x=new WeakMap;function ve(n,e,t=d){let o=x.get(n);o||(o=new Map,x.set(n,o)),o.set(t,e)}function Fe(n){const e=[],t=x.get(n);return t&&t.forEach((o,s)=>{e.push(o)}),e}function Se(n,e=d){const t=x.get(n);return t?t.get(e)??null:null}function ke(n,e=d){const t=x.get(n);return t?t.has(e):!1}function Ce(n){x.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 o=n;o[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 o=n;const s=new t;o.__proto__=s}return n}function Le(n,e,t){const o=Fe(e);let s=[];!t||t===d?s=[]:Array.isArray(t)?s=t:s=[String(t??"")];const r=[],i={},l={};o.forEach(a=>{const u=String(a.name??"");(s.length===0||s.includes(u))&&(r.push(a),Object.assign(i,a.original),Object.assign(l,a.last))}),n[$]=o,n[N]=r,n[_]=i,n[T]=l,n[O]=e,n[B]=t??d}function X(n,e,t,...o){const s=v(n);return Reflect.apply(s.emit,s,[e,t,...o])}function Y(n,e=!0,t){const o=v(n);let s=null;if(!t||t===d)t=void 0,s={maxLevel:1,level:1};else if(Array.isArray(t)){const i=t;s={name:l=>i.includes(l)}}else s={name:String(t)};const r=o.emitToChildren(s,"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 o=v(n);let s=null;if(!t||t===d)t=void 0,s={maxLevel:1,level:1};else if(Array.isArray(t)){const r=t;s={name:i=>r.includes(i)}}else s={name:String(t)};o.emitToChildren(s,"clearValidate",e)}function ee(n,e,t=!0){const o=v(n),s={maxLevel:1,level:1};o.emitToChildren(s,"setNameValidateRules",e,t)}const te=n=>`_fox_ctrl_${n.path??n.name??""}_${n.root??"default"}`;function je(n,e,t){if(n==null||typeof n!="object")return;let o=n;const s=e.split(".");for(let r=0;r<s.length&&Reflect.has(o,s[r]);r++){if(r===s.length-1){o[s[r]]=t;return}if(o=o[s[r]],o==null||typeof o!="object")break}}const Me=["beforeBack","back"],ne="getShareBus",oe="havePermission",Pe=["beforeExit","exit"],Ve=["setCheckConditions","check"],He="cancelSubmit",Be="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 Te="foxOpenType";let _e=n=>{const e=y.useRoute(n);return e&&e.params?e.params[Te]??"normal":"normal"};const g=Symbol("eventChainKey"),F=Symbol("sessionKey"),m=Symbol("proxyKey"),j=Symbol("userFlowKey"),S=Symbol("flowKey"),k=Symbol("stateKey"),I=Symbol("flowNameKey"),M=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(o,...s)=>{try{const r=Reflect.apply(n,e,[o,...s]);y.isPromise(r)&&r.then(i=>{$e(i)?o.reject(i):o.resolve(i)}).catch(i=>{o.reject(i)})}catch(r){console.error(`[${R}] exec hook error`,r),o.reject(r)}}};class ce{[g]=null;[F]=new Ke;[m];[j];[S]=null;[k]="none";[I]="";[M]=!1;constructor(e,t){this[j]=e,this[m]=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])}[p](e){if(!this[S]){const t=_e(this[m]);this[S]=Ae(this[j],t)}return Le(this[S],this[m],e),this[S]}[W](){this[g]=null,this[k]="none"}[h](e,t){const o=this[p](t);if(Array.isArray(e)){const s=this[C](!0);e.forEach(r=>{const i=o[r];if(typeof i=="function"){const l=E(i,o);s?.post(l)}})}else{const s=o[e];if(typeof s=="function")return Reflect.apply(s,o,[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[g]=null,e[F]=null,e[m]=null,e[j]=null,e[S]=null}get name(){return this[I]??""}get proxy(){return this[m]}set allowResubmit(e){this[M]=e}get allowResubmit(){return this[M]}submit(e,t){if(typeof e=="string"&&(t=e,e=void 0),this[I]=t??"",!this[M]&&this[k]==="submit")return console.warn(`[${R}]流程已经处于提交状态,无法重复提交`),!1;e&&typeof e=="object"&&Object.assign(this[F].data,e);const o=this[C]();if(this[k]==="pretreat"&&L){try{L.lock()}catch{}o?.post(r=>{L?.unlock(),r.resolve()})}const s=this[p](t);Ve.forEach(r=>{const i=s[r];typeof i=="function"&&o?.post(E(i,s))}),se.forEach(r=>{const i=s[r];typeof i=="function"&&o?.post(E(i,s))}),o?.wait((r,...i)=>{this[W]();const l=s[Be];typeof l=="function"&&Reflect.apply(l,s,[r,...i])},(r,...i)=>{this[W]();const l=()=>{const a=s[He];typeof a=="function"&&Reflect.apply(a,s,[r,...i])};if(Array.isArray(A)&&A.length>0){const a=this[C](!0);A.forEach(u=>{const K=s[u];typeof K=="function"&&a?.post(E(K,s))}),a?.wait(()=>l,()=>l)}else l()})}exit(e){return new Promise((t,o)=>{const s=this[C](!0),r=this[p](e);Pe.forEach(i=>{const l=r[i];typeof l=="function"&&s?.post(E(l,r))}),s?.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,o){const s=this[p](o??"");if(Array.isArray(s.allDataList)){for(let r of s.allDataList)if(r.name===o){je(r.last,e,t),r.last[e]=t;break}}}getValue(e,t){let o=null;const s=this[p](t??"");if(Array.isArray(s.allDataList)){for(let r of s.allDataList)if(r.name===t){o=r.last[e];break}}return o}get allDataList(){return this[p]().allDataList}get dataList(){return this[p]().dataList}getDataRecordByFieldName(e){return this.allDataList.find(s=>Reflect.ownKeys(s.last).includes(e))??null}broadcast(e,t,...o){return Reflect.apply(X,null,[this[m],e,t,...o])}resetFields(e,t){let o=[];Array.isArray(t)?o=t:typeof t=="string"?o=[t]:o=[d];const s=this[m];o.forEach(r=>{const i=Se(s,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"),Ne=Symbol.for("PageWrapperKey"),U=new WeakMap;let w=[];function Oe(n,e){const t=f.toRaw(n);ge(t,e)}function Ie(n,e,t){let o=t,s,r;const i={};if(typeof e=="string"?s=e:e&&typeof e=="object"&&(s=e.name,r=e.mixin,Object.assign(i,e)),!o){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");o=b.proxy}if(ke(o,s))throw new Error("duplicate definitions are not allowed, please Set different name!");const l=f.toRaw(n),a=xe(r);a&&y.extend(!0,l,a);const u=Q(o);if(!s)y.extend(!0,l,u);else{const b=u[s];b&&typeof b=="object"&&y.extend(!0,l,b)}const K={};y.extend(!0,K,l);const V=f.reactive(l);if(ve(o,{name:s??d,metadata:i,original:K,last:V},s),o){const b=v(o),me=()=>{s?b?.emitToChildren({name:s},"setModelValue",V):b?.emitToChildren({maxLevel:1,level:1},"setModelValue",V)};o.$.isMounted?me():f.onMounted(me)}return V}function We(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 o=y.useEventProxy(e);let s=null,r=null;const i=y.useRoute(e);i&&i.path&&i.root&&(r=te(i),s=(a,u)=>{a==="exit"?t.exit(u):a==="submit"?t.submit(u):a==="execHook"&&typeof u=="string"&&t[h](u)},o.on(r,s)),f.onBeforeMount(()=>{t[h]("beforeMount")}),f.onMounted(()=>{e&&Ge(e,"mounted"),t[h](["mounted","endMounted"])}),f.onBeforeUnmount(()=>{t[h]("beforeUnmount")}),f.onUnmounted(()=>{t[h]("unmounted"),t[ae](),e&&(qe(e),Re(e),U.delete(e),Ce(e)),r&&s&&o.off(r,s)}),y.onFoxActivated(()=>{t[h]("activated")}),y.onFoxInactivated(()=>{t[h]("inactivated")});const l=f.inject(Ne,null);l&&typeof l.beforeClose!="function"&&(l.used||(l.used=!0,l.beforeClose=async a=>{await t.exit(),typeof a=="function"&&a()},l.onShow=()=>{t[h]("activated")},l.onHide=()=>{t[h]("inactivated")}));try{t[h]("created")}catch(a){console.error(`[${R}] created error`,a)}return U.set(e,t),y.provideContextValue(e,ue,t),t}function Ue(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 Ge(n,e){for(let t=w.length-1;t>=0;t--){const o=w[t];if(o.proxy===n){o.state=e;break}}}function qe(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 o=t.proxy.$el;if(o===n||o.contains(n))return t}}return null}function ze(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:o,ctrlKey:s}=n,r=[];return t&&r.push("Shift"),o&&r.push("Alt"),s&&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,Je={mounted(n,e,t,o){const s=ye(e,"ENTER"),r=P(n),i=e.value??{},l=a=>{const u=fe(a);r&&r.controller&&u===s&&r.controller.submit(i)};n.addEventListener("keyup",l),G.set(n,l)},beforeUnmount(n,e,t,o){const s=G.get(n);G.delete(n),s&&n.removeEventListener("keyup",s)}},q=new WeakMap,Qe={mounted(n,e,t,o){const s=ye(e,"ESCAPE"),r=P(n),i=e.value??{},l=a=>{const u=fe(a);r&&r.controller&&u===s&&r.controller.exit(i)};n.addEventListener("keyup",l),q.set(n,l)},beforeUnmount(n,e,t,o){const s=q.get(n);q.delete(n),s&&n.removeEventListener("keyup",s)}},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"},Xe={mounted(n,e,t,o){const s=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=>{de(n,s,a)}):de(n,s,l)}})}},Ye={install(n){n.directive("submit",Je),n.directive("exit",Qe),n.directive("permission",Xe)}};function he(n,e){J.set(n,e)}const Ze={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 o=e.systemFlows[t];he(t,o)}Ye.install(n)}};c.BaseFlow=De,c.DefaultKey=d,c.FoxController=ce,c.TAG=R,c.createEventProxyName=te,c.default=Ze,c.defineFoxController=We,c.defineFoxData=Ie,c.defineFoxMixinData=Oe,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=P,c.useFoxController=Ue,c.useFoxSyncData=ze,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
{
"name": "@fox-js/flow",
"type": "module",
"version": "4.0.1-28",
"version": "4.0.1-29",
"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