paas-component-library 1.0.67 → 1.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/paas-ui.js CHANGED
@@ -155,23 +155,16 @@ const Yye = /* @__PURE__ */ Er(Zye, [["render", qye]]), Gye = {
155
155
  }
156
156
  },
157
157
  autoSelectMenu() {
158
- let r = this.current;
159
- if (!this.data || this.data.length === 0) return;
160
- const e = this.$route.path;
161
- if (e && e !== "/" && e !== "/system/login") {
162
- const n = this.findItemByKey(this.data, e);
163
- if (n) {
164
- this.selectAndOpenMenu(n);
165
- return;
166
- }
167
- }
168
- r || (r = this.data[0]?.url || "");
169
- const t = this.findItemByKey(this.data, r);
158
+ let r = window.location.hash || "";
159
+ if (r = r.replace("#", ""), !this.data || this.data.length === 0) return;
160
+ let e = this.current;
161
+ e || (e = this.data[0]?.url || "");
162
+ const t = this.findItemByKey(this.data, e);
170
163
  if (t)
171
- this.selectAndOpenMenu(t), this.$router.replace(t.key);
164
+ this.selectAndOpenMenu(t), this.$router.replace(r);
172
165
  else {
173
166
  const n = this.findFirstLeaf(this.data);
174
- n && (this.selectAndOpenMenu(n), this.$router.replace(n.key));
167
+ n && (this.selectAndOpenMenu(n), this.$router.replace(r));
175
168
  }
176
169
  },
177
170
  selectAndOpenMenu(r) {
@@ -295,7 +288,7 @@ function n9e(r, e, t, n, i, o) {
295
288
  }, 16, ["theme", "selectedKeys", "open-keys", "onOpenChange", "inline-collapsed", "mode"])
296
289
  ]);
297
290
  }
298
- const i9e = /* @__PURE__ */ Er(Gye, [["render", n9e], ["__scopeId", "data-v-2f79a554"]]);
291
+ const i9e = /* @__PURE__ */ Er(Gye, [["render", n9e], ["__scopeId", "data-v-2b351d86"]]);
299
292
  var a9e = typeof global == "object" && global && global.Object === Object && global, o9e = typeof self == "object" && self && self.Object === Object && self, ene = a9e || o9e || Function("return this")(), Q0 = ene.Symbol, tne = Object.prototype, l9e = tne.hasOwnProperty, s9e = tne.toString, P1 = Q0 ? Q0.toStringTag : void 0;
300
293
  function c9e(r) {
301
294
  var e = l9e.call(r, P1), t = r[P1];
@@ -1,4 +1,4 @@
1
- (function(er,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("vue"),require("ant-design-vue")):typeof define=="function"&&define.amd?define(["exports","vue","ant-design-vue"],A):(er=typeof globalThis<"u"?globalThis:er||self,A(er["pass-ui"]={},er.Vue,er.AntDesignVue))})(this,(function(er,A,Er){"use strict";const Pr=(r,e)=>{const t=r.__vccOpts||r;for(const[n,i]of e)t[n]=i;return t},$ce={name:"PaasDate",inheritAttrs:!1,props:{placeholder:{type:String,default:""},type:{type:String,default:"date"},icon:String,readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{type:[String,Array,Date]},showTime:{type:Boolean,default:!1},format:{type:String,default:null}},data(){return{}},methods:{handleChange(r){this.$emit("update:modelValue",r)}}};function Dce(r,e,t,n,i,o){const s=A.resolveComponent("a-date-picker");return A.openBlock(),A.createBlock(s,A.mergeProps(r.$attrs,{"show-time":t.showTime,readonly:t.readonly,disabled:t.disabled,value:t.modelValue,format:t.format,picker:t.type,onChange:o.handleChange,placeholder:t.placeholder,style:{width:"100%"}}),null,16,["show-time","readonly","disabled","value","format","picker","onChange","placeholder"])}const Ck=Pr($ce,[["render",Dce]]),Lce={name:"PaasMenu",components:{AMenu:Er.Menu,ASubMenu:Er.Menu.SubMenu,AMenuItem:Er.Menu.Item},props:{url:String,logoSrc:String,logoAlt:{type:String,default:"System Logo"},disabled:{type:Boolean,default:!1},theme:{type:String,default:"light"},selected:{type:String,default:""},mode:{type:String,default:"inline"},inlineCollapsed:{type:Boolean,default:!1}},data(){return{selectedKeys:this.selected?[this.selected]:[],selectValue:"",selectMenuOpend:!1,hostname:window.location.protocol+"//"+window.location.host}},computed:{current(){return this.$store.menus.current},menuOptions(){return this.$store.menus.menuOptions||[]},openKeys(){return this.$store.menus.openKeys},data(){return this.$store.menus.data}},watch:{selected(r){this.selectedKeys=r?[r]:[]},url(r){r?this.$post(r).then(e=>{this.$store.setMenuData(e.data.data),this.autoSelectMenu()}):this.data.length>0&&this.autoSelectMenu()},data(r){r.length>0&&!this.selectedKeys.length&&this.autoSelectMenu()}},beforeUnmount(){this.$bus.off("selectAndOpenMenu")},mounted(){this.$store.loginFlag&&this.data.length===0?this.$post(this.url).then(r=>{this.$store.setMenuData(r.data.data),this.autoSelectMenu()}):this.data.length>0&&this.autoSelectMenu(),this.$bus.on("selectAndOpenMenu",r=>{this.selectAndOpenMenu(r)})},methods:{renderIcon(r){let e="";r.icon?e=r.icon:e=this.selectedKeys.includes(r.key)?"FolderOpenOutlined":"FolderOutlined";try{const t=A.resolveComponent(e);return()=>A.h(t)}catch{return null}},autoSelectMenu(){let r=this.current;if(!this.data||this.data.length===0)return;const e=this.$route.path;if(e&&e!=="/"&&e!=="/system/login"){const n=this.findItemByKey(this.data,e);if(n){this.selectAndOpenMenu(n);return}}r||(r=this.data[0]?.url||"");const t=this.findItemByKey(this.data,r);if(t)this.selectAndOpenMenu(t),this.$router.replace(t.key);else{const n=this.findFirstLeaf(this.data);n&&(this.selectAndOpenMenu(n),this.$router.replace(n.key))}},selectAndOpenMenu(r){this.selectedKeys=[r.key];const e=this.getParentKeys(this.data,r.key);this.$store.setOpenKeys(e),this.$store.setCurrent(r.key),this.$store.setTitle(r.title),this.$store.setMenuId(r.id),this.$store.setButtons(r.buttons||[]),this.$store.setMenuCache({key:r.key,title:r.title,id:r.id,buttons:r.buttons||[]})},findItemByKey(r,e){if(!r||e===null)return null;for(const t of r){if(t.key===e)return t;if(t.children){const n=this.findItemByKey(t.children,e);if(n)return n}}return null},findFirstLeaf(r){for(const e of r)if(e.children&&e.children.length>0){const t=this.findFirstLeaf(e.children);if(t)return t}else return e;return null},getParentKeys(r,e,t=[]){for(const n of r){if(n.key===e)return t;if(n.children){const i=this.getParentKeys(n.children,e,[...t,n.key]);if(i.length)return i}}return[]},menuSelect(r){this.selectAndOpenMenu(r),this.$router.push(r.key)},onOpenChange(r){this.$store.setOpenKeys(r)},selectMenuClick(){if(!this.selectValue){this.selectMenuOpend=!1;return}this.selectMenuOpend=!0}}},Nce={class:"paas-menu-container"},Vce={class:"paas-menu-header"},Bce={key:0,class:"paas-menu-logo"},Ice=["src","alt"],Hce={class:"paas-menu-system-name"};function Fce(r,e,t,n,i,o){const s=A.resolveComponent("a-menu-item"),d=A.resolveComponent("a-sub-menu"),f=A.resolveComponent("a-menu");return A.openBlock(),A.createElementBlock("div",Nce,[A.createElementVNode("div",Vce,[t.logoSrc?(A.openBlock(),A.createElementBlock("div",Bce,[A.createElementVNode("img",{src:t.logoSrc,alt:t.logoAlt},null,8,Ice)])):A.createCommentVNode("",!0),A.createElementVNode("div",Hce,[A.createElementVNode("label",null,A.toDisplayString(r.$store.header.system.deviceName),1)])]),A.createVNode(f,A.mergeProps({ref:"menus",theme:t.theme,selectedKeys:i.selectedKeys,"open-keys":o.openKeys,onOpenChange:o.onOpenChange},r.$attrs,{"inline-collapsed":t.inlineCollapsed,mode:t.mode}),{default:A.withCtx(()=>[(A.openBlock(!0),A.createElementBlock(A.Fragment,null,A.renderList(o.data,p=>(A.openBlock(),A.createElementBlock(A.Fragment,{key:p.id},[p.children&&p.children.length?(A.openBlock(),A.createBlock(d,{key:p.key,title:p.title,icon:o.renderIcon(p)},{default:A.withCtx(()=>[(A.openBlock(!0),A.createElementBlock(A.Fragment,null,A.renderList(p.children,v=>(A.openBlock(),A.createBlock(s,{key:v.key,onClick:m=>o.menuSelect(v),icon:o.renderIcon(v)},{default:A.withCtx(()=>[A.createElementVNode("span",null,A.toDisplayString(v.title),1)]),_:2},1032,["onClick","icon"]))),128))]),_:2},1032,["title","icon"])):(A.openBlock(),A.createBlock(s,{key:p.key||"",onClick:v=>o.menuSelect(p),icon:o.renderIcon(p)},{default:A.withCtx(()=>[A.createElementVNode("span",null,A.toDisplayString(p.title),1)]),_:2},1032,["onClick","icon"]))],64))),128))]),_:1},16,["theme","selectedKeys","open-keys","onOpenChange","inline-collapsed","mode"])])}const Ak=Pr(Lce,[["render",Fce],["__scopeId","data-v-2f79a554"]]);var Qce=typeof global=="object"&&global&&global.Object===Object&&global,Wce=typeof self=="object"&&self&&self.Object===Object&&self,Mk=Qce||Wce||Function("return this")(),$d=Mk.Symbol,_k=Object.prototype,Uce=_k.hasOwnProperty,Xce=_k.toString,zf=$d?$d.toStringTag:void 0;function Zce(r){var e=Uce.call(r,zf),t=r[zf];try{r[zf]=void 0;var n=!0}catch{}var i=Xce.call(r);return n&&(e?r[zf]=t:delete r[zf]),i}var qce=Object.prototype,Yce=qce.toString;function Gce(r){return Yce.call(r)}var Jce="[object Null]",Kce="[object Undefined]",Ek=$d?$d.toStringTag:void 0;function eue(r){return r==null?r===void 0?Kce:Jce:Ek&&Ek in Object(r)?Zce(r):Gce(r)}function tue(r){return r!=null&&typeof r=="object"}var rue="[object Symbol]";function nue(r){return typeof r=="symbol"||tue(r)&&eue(r)==rue}var iue=/\s/;function aue(r){for(var e=r.length;e--&&iue.test(r.charAt(e)););return e}var oue=/^\s+/;function lue(r){return r&&r.slice(0,aue(r)+1).replace(oue,"")}function g3(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var kk=NaN,sue=/^[-+]0x[0-9a-f]+$/i,cue=/^0b[01]+$/i,uue=/^0o[0-7]+$/i,fue=parseInt;function zk(r){if(typeof r=="number")return r;if(nue(r))return kk;if(g3(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=g3(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=lue(r);var t=cue.test(r);return t||uue.test(r)?fue(r.slice(2),t?2:8):sue.test(r)?kk:+r}var O3=function(){return Mk.Date.now()},due="Expected a function",hue=Math.max,pue=Math.min;function vue(r,e,t){var n,i,o,s,d,f,p=0,v=!1,m=!1,O=!0;if(typeof r!="function")throw new TypeError(due);e=zk(e)||0,g3(t)&&(v=!!t.leading,m="maxWait"in t,o=m?hue(zk(t.maxWait)||0,e):o,O="trailing"in t?!!t.trailing:O);function b(L){var R=n,D=i;return n=i=void 0,p=L,s=r.apply(D,R),s}function S(L){return p=L,d=setTimeout(C,e),v?b(L):s}function w(L){var R=L-f,D=L-p,F=e-R;return m?pue(F,o-D):F}function x(L){var R=L-f,D=L-p;return f===void 0||R>=e||R<0||m&&D>=o}function C(){var L=O3();if(x(L))return _(L);d=setTimeout(C,w(L))}function _(L){return d=void 0,O&&n?b(L):(n=i=void 0,s)}function M(){d!==void 0&&clearTimeout(d),p=0,n=f=i=d=void 0}function k(){return d===void 0?s:_(O3())}function z(){var L=O3(),R=x(L);if(n=arguments,i=this,f=L,R){if(d===void 0)return S(f);if(m)return clearTimeout(d),d=setTimeout(C,e),b(f)}return d===void 0&&(d=setTimeout(C,e)),s}return z.cancel=M,z.flush=k,z}const mue={name:"MentionInput",props:{modelValue:{type:String,default:""},options:{type:Array,required:!0},saveSymbol:{type:String,default:"$"},height:{type:[String,Number],default:void 0},width:{type:[String,Number],default:void 0},placeholder:{type:String,default:void 0},mode:{type:String,default:"input"},multiple:{type:Boolean,default:!1}},emits:["update:modelValue","change"],data(){return{PREFIX:"/",SAVE_SYMBOL:this.saveSymbol||"$",showDropdown:!1,dropdownPos:null,triggerText:"",selectionRange:null,cascaderOptions:[],selectedValue:[],currentPathValues:[],currentPathLabels:[],optionMap:new Map,pathToNameMap:new Map,wrapperRef:null,inputRef:null,cascaderRef:null}},computed:{overlayStyle(){if(!this.dropdownPos)return{};let r=this.dropdownPos.top,e=this.dropdownPos.left;return{position:"fixed",top:r+"px",left:e+"px",zIndex:1050}}},mounted(){this.wrapperRef=this.$refs.wrapperRef,this.inputRef=this.$refs.inputRef,this.cascaderRef=this.$refs.cascaderRef,this.optionMap=this.buildOptionMap(this.options),this.pathToNameMap=this.buildPathToNameMap(this.options),this.inputRef&&this.inputRef.addEventListener("click",this.handleInputClick),document.addEventListener("click",this.handleClickOutside),this.initializeValue(),this.debouncedOnInput=vue(this._onInput,100)},beforeDestroy(){this.debouncedOnInput&&this.debouncedOnInput.cancel(),this.inputRef&&this.inputRef.removeEventListener("click",this.handleInputClick),document.removeEventListener("click",this.handleClickOutside)},watch:{modelValue:{handler(r){document.activeElement!==this.inputRef&&this.setValue(r||"")},immediate:!0},options:{handler(r){r&&(this.optionMap=this.buildOptionMap(r),this.pathToNameMap=this.buildPathToNameMap(r),this.modelValue&&this.setValue(this.modelValue))},deep:!0}},methods:{buildOptionMap(r,e=new Map){if(r){for(const t of r){const n=t.id||t.value||"",i=t.name||t.label||"";n&&i&&e.set(n,i),t.children&&this.buildOptionMap(t.children,e)}return e}},buildPathToNameMap(r,e=[],t=[]){if(!r)return;const n=new Map;for(const i of r){const o=i.id||i.value||"",s=i.name||i.label||"";if(!o)continue;const d=[...e,o],f=[...t,s],p=d.join("."),v=f.join("/");if(n.set(p,v),i.children){const m=this.buildPathToNameMap(i.children,d,f);for(const[O,b]of m)n.set(O,b)}}return n},onCascaderChange(r,e){r&&e&&(this.currentPathValues=[...r],this.currentPathLabels=e.map(t=>String(t.label||"")),this.insertMentionTag())},handleCascaderKeydown(r){r.key==="Escape"&&(this.showDropdown=!1)},onDropdownVisibleChange(r){},onInput(r){if(this.mode==="select"){r.preventDefault();return}this.debouncedOnInput(r)},_onInput(r){if(this.mode==="select")return;const e=r.target,t=this.parseContent(e);if(this.$emit("change",t),this.$emit("update:modelValue",this.serialize(t)),(e.textContent||"").lastIndexOf(this.PREFIX)===-1){this.showDropdown=!1;return}const o=this.getCurrentTextBeforeCursor(),s=o.lastIndexOf(this.PREFIX);if(s===-1){this.showDropdown=!1;return}const d=o.slice(s+this.PREFIX.length);if(d.includes(" ")||d.includes(" ")){this.showDropdown=!1;return}this.triggerText=d;const f=document.getSelection()?.getRangeAt(0);if(f&&this.inputRef){const p=f.getBoundingClientRect();this.dropdownPos={top:p.bottom+window.scrollY,left:p.left+window.scrollX},this.selectionRange=f.cloneRange(),this.cascaderOptions=this.options,this.showDropdown=!0}else this.showDropdown=!1},getCurrentTextBeforeCursor(){const r=window.getSelection();if(!r||r.rangeCount===0)return"";const e=r.getRangeAt(0).cloneRange(),t=e.cloneRange();return t.selectNodeContents(this.inputRef),t.setEnd(e.endContainer,e.endOffset),t.toString().replace(/\r\n|\r/g,`
1
+ (function(er,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("vue"),require("ant-design-vue")):typeof define=="function"&&define.amd?define(["exports","vue","ant-design-vue"],A):(er=typeof globalThis<"u"?globalThis:er||self,A(er["pass-ui"]={},er.Vue,er.AntDesignVue))})(this,(function(er,A,Er){"use strict";const Pr=(r,e)=>{const t=r.__vccOpts||r;for(const[n,i]of e)t[n]=i;return t},$ce={name:"PaasDate",inheritAttrs:!1,props:{placeholder:{type:String,default:""},type:{type:String,default:"date"},icon:String,readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelValue:{type:[String,Array,Date]},showTime:{type:Boolean,default:!1},format:{type:String,default:null}},data(){return{}},methods:{handleChange(r){this.$emit("update:modelValue",r)}}};function Dce(r,e,t,n,i,o){const s=A.resolveComponent("a-date-picker");return A.openBlock(),A.createBlock(s,A.mergeProps(r.$attrs,{"show-time":t.showTime,readonly:t.readonly,disabled:t.disabled,value:t.modelValue,format:t.format,picker:t.type,onChange:o.handleChange,placeholder:t.placeholder,style:{width:"100%"}}),null,16,["show-time","readonly","disabled","value","format","picker","onChange","placeholder"])}const Ck=Pr($ce,[["render",Dce]]),Lce={name:"PaasMenu",components:{AMenu:Er.Menu,ASubMenu:Er.Menu.SubMenu,AMenuItem:Er.Menu.Item},props:{url:String,logoSrc:String,logoAlt:{type:String,default:"System Logo"},disabled:{type:Boolean,default:!1},theme:{type:String,default:"light"},selected:{type:String,default:""},mode:{type:String,default:"inline"},inlineCollapsed:{type:Boolean,default:!1}},data(){return{selectedKeys:this.selected?[this.selected]:[],selectValue:"",selectMenuOpend:!1,hostname:window.location.protocol+"//"+window.location.host}},computed:{current(){return this.$store.menus.current},menuOptions(){return this.$store.menus.menuOptions||[]},openKeys(){return this.$store.menus.openKeys},data(){return this.$store.menus.data}},watch:{selected(r){this.selectedKeys=r?[r]:[]},url(r){r?this.$post(r).then(e=>{this.$store.setMenuData(e.data.data),this.autoSelectMenu()}):this.data.length>0&&this.autoSelectMenu()},data(r){r.length>0&&!this.selectedKeys.length&&this.autoSelectMenu()}},beforeUnmount(){this.$bus.off("selectAndOpenMenu")},mounted(){this.$store.loginFlag&&this.data.length===0?this.$post(this.url).then(r=>{this.$store.setMenuData(r.data.data),this.autoSelectMenu()}):this.data.length>0&&this.autoSelectMenu(),this.$bus.on("selectAndOpenMenu",r=>{this.selectAndOpenMenu(r)})},methods:{renderIcon(r){let e="";r.icon?e=r.icon:e=this.selectedKeys.includes(r.key)?"FolderOpenOutlined":"FolderOutlined";try{const t=A.resolveComponent(e);return()=>A.h(t)}catch{return null}},autoSelectMenu(){let r=window.location.hash||"";if(r=r.replace("#",""),!this.data||this.data.length===0)return;let e=this.current;e||(e=this.data[0]?.url||"");const t=this.findItemByKey(this.data,e);if(t)this.selectAndOpenMenu(t),this.$router.replace(r);else{const n=this.findFirstLeaf(this.data);n&&(this.selectAndOpenMenu(n),this.$router.replace(r))}},selectAndOpenMenu(r){this.selectedKeys=[r.key];const e=this.getParentKeys(this.data,r.key);this.$store.setOpenKeys(e),this.$store.setCurrent(r.key),this.$store.setTitle(r.title),this.$store.setMenuId(r.id),this.$store.setButtons(r.buttons||[]),this.$store.setMenuCache({key:r.key,title:r.title,id:r.id,buttons:r.buttons||[]})},findItemByKey(r,e){if(!r||e===null)return null;for(const t of r){if(t.key===e)return t;if(t.children){const n=this.findItemByKey(t.children,e);if(n)return n}}return null},findFirstLeaf(r){for(const e of r)if(e.children&&e.children.length>0){const t=this.findFirstLeaf(e.children);if(t)return t}else return e;return null},getParentKeys(r,e,t=[]){for(const n of r){if(n.key===e)return t;if(n.children){const i=this.getParentKeys(n.children,e,[...t,n.key]);if(i.length)return i}}return[]},menuSelect(r){this.selectAndOpenMenu(r),this.$router.push(r.key)},onOpenChange(r){this.$store.setOpenKeys(r)},selectMenuClick(){if(!this.selectValue){this.selectMenuOpend=!1;return}this.selectMenuOpend=!0}}},Nce={class:"paas-menu-container"},Vce={class:"paas-menu-header"},Bce={key:0,class:"paas-menu-logo"},Ice=["src","alt"],Hce={class:"paas-menu-system-name"};function Fce(r,e,t,n,i,o){const s=A.resolveComponent("a-menu-item"),d=A.resolveComponent("a-sub-menu"),f=A.resolveComponent("a-menu");return A.openBlock(),A.createElementBlock("div",Nce,[A.createElementVNode("div",Vce,[t.logoSrc?(A.openBlock(),A.createElementBlock("div",Bce,[A.createElementVNode("img",{src:t.logoSrc,alt:t.logoAlt},null,8,Ice)])):A.createCommentVNode("",!0),A.createElementVNode("div",Hce,[A.createElementVNode("label",null,A.toDisplayString(r.$store.header.system.deviceName),1)])]),A.createVNode(f,A.mergeProps({ref:"menus",theme:t.theme,selectedKeys:i.selectedKeys,"open-keys":o.openKeys,onOpenChange:o.onOpenChange},r.$attrs,{"inline-collapsed":t.inlineCollapsed,mode:t.mode}),{default:A.withCtx(()=>[(A.openBlock(!0),A.createElementBlock(A.Fragment,null,A.renderList(o.data,p=>(A.openBlock(),A.createElementBlock(A.Fragment,{key:p.id},[p.children&&p.children.length?(A.openBlock(),A.createBlock(d,{key:p.key,title:p.title,icon:o.renderIcon(p)},{default:A.withCtx(()=>[(A.openBlock(!0),A.createElementBlock(A.Fragment,null,A.renderList(p.children,v=>(A.openBlock(),A.createBlock(s,{key:v.key,onClick:m=>o.menuSelect(v),icon:o.renderIcon(v)},{default:A.withCtx(()=>[A.createElementVNode("span",null,A.toDisplayString(v.title),1)]),_:2},1032,["onClick","icon"]))),128))]),_:2},1032,["title","icon"])):(A.openBlock(),A.createBlock(s,{key:p.key||"",onClick:v=>o.menuSelect(p),icon:o.renderIcon(p)},{default:A.withCtx(()=>[A.createElementVNode("span",null,A.toDisplayString(p.title),1)]),_:2},1032,["onClick","icon"]))],64))),128))]),_:1},16,["theme","selectedKeys","open-keys","onOpenChange","inline-collapsed","mode"])])}const Ak=Pr(Lce,[["render",Fce],["__scopeId","data-v-2b351d86"]]);var Qce=typeof global=="object"&&global&&global.Object===Object&&global,Wce=typeof self=="object"&&self&&self.Object===Object&&self,Mk=Qce||Wce||Function("return this")(),$d=Mk.Symbol,_k=Object.prototype,Uce=_k.hasOwnProperty,Xce=_k.toString,zf=$d?$d.toStringTag:void 0;function Zce(r){var e=Uce.call(r,zf),t=r[zf];try{r[zf]=void 0;var n=!0}catch{}var i=Xce.call(r);return n&&(e?r[zf]=t:delete r[zf]),i}var qce=Object.prototype,Yce=qce.toString;function Gce(r){return Yce.call(r)}var Jce="[object Null]",Kce="[object Undefined]",Ek=$d?$d.toStringTag:void 0;function eue(r){return r==null?r===void 0?Kce:Jce:Ek&&Ek in Object(r)?Zce(r):Gce(r)}function tue(r){return r!=null&&typeof r=="object"}var rue="[object Symbol]";function nue(r){return typeof r=="symbol"||tue(r)&&eue(r)==rue}var iue=/\s/;function aue(r){for(var e=r.length;e--&&iue.test(r.charAt(e)););return e}var oue=/^\s+/;function lue(r){return r&&r.slice(0,aue(r)+1).replace(oue,"")}function g3(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var kk=NaN,sue=/^[-+]0x[0-9a-f]+$/i,cue=/^0b[01]+$/i,uue=/^0o[0-7]+$/i,fue=parseInt;function zk(r){if(typeof r=="number")return r;if(nue(r))return kk;if(g3(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=g3(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=lue(r);var t=cue.test(r);return t||uue.test(r)?fue(r.slice(2),t?2:8):sue.test(r)?kk:+r}var O3=function(){return Mk.Date.now()},due="Expected a function",hue=Math.max,pue=Math.min;function vue(r,e,t){var n,i,o,s,d,f,p=0,v=!1,m=!1,O=!0;if(typeof r!="function")throw new TypeError(due);e=zk(e)||0,g3(t)&&(v=!!t.leading,m="maxWait"in t,o=m?hue(zk(t.maxWait)||0,e):o,O="trailing"in t?!!t.trailing:O);function b(L){var R=n,D=i;return n=i=void 0,p=L,s=r.apply(D,R),s}function S(L){return p=L,d=setTimeout(C,e),v?b(L):s}function w(L){var R=L-f,D=L-p,F=e-R;return m?pue(F,o-D):F}function x(L){var R=L-f,D=L-p;return f===void 0||R>=e||R<0||m&&D>=o}function C(){var L=O3();if(x(L))return _(L);d=setTimeout(C,w(L))}function _(L){return d=void 0,O&&n?b(L):(n=i=void 0,s)}function M(){d!==void 0&&clearTimeout(d),p=0,n=f=i=d=void 0}function k(){return d===void 0?s:_(O3())}function z(){var L=O3(),R=x(L);if(n=arguments,i=this,f=L,R){if(d===void 0)return S(f);if(m)return clearTimeout(d),d=setTimeout(C,e),b(f)}return d===void 0&&(d=setTimeout(C,e)),s}return z.cancel=M,z.flush=k,z}const mue={name:"MentionInput",props:{modelValue:{type:String,default:""},options:{type:Array,required:!0},saveSymbol:{type:String,default:"$"},height:{type:[String,Number],default:void 0},width:{type:[String,Number],default:void 0},placeholder:{type:String,default:void 0},mode:{type:String,default:"input"},multiple:{type:Boolean,default:!1}},emits:["update:modelValue","change"],data(){return{PREFIX:"/",SAVE_SYMBOL:this.saveSymbol||"$",showDropdown:!1,dropdownPos:null,triggerText:"",selectionRange:null,cascaderOptions:[],selectedValue:[],currentPathValues:[],currentPathLabels:[],optionMap:new Map,pathToNameMap:new Map,wrapperRef:null,inputRef:null,cascaderRef:null}},computed:{overlayStyle(){if(!this.dropdownPos)return{};let r=this.dropdownPos.top,e=this.dropdownPos.left;return{position:"fixed",top:r+"px",left:e+"px",zIndex:1050}}},mounted(){this.wrapperRef=this.$refs.wrapperRef,this.inputRef=this.$refs.inputRef,this.cascaderRef=this.$refs.cascaderRef,this.optionMap=this.buildOptionMap(this.options),this.pathToNameMap=this.buildPathToNameMap(this.options),this.inputRef&&this.inputRef.addEventListener("click",this.handleInputClick),document.addEventListener("click",this.handleClickOutside),this.initializeValue(),this.debouncedOnInput=vue(this._onInput,100)},beforeDestroy(){this.debouncedOnInput&&this.debouncedOnInput.cancel(),this.inputRef&&this.inputRef.removeEventListener("click",this.handleInputClick),document.removeEventListener("click",this.handleClickOutside)},watch:{modelValue:{handler(r){document.activeElement!==this.inputRef&&this.setValue(r||"")},immediate:!0},options:{handler(r){r&&(this.optionMap=this.buildOptionMap(r),this.pathToNameMap=this.buildPathToNameMap(r),this.modelValue&&this.setValue(this.modelValue))},deep:!0}},methods:{buildOptionMap(r,e=new Map){if(r){for(const t of r){const n=t.id||t.value||"",i=t.name||t.label||"";n&&i&&e.set(n,i),t.children&&this.buildOptionMap(t.children,e)}return e}},buildPathToNameMap(r,e=[],t=[]){if(!r)return;const n=new Map;for(const i of r){const o=i.id||i.value||"",s=i.name||i.label||"";if(!o)continue;const d=[...e,o],f=[...t,s],p=d.join("."),v=f.join("/");if(n.set(p,v),i.children){const m=this.buildPathToNameMap(i.children,d,f);for(const[O,b]of m)n.set(O,b)}}return n},onCascaderChange(r,e){r&&e&&(this.currentPathValues=[...r],this.currentPathLabels=e.map(t=>String(t.label||"")),this.insertMentionTag())},handleCascaderKeydown(r){r.key==="Escape"&&(this.showDropdown=!1)},onDropdownVisibleChange(r){},onInput(r){if(this.mode==="select"){r.preventDefault();return}this.debouncedOnInput(r)},_onInput(r){if(this.mode==="select")return;const e=r.target,t=this.parseContent(e);if(this.$emit("change",t),this.$emit("update:modelValue",this.serialize(t)),(e.textContent||"").lastIndexOf(this.PREFIX)===-1){this.showDropdown=!1;return}const o=this.getCurrentTextBeforeCursor(),s=o.lastIndexOf(this.PREFIX);if(s===-1){this.showDropdown=!1;return}const d=o.slice(s+this.PREFIX.length);if(d.includes(" ")||d.includes(" ")){this.showDropdown=!1;return}this.triggerText=d;const f=document.getSelection()?.getRangeAt(0);if(f&&this.inputRef){const p=f.getBoundingClientRect();this.dropdownPos={top:p.bottom+window.scrollY,left:p.left+window.scrollX},this.selectionRange=f.cloneRange(),this.cascaderOptions=this.options,this.showDropdown=!0}else this.showDropdown=!1},getCurrentTextBeforeCursor(){const r=window.getSelection();if(!r||r.rangeCount===0)return"";const e=r.getRangeAt(0).cloneRange(),t=e.cloneRange();return t.selectNodeContents(this.inputRef),t.setEnd(e.endContainer,e.endOffset),t.toString().replace(/\r\n|\r/g,`
2
2
  `)},onKeydown(r){if(this.mode==="select"&&r.key!=="Tab"&&r.key!=="ArrowUp"&&r.key!=="ArrowDown"&&r.key!=="Enter"&&r.key!=="Escape"){r.preventDefault(),/[a-zA-Z0-9]/.test(r.key)&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&this.showSelectDropdown();return}if(!this.showDropdown){if(r.key==="Backspace")this.handleBackspace(r);else if(r.key==="Enter"){r.preventDefault();const e=window.getSelection();if(e&&e.rangeCount>0){const t=e.getRangeAt(0);t.deleteContents();const n=document.createElement("br");t.insertNode(n);const i=document.createRange();i.setStartAfter(n),i.collapse(!0),e.removeAllRanges(),e.addRange(i)}this.$nextTick(()=>{const t=this.parseContent(this.inputRef);this.$emit("change",t),this.$emit("update:modelValue",this.serialize(t))})}return}r.key==="Escape"&&(this.showDropdown=!1)},insertMentionTag(){if(!this.inputRef)return;this.multiple||(this.inputRef.innerHTML="");let r;this.selectionRange?r=this.selectionRange.cloneRange():(r=document.createRange(),r.selectNodeContents(this.inputRef),r.collapse(!1));let e=null,t=0;if(r.startContainer.nodeType===Node.TEXT_NODE)e=r.startContainer,t=r.startOffset;else{const f=document.createTreeWalker(this.inputRef,NodeFilter.SHOW_TEXT,null);let p=null;for(;f.nextNode();)(f.currentNode===r.startContainer||f.currentNode.contains(r.startContainer))&&(p=f.currentNode);p&&(e=p,t=p.textContent?.length||0)}const n=this.SAVE_SYMBOL+this.currentPathValues.join("."),i=this.currentPathLabels.join("/"),o=document.createElement("span");o.className="mention-tag",o.contentEditable="false",o.dataset.value=n,o.innerHTML=`
3
3
  <span class="tag-content">${i}</span>
4
4
  <span class="tag-close">×</span>