diff --git a/README.md b/README.md index e2a529c..b07e86e 100644 --- a/README.md +++ b/README.md @@ -84,9 +84,10 @@ This component does not depend on any other package, except Vue 3 | open-level | `0` | Number, String, Array | Default is `0` or folded. Number or String like (1 or '2' or 3) will open all levels up to that level. Array of levels like [2,3,5] will pre-open specifically those levels only, if 0 is not specified, it will still be folded initially. | | open-specific | `[]` | Array | Array of elements to pre-open. For ex. `window` object, has `window.navigator` and `window.history`, history has `window.history.state` objects. To pre-open them specify [`'window'`,`'window.history'`,`'window.history.state'`] or just `['window.history.state']` as it requires all of the above objects to be open already. If objects are not descendants then specify separately like this `['window.history.state',` ` 'window.navigator']` | | focus | `null` | String, Number | Focus element to open, similar to òpen-specific`, but just 1 item. The browser will open and scroll to that element if it is specified. | -| focus-offset-x | `-35` | Number | X plane offset when scrolling to focused element | -| focus-offset-y | `-15` | Number | Y plane offset when scrolling to focused element | -| focus-delay | `300` | Number | Delay in milliseconds, before focusing | +| focus-sticky | `false` | Boolean | Focus sticky, will keep 'sticking' to the focused element, even when object undergoes changes or you open and close levels, `false` by default. | +| focus-offset-x | `-35` | Number | X plane offset when scrolling to focused element | +| focus-offset-y | `-15` | Number | Y plane offset when scrolling to focused element | +| focus-delay | `300` | Number | Delay in milliseconds, before focusing | | preview | `5` | Number, Boolean `false` | Number of elements to preview when viewing an object or an array. This can be made less or more depending on performance needs. Less is faster, because there is less rendering. It can also be fully turned off by setting `0` or `false` | | preview-initial | `true` | Boolean | Initial object's preview can be turned off, to make the item take less space on the screen. Instead of `obj {1, 2, 3, 4, 5}`, it will just be `obj {...}` on the first level, when you open it, it will use `preview` value for the rest of the items. | | escape-quotes | `false` | Boolean | Strings will have escaped double quotes, " will be converted to \\" | diff --git a/vue-dd/dist/index.es.js b/vue-dd/dist/index.es.js index a25d5cb..f3bb2bd 100644 --- a/vue-dd/dist/index.es.js +++ b/vue-dd/dist/index.es.js @@ -1979,7 +1979,7 @@ const mn = Ke({ }, showEmit(e) { let { type: t, pointer: i, focusElement: o } = e; - this.emitFn(this, "show", e), console.log("show", i), this.saveFocus && this.useFocus === i && this.setFocus(); + this.emitFn(this, "show", e), this.saveFocus && this.useFocus === i && this.setFocus(); }, open(e) { const { open: t, pointer: i, level: o, user: s } = e; diff --git a/vue-dd/dist/index.umd.js b/vue-dd/dist/index.umd.js index 7a085a2..a2c27b0 100644 --- a/vue-dd/dist/index.umd.js +++ b/vue-dd/dist/index.umd.js @@ -7,4 +7,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),w=c,I=h),m===void 0&&(m=!0);const B={code:I,language:w};_("before:highlight",B);const M=B.result?B.result:p(B.language,B.code,m);return M.code=B.code,_("after:highlight",M),M}function p(c,h,m,I){const w=Object.create(null);function B(){if(!u.keywords)return void N.addText(b);let d=0;u.keywordPatternRe.lastIndex=0;let g=u.keywordPatternRe.exec(b),k="";for(;g;){k+=b.substring(d,g.index);const E=O.case_insensitive?g[0].toLowerCase():g[0],C=(y=E,u.keywords[y]);if(C){const[F,ye]=C;if(N.addText(k),k="",w[E]=(w[E]||0)+1,w[E]<=7&&(P+=ye),F.startsWith("_"))k+=g[0];else{const re=O.classNameAliases[F]||F;N.addKeyword(g[0],re)}}else k+=g[0];d=u.keywordPatternRe.lastIndex,g=u.keywordPatternRe.exec(b)}var y;k+=b.substring(d),N.addText(k)}function M(){u.subLanguage!=null?(()=>{if(b==="")return;let d=null;if(typeof u.subLanguage=="string"){if(!A[u.subLanguage])return void N.addText(b);d=p(u.subLanguage,b,!0,W[u.subLanguage]),W[u.subLanguage]=d._top}else d=S(b,u.subLanguage.length?u.subLanguage:null);u.relevance>0&&(P+=d.relevance),N.addSublanguage(d._emitter,d.language)})():B(),b=""}function Q(d,g){let k=1;const y=g.length-1;for(;k<=y;){if(!d._emit[k]){k++;continue}const E=O.classNameAliases[d[k]]||d[k],C=g[k];E?N.addKeyword(C,E):(b=C,B(),b=""),k++}}function v(d,g){return d.scope&&typeof d.scope=="string"&&N.openNode(O.classNameAliases[d.scope]||d.scope),d.beginScope&&(d.beginScope._wrap?(N.addKeyword(b,O.classNameAliases[d.beginScope._wrap]||d.beginScope._wrap),b=""):d.beginScope._multi&&(Q(d.beginScope,g),b="")),u=Object.create(d,{parent:{value:u}}),u}function x(d,g,k){let y=((E,C)=>{const F=E&&E.exec(C);return F&&F.index===0})(d.endRe,k);if(y){if(d["on:end"]){const E=new we(d);d["on:end"](g,E),E.isMatchIgnored&&(y=!1)}if(y){for(;d.endsParent&&d.parent;)d=d.parent;return d}}if(d.endsWithParent)return x(d.parent,g,k)}function se(d){return u.matcher.regexIndex===0?(b+=d[0],1):(be=!0,0)}function fe(d){const g=d[0],k=h.substring(d.index),y=x(u,d,k);if(!y)return De;const E=u;u.endScope&&u.endScope._wrap?(M(),N.addKeyword(g,u.endScope._wrap)):u.endScope&&u.endScope._multi?(M(),Q(u.endScope,d)):E.skip?b+=g:(E.returnEnd||E.excludeEnd||(b+=g),M(),E.excludeEnd&&(b=g));do u.scope&&N.closeNode(),u.skip||u.subLanguage||(P+=u.relevance),u=u.parent;while(u!==y.parent);return y.starts&&v(y.starts,d),E.returnEnd?0:g.length}let J={};function ee(d,g){const k=g&&g[0];if(b+=d,k==null)return M(),0;if(J.type==="begin"&&g.type==="end"&&J.index===g.index&&k===""){if(b+=h.slice(g.index,g.index+1),!o){const y=Error(`0 width match regex (${c})`);throw y.languageName=c,y.badRule=J.rule,y}return 1}if(J=g,g.type==="begin")return(y=>{const E=y[0],C=y.rule,F=new we(C),ye=[C.__beforeBegin,C["on:begin"]];for(const re of ye)if(re&&(re(y,F),F.isMatchIgnored))return se(E);return C.skip?b+=E:(C.excludeBegin&&(b+=E),M(),C.returnBegin||C.excludeBegin||(b=E)),v(C,y),C.returnBegin?0:E.length})(g);if(g.type==="illegal"&&!m){const y=Error('Illegal lexeme "'+k+'" for mode "'+(u.scope||"")+'"');throw y.mode=u,y}if(g.type==="end"){const y=fe(g);if(y!==De)return y}if(g.type==="illegal"&&k==="")return 1;if(Ae>1e5&&Ae>3*g.index)throw Error("potential infinite loop, way more iterations than matches");return b+=k,k.length}const O=L(c);if(!O)throw R(n.replace("{}",c)),Error('Unknown language: "'+c+'"');const Y=EA(O);let U="",u=I||Y;const W={},N=new l.__emitter(l);(()=>{const d=[];for(let g=u;g!==O;g=g.parent)g.scope&&d.unshift(g.scope);d.forEach(g=>N.openNode(g))})();let b="",P=0,D=0,Ae=0,be=!1;try{for(u.matcher.considerAll();;){Ae++,be?be=!1:u.matcher.considerAll(),u.matcher.lastIndex=D;const d=u.matcher.exec(h);if(!d)break;const g=ee(h.substring(D,d.index),d);D=d.index+g}return ee(h.substring(D)),N.closeAllNodes(),N.finalize(),U=N.toHTML(),{language:c,value:U,relevance:P,illegal:!1,_emitter:N,_top:u}}catch(d){if(d.message&&d.message.includes("Illegal"))return{language:c,value:ge(h),illegal:!0,relevance:0,_illegalBy:{message:d.message,index:D,context:h.slice(D-100,D+100),mode:d.mode,resultSoFar:U},_emitter:N};if(o)return{language:c,value:ge(h),illegal:!1,relevance:0,errorRaised:d,_emitter:N,_top:u};throw d}}function S(c,h){h=h||l.languages||Object.keys(A);const m=(v=>{const x={value:ge(v),illegal:!1,relevance:0,_top:a,_emitter:new l.__emitter(l)};return x._emitter.addText(v),x})(c),I=h.filter(L).filter($).map(v=>p(v,c,!1));I.unshift(m);const w=I.sort((v,x)=>{if(v.relevance!==x.relevance)return x.relevance-v.relevance;if(v.language&&x.language){if(L(v.language).supersetOf===x.language)return 1;if(L(x.language).supersetOf===v.language)return-1}return 0}),[B,M]=w,Q=B;return Q.secondBest=M,Q}function j(c){let h=null;const m=(B=>{let M=B.className+" ";M+=B.parentNode?B.parentNode.className:"";const Q=l.languageDetectRe.exec(M);if(Q){const v=L(Q[1]);return v||(Le(n.replace("{}",Q[1])),Le("Falling back to no-highlight mode for this block.",B)),v?Q[1]:"no-highlight"}return M.split(/\s+/).find(v=>s(v)||L(v))})(c);if(s(m))return;if(_("before:highlightElement",{el:c,language:m}),c.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(c)),l.throwUnescapedHTML))throw new wA("One of your code blocks includes unescaped HTML.",c.innerHTML);h=c;const I=h.textContent,w=m?f(I,{language:m,ignoreIllegals:!0}):S(I);c.innerHTML=w.value,((B,M,Q)=>{const v=M&&i[M]||Q;B.classList.add("hljs"),B.classList.add("language-"+v)})(c,m,w.language),c.result={language:w.language,re:w.relevance,relevance:w.relevance},w.secondBest&&(c.secondBest={language:w.secondBest.language,relevance:w.secondBest.relevance}),_("after:highlightElement",{el:c,result:w,text:I})}let Z=!1;function V(){document.readyState!=="loading"?document.querySelectorAll(l.cssSelector).forEach(j):Z=!0}function L(c){return c=(c||"").toLowerCase(),A[c]||A[i[c]]}function G(c,{languageName:h}){typeof c=="string"&&(c=[c]),c.forEach(m=>{i[m.toLowerCase()]=h})}function $(c){const h=L(c);return h&&!h.disableAutodetect}function _(c,h){const m=c;r.forEach(I=>{I[m]&&I[m](h)})}typeof window<"u"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",()=>{Z&&V()},!1),Object.assign(e,{highlight:f,highlightAuto:S,highlightAll:V,highlightElement:j,highlightBlock:c=>(X("10.7.0","highlightBlock will be removed entirely in v12.0"),X("10.7.0","Please use highlightElement now."),j(c)),configure:c=>{l=Te(l,c)},initHighlighting:()=>{V(),X("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:()=>{V(),X("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:(c,h)=>{let m=null;try{m=h(e)}catch(I){if(R("Language definition for '{}' could not be registered.".replace("{}",c)),!o)throw I;R(I),m=a}m.name||(m.name=c),A[c]=m,m.rawDefinition=h.bind(null,e),m.aliases&&G(m.aliases,{languageName:c})},unregisterLanguage:c=>{delete A[c];for(const h of Object.keys(i))i[h]===c&&delete i[h]},listLanguages:()=>Object.keys(A),getLanguage:L,registerAliases:G,autoDetection:$,inherit:Te,addPlugin:c=>{(h=>{h["before:highlightBlock"]&&!h["before:highlightElement"]&&(h["before:highlightElement"]=m=>{h["before:highlightBlock"](Object.assign({block:m.el},m))}),h["after:highlightBlock"]&&!h["after:highlightElement"]&&(h["after:highlightElement"]=m=>{h["after:highlightBlock"](Object.assign({block:m.el},m))})})(c),r.push(c)}}),e.debugMode=()=>{o=!1},e.safeMode=()=>{o=!0},e.versionString="11.7.0",e.regex={concat:H,lookahead:Me,either:de,optional:oA,anyNumberOfTimes:iA};for(const c in ie)typeof ie[c]=="object"&&le.exports(ie[c]);return Object.assign(e,ie),e})({});/*! `javascript` grammar compiled for Highlight.js 11.7.0 */var vA=(()=>{const e="[A-Za-z$_][0-9A-Za-z$_]*",A=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],i=["true","false","null","undefined","NaN","Infinity"],r=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],o=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],n=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],a=["arguments","this","super","console","window","document","localStorage","module","global"],l=[].concat(n,r,o);return s=>{const f=s.regex,p=e,S={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Y,U)=>{const u=Y[0].length+Y.index,W=Y.input[u];if(W==="<"||W===",")return void U.ignoreMatch();let N;W===">"&&(((P,{after:D})=>{const Ae="",O={match:[/const|var|let/,/\s+/,p,/\s*/,/=\s*/,/(async\s*)?/,f.lookahead(ee)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[B]};return{name:"Javascript",aliases:["js","jsx","mjs","cjs"],keywords:j,exports:{PARAMS_CONTAINS:w,CLASS_REFERENCE:Q},illegal:/#(?![$_A-z])/,contains:[s.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},s.APOS_STRING_MODE,s.QUOTE_STRING_MODE,$,_,c,h,{match:/\$\d+/},L,Q,{className:"attr",begin:p+f.lookahead(":"),relevance:0},O,{begin:"("+s.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[h,s.REGEXP_MODE,{className:"function",begin:ee,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:s.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:j,contains:w}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:""},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:S.begin,"on:begin":S.isTrulyOpeningTag,end:S.end}],subLanguage:"xml",contains:[{begin:S.begin,end:S.end,skip:!0,contains:["self"]}]}]},v,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+s.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[B,s.inherit(s.TITLE_MODE,{begin:p,className:"title.function"})]},{match:/\.\.\./,relevance:0},fe,{match:"\\$"+p,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[B]},x,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},M,J,{match:/\$[(.]/}]}}})();he.registerLanguage("javascript",vA);let pe={};const NA={name:"NodeComplex",inheritAttrs:!1,emits:["show","open","toggle","focus","openParent","forget"],props:{root:void 0,rootId:[String,Number],modelValue:void 0,name:[String,Number],openLevel:[Number,Array],openSpecific:Array,longText:Number,escapeQuotes:Boolean,deep:Boolean,watch:Boolean,preview:[Boolean,Number],previewInitial:Boolean,focus:[String,Number],arrow:String,delimiter:String,more:String,save:Boolean,saveFocus:Boolean,shared:Object,type:String,parentType:String,parentOpen:Boolean,pointer:{type:[String,Number],default:""},level:{type:Number,default:0},size:Number,position:Number,escapeQuotesFn:Function,isPrimitiveFn:Function,getTypeFn:Function,unwrapSpecificFn:Function,emitFn:Function},data(){return{id:this.getId(),hideTimes:0,open:!1,expanded:!1,items:[],getMapSet:{},getSize:0,useOpenLevel:this.openLevel,useOpenSpecific:this.openSpecific,originalOpenLevel:this.openLevel,askForget:!1,cleared:!1,hover:!1,unwatch:()=>{}}},mounted(){this.showEmit()},created(){this.expanded=this.allowPreview,this.items=this.makeItems(),this.watch&&(this.unwatch=this.watchModelValue(this.deep)),this.useOpenSpecific=this.openSpecific},methods:{showEmit(){return this.emit("show",{pointer:this.pointer,focusElement:this.$refs.focusElement,type:"complex"}),!0},getAllPointer(e){let A="*";if(e=String(e),e in pe)A=pe[e];else{const i=e.split(this.delimiter);i.pop(),i.length&&(A=i.join(this.delimiter)+this.delimiter+"*"),pe[e]=A}return A},forget(){this.emitFn(this,"forget",{askForget:this.askForget}),this.askForget=!1,this.cleared=!0,setTimeout(()=>this.cleared=!1,1e3)},openParent(){this.open||this.toggleOpen(null,!0)},getId(){return this.level===0?`_${this.rootId}`:`_${this.rootId}${this.delimiter}${this.pointer}`},watchModelValue(e){return this.$watch("modelValue",()=>{this.items=this.makeItems()},{deep:e})},getPointer(e){return this.pointer?this.pointer+this.delimiter+e:String(e)},getSpecialType(e){return this.isMapSet?this.getTypeFn(this.getMapSet[e]):this.getTypeFn(this.modelValue[e])},getModelValue(e){return this.isMapSet?this.getMapSet[e]:this.modelValue[e]},preventSelect(e){e.detail>1&&e.preventDefault()},getName(e){return this.isArray?"":e},expand(){this.open||this.toggleOpen(null,!0),this.expanded=!0},toggleOpen(e,A){const i=A===void 0?!this.open:A;this.setOpen(i,{user:!0}),this.expanded=this.allowPreview,this.open&&this.$emit("openParent"),this.emit("toggle",{event:e,open:this.open,level:this.level,pointer:this.pointer})},emit(e,...A){this.emitFn(this,e,...A)},makeItems(){switch(!0){case this.isObject:let e=[],A=0;switch(!0){case this.isSet:this.getMapSet=Array.from(this.modelValue),e=[...Array(this.getMapSet.length).keys()],this.getSize=this.getMapSet.length;break;case this.isMap:this.modelValue.forEach((i,r)=>{this.getMapSet[r]=i,e[A]=r,A++}),this.getSize=A;break;default:for(let i in this.modelValue)e[A]=i,A++;this.getSize=A}return e;case this.isArray:return this.getSize=this.modelValue.length,[...Array(this.modelValue.length).keys()];default:return this.modelValue}},parentIsOpen(){return this.$parent.$options.name==="NodeComplex"&&this.$parent.open||this.$parent.$options.name==="VueDd"},focusEmit(){this.emit("focus",{pointer:this.pointer,focusElement:this.$refs.focusElement})},setOpen(e,{user:A}){this.open=e,this.emit("open",{open:this.open,level:this.level,pointer:this.pointer,user:A})}},computed:{parentIsArray(){return this.parentType==="array"},unwrapSpecific(){return this.unwrapSpecificFn(this.openSpecific)},allowPreview(){return!this.previewInitial&&this.level===0?!1:this.preview},isMap(){return this.isObject&&this.modelValue instanceof Map},isSet(){return this.isObject&&this.modelValue instanceof Set},isMapSet(){return this.isMap||this.isSet},instanceOf(){const e=this.isObject&&"constructor"in this.modelValue&&"name"in this.modelValue.constructor?this.modelValue.constructor.name:"";return e==="Object"?"":e},nextLevel(){return this.level+1},charClass(){return this.isObject?"vue-dd-obj-char":"vue-dd-arr-char"},charOpen(){return this.isObject?"{":"["},charClose(){return this.isObject?"}":"]"},functionInlinePreview(){const e=this.items.toString().length,A=100;return e>A?this.items.toString().substring(0,A)+"...}":this.items.toString()},functionInline(){let e=this.modelValue.toString();switch(!0){case e.startsWith("function "):e=e.substring(9).trim(),e.startsWith(this.name)&&(e=e.substring(this.name.length));break;case e.startsWith("()"):e="(){...}";break;case e.startsWith(this.name):e=e.substring(this.name.length);break}const A=25;return e.length>A&&(e=e.substring(0,A)+"..."),e},functionName(){let e=String(this.items);const A=e.indexOf(` `);return A>=0&&(e=e.substring(0,A)),he.highlight(e,{language:"javascript"}).value},functionContent(){let e=String(this.items).trim().split(` `);if(e.length){const A=e.length-1,i=e[A].indexOf("}");e=e.map(n=>n.substring(i)),e.shift();const r=e.join(` -`);return he.highlight(r,{language:"javascript"}).value}return""},shouldComma(){return this.size&&this.position&&this.position!==this.size},longTextInline(){let e=this.modelValue.toString().substring(0,this.longText);return e=this.escapeQuotesFn(e),e=`"${e}..."`,e},longTextContent(){let e=this.modelValue;return e=this.escapeQuotesFn(e),e=`"${e}"`,e},isLongText(){return this.type==="longtext"},isRefReactive(){return this.isRef||this.isReactive},isIterable(){return this.isArray||this.isObject},isArray(){return this.type==="array"},isObject(){return this.type==="object"},isFunction(){return this.type==="function"},isPromise(){return qe(this.modelValue)},isReactive(){return t.isReactive(this.modelValue)},isRef(){return t.isRef(this.modelValue)},isFocused(){return String(this.pointer)===String(this.focus)},showName(){return!this.parentIsArray&&this.nameString||this.parentIsArray&&this.parentOpen},nameString(){return String(this.name)}},watch:{openLevel:{handler(e){if(typeof this.openLevel=="number"&&this.level{this.parentIsOpen()&&this.setOpen(!0,{user:!1})})}}},immediate:!0},open:{handler(e,A){if(e)this.items=this.makeItems(),this.useOpenLevel=this.openLevel,this.useOpenSpecific=this.openSpecific;else{const i=()=>{this.useOpenLevel=0,this.useOpenSpecific=[]};this.hideTimes===0?i():setTimeout(()=>i(),1),this.hideTimes++}},immediate:!0},preview(e){this.expanded=e,this.setOpen(!!(this.open&&e),{user:!1})}},components:{NodePrimitive:Be}},IA=["id"],MA={class:"vue-dd-start"},CA=["innerHTML"],QA={key:0,class:"vue-dd-colon"},SA=["innerHTML"],xA={key:0,class:"vue-dd-comma"},LA=["innerHTML"],jA={key:7,class:"vue-dd-instance"},OA={key:0},TA={key:1},DA={key:11},FA={key:12,class:"vue-dd-forget-cleared"},zA=["innerHTML"],GA={key:2,class:"vue-dd-promise-content"},HA=["innerHTML"],RA={key:4},ZA={key:5,class:"vue-dd-f-content"},VA={key:0},_A=["innerHTML"],YA={key:0,class:"vue-dd-comma"},UA={key:1},PA=["innerHTML"],XA={key:0,class:"vue-dd-comma"},JA={key:6,class:"vue-dd-string"},WA={key:0},KA={key:0,class:"vue-dd-comma"},qA={key:1},$A={key:0,class:"vue-dd-comma"},et=["innerHTML"],At=["innerHTML"],tt={key:9,class:"vue-dd-comma"};function nt(e,A,i,r,o,n){const a=t.resolveComponent("node-primitive"),l=t.resolveComponent("node-complex",!0);return t.openBlock(),t.createElementBlock("div",{id:o.id,class:t.normalizeClass({"vue-dd-body":!0,"vue-dd-box-inline":!o.open})},[t.createElementVNode("div",MA,[t.createElementVNode("button",{onClick:A[0]||(A[0]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),class:t.normalizeClass(["vue-dd-arrow",{"vue-dd-arrow-collapsed":!o.open}]),innerHTML:i.arrow},null,10,CA),n.showName?(t.openBlock(),t.createElementBlock("span",{key:0,onClick:A[1]||(A[1]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[2]||(A[2]=s=>n.preventSelect(s)),class:t.normalizeClass(["vue-dd-name",{"vue-dd-f-name":n.isFunction,"vue-dd-key-of-array":n.parentIsArray}])},[t.createTextVNode(t.toDisplayString(i.name),1),i.level!==0?(t.openBlock(),t.createElementBlock("span",QA,":")):t.createCommentVNode("",!0)],34)):t.createCommentVNode("",!0),o.open&&i.saveFocus?(t.openBlock(),t.createElementBlock("span",{key:1,ref:"focusElement",class:t.normalizeClass(["vue-dd-focus vue-dd-icon-eye",{"vue-dd-focus-hover":o.hover,"vue-dd-focus-selected":n.isFocused}]),onClick:A[3]||(A[3]=(...s)=>n.focusEmit&&n.focusEmit(...s)),onMouseenter:A[4]||(A[4]=s=>o.hover=!0),onMouseup:A[5]||(A[5]=s=>o.hover=!1),onMouseleave:A[6]||(A[6]=s=>o.hover=!1)},null,34)):t.createCommentVNode("",!0),n.isIterable&&n.isReactive?(t.openBlock(),t.createElementBlock("span",{key:2,onClick:A[7]||(A[7]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[8]||(A[8]=s=>n.preventSelect(s)),class:"vue-dd-r",title:"Reactive"},"R",32)):n.isIterable&&n.isRef?(t.openBlock(),t.createElementBlock("span",{key:3,onClick:A[9]||(A[9]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[10]||(A[10]=s=>n.preventSelect(s)),class:"vue-dd-ref",title:"Ref"},"Ref",32)):n.isFunction?(t.openBlock(),t.createElementBlock("span",{key:4,onClick:A[11]||(A[11]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[12]||(A[12]=s=>n.preventSelect(s)),class:"vue-dd-f",title:"Function"},"f",32)):t.createCommentVNode("",!0),n.isFunction&&o.open?(t.openBlock(),t.createElementBlock("pre",{key:5,onClick:A[13]||(A[13]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),class:"vue-dd-f-start"},[t.createElementVNode("span",{innerHTML:n.functionName},null,8,SA),n.shouldComma&&!o.open?(t.openBlock(),t.createElementBlock("span",xA,",")):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),n.isIterable&&o.open?(t.openBlock(),t.createElementBlock("span",{key:6,onClick:A[14]||(A[14]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[15]||(A[15]=s=>n.preventSelect(s)),class:t.normalizeClass(n.charClass),innerHTML:n.charOpen},null,42,LA)):t.createCommentVNode("",!0),n.isIterable&&o.open&&n.instanceOf?(t.openBlock(),t.createElementBlock("span",jA,t.toDisplayString(n.instanceOf),1)):t.createCommentVNode("",!0),n.isIterable&&o.open&&o.getSize?(t.openBlock(),t.createElementBlock("span",{key:8,onClick:A[16]||(A[16]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[17]||(A[17]=s=>n.preventSelect(s)),class:"vue-dd-size"},t.toDisplayString(o.getSize),33)):t.createCommentVNode("",!0),n.isIterable&&n.isPromise&&!o.open?(t.openBlock(),t.createElementBlock("span",{key:9,onClick:A[18]||(A[18]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[19]||(A[19]=s=>n.preventSelect(s)),class:"vue-dd-instance vue-dd-promise-prototype"},"Promise",32)):t.createCommentVNode("",!0),o.open&&i.level===0&&i.save&&!o.cleared?(t.openBlock(),t.createElementBlock("span",{key:10,onClick:A[20]||(A[20]=s=>o.askForget=!0),class:t.normalizeClass(["vue-dd-forget vue-dd-forget-q",{"vue-dd-forget-q-ask":o.askForget}])},[o.askForget?(t.openBlock(),t.createElementBlock("span",OA,"clear save?")):(t.openBlock(),t.createElementBlock("span",TA,"forget"))],2)):t.createCommentVNode("",!0),o.askForget?(t.openBlock(),t.createElementBlock("span",DA,[t.createElementVNode("span",{class:"vue-dd-forget vue-dd-forget-yes",onClick:A[21]||(A[21]=(...s)=>n.forget&&n.forget(...s))},"yes"),t.createElementVNode("span",{class:"vue-dd-forget vue-dd-forget-no",onClick:A[22]||(A[22]=s=>o.askForget=!1)},"no")])):t.createCommentVNode("",!0),o.cleared?(t.openBlock(),t.createElementBlock("span",FA," cleared ")):t.createCommentVNode("",!0)]),t.createElementVNode("div",{class:t.normalizeClass({"vue-dd-box":o.open,"vue-dd-box-inline":!o.open,"vue-dd-box-complex":!0})},[t.createElementVNode("div",null,[n.isIterable&&!o.open?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(n.charClass),innerHTML:n.charOpen},null,10,zA)):t.createCommentVNode("",!0),n.isIterable&&n.allowPreview&&!o.open&&o.getSize?(t.openBlock(),t.createElementBlock("span",{key:1,onClick:A[23]||(A[23]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[24]||(A[24]=s=>n.preventSelect(s)),class:"vue-dd-size"},t.toDisplayString(o.getSize),33)):t.createCommentVNode("",!0),n.isIterable&&n.isPromise?(t.openBlock(),t.createElementBlock("span",GA,"")):t.createCommentVNode("",!0),n.isIterable&&!o.open&&!n.allowPreview?(t.openBlock(),t.createElementBlock("button",{key:3,onClick:A[25]||(A[25]=(...s)=>n.expand&&n.expand(...s)),class:"vue-dd-expand",innerHTML:i.more},null,8,HA)):t.createCommentVNode("",!0),n.isIterable&&(o.open||o.expanded)?(t.openBlock(),t.createElementBlock("div",RA,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.open?o.items.length:n.allowPreview(t.openBlock(),t.createElementBlock("div",{key:s},[t.createElementVNode("div",null,[i.isPrimitiveFn(n.getSpecialType(o.items[s-1]))?(t.openBlock(),t.createBlock(a,{key:0,root:i.root,rootId:i.rootId,modelValue:n.getModelValue(o.items[s-1]),name:o.items[s-1],escapeQuotes:i.escapeQuotes,focus:i.focus,save:i.save,saveFocus:i.saveFocus,delimiter:i.delimiter,pointer:n.getPointer(o.items[s-1]),parentOpen:o.open,type:n.getSpecialType(o.items[s-1]),parentType:i.type,size:o.getSize,position:s,expanded:o.expanded,escapeQuotesFn:i.escapeQuotesFn,emitFn:i.emitFn,onOpenParent:n.openParent},null,8,["root","rootId","modelValue","name","escapeQuotes","focus","save","saveFocus","delimiter","pointer","parentOpen","type","parentType","size","position","expanded","escapeQuotesFn","emitFn","onOpenParent"])):(t.openBlock(),t.createBlock(l,{key:1,root:i.root,rootId:i.rootId,modelValue:n.getModelValue(o.items[s-1]),name:o.items[s-1],deep:n.isRef?!1:i.deep,watch:i.watch,preview:o.open?i.preview:!1,openLevel:o.useOpenLevel,openSpecific:o.useOpenSpecific,longText:i.longText,escapeQuotes:i.escapeQuotes,focus:i.focus,save:i.save,saveFocus:i.saveFocus,delimiter:i.delimiter,more:i.more,arrow:i.arrow,pointer:n.getPointer(o.items[s-1]),parentType:i.type,parentOpen:o.open,type:n.getSpecialType(o.items[s-1]),shared:i.shared,level:i.level+1,size:o.getSize,position:s,escapeQuotesFn:i.escapeQuotesFn,getTypeFn:i.getTypeFn,isPrimitiveFn:i.isPrimitiveFn,unwrapSpecificFn:i.unwrapSpecificFn,emitFn:i.emitFn,onOpenParent:n.openParent},null,8,["root","rootId","modelValue","name","deep","watch","preview","openLevel","openSpecific","longText","escapeQuotes","focus","save","saveFocus","delimiter","more","arrow","pointer","parentType","parentOpen","type","shared","level","size","position","escapeQuotesFn","getTypeFn","isPrimitiveFn","unwrapSpecificFn","emitFn","onOpenParent"]))])]))),128))])):t.createCommentVNode("",!0),n.isFunction?(t.openBlock(),t.createElementBlock("div",ZA,[o.open&&n.functionContent?(t.openBlock(),t.createElementBlock("pre",VA,[t.createElementVNode("span",{innerHTML:n.functionContent},null,8,_A),n.shouldComma?(t.openBlock(),t.createElementBlock("span",YA,",")):t.createCommentVNode("",!0)])):o.open&&!n.functionContent?(t.openBlock(),t.createElementBlock("span",UA)):(t.openBlock(),t.createElementBlock("span",{key:2,onClick:A[26]||(A[26]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),class:"vue-dd-f-inline"},[t.createElementVNode("span",{innerHTML:n.allowPreview?n.functionInlinePreview:n.functionInline},null,8,PA),n.shouldComma?(t.openBlock(),t.createElementBlock("span",XA,",")):t.createCommentVNode("",!0)]))])):t.createCommentVNode("",!0),n.isLongText?(t.openBlock(),t.createElementBlock("div",JA,[o.open?(t.openBlock(),t.createElementBlock("span",WA,[t.createTextVNode(t.toDisplayString(n.longTextContent),1),n.shouldComma?(t.openBlock(),t.createElementBlock("span",KA,",")):t.createCommentVNode("",!0)])):(t.openBlock(),t.createElementBlock("span",qA,[t.createTextVNode(t.toDisplayString(n.longTextInline),1),n.shouldComma?(t.openBlock(),t.createElementBlock("span",$A,",")):t.createCommentVNode("",!0)]))])):t.createCommentVNode("",!0),n.isIterable&&!o.open&&n.allowPreview!==!1&&i.previewn.expand&&n.expand(...s)),class:"vue-dd-expand",innerHTML:i.more},null,8,et)):t.createCommentVNode("",!0),n.isIterable?(t.openBlock(),t.createElementBlock("span",{key:8,class:t.normalizeClass(n.charClass),innerHTML:n.charClose},null,10,At)):t.createCommentVNode("",!0),n.isIterable&&n.shouldComma?(t.openBlock(),t.createElementBlock("span",tt,",")):t.createCommentVNode("",!0)])],2)],10,IA)}const it=te(NA,[["render",nt]]);let me={};const ot=t.defineComponent({name:"VueDd",inheritAttrs:!1,emits:["open","toggle","focus","show"],props:{modelValue:{type:void 0,required:!0},id:{type:[String,Number],default:""},name:{type:String,default:""},openLevel:{type:[Number,String,Array],default:0},openSpecific:{type:Array,default:()=>[]},focus:{type:[String,Number],default:null},focusSticky:{type:Boolean,default:!1},focusOffsetX:{type:Number,default:-35},focusOffsetY:{type:Number,default:-15},focusDelay:{type:Number,default:30},preview:{type:[Number,Boolean],default:5},previewInitial:{type:Boolean,default:!0},escapeQuotes:{type:Boolean,default:!1},longText:{type:Number,default:50},delimiter:{type:String,default:"."},more:{type:String,default:"..."},arrow:{type:String,default:"▼"},inline:{type:Boolean,default:!0},dark:{type:Boolean,default:!0},fontFamily:{type:String,default:'"JetBrains Mono", "Courier", serif'},fontSize:{type:String,default:".7rem"},lineHeight:{type:String,default:"1rem"},paddingLeft:{type:String,default:".7rem"},maxHeight:{type:String,default:"500px"},maxWidth:{type:String,default:"100%"},save:{type:Boolean,default:!1},saveFocus:{type:Boolean,default:!0},storage:{type:String,default:"session"},watch:{type:Boolean,default:!0},deep:{type:Boolean,default:!0}},data(){return{rootId:eA(this.id,this.name,window),openClass:!1,css:this.class,useOpenSpecific:this.openSpecific,useOpenLevel:typeof this.openLevel=="string"?parseInt(this.openLevel):this.openLevel,memory:null,shared:{hiddenPointers:{}},setFocusAlready:!1,useFocus:null}},created(){(this.save||this.saveFocus)&&this.initMemory(),this.useFocus=this.getFocus(),this.useOpenSpecific=this.getOpenSpecific()},mounted(){},computed:{cssVars(){return{"--vue-dd-fontFamily":this.fontFamily,"--vue-dd-fontSize":this.fontSize,"--vue-dd-lineHeight":this.lineHeight,"--vue-dd-paddingLeft":this.paddingLeft,"--vue-dd-maxHeight":this.maxHeight,"--vue-dd-maxWidth":this.maxWidth}},unwrapSpecific(){return this.unwrapSpecificFn(this.useOpenSpecific)},type(){return this.getTypeFn(this.modelValue)},primitive(){return this.isPrimitiveFn(this.type)},isSet(){return this.type==="object"&&this.modelValue instanceof Set},isRef(){return t.isRef(this.modelValue)}},methods:{forget(){this.save&&typeof this.memory=="object"&&(this.memory.open={},this.shared.hiddenPointers={},this.useOpenSpecific=this.baseOpenSpecific(),this.store().set(this.memory))},setFocus(){if(this.saveFocus&&this.useFocus!==null){let e=!0;this.setFocusAlready&&(e=!1),this.focusSticky&&(e=!0),e&&setTimeout(()=>{const A=this.getElement(this.useFocus);A&&(this.$refs.root.scrollLeft=A.offsetLeft+this.focusOffsetX,this.$refs.root.scrollTop=A.offsetTop+this.focusOffsetY,A.classList.add("vue-dd-highlight"),this.setFocusAlready=!0)},this.focusDelay)}},getElement(e){e=e===""?"":`${this.delimiter}${e}`;const A=`_${this.rootId}${e}`;return document.getElementById(A)},getFocus(){let e=this.focus;return this.saveFocus&&"focus"in this.memory&&this.memory.focus!==null&&(e=String(this.memory.focus)),e},initMemory(){this.memory=this.store().get(),Ee(this.memory)||(this.memory={}),(!("open"in this.memory)||!Ee(this.memory.open))&&(this.memory.open={}),"focus"in this.memory||(this.memory.focus=null)},getOpenSpecific(){if(this.save){this.memory.open={...this.memory.open,...this.unwrapSpecific},this.store().set(this.memory);let e=[];for(let A in this.memory.open)e.push(String(A));return e}else return this.baseOpenSpecific()},baseOpenSpecific(){return[...this.openSpecific,...this.useFocus===null?[]:[String(this.useFocus)]]},focusEmit(e){let{pointer:A,focusElement:i}=e;if(this.saveFocus){const r=this.useFocus;if(String(A)===String(r)&&String(A)!==String(this.focus))delete this.memory.open[A],A=null,i.classList.remove("vue-dd-focus-selected");else{delete this.memory.open[r];const o=this.getElement(r);if(o){const n=o.querySelector(".vue-dd-focus");n&&n.classList.remove("vue-dd-focus-selected")}i.classList.add("vue-dd-focus-selected")}this.memory.focus=A===null?this.focus:A,this.store().set(this.memory),this.useFocus=this.memory.focus,this.emitFn(this,"focus",{focus:this.memory.focus,focusElement:i})}},showEmit(e){let{type:A,pointer:i,focusElement:r}=e;this.emitFn(this,"show",e),console.log("show",i),this.saveFocus&&this.useFocus===i&&this.setFocus()},open(e){const{open:A,pointer:i,level:r,user:o}=e;r===0&&(this.openClass=A),this.$emit("open",e)},toggle(e){const{event:A,open:i,pointer:r,level:o}=e;if(this.save){if(i)delete this.shared.hiddenPointers[r],this.useOpenSpecific.push(r),this.memory.open[r]=!0;else{this.shared.hiddenPointers[r]=!0;const n=this.useOpenSpecific.indexOf(r);n>=0&&delete this.useOpenSpecific[n],delete this.memory.open[r]}this.store().set(this.memory)}this.$emit("toggle",e)},store(){const e="vue-dd."+this.rootId;return{get:()=>{try{return JSON.parse(window[`${this.storage}Storage`].getItem(e))}catch{}},set:A=>window[`${this.storage}Storage`].setItem(e,JSON.stringify(A))}},getTypeFn(e){let A=typeof e;return A==="object"?e===null?"null":Array.isArray(e)?"array":"object":(A==="string"&&e.length>this.longText&&(A="longtext"),A)},isPrimitiveFn(e){return!(e==="array"||e==="object"||e==="function"||e==="longtext")},escapeQuotesFn(e){return this.escapeQuotes?e.replaceAll('"','\\"'):e},unwrapSpecificFn(e){let A={};if(e.length){const i=e;if(i in me)return me[i];e.forEach(r=>{const o=String(r).split(this.delimiter);let n="",a=0;for(let l in o)n+=(a>0?this.delimiter:"")+o[l],A[n]=!0,a++;a>0&&(A[""]=!0)}),this.useFocus!==null&&(A[this.useFocus]=!0),me[i]=A}return A},emitFn(e,A,...i){for(;e&&!(e.$options.name!=="VueDd"&&e.$options.name!=="NodeComplex"&&e.$options.name!=="NodePrimitive");)e.$emit(A,...i),e=e.$parent}},watch:{modelValue:{handler(e,A){this.focusSticky&&e!==A&&this.setFocus()}}},components:{NodeComplex:it,NodePrimitive:Be}}),dt="",st=["id"];function rt(e,A,i,r,o,n){const a=t.resolveComponent("node-primitive"),l=t.resolveComponent("node-complex");return t.openBlock(),t.createElementBlock("div",{ref:"root",id:e.rootId,class:t.normalizeClass(["vue-dd",{"vue-dd-inline":e.inline,"vue-dd-open":e.openClass,"vue-dd-dark":e.dark},e.$attrs.class]),style:t.normalizeStyle([e.cssVars,e.$attrs.style])},[e.primitive?(t.openBlock(),t.createBlock(a,{key:0,root:e.$refs.root,rootId:e.rootId,modelValue:e.modelValue,name:e.name,focus:e.useFocus,escapeQuotes:e.escapeQuotes,save:e.save,saveFocus:e.saveFocus,delimiter:e.delimiter,pointer:"",type:e.type,parentOpen:!1,parentType:"",escapeQuotesFn:e.escapeQuotesFn,emitFn:e.emitFn,onFocus:e.focusEmit,onShow:e.showEmit},null,8,["root","rootId","modelValue","name","focus","escapeQuotes","save","saveFocus","delimiter","type","escapeQuotesFn","emitFn","onFocus","onShow"])):(t.openBlock(),t.createBlock(l,{key:1,root:e.$refs.root,rootId:e.rootId,modelValue:e.modelValue,name:e.name,openLevel:e.useOpenLevel,openSpecific:e.useOpenSpecific,focus:e.useFocus,escapeQuotes:e.escapeQuotes,longText:e.longText,preview:e.preview,previewInitial:e.previewInitial,deep:e.isRef?!0:e.deep,watch:e.watch,save:e.save,saveFocus:e.saveFocus,arrow:e.arrow,delimiter:e.delimiter,more:e.more,pointer:"",type:e.type,parentType:"",parentOpen:!1,shared:e.shared,getTypeFn:e.getTypeFn,isPrimitiveFn:e.isPrimitiveFn,escapeQuotesFn:e.escapeQuotesFn,unwrapSpecificFn:e.unwrapSpecificFn,emitFn:e.emitFn,onShow:e.showEmit,onToggle:e.toggle,onOpen:e.open,onFocus:e.focusEmit,onForget:e.forget},null,8,["root","rootId","modelValue","name","openLevel","openSpecific","focus","escapeQuotes","longText","preview","previewInitial","deep","watch","save","saveFocus","arrow","delimiter","more","type","shared","getTypeFn","isPrimitiveFn","escapeQuotesFn","unwrapSpecificFn","emitFn","onShow","onToggle","onOpen","onFocus","onForget"]))],14,st)}const Fe=te(ot,[["render",rt]]),lt={};function at(e,A){return t.openBlock(),t.createElementBlock("div",null,"Hello world")}const ze=te(lt,[["render",at]]);function ct(e){e.component("VueDd",Fe),e.component("XRay",ze)}T.VueDd=Fe,T.XRay=ze,T.install=ct,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}); +`);return he.highlight(r,{language:"javascript"}).value}return""},shouldComma(){return this.size&&this.position&&this.position!==this.size},longTextInline(){let e=this.modelValue.toString().substring(0,this.longText);return e=this.escapeQuotesFn(e),e=`"${e}..."`,e},longTextContent(){let e=this.modelValue;return e=this.escapeQuotesFn(e),e=`"${e}"`,e},isLongText(){return this.type==="longtext"},isRefReactive(){return this.isRef||this.isReactive},isIterable(){return this.isArray||this.isObject},isArray(){return this.type==="array"},isObject(){return this.type==="object"},isFunction(){return this.type==="function"},isPromise(){return qe(this.modelValue)},isReactive(){return t.isReactive(this.modelValue)},isRef(){return t.isRef(this.modelValue)},isFocused(){return String(this.pointer)===String(this.focus)},showName(){return!this.parentIsArray&&this.nameString||this.parentIsArray&&this.parentOpen},nameString(){return String(this.name)}},watch:{openLevel:{handler(e){if(typeof this.openLevel=="number"&&this.level{this.parentIsOpen()&&this.setOpen(!0,{user:!1})})}}},immediate:!0},open:{handler(e,A){if(e)this.items=this.makeItems(),this.useOpenLevel=this.openLevel,this.useOpenSpecific=this.openSpecific;else{const i=()=>{this.useOpenLevel=0,this.useOpenSpecific=[]};this.hideTimes===0?i():setTimeout(()=>i(),1),this.hideTimes++}},immediate:!0},preview(e){this.expanded=e,this.setOpen(!!(this.open&&e),{user:!1})}},components:{NodePrimitive:Be}},IA=["id"],MA={class:"vue-dd-start"},CA=["innerHTML"],QA={key:0,class:"vue-dd-colon"},SA=["innerHTML"],xA={key:0,class:"vue-dd-comma"},LA=["innerHTML"],jA={key:7,class:"vue-dd-instance"},OA={key:0},TA={key:1},DA={key:11},FA={key:12,class:"vue-dd-forget-cleared"},zA=["innerHTML"],GA={key:2,class:"vue-dd-promise-content"},HA=["innerHTML"],RA={key:4},ZA={key:5,class:"vue-dd-f-content"},VA={key:0},_A=["innerHTML"],YA={key:0,class:"vue-dd-comma"},UA={key:1},PA=["innerHTML"],XA={key:0,class:"vue-dd-comma"},JA={key:6,class:"vue-dd-string"},WA={key:0},KA={key:0,class:"vue-dd-comma"},qA={key:1},$A={key:0,class:"vue-dd-comma"},et=["innerHTML"],At=["innerHTML"],tt={key:9,class:"vue-dd-comma"};function nt(e,A,i,r,o,n){const a=t.resolveComponent("node-primitive"),l=t.resolveComponent("node-complex",!0);return t.openBlock(),t.createElementBlock("div",{id:o.id,class:t.normalizeClass({"vue-dd-body":!0,"vue-dd-box-inline":!o.open})},[t.createElementVNode("div",MA,[t.createElementVNode("button",{onClick:A[0]||(A[0]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),class:t.normalizeClass(["vue-dd-arrow",{"vue-dd-arrow-collapsed":!o.open}]),innerHTML:i.arrow},null,10,CA),n.showName?(t.openBlock(),t.createElementBlock("span",{key:0,onClick:A[1]||(A[1]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[2]||(A[2]=s=>n.preventSelect(s)),class:t.normalizeClass(["vue-dd-name",{"vue-dd-f-name":n.isFunction,"vue-dd-key-of-array":n.parentIsArray}])},[t.createTextVNode(t.toDisplayString(i.name),1),i.level!==0?(t.openBlock(),t.createElementBlock("span",QA,":")):t.createCommentVNode("",!0)],34)):t.createCommentVNode("",!0),o.open&&i.saveFocus?(t.openBlock(),t.createElementBlock("span",{key:1,ref:"focusElement",class:t.normalizeClass(["vue-dd-focus vue-dd-icon-eye",{"vue-dd-focus-hover":o.hover,"vue-dd-focus-selected":n.isFocused}]),onClick:A[3]||(A[3]=(...s)=>n.focusEmit&&n.focusEmit(...s)),onMouseenter:A[4]||(A[4]=s=>o.hover=!0),onMouseup:A[5]||(A[5]=s=>o.hover=!1),onMouseleave:A[6]||(A[6]=s=>o.hover=!1)},null,34)):t.createCommentVNode("",!0),n.isIterable&&n.isReactive?(t.openBlock(),t.createElementBlock("span",{key:2,onClick:A[7]||(A[7]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[8]||(A[8]=s=>n.preventSelect(s)),class:"vue-dd-r",title:"Reactive"},"R",32)):n.isIterable&&n.isRef?(t.openBlock(),t.createElementBlock("span",{key:3,onClick:A[9]||(A[9]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[10]||(A[10]=s=>n.preventSelect(s)),class:"vue-dd-ref",title:"Ref"},"Ref",32)):n.isFunction?(t.openBlock(),t.createElementBlock("span",{key:4,onClick:A[11]||(A[11]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[12]||(A[12]=s=>n.preventSelect(s)),class:"vue-dd-f",title:"Function"},"f",32)):t.createCommentVNode("",!0),n.isFunction&&o.open?(t.openBlock(),t.createElementBlock("pre",{key:5,onClick:A[13]||(A[13]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),class:"vue-dd-f-start"},[t.createElementVNode("span",{innerHTML:n.functionName},null,8,SA),n.shouldComma&&!o.open?(t.openBlock(),t.createElementBlock("span",xA,",")):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),n.isIterable&&o.open?(t.openBlock(),t.createElementBlock("span",{key:6,onClick:A[14]||(A[14]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[15]||(A[15]=s=>n.preventSelect(s)),class:t.normalizeClass(n.charClass),innerHTML:n.charOpen},null,42,LA)):t.createCommentVNode("",!0),n.isIterable&&o.open&&n.instanceOf?(t.openBlock(),t.createElementBlock("span",jA,t.toDisplayString(n.instanceOf),1)):t.createCommentVNode("",!0),n.isIterable&&o.open&&o.getSize?(t.openBlock(),t.createElementBlock("span",{key:8,onClick:A[16]||(A[16]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[17]||(A[17]=s=>n.preventSelect(s)),class:"vue-dd-size"},t.toDisplayString(o.getSize),33)):t.createCommentVNode("",!0),n.isIterable&&n.isPromise&&!o.open?(t.openBlock(),t.createElementBlock("span",{key:9,onClick:A[18]||(A[18]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[19]||(A[19]=s=>n.preventSelect(s)),class:"vue-dd-instance vue-dd-promise-prototype"},"Promise",32)):t.createCommentVNode("",!0),o.open&&i.level===0&&i.save&&!o.cleared?(t.openBlock(),t.createElementBlock("span",{key:10,onClick:A[20]||(A[20]=s=>o.askForget=!0),class:t.normalizeClass(["vue-dd-forget vue-dd-forget-q",{"vue-dd-forget-q-ask":o.askForget}])},[o.askForget?(t.openBlock(),t.createElementBlock("span",OA,"clear save?")):(t.openBlock(),t.createElementBlock("span",TA,"forget"))],2)):t.createCommentVNode("",!0),o.askForget?(t.openBlock(),t.createElementBlock("span",DA,[t.createElementVNode("span",{class:"vue-dd-forget vue-dd-forget-yes",onClick:A[21]||(A[21]=(...s)=>n.forget&&n.forget(...s))},"yes"),t.createElementVNode("span",{class:"vue-dd-forget vue-dd-forget-no",onClick:A[22]||(A[22]=s=>o.askForget=!1)},"no")])):t.createCommentVNode("",!0),o.cleared?(t.openBlock(),t.createElementBlock("span",FA," cleared ")):t.createCommentVNode("",!0)]),t.createElementVNode("div",{class:t.normalizeClass({"vue-dd-box":o.open,"vue-dd-box-inline":!o.open,"vue-dd-box-complex":!0})},[t.createElementVNode("div",null,[n.isIterable&&!o.open?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(n.charClass),innerHTML:n.charOpen},null,10,zA)):t.createCommentVNode("",!0),n.isIterable&&n.allowPreview&&!o.open&&o.getSize?(t.openBlock(),t.createElementBlock("span",{key:1,onClick:A[23]||(A[23]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),onMousedown:A[24]||(A[24]=s=>n.preventSelect(s)),class:"vue-dd-size"},t.toDisplayString(o.getSize),33)):t.createCommentVNode("",!0),n.isIterable&&n.isPromise?(t.openBlock(),t.createElementBlock("span",GA,"")):t.createCommentVNode("",!0),n.isIterable&&!o.open&&!n.allowPreview?(t.openBlock(),t.createElementBlock("button",{key:3,onClick:A[25]||(A[25]=(...s)=>n.expand&&n.expand(...s)),class:"vue-dd-expand",innerHTML:i.more},null,8,HA)):t.createCommentVNode("",!0),n.isIterable&&(o.open||o.expanded)?(t.openBlock(),t.createElementBlock("div",RA,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.open?o.items.length:n.allowPreview(t.openBlock(),t.createElementBlock("div",{key:s},[t.createElementVNode("div",null,[i.isPrimitiveFn(n.getSpecialType(o.items[s-1]))?(t.openBlock(),t.createBlock(a,{key:0,root:i.root,rootId:i.rootId,modelValue:n.getModelValue(o.items[s-1]),name:o.items[s-1],escapeQuotes:i.escapeQuotes,focus:i.focus,save:i.save,saveFocus:i.saveFocus,delimiter:i.delimiter,pointer:n.getPointer(o.items[s-1]),parentOpen:o.open,type:n.getSpecialType(o.items[s-1]),parentType:i.type,size:o.getSize,position:s,expanded:o.expanded,escapeQuotesFn:i.escapeQuotesFn,emitFn:i.emitFn,onOpenParent:n.openParent},null,8,["root","rootId","modelValue","name","escapeQuotes","focus","save","saveFocus","delimiter","pointer","parentOpen","type","parentType","size","position","expanded","escapeQuotesFn","emitFn","onOpenParent"])):(t.openBlock(),t.createBlock(l,{key:1,root:i.root,rootId:i.rootId,modelValue:n.getModelValue(o.items[s-1]),name:o.items[s-1],deep:n.isRef?!1:i.deep,watch:i.watch,preview:o.open?i.preview:!1,openLevel:o.useOpenLevel,openSpecific:o.useOpenSpecific,longText:i.longText,escapeQuotes:i.escapeQuotes,focus:i.focus,save:i.save,saveFocus:i.saveFocus,delimiter:i.delimiter,more:i.more,arrow:i.arrow,pointer:n.getPointer(o.items[s-1]),parentType:i.type,parentOpen:o.open,type:n.getSpecialType(o.items[s-1]),shared:i.shared,level:i.level+1,size:o.getSize,position:s,escapeQuotesFn:i.escapeQuotesFn,getTypeFn:i.getTypeFn,isPrimitiveFn:i.isPrimitiveFn,unwrapSpecificFn:i.unwrapSpecificFn,emitFn:i.emitFn,onOpenParent:n.openParent},null,8,["root","rootId","modelValue","name","deep","watch","preview","openLevel","openSpecific","longText","escapeQuotes","focus","save","saveFocus","delimiter","more","arrow","pointer","parentType","parentOpen","type","shared","level","size","position","escapeQuotesFn","getTypeFn","isPrimitiveFn","unwrapSpecificFn","emitFn","onOpenParent"]))])]))),128))])):t.createCommentVNode("",!0),n.isFunction?(t.openBlock(),t.createElementBlock("div",ZA,[o.open&&n.functionContent?(t.openBlock(),t.createElementBlock("pre",VA,[t.createElementVNode("span",{innerHTML:n.functionContent},null,8,_A),n.shouldComma?(t.openBlock(),t.createElementBlock("span",YA,",")):t.createCommentVNode("",!0)])):o.open&&!n.functionContent?(t.openBlock(),t.createElementBlock("span",UA)):(t.openBlock(),t.createElementBlock("span",{key:2,onClick:A[26]||(A[26]=(...s)=>n.toggleOpen&&n.toggleOpen(...s)),class:"vue-dd-f-inline"},[t.createElementVNode("span",{innerHTML:n.allowPreview?n.functionInlinePreview:n.functionInline},null,8,PA),n.shouldComma?(t.openBlock(),t.createElementBlock("span",XA,",")):t.createCommentVNode("",!0)]))])):t.createCommentVNode("",!0),n.isLongText?(t.openBlock(),t.createElementBlock("div",JA,[o.open?(t.openBlock(),t.createElementBlock("span",WA,[t.createTextVNode(t.toDisplayString(n.longTextContent),1),n.shouldComma?(t.openBlock(),t.createElementBlock("span",KA,",")):t.createCommentVNode("",!0)])):(t.openBlock(),t.createElementBlock("span",qA,[t.createTextVNode(t.toDisplayString(n.longTextInline),1),n.shouldComma?(t.openBlock(),t.createElementBlock("span",$A,",")):t.createCommentVNode("",!0)]))])):t.createCommentVNode("",!0),n.isIterable&&!o.open&&n.allowPreview!==!1&&i.previewn.expand&&n.expand(...s)),class:"vue-dd-expand",innerHTML:i.more},null,8,et)):t.createCommentVNode("",!0),n.isIterable?(t.openBlock(),t.createElementBlock("span",{key:8,class:t.normalizeClass(n.charClass),innerHTML:n.charClose},null,10,At)):t.createCommentVNode("",!0),n.isIterable&&n.shouldComma?(t.openBlock(),t.createElementBlock("span",tt,",")):t.createCommentVNode("",!0)])],2)],10,IA)}const it=te(NA,[["render",nt]]);let me={};const ot=t.defineComponent({name:"VueDd",inheritAttrs:!1,emits:["open","toggle","focus","show"],props:{modelValue:{type:void 0,required:!0},id:{type:[String,Number],default:""},name:{type:String,default:""},openLevel:{type:[Number,String,Array],default:0},openSpecific:{type:Array,default:()=>[]},focus:{type:[String,Number],default:null},focusSticky:{type:Boolean,default:!1},focusOffsetX:{type:Number,default:-35},focusOffsetY:{type:Number,default:-15},focusDelay:{type:Number,default:30},preview:{type:[Number,Boolean],default:5},previewInitial:{type:Boolean,default:!0},escapeQuotes:{type:Boolean,default:!1},longText:{type:Number,default:50},delimiter:{type:String,default:"."},more:{type:String,default:"..."},arrow:{type:String,default:"▼"},inline:{type:Boolean,default:!0},dark:{type:Boolean,default:!0},fontFamily:{type:String,default:'"JetBrains Mono", "Courier", serif'},fontSize:{type:String,default:".7rem"},lineHeight:{type:String,default:"1rem"},paddingLeft:{type:String,default:".7rem"},maxHeight:{type:String,default:"500px"},maxWidth:{type:String,default:"100%"},save:{type:Boolean,default:!1},saveFocus:{type:Boolean,default:!0},storage:{type:String,default:"session"},watch:{type:Boolean,default:!0},deep:{type:Boolean,default:!0}},data(){return{rootId:eA(this.id,this.name,window),openClass:!1,css:this.class,useOpenSpecific:this.openSpecific,useOpenLevel:typeof this.openLevel=="string"?parseInt(this.openLevel):this.openLevel,memory:null,shared:{hiddenPointers:{}},setFocusAlready:!1,useFocus:null}},created(){(this.save||this.saveFocus)&&this.initMemory(),this.useFocus=this.getFocus(),this.useOpenSpecific=this.getOpenSpecific()},mounted(){},computed:{cssVars(){return{"--vue-dd-fontFamily":this.fontFamily,"--vue-dd-fontSize":this.fontSize,"--vue-dd-lineHeight":this.lineHeight,"--vue-dd-paddingLeft":this.paddingLeft,"--vue-dd-maxHeight":this.maxHeight,"--vue-dd-maxWidth":this.maxWidth}},unwrapSpecific(){return this.unwrapSpecificFn(this.useOpenSpecific)},type(){return this.getTypeFn(this.modelValue)},primitive(){return this.isPrimitiveFn(this.type)},isSet(){return this.type==="object"&&this.modelValue instanceof Set},isRef(){return t.isRef(this.modelValue)}},methods:{forget(){this.save&&typeof this.memory=="object"&&(this.memory.open={},this.shared.hiddenPointers={},this.useOpenSpecific=this.baseOpenSpecific(),this.store().set(this.memory))},setFocus(){if(this.saveFocus&&this.useFocus!==null){let e=!0;this.setFocusAlready&&(e=!1),this.focusSticky&&(e=!0),e&&setTimeout(()=>{const A=this.getElement(this.useFocus);A&&(this.$refs.root.scrollLeft=A.offsetLeft+this.focusOffsetX,this.$refs.root.scrollTop=A.offsetTop+this.focusOffsetY,A.classList.add("vue-dd-highlight"),this.setFocusAlready=!0)},this.focusDelay)}},getElement(e){e=e===""?"":`${this.delimiter}${e}`;const A=`_${this.rootId}${e}`;return document.getElementById(A)},getFocus(){let e=this.focus;return this.saveFocus&&"focus"in this.memory&&this.memory.focus!==null&&(e=String(this.memory.focus)),e},initMemory(){this.memory=this.store().get(),Ee(this.memory)||(this.memory={}),(!("open"in this.memory)||!Ee(this.memory.open))&&(this.memory.open={}),"focus"in this.memory||(this.memory.focus=null)},getOpenSpecific(){if(this.save){this.memory.open={...this.memory.open,...this.unwrapSpecific},this.store().set(this.memory);let e=[];for(let A in this.memory.open)e.push(String(A));return e}else return this.baseOpenSpecific()},baseOpenSpecific(){return[...this.openSpecific,...this.useFocus===null?[]:[String(this.useFocus)]]},focusEmit(e){let{pointer:A,focusElement:i}=e;if(this.saveFocus){const r=this.useFocus;if(String(A)===String(r)&&String(A)!==String(this.focus))delete this.memory.open[A],A=null,i.classList.remove("vue-dd-focus-selected");else{delete this.memory.open[r];const o=this.getElement(r);if(o){const n=o.querySelector(".vue-dd-focus");n&&n.classList.remove("vue-dd-focus-selected")}i.classList.add("vue-dd-focus-selected")}this.memory.focus=A===null?this.focus:A,this.store().set(this.memory),this.useFocus=this.memory.focus,this.emitFn(this,"focus",{focus:this.memory.focus,focusElement:i})}},showEmit(e){let{type:A,pointer:i,focusElement:r}=e;this.emitFn(this,"show",e),this.saveFocus&&this.useFocus===i&&this.setFocus()},open(e){const{open:A,pointer:i,level:r,user:o}=e;r===0&&(this.openClass=A),this.$emit("open",e)},toggle(e){const{event:A,open:i,pointer:r,level:o}=e;if(this.save){if(i)delete this.shared.hiddenPointers[r],this.useOpenSpecific.push(r),this.memory.open[r]=!0;else{this.shared.hiddenPointers[r]=!0;const n=this.useOpenSpecific.indexOf(r);n>=0&&delete this.useOpenSpecific[n],delete this.memory.open[r]}this.store().set(this.memory)}this.$emit("toggle",e)},store(){const e="vue-dd."+this.rootId;return{get:()=>{try{return JSON.parse(window[`${this.storage}Storage`].getItem(e))}catch{}},set:A=>window[`${this.storage}Storage`].setItem(e,JSON.stringify(A))}},getTypeFn(e){let A=typeof e;return A==="object"?e===null?"null":Array.isArray(e)?"array":"object":(A==="string"&&e.length>this.longText&&(A="longtext"),A)},isPrimitiveFn(e){return!(e==="array"||e==="object"||e==="function"||e==="longtext")},escapeQuotesFn(e){return this.escapeQuotes?e.replaceAll('"','\\"'):e},unwrapSpecificFn(e){let A={};if(e.length){const i=e;if(i in me)return me[i];e.forEach(r=>{const o=String(r).split(this.delimiter);let n="",a=0;for(let l in o)n+=(a>0?this.delimiter:"")+o[l],A[n]=!0,a++;a>0&&(A[""]=!0)}),this.useFocus!==null&&(A[this.useFocus]=!0),me[i]=A}return A},emitFn(e,A,...i){for(;e&&!(e.$options.name!=="VueDd"&&e.$options.name!=="NodeComplex"&&e.$options.name!=="NodePrimitive");)e.$emit(A,...i),e=e.$parent}},watch:{modelValue:{handler(e,A){this.focusSticky&&e!==A&&this.setFocus()}}},components:{NodeComplex:it,NodePrimitive:Be}}),dt="",st=["id"];function rt(e,A,i,r,o,n){const a=t.resolveComponent("node-primitive"),l=t.resolveComponent("node-complex");return t.openBlock(),t.createElementBlock("div",{ref:"root",id:e.rootId,class:t.normalizeClass(["vue-dd",{"vue-dd-inline":e.inline,"vue-dd-open":e.openClass,"vue-dd-dark":e.dark},e.$attrs.class]),style:t.normalizeStyle([e.cssVars,e.$attrs.style])},[e.primitive?(t.openBlock(),t.createBlock(a,{key:0,root:e.$refs.root,rootId:e.rootId,modelValue:e.modelValue,name:e.name,focus:e.useFocus,escapeQuotes:e.escapeQuotes,save:e.save,saveFocus:e.saveFocus,delimiter:e.delimiter,pointer:"",type:e.type,parentOpen:!1,parentType:"",escapeQuotesFn:e.escapeQuotesFn,emitFn:e.emitFn,onFocus:e.focusEmit,onShow:e.showEmit},null,8,["root","rootId","modelValue","name","focus","escapeQuotes","save","saveFocus","delimiter","type","escapeQuotesFn","emitFn","onFocus","onShow"])):(t.openBlock(),t.createBlock(l,{key:1,root:e.$refs.root,rootId:e.rootId,modelValue:e.modelValue,name:e.name,openLevel:e.useOpenLevel,openSpecific:e.useOpenSpecific,focus:e.useFocus,escapeQuotes:e.escapeQuotes,longText:e.longText,preview:e.preview,previewInitial:e.previewInitial,deep:e.isRef?!0:e.deep,watch:e.watch,save:e.save,saveFocus:e.saveFocus,arrow:e.arrow,delimiter:e.delimiter,more:e.more,pointer:"",type:e.type,parentType:"",parentOpen:!1,shared:e.shared,getTypeFn:e.getTypeFn,isPrimitiveFn:e.isPrimitiveFn,escapeQuotesFn:e.escapeQuotesFn,unwrapSpecificFn:e.unwrapSpecificFn,emitFn:e.emitFn,onShow:e.showEmit,onToggle:e.toggle,onOpen:e.open,onFocus:e.focusEmit,onForget:e.forget},null,8,["root","rootId","modelValue","name","openLevel","openSpecific","focus","escapeQuotes","longText","preview","previewInitial","deep","watch","save","saveFocus","arrow","delimiter","more","type","shared","getTypeFn","isPrimitiveFn","escapeQuotesFn","unwrapSpecificFn","emitFn","onShow","onToggle","onOpen","onFocus","onForget"]))],14,st)}const Fe=te(ot,[["render",rt]]),lt={};function at(e,A){return t.openBlock(),t.createElementBlock("div",null,"Hello world")}const ze=te(lt,[["render",at]]);function ct(e){e.component("VueDd",Fe),e.component("XRay",ze)}T.VueDd=Fe,T.XRay=ze,T.install=ct,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}); diff --git a/vue-dd/src/VueDd.vue b/vue-dd/src/VueDd.vue index f05406d..1c304e4 100644 --- a/vue-dd/src/VueDd.vue +++ b/vue-dd/src/VueDd.vue @@ -336,7 +336,7 @@ export default defineComponent({ this.emitFn(this, 'show', setup) - console.log('show', pointer) + // console.log('show', pointer) if (this.saveFocus && this.useFocus === pointer) { this.setFocus() } diff --git a/vue3/src/components/VueDdApiTest.vue b/vue3/src/components/VueDdApiTest.vue index 7f1ba4d..4549e38 100644 --- a/vue3/src/components/VueDdApiTest.vue +++ b/vue3/src/components/VueDdApiTest.vue @@ -55,10 +55,10 @@ // import the ref import { ref } from 'vue'; -// import { VueDd } from 'vue-dd'; +import { VueDd } from 'vue-dd'; export default { - // components: { VueDd }, + components: { VueDd }, data() { return { previous: null,