@pardnchiu/nanojson
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,1 +0,1 @@ | ||
!function(){const e=window,t=document,n=Object,r=Number,o=Boolean,i=(DocumentFragment,Math),s=/\.([\w_-]+)?/gi,l=/\#([\w_-]+)?/i,a=/^\w+(?=[\#\.]*)/i,c="add",d="appendChild",p="color",h="createDocumentFragment",u="contentEditable",y="replaceChildren",f="type",g="script",b="console",m="body",j="apply",w="void",O="remove",N="display",v="float",k="dom",A="input",S="textarea",C="height",L="img",T="parent",x="inner",E="isArray",B="length",M="map",_="match",J="number",R="object",H="replace",F="source",I="style",$="string",D="temp",U="test",z="textContent",P="trim",G="value",K="width",V="Array",q="children",Q="editor",W="getElementById",X="nextElementSibling",Y="link",Z="rel",ee="preconnect",te="href",ne="crossOrigin",re="preload",oe="as",ie="anonymous",se="backgroundColor",le="classList",ae="createElement",ce="hasOwnProperty",de="indexOf",pe=x+"HTML",he=x+"Text",ue="setAttribute",ye=["String","Array","Boolean","Number","Object"],fe="https://fonts.googleapis.com",ge=fe+"/css2?family=Roboto+Mono:wght@400&family=Noto+Sans+TC:wght@400&display=swap",be=fe+"/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&display=swap",me="https://cdn.jsdelivr.net/npm/@pardnchiu/nanojson@0.1.1/dist/NanoJSON.css",je="NanoJSON\nGitHub: https://github.com/pardnchiu/NanoJSON\nCreator: Pardn Chiu\nLicense: Proprietary";for(let e of[Oe(Y,{[Z]:ee,[te]:"https://fonts.gstatic.com",[ne]:""}),Oe(Y,{[Z]:ee,[te]:fe,[ne]:""}),Oe(Y,{[Z]:re,[te]:ge,[oe]:I,[ne]:ie}),Oe(Y,{[Z]:"stylesheet",[te]:ge}),Oe(Y,{[Z]:re,[te]:be,[oe]:I,[ne]:ie}),Oe(Y,{[Z]:"stylesheet",[te]:be}),Oe(Y,{[Z]:"preconnect",[te]:"https://cdn.jsdelivr.net"}),Oe(Y,{[Z]:re,[te]:me,[oe]:I}),Oe(Y,{[Z]:"stylesheet",[te]:me})])t.head[d](e);function we(e={}){let t;if("object"==typeof e&&e[ce]("dom")){t=e.dom;for(let n of Object.keys(e))"dom"!==n&&(t[n]=t=>e[n](t));return t}}function Oe(e="",n,r){const o=((e[_](a)||[])[0]||"")[P](),i=((e[_](l)||[])[1]||"")[P](),y=(s[U](e)?e[_](s):[])[M]((e=>e[H](/^\./,"")));if(o[B]<1)return;let f,g,b,m=!1;if(e===D?(m=!0,f=t[h]()):f=t[ae](o),95!=je[B])return f;i[B]&&(f.id=i);for(let e of y)f[le][c](e);if(null==n&&null!=r&&([n,r]=[r,null]),null!=n&&null!=r)[g,b]=[n,r];else if(null==r)typeof n===$||typeof n===J||Array[E](n)?b=n:g=n;else if(null==n)return f;if(typeof g===R&&null!=g)for(const e in g){if(!g[ce](e))continue;const t=g[e];-1!=[G,he,pe,z,u][de](e)?f[e]=t:-1!=[p,se,K,C,N,v][de](e)?f[I][e]=t:null!=t&&f[ue](e,t)}if(null!=b){const e=typeof b===$,n=typeof b===J,r=Array[E](b);if(e||n){const e=b,n=o===A,r=o===S;o===L||o===F?f[_src]=e:r||n?f[G]=e:m?f[d](t[_createTextNode](b)):f[pe]=e}else if(r)for(let e of b){const n=e instanceof Element;typeof e===$||typeof e===J?m?f[d](t[_createTextNode](e)):f[pe]+=e:n&&f[d](e)}}return f}document.addEventListener("DOMContentLoaded",(e=>{!function(...e){const n=Oe(g,`${b}.log.${j}(${w} 0, ${JSON.stringify(e)});`);t[m][d](n),n[O]()}("%c"+je,"line-height: 1.75rem; font-size: 0.875rem;")}));new Map;e.JSONEditor=class{body;editor;type="Object";children=[];constructor(e={}){"object"==typeof e?(this.#e(e),this.#t()):console.error("Config Error: JSONEditor")}#e(e={}){this[Q]=Oe("div");const n=e.title??"",r=e.description??"",i=o(null==e.fill?1:e.fill)?1:0;let s=Oe("temp",[Math.max(n.length,r.length)>0?Oe("header",[n.length>0?Oe("strong",n):null,r.length>0?Oe("p",r):null]):null,this[Q],Oe("footer",[we({[k]:Oe("button.add-btn",[Oe("span.material-symbols-outlined","add")]),onclick:e=>this.#n()}),we({[k]:Oe("button.add-btn",[Oe("span.material-symbols-outlined","folder_open")]),onclick:e=>e.target.parentElement[X].click()}),we({[k]:Oe("input",{type:"file",accept:".json",display:"none"}),onchange:e=>this.import(e.target.files[0])}),we({[k]:Oe("button.add-btn",[Oe("span.material-symbols-outlined","download")]),onclick:e=>this.export()})])]);null==e.id?(this[m]=Oe("section.pd-json-editor"),this[m][d](s)):(this[m]=t[W](e.id),this[m][le].add("pd-json-editor"),this[m][y](...s[q])),this[m].dataset.fill=i,this.#n()}#t(){let e=Oe("temp",this[q].map(((e,t)=>this.#r(e,t))));this[Q][y](...e[q])}#n(){this[q].push(new Ne({parent:this})),this.#t()}#o(e){return we({[k]:Oe("button.collapse-btn",[Oe("span.material-symbols-outlined","Object"===e.type||"Array"===e.type?e.collapsed?"arrow_right":"arrow_drop_down":"chevron_right")]),onclick:"Object"===e.type||"Array"===e.type?t=>{e.collapsed=!e.collapsed,this.#t()}:e=>{}})}#i(e,t,n){return n?Oe("span.array-index",`${t}`):Oe("label",[we({[k]:Oe("textarea#key-"+e.id,{placeholder:"鍵"},e.key[H](/\n/g,"")),oninput:e=>{const t=e.target;t[G]=t[G][H](/\n/g,""),t[X].innerHTML=t[G][H](/\n/g,"<br>")},onchange:t=>{const n=t.target;n[G]=n[G][H](/\n/g,""),n[X].innerHTML=n[G][H](/\n/g,"<br>"),e.key=n[G]}}),Oe("pre",e.key[H](/\n/g,"")[H](/\n/g,"<br>"))])}#s(e){return Oe("label",[Oe("span.material-symbols-outlined","Number"===e.type?"123":"Boolean"===e.type?"toggle_on":"Array"===e.type?"data_array":"Object"===e.type?"data_object":"Abc"),we({[k]:Oe("select.type-select",ye.map((t=>Oe("option",{value:t,selected:t===e.type?"":null},t)))),onchange:n=>{if(e.type=n.target[G],"Object"===n.target[G]||"Array"===n.target[G])e[G]="",0===e[q].length&&e.add();else if("Number"===n.target[G]){const t=parseFloat(e[G]);e[G]=isNaN(t)?"":t}else e[q]=[];this.#t(),t[W]("value-"+e.id).focus()}})])}#l(e){if("Number"===e.type){var t=/[^\d\-\.]/g;let n=parseFloat(e[G][H](t,"")[H](/\s/g,"")[H](/\n/g,"<br>"));return Oe("label",[we({[k]:Oe("textarea#value-"+e.id,{placeholder:"數字"},isNaN(n)?"":n),oninput:e=>{const n=e.target;n[G]=n[G][H](/\s/g,"")[H](t,""),n[X].innerHTML=n[G][H](/\n/g,"<br>")},onchange:n=>{const r=n.target;r[G]=r[G][H](/\s/g,"")[H](t,""),r[X].innerHTML=r[G][H](/\n/g,"<br>"),e[G]=r[G]}}),Oe("pre",isNaN(n)?"":n)])}return"Boolean"===e.type?we({[k]:Oe("select#value-"+e.id,[Oe("option",{value:"true",selected:e[G]?"":null},"true"),Oe("option",{value:"false",selected:e[G]?null:""},"false")]),onchange:t=>{e[G]=t.target[G]}}):Oe("label",{display:"Object"===e.type||"Array"===e.type?"none":"block"},[we({[k]:Oe("textarea#value-"+e.id,{placeholder:"字串"},e[G]),oninput:e=>{const t=e.target;t[X].innerHTML=t[G][H](/\n/g,"<br>")},onchange:t=>{const n=t.target;n[X].innerHTML=n[G][H](/\n/g,"<br>"),e[G]=n[G]}}),Oe("pre",e[G][H](/\n/g,"<br>"))])}#a(e){return we({[k]:Oe("button.delete-btn",[Oe("span.material-symbols-outlined","close")]),onclick:t=>{e.remove(),this.#t()}})}#c(e,t){if(("Object"===e.type||"Array"===e.type)&&!e.collapsed)return Oe("section.pd-json-editor-nested-child",[...e[q].map(((n,r)=>this.#r(n,r,t+1,"Array"===e.type))),we({[k]:Oe("button.add-btn",[Oe("span.material-symbols-outlined","add")]),onclick:t=>{e.add(),this.#t()}})])}#r(e,t,n=0,r=!1){return Oe("section.pd-json-editor-child",[Oe("div.pair-wrapper",[Oe("div#"+e.id+".input-group",[this.#o(e),this.#i(e,t,r),Oe("span",":"),this.#s(e),this.#l(e),this.#a(e)]),this.#c(e,n)])])}import(e){if(!e)return;const t=new FileReader;t.onload=e=>{try{const t=JSON.parse(e.target.result);this[q]=this.#d(t),this.#t()}catch(e){console.error(e),alert("JSON 格式錯誤,請檢查文件內容")}},t.readAsText(e)}#d(e,t=null){const n=[];if(console.log(e),Array.isArray(e))e.forEach(((e,r)=>{const o=this.#p(e),i=new Ne({type:o,parent:t??this});"Object"===o&&null!=e||"Array"===o?i[q]=this.#d(e,i):i[G]=String(e),n.push(i)}));else for(const[r,o]of Object.entries(e)){const e=this.#p(o),i=new Ne({key:r,type:e,parent:t??this});"Object"===e&&null!=o||"Array"===e?i[q]=this.#d(o,i):i[G]=null==o?"":String(o),n.push(i)}return n}#p(e){return Array.isArray(e)?"Array":"boolean"==typeof e?"Boolean":"number"==typeof e?"Number":"object"==typeof e?"Object":"String"}get json(){const e={};return this[q].forEach((t=>{t.key&&(console.log(t),e[t.key||0]=t.json)})),JSON.stringify(e,null,4)}export(){const e={};this[q].forEach((t=>{(t.key||1===this[q].length)&&(e[t.key||0]=t.json)}));const n=new Blob([JSON.stringify(e,null,4)],{type:"application/json"}),r=URL.createObjectURL(n),o=Oe("a",{href:r,download:`JSONEditor-${Date.now()}.json`});t[m][d](o),o.click(),t[m].removeChild(o),URL.revokeObjectURL(r)}};class Ne{key="";type="String";value="";parent=null;children=[];collapsed=!1;constructor(e={}){"object"==typeof e?(this.id=function(e=64){let t="";for(let n=0;n<e;n++)t+="abcdefghijklmnopqrstuvwxyz0123456789".charAt(i.floor(36*i.random()));return t}(),this.key=e.key??this.key,this.type=e.type??this.type,this.value=e.value??this.value,this[T]=e[T]??this[T],this[q]=e[q]??this[q],this.collapsed=e.collapsed??this.collapsed):console.error("Config Error: JSONEditor.Node")}add(){this.#h()}remove(){this.#u()}get json(){return this.#y()}#h(){this[q].push(new Ne({[T]:this}))}#u(){if(!this[T])return;const e=this[T][q][de](this);-1!==e&&this[T][q].splice(e,1)}#y(){if(!this[T])return;if(this[f]===V)return this[q][M]((e=>e.#y()));if("Object"===this[f]){const e={};for(let t of this[q])(t.key||this[T][f]===V)&&(e[t.key||n.keys(e)[B]]=t.#y());return e}let e=this[G];return"Boolean"===this[f]?e="true"===e.toLowerCase():"Number"===this[f]&&(e=r(e)),e}}}("undefined"==typeof window?window={}:window);export const JSONEditor = window.JSONEditor; | ||
!function(){const e=window,t=document,n=Object,r=Number,o=Boolean,i=(DocumentFragment,Math),s=/\.([\w_-]+)?/gi,l=/\#([\w_-]+)?/i,a=/^\w+(?=[\#\.]*)/i,c="add",d="appendChild",p="color",h="createDocumentFragment",u="contentEditable",y="replaceChildren",f="type",g="script",b="console",m="body",j="apply",O="void",w="remove",N="display",v="float",k="dom",A="input",S="textarea",C="height",L="img",T="parent",x="inner",E="isArray",B="length",M="map",_="match",J="number",R="object",H="replace",F="source",I="style",$="string",D="temp",U="test",z="textContent",P="trim",G="value",K="width",V="Array",q="children",Q="editor",W="getElementById",X="nextElementSibling",Y="link",Z="rel",ee="preconnect",te="href",ne="crossOrigin",re="preload",oe="as",ie="anonymous",se="backgroundColor",le="classList",ae="createElement",ce="hasOwnProperty",de="indexOf",pe=x+"HTML",he=x+"Text",ue="setAttribute",ye=["String","Array","Boolean","Number","Object"],fe="https://fonts.googleapis.com",ge=fe+"/css2?family=Roboto+Mono:wght@400&family=Noto+Sans+TC:wght@400&display=swap",be=fe+"/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&display=swap",me="https://cdn.jsdelivr.net/npm/@pardnchiu/nanojson@0.1.2/dist/NanoJSON.css",je="NanoJSON\nGitHub: https://github.com/pardnchiu/NanoJSON\nCreator: Pardn Chiu\nLicense: Proprietary";for(let e of[we(Y,{[Z]:ee,[te]:"https://fonts.gstatic.com",[ne]:""}),we(Y,{[Z]:ee,[te]:fe,[ne]:""}),we(Y,{[Z]:re,[te]:ge,[oe]:I,[ne]:ie}),we(Y,{[Z]:"stylesheet",[te]:ge}),we(Y,{[Z]:re,[te]:be,[oe]:I,[ne]:ie}),we(Y,{[Z]:"stylesheet",[te]:be}),we(Y,{[Z]:"preconnect",[te]:"https://cdn.jsdelivr.net"}),we(Y,{[Z]:re,[te]:me,[oe]:I}),we(Y,{[Z]:"stylesheet",[te]:me})])t.head[d](e);function Oe(e={}){let t;if("object"==typeof e&&e[ce]("dom")){t=e.dom;for(let n of Object.keys(e))"dom"!==n&&(t[n]=t=>e[n](t));return t}}function we(e="",n,r){const o=((e[_](a)||[])[0]||"")[P](),i=((e[_](l)||[])[1]||"")[P](),y=(s[U](e)?e[_](s):[])[M]((e=>e[H](/^\./,"")));if(o[B]<1)return;let f,g,b,m=!1;if(e===D?(m=!0,f=t[h]()):f=t[ae](o),95!=je[B])return f;i[B]&&(f.id=i);for(let e of y)f[le][c](e);if(null==n&&null!=r&&([n,r]=[r,null]),null!=n&&null!=r)[g,b]=[n,r];else if(null==r)typeof n===$||typeof n===J||Array[E](n)?b=n:g=n;else if(null==n)return f;if(typeof g===R&&null!=g)for(const e in g){if(!g[ce](e))continue;const t=g[e];-1!=[G,he,pe,z,u][de](e)?f[e]=t:-1!=[p,se,K,C,N,v][de](e)?f[I][e]=t:null!=t&&f[ue](e,t)}if(null!=b){const e=typeof b===$,n=typeof b===J,r=Array[E](b);if(e||n){const e=b,n=o===A,r=o===S;o===L||o===F?f[_src]=e:r||n?f[G]=e:m?f[d](t[_createTextNode](b)):f[pe]=e}else if(r)for(let e of b){const n=e instanceof Element;typeof e===$||typeof e===J?m?f[d](t[_createTextNode](e)):f[pe]+=e:n&&f[d](e)}}return f}document.addEventListener("DOMContentLoaded",(e=>{!function(...e){const n=we(g,`${b}.log.${j}(${O} 0, ${JSON.stringify(e)});`);t[m][d](n),n[w]()}("%c"+je,"line-height: 1.75rem; font-size: 0.875rem;")}));new Map;e.JSONEditor=class{body;editor;type="Object";children=[];constructor(e={}){"object"==typeof e?(this.#e(e),this.#t()):console.error("Config Error: JSONEditor")}#e(e={}){this[Q]=we("div");const n=e.title??"",r=e.description??"",i=o(null==e.fill?1:e.fill)?1:0;let s=we("temp",[Math.max(n.length,r.length)>0?we("header",[n.length>0?we("strong",n):null,r.length>0?we("p",r):null]):null,this[Q],we("footer",[Oe({[k]:we("button.add-btn",[we("span.material-symbols-outlined","add")]),onclick:e=>this.#n()}),Oe({[k]:we("button.add-btn",[we("span.material-symbols-outlined","folder_open")]),onclick:e=>e.target.parentElement[X].click()}),Oe({[k]:we("input",{type:"file",accept:".json",display:"none"}),onchange:e=>this.import(e.target.files[0])}),Oe({[k]:we("button.add-btn",[we("span.material-symbols-outlined","download")]),onclick:e=>this.export()})])]);null==e.id?(this[m]=we("section.pd-json-editor"),this[m][d](s)):(this[m]=t[W](e.id),this[m][le].add("pd-json-editor"),this[m][y](...s[q])),this[m].dataset.fill=i,this.#n()}#t(){let e=we("temp",this[q].map(((e,t)=>this.#r(e,t))));this[Q][y](...e[q])}#n(){this[q].push(new Ne({parent:this})),this.#t()}#o(e){return Oe({[k]:we("button.collapse-btn",{"data-collapse":"Object"===e.type||"Array"===e.type?1:0},[we("span.material-symbols-outlined","Object"===e.type||"Array"===e.type?e.collapsed?"arrow_right":"arrow_drop_down":"chevron_right")]),onclick:"Object"===e.type||"Array"===e.type?t=>{e.collapsed=!e.collapsed,this.#t()}:e=>{}})}#i(e,t,n){return n?we("span.array-index",`${t}`):we("label",[Oe({[k]:we("textarea#key-"+e.id,{placeholder:"鍵"},e.key[H](/\n/g,"")),oninput:e=>{const t=e.target;t[G]=t[G][H](/\n/g,""),t[X].innerHTML=t[G][H](/\n/g,"<br>")},onchange:t=>{const n=t.target;n[G]=n[G][H](/\n/g,""),n[X].innerHTML=n[G][H](/\n/g,"<br>"),e.key=n[G]}}),we("pre",e.key[H](/\n/g,"")[H](/\n/g,"<br>"))])}#s(e){return we("label",[we("span.material-symbols-outlined","Number"===e.type?"123":"Boolean"===e.type?"toggle_on":"Array"===e.type?"data_array":"Object"===e.type?"data_object":"Abc"),Oe({[k]:we("select.type-select",ye.map((t=>we("option",{value:t,selected:t===e.type?"":null},t)))),onchange:n=>{if(e.type=n.target[G],"Object"===n.target[G]||"Array"===n.target[G])e[G]="",0===e[q].length&&e.add();else if("Number"===n.target[G]){const t=parseFloat(e[G]);e[G]=isNaN(t)?"":t}else e[q]=[];this.#t(),t[W]("value-"+e.id).focus()}})])}#l(e){if("Number"===e.type){var t=/[^\d\-\.]/g;let n=parseFloat(e[G][H](t,"")[H](/\s/g,"")[H](/\n/g,"<br>"));return we("label",[Oe({[k]:we("textarea#value-"+e.id,{placeholder:"數字"},isNaN(n)?"":n),oninput:e=>{const n=e.target;n[G]=n[G][H](/\s/g,"")[H](t,""),n[X].innerHTML=n[G][H](/\n/g,"<br>")},onchange:n=>{const r=n.target;r[G]=r[G][H](/\s/g,"")[H](t,""),r[X].innerHTML=r[G][H](/\n/g,"<br>"),e[G]=r[G]}}),we("pre",isNaN(n)?"":n)])}return"Boolean"===e.type?Oe({[k]:we("select#value-"+e.id,[we("option",{value:"true",selected:e[G]?"":null},"true"),we("option",{value:"false",selected:e[G]?null:""},"false")]),onchange:t=>{e[G]=t.target[G]}}):we("label",{display:"Object"===e.type||"Array"===e.type?"none":"block"},[Oe({[k]:we("textarea#value-"+e.id,{placeholder:"字串"},e[G]),oninput:e=>{const t=e.target;t[X].innerHTML=t[G][H](/\n/g,"<br>")},onchange:t=>{const n=t.target;n[X].innerHTML=n[G][H](/\n/g,"<br>"),e[G]=n[G]}}),we("pre",e[G][H](/\n/g,"<br>"))])}#a(e){return Oe({[k]:we("button.delete-btn",[we("span.material-symbols-outlined","close")]),onclick:t=>{e.remove(),this.#t()}})}#c(e,t){if(("Object"===e.type||"Array"===e.type)&&!e.collapsed)return we("section.pd-json-editor-nested-child",[...e[q].map(((n,r)=>this.#r(n,r,t+1,"Array"===e.type))),Oe({[k]:we("button.add-btn",[we("span.material-symbols-outlined","add")]),onclick:t=>{e.add(),this.#t()}})])}#r(e,t,n=0,r=!1){return we("section.pd-json-editor-child",[we("div.pair-wrapper",[we("div#"+e.id+".input-group",[this.#o(e),this.#i(e,t,r),we("span",":"),this.#s(e),this.#l(e),this.#a(e)]),this.#c(e,n)])])}import(e){if(!e)return;const t=new FileReader;t.onload=e=>{try{const t=JSON.parse(e.target.result);this[q]=this.#d(t),this.#t()}catch(e){console.error(e),alert("JSON 格式錯誤,請檢查文件內容")}},t.readAsText(e)}#d(e,t=null){const n=[];if(console.log(e),Array.isArray(e))e.forEach(((e,r)=>{const o=this.#p(e),i=new Ne({type:o,parent:t??this});"Object"===o&&null!=e||"Array"===o?i[q]=this.#d(e,i):i[G]=String(e),n.push(i)}));else for(const[r,o]of Object.entries(e)){const e=this.#p(o),i=new Ne({key:r,type:e,parent:t??this});"Object"===e&&null!=o||"Array"===e?i[q]=this.#d(o,i):i[G]=null==o?"":String(o),n.push(i)}return n}#p(e){return Array.isArray(e)?"Array":"boolean"==typeof e?"Boolean":"number"==typeof e?"Number":"object"==typeof e?"Object":"String"}get json(){const e={};return this[q].forEach((t=>{t.key&&(console.log(t),e[t.key||0]=t.json)})),JSON.stringify(e,null,4)}export(){const e={};this[q].forEach((t=>{(t.key||1===this[q].length)&&(e[t.key||0]=t.json)}));const n=new Blob([JSON.stringify(e,null,4)],{type:"application/json"}),r=URL.createObjectURL(n),o=we("a",{href:r,download:`JSONEditor-${Date.now()}.json`});t[m][d](o),o.click(),t[m].removeChild(o),URL.revokeObjectURL(r)}};class Ne{key="";type="String";value="";parent=null;children=[];collapsed=!1;constructor(e={}){"object"==typeof e?(this.id=function(e=64){let t="";for(let n=0;n<e;n++)t+="abcdefghijklmnopqrstuvwxyz0123456789".charAt(i.floor(36*i.random()));return t}(),this.key=e.key??this.key,this.type=e.type??this.type,this.value=e.value??this.value,this[T]=e[T]??this[T],this[q]=e[q]??this[q],this.collapsed=e.collapsed??this.collapsed):console.error("Config Error: JSONEditor.Node")}add(){this.#h()}remove(){this.#u()}get json(){return this.#y()}#h(){this[q].push(new Ne({[T]:this}))}#u(){if(!this[T])return;const e=this[T][q][de](this);-1!==e&&this[T][q].splice(e,1)}#y(){if(!this[T])return;if(this[f]===V)return this[q][M]((e=>e.#y()));if("Object"===this[f]){const e={};for(let t of this[q])(t.key||this[T][f]===V)&&(e[t.key||n.keys(e)[B]]=t.#y());return e}let e=this[G];return"Boolean"===this[f]?e="true"===e.toLowerCase():"Number"===this[f]&&(e=r(e)),e}}}("undefined"==typeof window?window={}:window);export const JSONEditor = window.JSONEditor; |
@@ -1,1 +0,1 @@ | ||
!function(){const e=window,t=document,n=Object,r=Number,o=Boolean,i=(DocumentFragment,Math),s=/\.([\w_-]+)?/gi,l=/\#([\w_-]+)?/i,a=/^\w+(?=[\#\.]*)/i,c="add",d="appendChild",p="color",h="createDocumentFragment",u="contentEditable",y="replaceChildren",f="type",g="script",b="console",m="body",j="apply",w="void",O="remove",N="display",v="float",k="dom",A="input",S="textarea",C="height",L="img",T="parent",x="inner",E="isArray",B="length",M="map",_="match",J="number",R="object",H="replace",F="source",I="style",$="string",D="temp",U="test",z="textContent",P="trim",G="value",K="width",V="Array",q="children",Q="editor",W="getElementById",X="nextElementSibling",Y="link",Z="rel",ee="preconnect",te="href",ne="crossOrigin",re="preload",oe="as",ie="anonymous",se="backgroundColor",le="classList",ae="createElement",ce="hasOwnProperty",de="indexOf",pe=x+"HTML",he=x+"Text",ue="setAttribute",ye=["String","Array","Boolean","Number","Object"],fe="https://fonts.googleapis.com",ge=fe+"/css2?family=Roboto+Mono:wght@400&family=Noto+Sans+TC:wght@400&display=swap",be=fe+"/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&display=swap",me="https://cdn.jsdelivr.net/npm/@pardnchiu/nanojson@0.1.1/dist/NanoJSON.css",je="NanoJSON\nGitHub: https://github.com/pardnchiu/NanoJSON\nCreator: Pardn Chiu\nLicense: Proprietary";for(let e of[Oe(Y,{[Z]:ee,[te]:"https://fonts.gstatic.com",[ne]:""}),Oe(Y,{[Z]:ee,[te]:fe,[ne]:""}),Oe(Y,{[Z]:re,[te]:ge,[oe]:I,[ne]:ie}),Oe(Y,{[Z]:"stylesheet",[te]:ge}),Oe(Y,{[Z]:re,[te]:be,[oe]:I,[ne]:ie}),Oe(Y,{[Z]:"stylesheet",[te]:be}),Oe(Y,{[Z]:"preconnect",[te]:"https://cdn.jsdelivr.net"}),Oe(Y,{[Z]:re,[te]:me,[oe]:I}),Oe(Y,{[Z]:"stylesheet",[te]:me})])t.head[d](e);function we(e={}){let t;if("object"==typeof e&&e[ce]("dom")){t=e.dom;for(let n of Object.keys(e))"dom"!==n&&(t[n]=t=>e[n](t));return t}}function Oe(e="",n,r){const o=((e[_](a)||[])[0]||"")[P](),i=((e[_](l)||[])[1]||"")[P](),y=(s[U](e)?e[_](s):[])[M]((e=>e[H](/^\./,"")));if(o[B]<1)return;let f,g,b,m=!1;if(e===D?(m=!0,f=t[h]()):f=t[ae](o),95!=je[B])return f;i[B]&&(f.id=i);for(let e of y)f[le][c](e);if(null==n&&null!=r&&([n,r]=[r,null]),null!=n&&null!=r)[g,b]=[n,r];else if(null==r)typeof n===$||typeof n===J||Array[E](n)?b=n:g=n;else if(null==n)return f;if(typeof g===R&&null!=g)for(const e in g){if(!g[ce](e))continue;const t=g[e];-1!=[G,he,pe,z,u][de](e)?f[e]=t:-1!=[p,se,K,C,N,v][de](e)?f[I][e]=t:null!=t&&f[ue](e,t)}if(null!=b){const e=typeof b===$,n=typeof b===J,r=Array[E](b);if(e||n){const e=b,n=o===A,r=o===S;o===L||o===F?f[_src]=e:r||n?f[G]=e:m?f[d](t[_createTextNode](b)):f[pe]=e}else if(r)for(let e of b){const n=e instanceof Element;typeof e===$||typeof e===J?m?f[d](t[_createTextNode](e)):f[pe]+=e:n&&f[d](e)}}return f}document.addEventListener("DOMContentLoaded",(e=>{!function(...e){const n=Oe(g,`${b}.log.${j}(${w} 0, ${JSON.stringify(e)});`);t[m][d](n),n[O]()}("%c"+je,"line-height: 1.75rem; font-size: 0.875rem;")}));new Map;e.JSONEditor=class{body;editor;type="Object";children=[];constructor(e={}){"object"==typeof e?(this.#e(e),this.#t()):console.error("Config Error: JSONEditor")}#e(e={}){this[Q]=Oe("div");const n=e.title??"",r=e.description??"",i=o(null==e.fill?1:e.fill)?1:0;let s=Oe("temp",[Math.max(n.length,r.length)>0?Oe("header",[n.length>0?Oe("strong",n):null,r.length>0?Oe("p",r):null]):null,this[Q],Oe("footer",[we({[k]:Oe("button.add-btn",[Oe("span.material-symbols-outlined","add")]),onclick:e=>this.#n()}),we({[k]:Oe("button.add-btn",[Oe("span.material-symbols-outlined","folder_open")]),onclick:e=>e.target.parentElement[X].click()}),we({[k]:Oe("input",{type:"file",accept:".json",display:"none"}),onchange:e=>this.import(e.target.files[0])}),we({[k]:Oe("button.add-btn",[Oe("span.material-symbols-outlined","download")]),onclick:e=>this.export()})])]);null==e.id?(this[m]=Oe("section.pd-json-editor"),this[m][d](s)):(this[m]=t[W](e.id),this[m][le].add("pd-json-editor"),this[m][y](...s[q])),this[m].dataset.fill=i,this.#n()}#t(){let e=Oe("temp",this[q].map(((e,t)=>this.#r(e,t))));this[Q][y](...e[q])}#n(){this[q].push(new Ne({parent:this})),this.#t()}#o(e){return we({[k]:Oe("button.collapse-btn",[Oe("span.material-symbols-outlined","Object"===e.type||"Array"===e.type?e.collapsed?"arrow_right":"arrow_drop_down":"chevron_right")]),onclick:"Object"===e.type||"Array"===e.type?t=>{e.collapsed=!e.collapsed,this.#t()}:e=>{}})}#i(e,t,n){return n?Oe("span.array-index",`${t}`):Oe("label",[we({[k]:Oe("textarea#key-"+e.id,{placeholder:"鍵"},e.key[H](/\n/g,"")),oninput:e=>{const t=e.target;t[G]=t[G][H](/\n/g,""),t[X].innerHTML=t[G][H](/\n/g,"<br>")},onchange:t=>{const n=t.target;n[G]=n[G][H](/\n/g,""),n[X].innerHTML=n[G][H](/\n/g,"<br>"),e.key=n[G]}}),Oe("pre",e.key[H](/\n/g,"")[H](/\n/g,"<br>"))])}#s(e){return Oe("label",[Oe("span.material-symbols-outlined","Number"===e.type?"123":"Boolean"===e.type?"toggle_on":"Array"===e.type?"data_array":"Object"===e.type?"data_object":"Abc"),we({[k]:Oe("select.type-select",ye.map((t=>Oe("option",{value:t,selected:t===e.type?"":null},t)))),onchange:n=>{if(e.type=n.target[G],"Object"===n.target[G]||"Array"===n.target[G])e[G]="",0===e[q].length&&e.add();else if("Number"===n.target[G]){const t=parseFloat(e[G]);e[G]=isNaN(t)?"":t}else e[q]=[];this.#t(),t[W]("value-"+e.id).focus()}})])}#l(e){if("Number"===e.type){var t=/[^\d\-\.]/g;let n=parseFloat(e[G][H](t,"")[H](/\s/g,"")[H](/\n/g,"<br>"));return Oe("label",[we({[k]:Oe("textarea#value-"+e.id,{placeholder:"數字"},isNaN(n)?"":n),oninput:e=>{const n=e.target;n[G]=n[G][H](/\s/g,"")[H](t,""),n[X].innerHTML=n[G][H](/\n/g,"<br>")},onchange:n=>{const r=n.target;r[G]=r[G][H](/\s/g,"")[H](t,""),r[X].innerHTML=r[G][H](/\n/g,"<br>"),e[G]=r[G]}}),Oe("pre",isNaN(n)?"":n)])}return"Boolean"===e.type?we({[k]:Oe("select#value-"+e.id,[Oe("option",{value:"true",selected:e[G]?"":null},"true"),Oe("option",{value:"false",selected:e[G]?null:""},"false")]),onchange:t=>{e[G]=t.target[G]}}):Oe("label",{display:"Object"===e.type||"Array"===e.type?"none":"block"},[we({[k]:Oe("textarea#value-"+e.id,{placeholder:"字串"},e[G]),oninput:e=>{const t=e.target;t[X].innerHTML=t[G][H](/\n/g,"<br>")},onchange:t=>{const n=t.target;n[X].innerHTML=n[G][H](/\n/g,"<br>"),e[G]=n[G]}}),Oe("pre",e[G][H](/\n/g,"<br>"))])}#a(e){return we({[k]:Oe("button.delete-btn",[Oe("span.material-symbols-outlined","close")]),onclick:t=>{e.remove(),this.#t()}})}#c(e,t){if(("Object"===e.type||"Array"===e.type)&&!e.collapsed)return Oe("section.pd-json-editor-nested-child",[...e[q].map(((n,r)=>this.#r(n,r,t+1,"Array"===e.type))),we({[k]:Oe("button.add-btn",[Oe("span.material-symbols-outlined","add")]),onclick:t=>{e.add(),this.#t()}})])}#r(e,t,n=0,r=!1){return Oe("section.pd-json-editor-child",[Oe("div.pair-wrapper",[Oe("div#"+e.id+".input-group",[this.#o(e),this.#i(e,t,r),Oe("span",":"),this.#s(e),this.#l(e),this.#a(e)]),this.#c(e,n)])])}import(e){if(!e)return;const t=new FileReader;t.onload=e=>{try{const t=JSON.parse(e.target.result);this[q]=this.#d(t),this.#t()}catch(e){console.error(e),alert("JSON 格式錯誤,請檢查文件內容")}},t.readAsText(e)}#d(e,t=null){const n=[];if(console.log(e),Array.isArray(e))e.forEach(((e,r)=>{const o=this.#p(e),i=new Ne({type:o,parent:t??this});"Object"===o&&null!=e||"Array"===o?i[q]=this.#d(e,i):i[G]=String(e),n.push(i)}));else for(const[r,o]of Object.entries(e)){const e=this.#p(o),i=new Ne({key:r,type:e,parent:t??this});"Object"===e&&null!=o||"Array"===e?i[q]=this.#d(o,i):i[G]=null==o?"":String(o),n.push(i)}return n}#p(e){return Array.isArray(e)?"Array":"boolean"==typeof e?"Boolean":"number"==typeof e?"Number":"object"==typeof e?"Object":"String"}get json(){const e={};return this[q].forEach((t=>{t.key&&(console.log(t),e[t.key||0]=t.json)})),JSON.stringify(e,null,4)}export(){const e={};this[q].forEach((t=>{(t.key||1===this[q].length)&&(e[t.key||0]=t.json)}));const n=new Blob([JSON.stringify(e,null,4)],{type:"application/json"}),r=URL.createObjectURL(n),o=Oe("a",{href:r,download:`JSONEditor-${Date.now()}.json`});t[m][d](o),o.click(),t[m].removeChild(o),URL.revokeObjectURL(r)}};class Ne{key="";type="String";value="";parent=null;children=[];collapsed=!1;constructor(e={}){"object"==typeof e?(this.id=function(e=64){let t="";for(let n=0;n<e;n++)t+="abcdefghijklmnopqrstuvwxyz0123456789".charAt(i.floor(36*i.random()));return t}(),this.key=e.key??this.key,this.type=e.type??this.type,this.value=e.value??this.value,this[T]=e[T]??this[T],this[q]=e[q]??this[q],this.collapsed=e.collapsed??this.collapsed):console.error("Config Error: JSONEditor.Node")}add(){this.#h()}remove(){this.#u()}get json(){return this.#y()}#h(){this[q].push(new Ne({[T]:this}))}#u(){if(!this[T])return;const e=this[T][q][de](this);-1!==e&&this[T][q].splice(e,1)}#y(){if(!this[T])return;if(this[f]===V)return this[q][M]((e=>e.#y()));if("Object"===this[f]){const e={};for(let t of this[q])(t.key||this[T][f]===V)&&(e[t.key||n.keys(e)[B]]=t.#y());return e}let e=this[G];return"Boolean"===this[f]?e="true"===e.toLowerCase():"Number"===this[f]&&(e=r(e)),e}}}("undefined"==typeof window?window={}:window); | ||
!function(){const e=window,t=document,n=Object,r=Number,o=Boolean,i=(DocumentFragment,Math),s=/\.([\w_-]+)?/gi,l=/\#([\w_-]+)?/i,a=/^\w+(?=[\#\.]*)/i,c="add",d="appendChild",p="color",h="createDocumentFragment",u="contentEditable",y="replaceChildren",f="type",g="script",b="console",m="body",j="apply",O="void",w="remove",N="display",v="float",k="dom",A="input",S="textarea",C="height",L="img",T="parent",x="inner",E="isArray",B="length",M="map",_="match",J="number",R="object",H="replace",F="source",I="style",$="string",D="temp",U="test",z="textContent",P="trim",G="value",K="width",V="Array",q="children",Q="editor",W="getElementById",X="nextElementSibling",Y="link",Z="rel",ee="preconnect",te="href",ne="crossOrigin",re="preload",oe="as",ie="anonymous",se="backgroundColor",le="classList",ae="createElement",ce="hasOwnProperty",de="indexOf",pe=x+"HTML",he=x+"Text",ue="setAttribute",ye=["String","Array","Boolean","Number","Object"],fe="https://fonts.googleapis.com",ge=fe+"/css2?family=Roboto+Mono:wght@400&family=Noto+Sans+TC:wght@400&display=swap",be=fe+"/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0&display=swap",me="https://cdn.jsdelivr.net/npm/@pardnchiu/nanojson@0.1.2/dist/NanoJSON.css",je="NanoJSON\nGitHub: https://github.com/pardnchiu/NanoJSON\nCreator: Pardn Chiu\nLicense: Proprietary";for(let e of[we(Y,{[Z]:ee,[te]:"https://fonts.gstatic.com",[ne]:""}),we(Y,{[Z]:ee,[te]:fe,[ne]:""}),we(Y,{[Z]:re,[te]:ge,[oe]:I,[ne]:ie}),we(Y,{[Z]:"stylesheet",[te]:ge}),we(Y,{[Z]:re,[te]:be,[oe]:I,[ne]:ie}),we(Y,{[Z]:"stylesheet",[te]:be}),we(Y,{[Z]:"preconnect",[te]:"https://cdn.jsdelivr.net"}),we(Y,{[Z]:re,[te]:me,[oe]:I}),we(Y,{[Z]:"stylesheet",[te]:me})])t.head[d](e);function Oe(e={}){let t;if("object"==typeof e&&e[ce]("dom")){t=e.dom;for(let n of Object.keys(e))"dom"!==n&&(t[n]=t=>e[n](t));return t}}function we(e="",n,r){const o=((e[_](a)||[])[0]||"")[P](),i=((e[_](l)||[])[1]||"")[P](),y=(s[U](e)?e[_](s):[])[M]((e=>e[H](/^\./,"")));if(o[B]<1)return;let f,g,b,m=!1;if(e===D?(m=!0,f=t[h]()):f=t[ae](o),95!=je[B])return f;i[B]&&(f.id=i);for(let e of y)f[le][c](e);if(null==n&&null!=r&&([n,r]=[r,null]),null!=n&&null!=r)[g,b]=[n,r];else if(null==r)typeof n===$||typeof n===J||Array[E](n)?b=n:g=n;else if(null==n)return f;if(typeof g===R&&null!=g)for(const e in g){if(!g[ce](e))continue;const t=g[e];-1!=[G,he,pe,z,u][de](e)?f[e]=t:-1!=[p,se,K,C,N,v][de](e)?f[I][e]=t:null!=t&&f[ue](e,t)}if(null!=b){const e=typeof b===$,n=typeof b===J,r=Array[E](b);if(e||n){const e=b,n=o===A,r=o===S;o===L||o===F?f[_src]=e:r||n?f[G]=e:m?f[d](t[_createTextNode](b)):f[pe]=e}else if(r)for(let e of b){const n=e instanceof Element;typeof e===$||typeof e===J?m?f[d](t[_createTextNode](e)):f[pe]+=e:n&&f[d](e)}}return f}document.addEventListener("DOMContentLoaded",(e=>{!function(...e){const n=we(g,`${b}.log.${j}(${O} 0, ${JSON.stringify(e)});`);t[m][d](n),n[w]()}("%c"+je,"line-height: 1.75rem; font-size: 0.875rem;")}));new Map;e.JSONEditor=class{body;editor;type="Object";children=[];constructor(e={}){"object"==typeof e?(this.#e(e),this.#t()):console.error("Config Error: JSONEditor")}#e(e={}){this[Q]=we("div");const n=e.title??"",r=e.description??"",i=o(null==e.fill?1:e.fill)?1:0;let s=we("temp",[Math.max(n.length,r.length)>0?we("header",[n.length>0?we("strong",n):null,r.length>0?we("p",r):null]):null,this[Q],we("footer",[Oe({[k]:we("button.add-btn",[we("span.material-symbols-outlined","add")]),onclick:e=>this.#n()}),Oe({[k]:we("button.add-btn",[we("span.material-symbols-outlined","folder_open")]),onclick:e=>e.target.parentElement[X].click()}),Oe({[k]:we("input",{type:"file",accept:".json",display:"none"}),onchange:e=>this.import(e.target.files[0])}),Oe({[k]:we("button.add-btn",[we("span.material-symbols-outlined","download")]),onclick:e=>this.export()})])]);null==e.id?(this[m]=we("section.pd-json-editor"),this[m][d](s)):(this[m]=t[W](e.id),this[m][le].add("pd-json-editor"),this[m][y](...s[q])),this[m].dataset.fill=i,this.#n()}#t(){let e=we("temp",this[q].map(((e,t)=>this.#r(e,t))));this[Q][y](...e[q])}#n(){this[q].push(new Ne({parent:this})),this.#t()}#o(e){return Oe({[k]:we("button.collapse-btn",{"data-collapse":"Object"===e.type||"Array"===e.type?1:0},[we("span.material-symbols-outlined","Object"===e.type||"Array"===e.type?e.collapsed?"arrow_right":"arrow_drop_down":"chevron_right")]),onclick:"Object"===e.type||"Array"===e.type?t=>{e.collapsed=!e.collapsed,this.#t()}:e=>{}})}#i(e,t,n){return n?we("span.array-index",`${t}`):we("label",[Oe({[k]:we("textarea#key-"+e.id,{placeholder:"鍵"},e.key[H](/\n/g,"")),oninput:e=>{const t=e.target;t[G]=t[G][H](/\n/g,""),t[X].innerHTML=t[G][H](/\n/g,"<br>")},onchange:t=>{const n=t.target;n[G]=n[G][H](/\n/g,""),n[X].innerHTML=n[G][H](/\n/g,"<br>"),e.key=n[G]}}),we("pre",e.key[H](/\n/g,"")[H](/\n/g,"<br>"))])}#s(e){return we("label",[we("span.material-symbols-outlined","Number"===e.type?"123":"Boolean"===e.type?"toggle_on":"Array"===e.type?"data_array":"Object"===e.type?"data_object":"Abc"),Oe({[k]:we("select.type-select",ye.map((t=>we("option",{value:t,selected:t===e.type?"":null},t)))),onchange:n=>{if(e.type=n.target[G],"Object"===n.target[G]||"Array"===n.target[G])e[G]="",0===e[q].length&&e.add();else if("Number"===n.target[G]){const t=parseFloat(e[G]);e[G]=isNaN(t)?"":t}else e[q]=[];this.#t(),t[W]("value-"+e.id).focus()}})])}#l(e){if("Number"===e.type){var t=/[^\d\-\.]/g;let n=parseFloat(e[G][H](t,"")[H](/\s/g,"")[H](/\n/g,"<br>"));return we("label",[Oe({[k]:we("textarea#value-"+e.id,{placeholder:"數字"},isNaN(n)?"":n),oninput:e=>{const n=e.target;n[G]=n[G][H](/\s/g,"")[H](t,""),n[X].innerHTML=n[G][H](/\n/g,"<br>")},onchange:n=>{const r=n.target;r[G]=r[G][H](/\s/g,"")[H](t,""),r[X].innerHTML=r[G][H](/\n/g,"<br>"),e[G]=r[G]}}),we("pre",isNaN(n)?"":n)])}return"Boolean"===e.type?Oe({[k]:we("select#value-"+e.id,[we("option",{value:"true",selected:e[G]?"":null},"true"),we("option",{value:"false",selected:e[G]?null:""},"false")]),onchange:t=>{e[G]=t.target[G]}}):we("label",{display:"Object"===e.type||"Array"===e.type?"none":"block"},[Oe({[k]:we("textarea#value-"+e.id,{placeholder:"字串"},e[G]),oninput:e=>{const t=e.target;t[X].innerHTML=t[G][H](/\n/g,"<br>")},onchange:t=>{const n=t.target;n[X].innerHTML=n[G][H](/\n/g,"<br>"),e[G]=n[G]}}),we("pre",e[G][H](/\n/g,"<br>"))])}#a(e){return Oe({[k]:we("button.delete-btn",[we("span.material-symbols-outlined","close")]),onclick:t=>{e.remove(),this.#t()}})}#c(e,t){if(("Object"===e.type||"Array"===e.type)&&!e.collapsed)return we("section.pd-json-editor-nested-child",[...e[q].map(((n,r)=>this.#r(n,r,t+1,"Array"===e.type))),Oe({[k]:we("button.add-btn",[we("span.material-symbols-outlined","add")]),onclick:t=>{e.add(),this.#t()}})])}#r(e,t,n=0,r=!1){return we("section.pd-json-editor-child",[we("div.pair-wrapper",[we("div#"+e.id+".input-group",[this.#o(e),this.#i(e,t,r),we("span",":"),this.#s(e),this.#l(e),this.#a(e)]),this.#c(e,n)])])}import(e){if(!e)return;const t=new FileReader;t.onload=e=>{try{const t=JSON.parse(e.target.result);this[q]=this.#d(t),this.#t()}catch(e){console.error(e),alert("JSON 格式錯誤,請檢查文件內容")}},t.readAsText(e)}#d(e,t=null){const n=[];if(console.log(e),Array.isArray(e))e.forEach(((e,r)=>{const o=this.#p(e),i=new Ne({type:o,parent:t??this});"Object"===o&&null!=e||"Array"===o?i[q]=this.#d(e,i):i[G]=String(e),n.push(i)}));else for(const[r,o]of Object.entries(e)){const e=this.#p(o),i=new Ne({key:r,type:e,parent:t??this});"Object"===e&&null!=o||"Array"===e?i[q]=this.#d(o,i):i[G]=null==o?"":String(o),n.push(i)}return n}#p(e){return Array.isArray(e)?"Array":"boolean"==typeof e?"Boolean":"number"==typeof e?"Number":"object"==typeof e?"Object":"String"}get json(){const e={};return this[q].forEach((t=>{t.key&&(console.log(t),e[t.key||0]=t.json)})),JSON.stringify(e,null,4)}export(){const e={};this[q].forEach((t=>{(t.key||1===this[q].length)&&(e[t.key||0]=t.json)}));const n=new Blob([JSON.stringify(e,null,4)],{type:"application/json"}),r=URL.createObjectURL(n),o=we("a",{href:r,download:`JSONEditor-${Date.now()}.json`});t[m][d](o),o.click(),t[m].removeChild(o),URL.revokeObjectURL(r)}};class Ne{key="";type="String";value="";parent=null;children=[];collapsed=!1;constructor(e={}){"object"==typeof e?(this.id=function(e=64){let t="";for(let n=0;n<e;n++)t+="abcdefghijklmnopqrstuvwxyz0123456789".charAt(i.floor(36*i.random()));return t}(),this.key=e.key??this.key,this.type=e.type??this.type,this.value=e.value??this.value,this[T]=e[T]??this[T],this[q]=e[q]??this[q],this.collapsed=e.collapsed??this.collapsed):console.error("Config Error: JSONEditor.Node")}add(){this.#h()}remove(){this.#u()}get json(){return this.#y()}#h(){this[q].push(new Ne({[T]:this}))}#u(){if(!this[T])return;const e=this[T][q][de](this);-1!==e&&this[T][q].splice(e,1)}#y(){if(!this[T])return;if(this[f]===V)return this[q][M]((e=>e.#y()));if("Object"===this[f]){const e={};for(let t of this[q])(t.key||this[T][f]===V)&&(e[t.key||n.keys(e)[B]]=t.#y());return e}let e=this[G];return"Boolean"===this[f]?e="true"===e.toLowerCase():"Number"===this[f]&&(e=r(e)),e}}}("undefined"==typeof window?window={}:window); |
{ | ||
"name": "@pardnchiu/nanojson", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "NanoJSON is a lightweight JSON editing library built on pure JavaScript and native APIs. Can be easily embedded into websites.", | ||
@@ -5,0 +5,0 @@ "main": "dist/NanoJSON.js", |
Sorry, the diff of this file is not supported yet
33413
56