art-format-json
Version:
2 lines • 8.6 kB
JavaScript
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["formatJson"]=t(require("vue")):e["formatJson"]=t(e["Vue"])})("undefined"!==typeof self?self:this,(function(e){return function(e){var t={};function o(c){if(t[c])return t[c].exports;var n=t[c]={i:c,l:!1,exports:{}};return e[c].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,c){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:c})},o.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var c=Object.create(null);if(o.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(c,n,function(t){return e[t]}.bind(null,n));return c},o.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s="fb15")}({"3a74":function(e,t,o){},6563:function(e,t,o){"use strict";o("3a74")},"6b0d":function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=(e,t)=>{const o=e.__vccOpts||e;for(const[c,n]of t)o[c]=n;return o}},8875:function(e,t,o){var c,n,r;(function(o,a){n=[],c=a,r="function"===typeof c?c.apply(t,n):c,void 0===r||(e.exports=r)})("undefined"!==typeof self&&self,(function(){function e(){var t=Object.getOwnPropertyDescriptor(document,"currentScript");if(!t&&"currentScript"in document&&document.currentScript)return document.currentScript;if(t&&t.get!==e&&document.currentScript)return document.currentScript;try{throw new Error}catch(j){var o,c,n,r=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,a=/@([^@]*):(\d+):(\d+)\s*$/gi,l=r.exec(j.stack)||a.exec(j.stack),s=l&&l[1]||!1,i=l&&l[2]||!1,p=document.location.href.replace(document.location.hash,""),b=document.getElementsByTagName("script");s===p&&(o=document.documentElement.outerHTML,c=new RegExp("(?:[^\\n]+?\\n){0,"+(i-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),n=o.replace(c,"$1").trim());for(var u=0;u<b.length;u++){if("interactive"===b[u].readyState)return b[u];if(b[u].src===s)return b[u];if(s===p&&b[u].innerHTML&&b[u].innerHTML.trim()===n)return b[u]}return null}}return e}))},"8bbf":function(t,o){t.exports=e},fb15:function(e,t,o){"use strict";if(o.r(t),o.d(t,"FormatJson",(function(){return x})),"undefined"!==typeof window){var c=window.document.currentScript,n=o("8875");c=n(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:n});var r=c&&c.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);r&&(o.p=r[1])}var a=o("8bbf");const l={key:0},s={key:1,class:"v-object"},i=Object(a["createElementVNode"])("i",{class:"v-operator"},"[",-1),p={key:2,class:"v-object"},b=Object(a["createElementVNode"])("i",{class:"v-operator"},"{",-1),u={key:0,class:"v-key"},j={key:1,class:"v-operator"},d={key:0,class:"v-comma"},m={key:1,class:"v-comma"},O={key:6,class:"v-comma"},f={key:3,class:"v-object"},y=Object(a["createElementVNode"])("i",{class:"v-operator"},"]",-1),k={key:4,class:"v-object"},v=Object(a["createElementVNode"])("i",{class:"v-operator"},"}",-1);function g(e,t,o,c,n,r){const g=Object(a["resolveComponent"])("format-json",!0);return Object(a["openBlock"])(),Object(a["createElementBlock"])("div",{class:Object(a["normalizeClass"])("formatJson "+o.className)},[c.data?Object(a["createCommentVNode"])("",!0):(Object(a["openBlock"])(),Object(a["createElementBlock"])("div",l,"--")),"[object Array]"===Object.prototype.toString.call(c.data)?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",s,[c.data.length>0?(Object(a["openBlock"])(),Object(a["createElementBlock"])("i",{key:0,onClick:t[0]||(t[0]=t=>e.is_open=!e.is_open),class:Object(a["normalizeClass"])(e.is_open?"v-toggle v-open":"v-toggle")},null,2)):Object(a["createCommentVNode"])("",!0),i])):Object(a["createCommentVNode"])("",!0),"[object Object]"===Object.prototype.toString.call(c.data)?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",p,[Object.keys(c.data).length>0?(Object(a["openBlock"])(),Object(a["createElementBlock"])("i",{key:0,onClick:t[1]||(t[1]=t=>e.is_open=!e.is_open),class:Object(a["normalizeClass"])(e.is_open?"v-toggle v-open":"v-toggle")},null,2)):Object(a["createCommentVNode"])("",!0),b])):Object(a["createCommentVNode"])("",!0),(Object(a["openBlock"])(!0),Object(a["createElementBlock"])(a["Fragment"],null,Object(a["renderList"])(c.data,(t,n,r)=>Object(a["withDirectives"])((Object(a["openBlock"])(),Object(a["createElementBlock"])("div",{key:r,class:"v-pre"},["[object Array]"!==Object.prototype.toString.call(c.data)?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",u,'"'+Object(a["toDisplayString"])(n)+'"',1)):Object(a["createCommentVNode"])("",!0),"[object Array]"!==Object.prototype.toString.call(c.data)?(Object(a["openBlock"])(),Object(a["createElementBlock"])("i",j,":")):Object(a["createCommentVNode"])("",!0),t&&"object"===typeof t?(Object(a["openBlock"])(),Object(a["createBlock"])(g,{key:2,value:t,root:!1,open:o.open,parentIndex:r,className:"v-children"},{comma:Object(a["withCtx"])(e=>["[object Array]"===Object.prototype.toString.call(c.data)&&Object.keys(c.data).length-1>=n+1&&"object"===typeof t?(Object(a["openBlock"])(),Object(a["createElementBlock"])("i",d,",")):Object(a["createCommentVNode"])("",!0),"[object Object]"===Object.prototype.toString.call(c.data)&&Object.keys(c.data).length-1>e.slotIndex&&"object"===typeof t?(Object(a["openBlock"])(),Object(a["createElementBlock"])("i",m,",")):Object(a["createCommentVNode"])("",!0)]),_:2},1032,["value","open","parentIndex"])):"string"===typeof t?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",{key:3,class:Object(a["normalizeClass"])("v-all v-"+typeof t)},' "'+Object(a["toDisplayString"])(t)+'" ',3)):null==t||void 0==t?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",{key:4,class:Object(a["normalizeClass"])("v-all v-"+String(t))},Object(a["toDisplayString"])(String(t)),3)):(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",{key:5,class:Object(a["normalizeClass"])("v-all v-"+typeof t)},Object(a["toDisplayString"])(t),3)),Object.keys(c.data).length-1>(r||n)&&"object"!==(t&&typeof t)?(Object(a["openBlock"])(),Object(a["createElementBlock"])("i",O,",")):Object(a["createCommentVNode"])("",!0)])),[[a["vShow"],e.is_open]])),128)),"[object Array]"===Object.prototype.toString.call(c.data)?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",f,[!e.is_open&&c.data.length>0?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",{key:0,onClick:t[2]||(t[2]=t=>e.is_open=!e.is_open),class:"v-ellipsis"},"...")):Object(a["createCommentVNode"])("",!0),y,Object(a["renderSlot"])(e.$slots,"comma",{slotIndex:o.parentIndex})])):Object(a["createCommentVNode"])("",!0),"[object Object]"===Object.prototype.toString.call(c.data)?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",k,[!e.is_open&&Object.keys(c.data).length>0?(Object(a["openBlock"])(),Object(a["createElementBlock"])("span",{key:0,onClick:t[3]||(t[3]=t=>e.is_open=!e.is_open),class:"v-ellipsis"},"...")):Object(a["createCommentVNode"])("",!0),v,Object(a["renderSlot"])(e.$slots,"comma",{slotIndex:o.parentIndex})])):Object(a["createCommentVNode"])("",!0)],2)}var B={name:"formatJson",emits:["open"],props:{className:{type:String,default:""},value:{type:null,default:""},parentIndex:{type:Number,default:0},root:{type:Boolean,default:!0},open:{type:Boolean,default:!1}},setup(e,t){const{proxy:o}=Object(a["getCurrentInstance"])(),c=Object(a["reactive"])({is_open:e.open}),n=()=>{c.is_open=!c.is_open},r=Object(a["computed"])({get:()=>{let t=e.value;if(""==t||void 0==t||null==t)return t;if("string"!=typeof t)return console.log(t,typeof t,"object===format"),t;console.log(t,typeof t,"string===format");try{t=JSON.parse(t)}catch(o){console.log(o,"=============")}return t},set:e=>{o.$emit("update:modelValue",e)}});return{...Object(a["toRefs"])(c),data:r,isOpen:n}}},S=(o("6563"),o("6b0d")),E=o.n(S);const C=E()(B,[["render",g]]);var _=C;_.install=e=>e.component(_.name,_);var x=_;const N=[x],V=function(e,t={}){V.installed||(N.map(t=>{e.component(t.name,t)}),"undefined"!=typeof window&&window.Vue&&V(window.Vue))};var h={install:V,FormatJson:x};t["default"]=h}})}));
//# sourceMappingURL=formatJson.umd.min.js.map