jjsontree.js
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -26,66 +26,69 @@ var __getOwnPropNames = Object.getOwnPropertyNames; | ||
(e => { | ||
function t(e) { | ||
let t; | ||
(e => { | ||
function t(e) { | ||
let t = e.length >= 2 && e.length <= 7; | ||
if (t && e[0] === "#") { | ||
t = isNaN(+e.substring(1, e.length - 1)); | ||
} | ||
return t; | ||
} | ||
e.hexColor = t; | ||
function n(e) { | ||
return e.toString().toLowerCase().trim() === "true" || e.toString().toLowerCase().trim() === "false"; | ||
} | ||
e.boolean = n; | ||
function o(e) { | ||
return !isNaN(+new Date(e)); | ||
} | ||
e.date = o; | ||
})(t = e.String || (e.String = {})); | ||
function n(e) { | ||
return e !== null && e !== void 0 && e.toString() !== ""; | ||
} | ||
e.defined = t; | ||
function n(e) { | ||
return t(e) && typeof e === "object"; | ||
e.defined = n; | ||
function o(e) { | ||
return n(e) && typeof e === "object"; | ||
} | ||
e.definedObject = n; | ||
e.definedObject = o; | ||
function r(e) { | ||
return t(e) && typeof e === "boolean"; | ||
return n(e) && typeof e === "boolean"; | ||
} | ||
e.definedBoolean = r; | ||
function o(e) { | ||
return t(e) && typeof e === "string"; | ||
} | ||
e.definedString = o; | ||
function i(e) { | ||
return t(e) && typeof e === "function"; | ||
return n(e) && typeof e === "string"; | ||
} | ||
e.definedFunction = i; | ||
e.definedString = i; | ||
function l(e) { | ||
return t(e) && typeof e === "number"; | ||
return n(e) && typeof e === "function"; | ||
} | ||
e.definedNumber = l; | ||
e.definedFunction = l; | ||
function s(e) { | ||
return n(e) && typeof e === "number"; | ||
} | ||
e.definedNumber = s; | ||
function a(e) { | ||
return t(e) && typeof e === "bigint"; | ||
return n(e) && typeof e === "bigint"; | ||
} | ||
e.definedBigInt = a; | ||
function s(e) { | ||
return n(e) && e instanceof Array; | ||
} | ||
e.definedArray = s; | ||
function u(e) { | ||
return n(e) && e instanceof Date; | ||
return o(e) && e instanceof Array; | ||
} | ||
e.definedDate = u; | ||
e.definedArray = u; | ||
function c(e) { | ||
return t(e) && typeof e === "number" && e % 1 !== 0; | ||
return o(e) && e instanceof Date; | ||
} | ||
e.definedDecimal = c; | ||
e.definedDate = c; | ||
function d(e) { | ||
return t(e) && typeof e === "symbol"; | ||
return n(e) && typeof e === "number" && e % 1 !== 0; | ||
} | ||
e.definedSymbol = d; | ||
function f(e, t = 1) { | ||
return !s(e) || e.length < t; | ||
e.definedDecimal = d; | ||
function f(e) { | ||
return n(e) && typeof e === "symbol"; | ||
} | ||
e.invalidOptionArray = f; | ||
function g(e) { | ||
let t = e.length >= 2 && e.length <= 7; | ||
if (t && e[0] === "#") { | ||
t = isNaN(+e.substring(1, e.length - 1)); | ||
} | ||
return t; | ||
e.definedSymbol = f; | ||
function g(e, t = 1) { | ||
return !u(e) || e.length < t; | ||
} | ||
e.hexColor = g; | ||
function m(e) { | ||
return e.toString().toLowerCase().trim() === "true" || e.toString().toLowerCase().trim() === "false"; | ||
} | ||
e.stringValueBoolean = m; | ||
function p(e) { | ||
return !isNaN(+new Date(e)); | ||
} | ||
e.stringValueDate = p; | ||
e.invalidOptionArray = g; | ||
})(Is || (Is = {})); | ||
@@ -111,10 +114,10 @@ } | ||
e.getString = n; | ||
function r(e, t) { | ||
function o(e, t) { | ||
return Is.definedBoolean(e) ? e : t; | ||
} | ||
e.getBoolean = r; | ||
function o(e, t) { | ||
e.getBoolean = o; | ||
function r(e, t) { | ||
return Is.definedNumber(e) ? e : t; | ||
} | ||
e.getNumber = o; | ||
e.getNumber = r; | ||
function i(e, t) { | ||
@@ -128,14 +131,14 @@ return Is.definedFunction(e) ? e : t; | ||
e.getArray = l; | ||
function a(e, t) { | ||
function s(e, t) { | ||
return Is.definedObject(e) ? e : t; | ||
} | ||
e.getObject = a; | ||
function s(e, t) { | ||
e.getObject = s; | ||
function a(e, t) { | ||
let n = t; | ||
if (Is.definedString(e)) { | ||
const r = e.toString().split(" "); | ||
if (r.length === 0) { | ||
const o = e.toString().split(" "); | ||
if (o.length === 0) { | ||
e = t; | ||
} else { | ||
n = r; | ||
n = o; | ||
} | ||
@@ -147,7 +150,7 @@ } else { | ||
} | ||
e.getStringOrArray = s; | ||
e.getStringOrArray = a; | ||
function u(e, t) { | ||
var n; | ||
const r = new RegExp(`^-?\\d+(?:.\\d{0,${t || -1}})?`); | ||
return ((n = e.toString().match(r)) == null ? void 0 : n[0]) || ""; | ||
const o = new RegExp(`^-?\\d+(?:.\\d{0,${t || -1}})?`); | ||
return ((n = e.toString().match(o)) == null ? void 0 : n[0]) || ""; | ||
} | ||
@@ -158,7 +161,7 @@ e.getFixedDecimalPlacesValue = u; | ||
const n = e.toString().split("("); | ||
const r = n[0].split(" "); | ||
if (r.length === 2) { | ||
t = r[1]; | ||
const o = n[0].split(" "); | ||
if (o.length === 2) { | ||
t = o[1]; | ||
} else { | ||
t = r[0]; | ||
t = o[0]; | ||
} | ||
@@ -181,11 +184,11 @@ t += "()"; | ||
(e => { | ||
function t(e, t, n = "", r = null) { | ||
const o = t.toLowerCase(); | ||
const i = o === "text"; | ||
let l = i ? document.createTextNode("") : document.createElement(o); | ||
function t(e, t, n = "", o = null) { | ||
const r = t.toLowerCase(); | ||
const i = r === "text"; | ||
let l = i ? document.createTextNode("") : document.createElement(r); | ||
if (Is.defined(n)) { | ||
l.className = n; | ||
} | ||
if (Is.defined(r)) { | ||
e.insertBefore(l, r); | ||
if (Is.defined(o)) { | ||
e.insertBefore(l, o); | ||
} else { | ||
@@ -197,17 +200,17 @@ e.appendChild(l); | ||
e.create = t; | ||
function n(e, n, r, o, i = null) { | ||
const l = t(e, n, r, i); | ||
l.innerHTML = o; | ||
function n(e, n, o, r, i = null) { | ||
const l = t(e, n, o, i); | ||
l.innerHTML = r; | ||
return l; | ||
} | ||
e.createWithHTML = n; | ||
function r(e, t) { | ||
function o(e, t) { | ||
e.classList.add(t); | ||
} | ||
e.addClass = r; | ||
function o(e) { | ||
e.addClass = o; | ||
function r(e) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
} | ||
e.cancelBubble = o; | ||
e.cancelBubble = r; | ||
function i() { | ||
@@ -224,4 +227,4 @@ const e = document.documentElement; | ||
let n = e.pageX; | ||
let r = e.pageY; | ||
const o = i(); | ||
let o = e.pageY; | ||
const r = i(); | ||
t.style.display = "block"; | ||
@@ -233,15 +236,15 @@ if (n + t.offsetWidth > window.innerWidth) { | ||
} | ||
if (r + t.offsetHeight > window.innerHeight) { | ||
r -= t.offsetHeight; | ||
if (o + t.offsetHeight > window.innerHeight) { | ||
o -= t.offsetHeight; | ||
} else { | ||
r++; | ||
o++; | ||
} | ||
if (n < o.left) { | ||
if (n < r.left) { | ||
n = e.pageX + 1; | ||
} | ||
if (r < o.top) { | ||
r = e.pageY + 1; | ||
if (o < r.top) { | ||
o = e.pageY + 1; | ||
} | ||
t.style.left = `${n}px`; | ||
t.style.top = `${r}px`; | ||
t.style.top = `${o}px`; | ||
} | ||
@@ -274,8 +277,8 @@ e.showElementAtMousePosition = l; | ||
const n = e.toString(); | ||
let r = n; | ||
let o = n; | ||
if (n.length < t) { | ||
const e = t - n.length + 1; | ||
r = Array(e).join("0") + n; | ||
o = Array(e).join("0") + n; | ||
} | ||
return r; | ||
return o; | ||
} | ||
@@ -310,27 +313,29 @@ e.padNumber = n; | ||
e.getDayOrdinal = n; | ||
function r(e, r, o) { | ||
let i = o; | ||
const l = t(r); | ||
i = i.replace("{hh}", Str.padNumber(r.getHours(), 2)); | ||
i = i.replace("{h}", r.getHours().toString()); | ||
i = i.replace("{MM}", Str.padNumber(r.getMinutes(), 2)); | ||
i = i.replace("{M}", r.getMinutes().toString()); | ||
i = i.replace("{ss}", Str.padNumber(r.getSeconds(), 2)); | ||
i = i.replace("{s}", r.getSeconds().toString()); | ||
function o(e, o, r) { | ||
let i = r; | ||
const l = t(o); | ||
i = i.replace("{hh}", Str.padNumber(o.getHours(), 2)); | ||
i = i.replace("{h}", o.getHours().toString()); | ||
i = i.replace("{MM}", Str.padNumber(o.getMinutes(), 2)); | ||
i = i.replace("{M}", o.getMinutes().toString()); | ||
i = i.replace("{ss}", Str.padNumber(o.getSeconds(), 2)); | ||
i = i.replace("{s}", o.getSeconds().toString()); | ||
i = i.replace("{ff}", Str.padNumber(o.getMilliseconds(), 3)); | ||
i = i.replace("{f}", o.getMilliseconds().toString()); | ||
i = i.replace("{dddd}", e.text.dayNames[l]); | ||
i = i.replace("{ddd}", e.text.dayNamesAbbreviated[l]); | ||
i = i.replace("{dd}", Str.padNumber(r.getDate())); | ||
i = i.replace("{d}", r.getDate().toString()); | ||
i = i.replace("{o}", n(e, r.getDate())); | ||
i = i.replace("{mmmm}", e.text.monthNames[r.getMonth()]); | ||
i = i.replace("{mmm}", e.text.monthNamesAbbreviated[r.getMonth()]); | ||
i = i.replace("{mm}", Str.padNumber(r.getMonth() + 1)); | ||
i = i.replace("{m}", (r.getMonth() + 1).toString()); | ||
i = i.replace("{yyyy}", r.getFullYear().toString()); | ||
i = i.replace("{yyy}", r.getFullYear().toString().substring(1)); | ||
i = i.replace("{yy}", r.getFullYear().toString().substring(2)); | ||
i = i.replace("{y}", Number.parseInt(r.getFullYear().toString().substring(2)).toString()); | ||
i = i.replace("{dd}", Str.padNumber(o.getDate())); | ||
i = i.replace("{d}", o.getDate().toString()); | ||
i = i.replace("{o}", n(e, o.getDate())); | ||
i = i.replace("{mmmm}", e.text.monthNames[o.getMonth()]); | ||
i = i.replace("{mmm}", e.text.monthNamesAbbreviated[o.getMonth()]); | ||
i = i.replace("{mm}", Str.padNumber(o.getMonth() + 1)); | ||
i = i.replace("{m}", (o.getMonth() + 1).toString()); | ||
i = i.replace("{yyyy}", o.getFullYear().toString()); | ||
i = i.replace("{yyy}", o.getFullYear().toString().substring(1)); | ||
i = i.replace("{yy}", o.getFullYear().toString().substring(2)); | ||
i = i.replace("{y}", Number.parseInt(o.getFullYear().toString().substring(2)).toString()); | ||
return i; | ||
} | ||
e.getCustomFormattedDateText = r; | ||
e.getCustomFormattedDateText = o; | ||
})(DateTime || (DateTime = {})); | ||
@@ -361,11 +366,11 @@ } | ||
function n(t, n) { | ||
const r = e.Options.get(t); | ||
r._currentView = {}; | ||
r._currentView.element = n; | ||
r._currentView.dataArrayCurrentIndex = 0; | ||
r._currentView.titleBarButtons = null; | ||
return r; | ||
const o = e.Options.get(t); | ||
o._currentView = {}; | ||
o._currentView.element = n; | ||
o._currentView.dataArrayCurrentIndex = 0; | ||
o._currentView.titleBarButtons = null; | ||
return o; | ||
} | ||
t.getForNewInstance = n; | ||
function r(e) { | ||
function o(e) { | ||
let t = Default.getObject(e, {}); | ||
@@ -393,11 +398,13 @@ t.data = Default.getObject(t.data, null); | ||
t.showArrayIndexBrackets = Default.getBoolean(t.showArrayIndexBrackets, true); | ||
t = o(t); | ||
t.showOpeningClosingCurlyBraces = Default.getBoolean(t.showOpeningClosingCurlyBraces, false); | ||
t.showOpeningClosingSquaredBrackets = Default.getBoolean(t.showOpeningClosingSquaredBrackets, false); | ||
t = r(t); | ||
t = i(t); | ||
t = l(t); | ||
t = s(t); | ||
t = a(t); | ||
t = s(t); | ||
return t; | ||
} | ||
t.get = r; | ||
function o(e) { | ||
t.get = o; | ||
function r(e) { | ||
e.title = Default.getObject(e.title, {}); | ||
@@ -425,2 +432,3 @@ e.title.text = Default.getString(e.title.text, "JsonTree.js"); | ||
e.ignore.emptyObjects = Default.getBoolean(e.ignore.emptyObjects, true); | ||
e.ignore.undefinedValues = Default.getBoolean(e.ignore.undefinedValues, false); | ||
return e; | ||
@@ -433,3 +441,3 @@ } | ||
} | ||
function a(e) { | ||
function s(e) { | ||
e.parse = Default.getObject(e.parse, {}); | ||
@@ -441,3 +449,3 @@ e.parse.stringsToDates = Default.getBoolean(e.parse.stringsToDates, false); | ||
} | ||
function s(e) { | ||
function a(e) { | ||
e.events = Default.getObject(e.events, {}); | ||
@@ -462,2 +470,4 @@ e.events.onBeforeRender = Default.getFunction(e.events.onBeforeRender, null); | ||
e.events.onSymbolRender = Default.getFunction(e.events.onSymbolRender, null); | ||
e.events.onCopyJsonReplacer = Default.getFunction(e.events.onCopyJsonReplacer, null); | ||
e.events.onUndefinedRender = Default.getFunction(e.events.onUndefinedRender, null); | ||
return e; | ||
@@ -567,7 +577,7 @@ } | ||
let n = t ? window.addEventListener : window.removeEventListener; | ||
let r = t ? document.addEventListener : document.removeEventListener; | ||
let o = t ? document.addEventListener : document.removeEventListener; | ||
n("mousemove", (() => { | ||
i(e); | ||
})); | ||
r("scroll", (() => { | ||
o("scroll", (() => { | ||
i(e); | ||
@@ -577,11 +587,11 @@ })); | ||
e.assignToEvents = n; | ||
function r(e, t, n) { | ||
function o(e, t, n) { | ||
if (e !== null) { | ||
e.onmousemove = e => { | ||
o(e, t, n); | ||
r(e, t, n); | ||
}; | ||
} | ||
} | ||
e.add = r; | ||
function o(e, t, n) { | ||
e.add = o; | ||
function r(e, t, n) { | ||
DomElement.cancelBubble(e); | ||
@@ -595,3 +605,3 @@ i(t); | ||
} | ||
e.show = o; | ||
e.show = r; | ||
function i(e) { | ||
@@ -634,6 +644,6 @@ if (Is.defined(e._currentView.tooltip)) { | ||
const t = document.getElementsByTagName(e[n]); | ||
const r = [].slice.call(t); | ||
const o = r.length; | ||
for (let e = 0; e < o; e++) { | ||
if (!renderElement(r[e])) { | ||
const o = [].slice.call(t); | ||
const r = o.length; | ||
for (let e = 0; e < r; e++) { | ||
if (!renderElement(o[e])) { | ||
break; | ||
@@ -649,5 +659,5 @@ } | ||
if (Is.definedString(n)) { | ||
const r = getObjectFromString(n); | ||
if (r.parsed && Is.definedObject(r.object)) { | ||
renderControl(Binding.Options.getForNewInstance(r.object, e)); | ||
const o = getObjectFromString(n); | ||
if (o.parsed && Is.definedObject(o.object)) { | ||
renderControl(Binding.Options.getForNewInstance(o.object, e)); | ||
} else { | ||
@@ -716,6 +726,10 @@ if (!_configuration.safeMode) { | ||
let n = null; | ||
let o = jsonStringifyReplacer; | ||
if (Is.definedFunction(e.events.onCopyJsonReplacer)) { | ||
o = e.events.onCopyJsonReplacer; | ||
} | ||
if (e.copyOnlyCurrentPage && e.showArrayItemsAsSeparateObjects) { | ||
n = JSON.stringify(t[e._currentView.dataArrayCurrentIndex], jsonStringifyReplacer, e.copyIndentSpaces); | ||
n = JSON.stringify(t[e._currentView.dataArrayCurrentIndex], o, e.copyIndentSpaces); | ||
} else { | ||
n = JSON.stringify(t, jsonStringifyReplacer, e.copyIndentSpaces); | ||
n = JSON.stringify(t, o, e.copyIndentSpaces); | ||
} | ||
@@ -750,6 +764,6 @@ navigator.clipboard.writeText(n); | ||
} | ||
const r = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "next", _configuration.text.nextButtonSymbolText); | ||
ToolTip.add(r, e, _configuration.text.nextButtonText); | ||
const o = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "next", _configuration.text.nextButtonSymbolText); | ||
ToolTip.add(o, e, _configuration.text.nextButtonText); | ||
if (e._currentView.dataArrayCurrentIndex < t.length - 1) { | ||
r.onclick = () => { | ||
o.onclick = () => { | ||
e._currentView.dataArrayCurrentIndex++; | ||
@@ -760,3 +774,3 @@ renderControlContainer(e); | ||
} else { | ||
r.disabled = true; | ||
o.disabled = true; | ||
} | ||
@@ -790,81 +804,75 @@ } else { | ||
} | ||
function renderObject(e, t, n, r = false) { | ||
const o = DomElement.create(e, "div", "object-type-title"); | ||
const i = DomElement.create(e, "div", "object-type-contents"); | ||
const l = t.showArrowToggles ? DomElement.create(o, "div", "down-arrow") : null; | ||
const a = renderObjectValues(l, i, t, n); | ||
if (a === 0 && t.ignore.emptyObjects) { | ||
e.removeChild(o); | ||
e.removeChild(i); | ||
} else { | ||
const e = DomElement.createWithHTML(o, "span", t.showValueColors ? "object" : "", _configuration.text.objectText); | ||
if (r && t.showArrayItemsAsSeparateObjects) { | ||
let n = t.useZeroIndexingForArrays ? t._currentView.dataArrayCurrentIndex.toString() : (t._currentView.dataArrayCurrentIndex + 1).toString(); | ||
function renderObject(e, t, n, o = false) { | ||
const r = getObjectPropertyNames(n, t); | ||
const i = r.length; | ||
if (i !== 0 || !t.ignore.emptyObjects) { | ||
const l = DomElement.create(e, "div", "object-type-title"); | ||
const s = DomElement.create(e, "div", "object-type-contents"); | ||
const a = t.showArrowToggles ? DomElement.create(l, "div", "down-arrow") : null; | ||
const u = DomElement.createWithHTML(l, "span", t.showValueColors ? "object" : "", _configuration.text.objectText); | ||
let c = null; | ||
if (o && t.showArrayItemsAsSeparateObjects) { | ||
let e = t.useZeroIndexingForArrays ? t._currentView.dataArrayCurrentIndex.toString() : (t._currentView.dataArrayCurrentIndex + 1).toString(); | ||
if (t.showArrayIndexBrackets) { | ||
n = `[${n}]:`; | ||
e = `[${e}]:`; | ||
} | ||
DomElement.createWithHTML(o, "span", t.showValueColors ? "object data-array-index" : "data-array-index", n, e); | ||
DomElement.createWithHTML(l, "span", t.showValueColors ? "object data-array-index" : "data-array-index", e, u); | ||
} | ||
if (t.showCounts && a > 0) { | ||
DomElement.createWithHTML(o, "span", t.showValueColors ? "object count" : "count", `{${a}}`); | ||
if (t.showCounts && i > 0) { | ||
DomElement.createWithHTML(l, "span", t.showValueColors ? "object count" : "count", `{${i}}`); | ||
} | ||
if (t.showOpeningClosingCurlyBraces) { | ||
c = DomElement.createWithHTML(l, "span", "opening-symbol", "{"); | ||
} | ||
renderObjectValues(a, null, s, t, n, r, c, false, true); | ||
} | ||
} | ||
function renderArray(e, t, n) { | ||
const r = DomElement.create(e, "div", "object-type-title"); | ||
const o = DomElement.create(e, "div", "object-type-contents"); | ||
const i = t.showArrowToggles ? DomElement.create(r, "div", "down-arrow") : null; | ||
DomElement.createWithHTML(r, "span", t.showValueColors ? "array" : "", _configuration.text.arrayText); | ||
renderArrayValues(i, o, t, n); | ||
const o = DomElement.create(e, "div", "object-type-title"); | ||
const r = DomElement.create(e, "div", "object-type-contents"); | ||
const i = t.showArrowToggles ? DomElement.create(o, "div", "down-arrow") : null; | ||
let l = null; | ||
DomElement.createWithHTML(o, "span", t.showValueColors ? "array" : "", _configuration.text.arrayText); | ||
if (t.showCounts) { | ||
DomElement.createWithHTML(r, "span", t.showValueColors ? "array count" : "count", `[${n.length}]`); | ||
DomElement.createWithHTML(o, "span", t.showValueColors ? "array count" : "count", `[${n.length}]`); | ||
} | ||
if (t.showOpeningClosingCurlyBraces) { | ||
l = DomElement.createWithHTML(o, "span", "opening-symbol", "["); | ||
} | ||
renderArrayValues(i, null, r, t, n, l, false, true); | ||
} | ||
function renderObjectValues(e, t, n, r) { | ||
let o = 0; | ||
let i = []; | ||
for (let e in r) { | ||
if (r.hasOwnProperty(e)) { | ||
i.push(e); | ||
function renderObjectValues(e, t, n, o, r, i, l, s, a) { | ||
const u = i.length; | ||
for (let e = 0; e < u; e++) { | ||
const t = i[e]; | ||
if (r.hasOwnProperty(t)) { | ||
renderValue(n, o, t, r[t], e === u - 1); | ||
} | ||
} | ||
if (n.sortPropertyNames) { | ||
let e = new Intl.Collator(void 0, { | ||
numeric: true, | ||
sensitivity: "base" | ||
}); | ||
i = i.sort(e.compare); | ||
if (!n.sortPropertyNamesInAlphabeticalOrder) { | ||
i = i.reverse(); | ||
} | ||
if (o.showOpeningClosingCurlyBraces) { | ||
createClosingSymbol(o, n, "}", s, a); | ||
} | ||
const l = i.length; | ||
for (let e = 0; e < l; e++) { | ||
const a = i[e]; | ||
if (r.hasOwnProperty(a)) { | ||
renderValue(t, n, a, r[a], e === l - 1); | ||
o++; | ||
} | ||
} | ||
addArrowEvent(n, e, t); | ||
return o; | ||
addArrowEvent(o, e, t, n, l); | ||
} | ||
function renderArrayValues(e, t, n, r) { | ||
const o = r.length; | ||
if (!n.reverseArrayValues) { | ||
for (let e = 0; e < o; e++) { | ||
renderValue(t, n, getIndexName(n, e, o), r[e], e === o - 1); | ||
function renderArrayValues(e, t, n, o, r, i, l, s) { | ||
const a = r.length; | ||
if (!o.reverseArrayValues) { | ||
for (let e = 0; e < a; e++) { | ||
renderValue(n, o, getIndexName(o, e, a), r[e], e === a - 1); | ||
} | ||
} else { | ||
for (let e = o; e--; ) { | ||
renderValue(t, n, getIndexName(n, e, o), r[e], e === 0); | ||
for (let e = a; e--; ) { | ||
renderValue(n, o, getIndexName(o, e, a), r[e], e === 0); | ||
} | ||
} | ||
addArrowEvent(n, e, t); | ||
if (o.showOpeningClosingCurlyBraces) { | ||
createClosingSymbol(o, n, "]", l, s); | ||
} | ||
addArrowEvent(o, e, t, n, i); | ||
} | ||
function renderValue(e, t, n, r, o) { | ||
function renderValue(e, t, n, o, r) { | ||
const i = DomElement.create(e, "div", "object-type-value"); | ||
const l = t.showArrowToggles ? DomElement.create(i, "div", "no-arrow") : null; | ||
let s = null; | ||
let a = null; | ||
let s = null; | ||
let u = false; | ||
@@ -874,106 +882,118 @@ let c = null; | ||
DomElement.createWithHTML(i, "span", "split", ":"); | ||
if (!Is.defined(r)) { | ||
if (o === null) { | ||
if (!t.ignore.nullValues) { | ||
a = t.showValueColors ? "null" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, "null"); | ||
s = t.showValueColors ? "null" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, "null"); | ||
c = "null"; | ||
if (Is.definedFunction(t.events.onNullRender)) { | ||
Trigger.customEvent(t.events.onNullRender, s); | ||
Trigger.customEvent(t.events.onNullRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedFunction(r)) { | ||
} else if (o === void 0) { | ||
if (!t.ignore.undefinedValues) { | ||
s = t.showValueColors ? "undefined" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, "undefined"); | ||
c = "undefined"; | ||
if (Is.definedFunction(t.events.onUndefinedRender)) { | ||
Trigger.customEvent(t.events.onUndefinedRender, a); | ||
} | ||
createComma(t, i, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedFunction(o)) { | ||
if (!t.ignore.functionValues) { | ||
a = t.showValueColors ? "function" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, Default.getFunctionName(r)); | ||
s = t.showValueColors ? "function" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, Default.getFunctionName(o)); | ||
c = "function"; | ||
if (Is.definedFunction(t.events.onFunctionRender)) { | ||
Trigger.customEvent(t.events.onFunctionRender, s); | ||
Trigger.customEvent(t.events.onFunctionRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedBoolean(r)) { | ||
} else if (Is.definedBoolean(o)) { | ||
if (!t.ignore.booleanValues) { | ||
a = t.showValueColors ? "boolean" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, r); | ||
s = t.showValueColors ? "boolean" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, o); | ||
c = "boolean"; | ||
if (Is.definedFunction(t.events.onBooleanRender)) { | ||
Trigger.customEvent(t.events.onBooleanRender, s); | ||
Trigger.customEvent(t.events.onBooleanRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedDecimal(r)) { | ||
} else if (Is.definedDecimal(o)) { | ||
if (!t.ignore.decimalValues) { | ||
const e = Default.getFixedDecimalPlacesValue(r, t.maximumDecimalPlaces); | ||
a = t.showValueColors ? "decimal" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, e); | ||
const e = Default.getFixedDecimalPlacesValue(o, t.maximumDecimalPlaces); | ||
s = t.showValueColors ? "decimal" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, e); | ||
c = "decimal"; | ||
if (Is.definedFunction(t.events.onDecimalRender)) { | ||
Trigger.customEvent(t.events.onDecimalRender, s); | ||
Trigger.customEvent(t.events.onDecimalRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedNumber(r)) { | ||
} else if (Is.definedNumber(o)) { | ||
if (!t.ignore.numberValues) { | ||
a = t.showValueColors ? "number" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, r); | ||
s = t.showValueColors ? "number" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, o); | ||
c = "number"; | ||
if (Is.definedFunction(t.events.onNumberRender)) { | ||
Trigger.customEvent(t.events.onNumberRender, s); | ||
Trigger.customEvent(t.events.onNumberRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedBigInt(r)) { | ||
} else if (Is.definedBigInt(o)) { | ||
if (!t.ignore.bigIntValues) { | ||
a = t.showValueColors ? "bigint" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, r); | ||
s = t.showValueColors ? "bigint" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, o); | ||
c = "bigint"; | ||
if (Is.definedFunction(t.events.onBigIntRender)) { | ||
Trigger.customEvent(t.events.onBigIntRender, s); | ||
Trigger.customEvent(t.events.onBigIntRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedString(r)) { | ||
} else if (Is.definedString(o)) { | ||
if (!t.ignore.stringValues) { | ||
if (t.parse.stringsToBooleans && Is.stringValueBoolean(r)) { | ||
renderValue(e, t, n, r.toString().toLowerCase().trim() === "true", o); | ||
if (t.parse.stringsToBooleans && Is.String.boolean(o)) { | ||
renderValue(e, t, n, o.toString().toLowerCase().trim() === "true", r); | ||
u = true; | ||
} else if (t.parse.stringsToNumbers && !isNaN(r)) { | ||
renderValue(e, t, n, parseFloat(r), o); | ||
} else if (t.parse.stringsToNumbers && !isNaN(o)) { | ||
renderValue(e, t, n, parseFloat(o), r); | ||
u = true; | ||
} else if (t.parse.stringsToDates && Is.stringValueDate(r)) { | ||
renderValue(e, t, n, new Date(r), o); | ||
} else if (t.parse.stringsToDates && Is.String.date(o)) { | ||
renderValue(e, t, n, new Date(o), r); | ||
u = true; | ||
} else { | ||
let e = null; | ||
if (t.showValueColors && t.showStringHexColors && Is.hexColor(r)) { | ||
e = r; | ||
if (t.showValueColors && t.showStringHexColors && Is.String.hexColor(o)) { | ||
e = o; | ||
} else { | ||
if (t.maximumStringLength > 0 && r.length > t.maximumStringLength) { | ||
r = r.substring(0, t.maximumStringLength) + _configuration.text.ellipsisText; | ||
if (t.maximumStringLength > 0 && o.length > t.maximumStringLength) { | ||
o = o.substring(0, t.maximumStringLength) + _configuration.text.ellipsisText; | ||
} | ||
} | ||
const n = t.showStringQuotes ? `"${r}"` : r; | ||
a = t.showValueColors ? "string" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, n); | ||
const n = t.showStringQuotes ? `"${o}"` : o; | ||
s = t.showValueColors ? "string" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, n); | ||
c = "string"; | ||
if (Is.definedString(e)) { | ||
s.style.color = e; | ||
a.style.color = e; | ||
} | ||
if (Is.definedFunction(t.events.onStringRender)) { | ||
Trigger.customEvent(t.events.onStringRender, s); | ||
Trigger.customEvent(t.events.onStringRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} | ||
@@ -983,39 +1003,45 @@ } else { | ||
} | ||
} else if (Is.definedDate(r)) { | ||
} else if (Is.definedDate(o)) { | ||
if (!t.ignore.dateValues) { | ||
a = t.showValueColors ? "date" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, DateTime.getCustomFormattedDateText(_configuration, r, t.dateTimeFormat)); | ||
s = t.showValueColors ? "date" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, DateTime.getCustomFormattedDateText(_configuration, o, t.dateTimeFormat)); | ||
c = "date"; | ||
if (Is.definedFunction(t.events.onDateRender)) { | ||
Trigger.customEvent(t.events.onDateRender, s); | ||
Trigger.customEvent(t.events.onDateRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedSymbol(r)) { | ||
} else if (Is.definedSymbol(o)) { | ||
if (!t.ignore.symbolValues) { | ||
a = t.showValueColors ? "symbol" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, r.toString()); | ||
s = t.showValueColors ? "symbol" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, o.toString()); | ||
c = "symbol"; | ||
if (Is.definedFunction(t.events.onSymbolRender)) { | ||
Trigger.customEvent(t.events.onSymbolRender, s); | ||
Trigger.customEvent(t.events.onSymbolRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedObject(r) && !Is.definedArray(r)) { | ||
} else if (Is.definedObject(o) && !Is.definedArray(o)) { | ||
if (!t.ignore.objectValues) { | ||
const e = DomElement.create(i, "span", t.showValueColors ? "object" : ""); | ||
const n = DomElement.create(i, "div", "object-type-contents"); | ||
const a = renderObjectValues(l, n, t, r); | ||
if (a === 0 && t.ignore.emptyObjects) { | ||
const e = getObjectPropertyNames(o, t); | ||
const n = e.length; | ||
if (n === 0 && t.ignore.emptyObjects) { | ||
u = true; | ||
} else { | ||
DomElement.createWithHTML(e, "span", "title", _configuration.text.objectText); | ||
if (t.showCounts && a > 0) { | ||
DomElement.createWithHTML(e, "span", "count", `{${a}}`); | ||
const s = DomElement.create(i, "span", t.showValueColors ? "object" : ""); | ||
const a = DomElement.create(i, "div", "object-type-contents"); | ||
let u = null; | ||
DomElement.createWithHTML(s, "span", "title", _configuration.text.objectText); | ||
if (t.showCounts && n > 0) { | ||
DomElement.createWithHTML(s, "span", "count", `{${n}}`); | ||
} | ||
createComma(t, e, o); | ||
if (t.showOpeningClosingCurlyBraces) { | ||
u = DomElement.createWithHTML(s, "span", "opening-symbol", "{"); | ||
} | ||
let d = createComma(t, s, r); | ||
renderObjectValues(l, d, a, t, o, e, u, true, r); | ||
c = "object"; | ||
@@ -1026,12 +1052,16 @@ } | ||
} | ||
} else if (Is.definedArray(r)) { | ||
} else if (Is.definedArray(o)) { | ||
if (!t.ignore.arrayValues) { | ||
const e = DomElement.create(i, "span", t.showValueColors ? "array" : ""); | ||
const n = DomElement.create(i, "div", "object-type-contents"); | ||
let s = null; | ||
DomElement.createWithHTML(e, "span", "title", _configuration.text.arrayText); | ||
if (t.showCounts) { | ||
DomElement.createWithHTML(e, "span", "count", `[${r.length}]`); | ||
DomElement.createWithHTML(e, "span", "count", `[${o.length}]`); | ||
} | ||
createComma(t, e, o); | ||
renderArrayValues(l, n, t, r); | ||
if (t.showOpeningClosingCurlyBraces) { | ||
s = DomElement.createWithHTML(e, "span", "opening-symbol", "["); | ||
} | ||
let a = createComma(t, e, r); | ||
renderArrayValues(l, a, n, t, o, s, true, r); | ||
c = "array"; | ||
@@ -1043,9 +1073,9 @@ } else { | ||
if (!t.ignore.unknownValues) { | ||
a = t.showValueColors ? "unknown" : ""; | ||
s = DomElement.createWithHTML(i, "span", a, r.toString()); | ||
s = t.showValueColors ? "unknown" : ""; | ||
a = DomElement.createWithHTML(i, "span", s, o.toString()); | ||
c = "unknown"; | ||
if (Is.definedFunction(t.events.onUnknownRender)) { | ||
Trigger.customEvent(t.events.onUnknownRender, s); | ||
Trigger.customEvent(t.events.onUnknownRender, a); | ||
} | ||
createComma(t, i, o); | ||
createComma(t, i, r); | ||
} else { | ||
@@ -1058,11 +1088,11 @@ u = true; | ||
} else { | ||
if (Is.defined(s)) { | ||
addValueClickEvent(t, s, r, c); | ||
if (Is.defined(a)) { | ||
addValueClickEvent(t, a, o, c); | ||
} | ||
} | ||
} | ||
function addValueClickEvent(e, t, n, r) { | ||
function addValueClickEvent(e, t, n, o) { | ||
if (Is.definedFunction(e.events.onValueClick)) { | ||
t.onclick = () => { | ||
Trigger.customEvent(e.events.onValueClick, n, r); | ||
Trigger.customEvent(e.events.onValueClick, n, o); | ||
}; | ||
@@ -1073,18 +1103,35 @@ } else { | ||
} | ||
function addArrowEvent(e, t, n) { | ||
function addArrowEvent(e, t, n, o, r) { | ||
if (Is.defined(t)) { | ||
const i = () => { | ||
o.style.display = "none"; | ||
t.className = "right-arrow"; | ||
if (Is.defined(r)) { | ||
r.style.display = "none"; | ||
} | ||
if (Is.defined(n)) { | ||
n.style.display = "inline-block"; | ||
} | ||
}; | ||
const l = () => { | ||
o.style.display = "block"; | ||
t.className = "down-arrow"; | ||
if (Is.defined(r)) { | ||
r.style.display = "inline-block"; | ||
} | ||
if (Is.defined(n)) { | ||
n.style.display = "none"; | ||
} | ||
}; | ||
t.onclick = () => { | ||
if (t.className === "down-arrow") { | ||
n.style.display = "none"; | ||
t.className = "right-arrow"; | ||
i(); | ||
} else { | ||
n.style.display = "block"; | ||
t.className = "down-arrow"; | ||
l(); | ||
} | ||
}; | ||
if (e.showAllAsClosed) { | ||
n.style.display = "none"; | ||
t.className = "right-arrow"; | ||
i(); | ||
} else { | ||
t.className = "down-arrow"; | ||
l(); | ||
} | ||
@@ -1094,16 +1141,45 @@ } | ||
function createComma(e, t, n) { | ||
let o = null; | ||
if (e.showCommas && !n) { | ||
DomElement.createWithHTML(t, "span", "comma", ","); | ||
o = DomElement.createWithHTML(t, "span", "comma", ","); | ||
} | ||
return o; | ||
} | ||
function getIndexName(e, t, n) { | ||
let r = e.useZeroIndexingForArrays ? t.toString() : (t + 1).toString(); | ||
let o = e.useZeroIndexingForArrays ? t.toString() : (t + 1).toString(); | ||
if (!e.addArrayIndexPadding) { | ||
r = Str.padNumber(parseInt(r), n.toString().length); | ||
o = Str.padNumber(parseInt(o), n.toString().length); | ||
} | ||
if (e.showArrayIndexBrackets) { | ||
r = `[${r}]`; | ||
o = `[${o}]`; | ||
} | ||
return r; | ||
return o; | ||
} | ||
function getObjectPropertyNames(e, t) { | ||
let n = []; | ||
for (let t in e) { | ||
if (e.hasOwnProperty(t)) { | ||
n.push(t); | ||
} | ||
} | ||
if (t.sortPropertyNames) { | ||
let e = new Intl.Collator(void 0, { | ||
numeric: true, | ||
sensitivity: "base" | ||
}); | ||
n = n.sort(e.compare); | ||
if (!t.sortPropertyNamesInAlphabeticalOrder) { | ||
n = n.reverse(); | ||
} | ||
} | ||
return n; | ||
} | ||
function createClosingSymbol(e, t, n, o, r) { | ||
let i = DomElement.create(t, "div", "closing-symbol"); | ||
if (o) { | ||
DomElement.create(i, "div", "no-arrow"); | ||
} | ||
DomElement.createWithHTML(i, "div", "object-type-end", n); | ||
createComma(e, i, r); | ||
} | ||
function makeAreaDroppable(e, t) { | ||
@@ -1124,6 +1200,6 @@ if (t.fileDroppingEnabled) { | ||
const n = e.length; | ||
for (let r = 0; r < n; r++) { | ||
const n = e[r]; | ||
const o = n.name.split(".").pop().toLowerCase(); | ||
if (o === "json") { | ||
for (let o = 0; o < n; o++) { | ||
const n = e[o]; | ||
const r = n.name.split(".").pop().toLowerCase(); | ||
if (r === "json") { | ||
importFromJson(n, t); | ||
@@ -1135,6 +1211,6 @@ } | ||
const n = new FileReader; | ||
let r = null; | ||
let o = null; | ||
n.onloadend = () => { | ||
t._currentView.dataArrayCurrentIndex = 0; | ||
t.data = r; | ||
t.data = o; | ||
renderControlContainer(t); | ||
@@ -1146,3 +1222,3 @@ Trigger.customEvent(t.events.onSetJson, t._currentView.element); | ||
if (t.parsed && Is.definedObject(t.object)) { | ||
r = t.object; | ||
o = t.object; | ||
} | ||
@@ -1235,7 +1311,7 @@ }; | ||
} | ||
const r = _elements_Data[e]; | ||
r._currentView.dataArrayCurrentIndex = 0; | ||
r.data = n; | ||
renderControlContainer(r); | ||
Trigger.customEvent(r.events.onSetJson, r._currentView.element); | ||
const o = _elements_Data[e]; | ||
o._currentView.dataArrayCurrentIndex = 0; | ||
o.data = n; | ||
renderControlContainer(o); | ||
Trigger.customEvent(o.events.onSetJson, o._currentView.element); | ||
} | ||
@@ -1271,5 +1347,5 @@ return _public; | ||
const n = _configuration; | ||
for (let r in e) { | ||
if (e.hasOwnProperty(r) && _configuration.hasOwnProperty(r) && n[r] !== e[r]) { | ||
n[r] = e[r]; | ||
for (let o in e) { | ||
if (e.hasOwnProperty(o) && _configuration.hasOwnProperty(o) && n[o] !== e[o]) { | ||
n[o] = e[o]; | ||
t = true; | ||
@@ -1294,3 +1370,3 @@ } | ||
getVersion: function() { | ||
return "2.3.0"; | ||
return "2.4.0"; | ||
} | ||
@@ -1297,0 +1373,0 @@ }; |
@@ -6,66 +6,69 @@ "use strict"; | ||
(e => { | ||
function t(e) { | ||
let t; | ||
(e => { | ||
function t(e) { | ||
let t = e.length >= 2 && e.length <= 7; | ||
if (t && e[0] === "#") { | ||
t = isNaN(+e.substring(1, e.length - 1)); | ||
} | ||
return t; | ||
} | ||
e.hexColor = t; | ||
function n(e) { | ||
return e.toString().toLowerCase().trim() === "true" || e.toString().toLowerCase().trim() === "false"; | ||
} | ||
e.boolean = n; | ||
function o(e) { | ||
return !isNaN(+new Date(e)); | ||
} | ||
e.date = o; | ||
})(t = e.String || (e.String = {})); | ||
function n(e) { | ||
return e !== null && e !== void 0 && e.toString() !== ""; | ||
} | ||
e.defined = t; | ||
function n(e) { | ||
return t(e) && typeof e === "object"; | ||
e.defined = n; | ||
function o(e) { | ||
return n(e) && typeof e === "object"; | ||
} | ||
e.definedObject = n; | ||
e.definedObject = o; | ||
function r(e) { | ||
return t(e) && typeof e === "boolean"; | ||
return n(e) && typeof e === "boolean"; | ||
} | ||
e.definedBoolean = r; | ||
function o(e) { | ||
return t(e) && typeof e === "string"; | ||
} | ||
e.definedString = o; | ||
function l(e) { | ||
return t(e) && typeof e === "function"; | ||
return n(e) && typeof e === "string"; | ||
} | ||
e.definedFunction = l; | ||
e.definedString = l; | ||
function i(e) { | ||
return t(e) && typeof e === "number"; | ||
return n(e) && typeof e === "function"; | ||
} | ||
e.definedNumber = i; | ||
e.definedFunction = i; | ||
function a(e) { | ||
return t(e) && typeof e === "bigint"; | ||
return n(e) && typeof e === "number"; | ||
} | ||
e.definedBigInt = a; | ||
e.definedNumber = a; | ||
function s(e) { | ||
return n(e) && e instanceof Array; | ||
return n(e) && typeof e === "bigint"; | ||
} | ||
e.definedArray = s; | ||
e.definedBigInt = s; | ||
function u(e) { | ||
return n(e) && e instanceof Date; | ||
return o(e) && e instanceof Array; | ||
} | ||
e.definedDate = u; | ||
e.definedArray = u; | ||
function c(e) { | ||
return t(e) && typeof e === "number" && e % 1 !== 0; | ||
return o(e) && e instanceof Date; | ||
} | ||
e.definedDecimal = c; | ||
e.definedDate = c; | ||
function d(e) { | ||
return t(e) && typeof e === "symbol"; | ||
return n(e) && typeof e === "number" && e % 1 !== 0; | ||
} | ||
e.definedSymbol = d; | ||
function f(e, t = 1) { | ||
return !s(e) || e.length < t; | ||
e.definedDecimal = d; | ||
function f(e) { | ||
return n(e) && typeof e === "symbol"; | ||
} | ||
e.invalidOptionArray = f; | ||
function g(e) { | ||
let t = e.length >= 2 && e.length <= 7; | ||
if (t && e[0] === "#") { | ||
t = isNaN(+e.substring(1, e.length - 1)); | ||
} | ||
return t; | ||
e.definedSymbol = f; | ||
function g(e, t = 1) { | ||
return !u(e) || e.length < t; | ||
} | ||
e.hexColor = g; | ||
function m(e) { | ||
return e.toString().toLowerCase().trim() === "true" || e.toString().toLowerCase().trim() === "false"; | ||
} | ||
e.stringValueBoolean = m; | ||
function p(e) { | ||
return !isNaN(+new Date(e)); | ||
} | ||
e.stringValueDate = p; | ||
e.invalidOptionArray = g; | ||
})(Is || (Is = {})); | ||
@@ -84,10 +87,10 @@ | ||
e.getString = n; | ||
function r(e, t) { | ||
function o(e, t) { | ||
return Is.definedBoolean(e) ? e : t; | ||
} | ||
e.getBoolean = r; | ||
function o(e, t) { | ||
e.getBoolean = o; | ||
function r(e, t) { | ||
return Is.definedNumber(e) ? e : t; | ||
} | ||
e.getNumber = o; | ||
e.getNumber = r; | ||
function l(e, t) { | ||
@@ -108,7 +111,7 @@ return Is.definedFunction(e) ? e : t; | ||
if (Is.definedString(e)) { | ||
const r = e.toString().split(" "); | ||
if (r.length === 0) { | ||
const o = e.toString().split(" "); | ||
if (o.length === 0) { | ||
e = t; | ||
} else { | ||
n = r; | ||
n = o; | ||
} | ||
@@ -123,4 +126,4 @@ } else { | ||
var n; | ||
const r = new RegExp(`^-?\\d+(?:.\\d{0,${t || -1}})?`); | ||
return ((n = e.toString().match(r)) == null ? void 0 : n[0]) || ""; | ||
const o = new RegExp(`^-?\\d+(?:.\\d{0,${t || -1}})?`); | ||
return ((n = e.toString().match(o)) == null ? void 0 : n[0]) || ""; | ||
} | ||
@@ -131,7 +134,7 @@ e.getFixedDecimalPlacesValue = u; | ||
const n = e.toString().split("("); | ||
const r = n[0].split(" "); | ||
if (r.length === 2) { | ||
t = r[1]; | ||
const o = n[0].split(" "); | ||
if (o.length === 2) { | ||
t = o[1]; | ||
} else { | ||
t = r[0]; | ||
t = o[0]; | ||
} | ||
@@ -147,11 +150,11 @@ t += "()"; | ||
(e => { | ||
function t(e, t, n = "", r = null) { | ||
const o = t.toLowerCase(); | ||
const l = o === "text"; | ||
let i = l ? document.createTextNode("") : document.createElement(o); | ||
function t(e, t, n = "", o = null) { | ||
const r = t.toLowerCase(); | ||
const l = r === "text"; | ||
let i = l ? document.createTextNode("") : document.createElement(r); | ||
if (Is.defined(n)) { | ||
i.className = n; | ||
} | ||
if (Is.defined(r)) { | ||
e.insertBefore(i, r); | ||
if (Is.defined(o)) { | ||
e.insertBefore(i, o); | ||
} else { | ||
@@ -163,17 +166,17 @@ e.appendChild(i); | ||
e.create = t; | ||
function n(e, n, r, o, l = null) { | ||
const i = t(e, n, r, l); | ||
i.innerHTML = o; | ||
function n(e, n, o, r, l = null) { | ||
const i = t(e, n, o, l); | ||
i.innerHTML = r; | ||
return i; | ||
} | ||
e.createWithHTML = n; | ||
function r(e, t) { | ||
function o(e, t) { | ||
e.classList.add(t); | ||
} | ||
e.addClass = r; | ||
function o(e) { | ||
e.addClass = o; | ||
function r(e) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
} | ||
e.cancelBubble = o; | ||
e.cancelBubble = r; | ||
function l() { | ||
@@ -190,4 +193,4 @@ const e = document.documentElement; | ||
let n = e.pageX; | ||
let r = e.pageY; | ||
const o = l(); | ||
let o = e.pageY; | ||
const r = l(); | ||
t.style.display = "block"; | ||
@@ -199,15 +202,15 @@ if (n + t.offsetWidth > window.innerWidth) { | ||
} | ||
if (r + t.offsetHeight > window.innerHeight) { | ||
r -= t.offsetHeight; | ||
if (o + t.offsetHeight > window.innerHeight) { | ||
o -= t.offsetHeight; | ||
} else { | ||
r++; | ||
o++; | ||
} | ||
if (n < o.left) { | ||
if (n < r.left) { | ||
n = e.pageX + 1; | ||
} | ||
if (r < o.top) { | ||
r = e.pageY + 1; | ||
if (o < r.top) { | ||
o = e.pageY + 1; | ||
} | ||
t.style.left = `${n}px`; | ||
t.style.top = `${r}px`; | ||
t.style.top = `${o}px`; | ||
} | ||
@@ -234,8 +237,8 @@ e.showElementAtMousePosition = i; | ||
const n = e.toString(); | ||
let r = n; | ||
let o = n; | ||
if (n.length < t) { | ||
const e = t - n.length + 1; | ||
r = Array(e).join("0") + n; | ||
o = Array(e).join("0") + n; | ||
} | ||
return r; | ||
return o; | ||
} | ||
@@ -264,27 +267,29 @@ e.padNumber = n; | ||
e.getDayOrdinal = n; | ||
function r(e, r, o) { | ||
let l = o; | ||
const i = t(r); | ||
l = l.replace("{hh}", Str.padNumber(r.getHours(), 2)); | ||
l = l.replace("{h}", r.getHours().toString()); | ||
l = l.replace("{MM}", Str.padNumber(r.getMinutes(), 2)); | ||
l = l.replace("{M}", r.getMinutes().toString()); | ||
l = l.replace("{ss}", Str.padNumber(r.getSeconds(), 2)); | ||
l = l.replace("{s}", r.getSeconds().toString()); | ||
function o(e, o, r) { | ||
let l = r; | ||
const i = t(o); | ||
l = l.replace("{hh}", Str.padNumber(o.getHours(), 2)); | ||
l = l.replace("{h}", o.getHours().toString()); | ||
l = l.replace("{MM}", Str.padNumber(o.getMinutes(), 2)); | ||
l = l.replace("{M}", o.getMinutes().toString()); | ||
l = l.replace("{ss}", Str.padNumber(o.getSeconds(), 2)); | ||
l = l.replace("{s}", o.getSeconds().toString()); | ||
l = l.replace("{ff}", Str.padNumber(o.getMilliseconds(), 3)); | ||
l = l.replace("{f}", o.getMilliseconds().toString()); | ||
l = l.replace("{dddd}", e.text.dayNames[i]); | ||
l = l.replace("{ddd}", e.text.dayNamesAbbreviated[i]); | ||
l = l.replace("{dd}", Str.padNumber(r.getDate())); | ||
l = l.replace("{d}", r.getDate().toString()); | ||
l = l.replace("{o}", n(e, r.getDate())); | ||
l = l.replace("{mmmm}", e.text.monthNames[r.getMonth()]); | ||
l = l.replace("{mmm}", e.text.monthNamesAbbreviated[r.getMonth()]); | ||
l = l.replace("{mm}", Str.padNumber(r.getMonth() + 1)); | ||
l = l.replace("{m}", (r.getMonth() + 1).toString()); | ||
l = l.replace("{yyyy}", r.getFullYear().toString()); | ||
l = l.replace("{yyy}", r.getFullYear().toString().substring(1)); | ||
l = l.replace("{yy}", r.getFullYear().toString().substring(2)); | ||
l = l.replace("{y}", Number.parseInt(r.getFullYear().toString().substring(2)).toString()); | ||
l = l.replace("{dd}", Str.padNumber(o.getDate())); | ||
l = l.replace("{d}", o.getDate().toString()); | ||
l = l.replace("{o}", n(e, o.getDate())); | ||
l = l.replace("{mmmm}", e.text.monthNames[o.getMonth()]); | ||
l = l.replace("{mmm}", e.text.monthNamesAbbreviated[o.getMonth()]); | ||
l = l.replace("{mm}", Str.padNumber(o.getMonth() + 1)); | ||
l = l.replace("{m}", (o.getMonth() + 1).toString()); | ||
l = l.replace("{yyyy}", o.getFullYear().toString()); | ||
l = l.replace("{yyy}", o.getFullYear().toString().substring(1)); | ||
l = l.replace("{yy}", o.getFullYear().toString().substring(2)); | ||
l = l.replace("{y}", Number.parseInt(o.getFullYear().toString().substring(2)).toString()); | ||
return l; | ||
} | ||
e.getCustomFormattedDateText = r; | ||
e.getCustomFormattedDateText = o; | ||
})(DateTime || (DateTime = {})); | ||
@@ -304,11 +309,11 @@ | ||
function n(t, n) { | ||
const r = e.Options.get(t); | ||
r._currentView = {}; | ||
r._currentView.element = n; | ||
r._currentView.dataArrayCurrentIndex = 0; | ||
r._currentView.titleBarButtons = null; | ||
return r; | ||
const o = e.Options.get(t); | ||
o._currentView = {}; | ||
o._currentView.element = n; | ||
o._currentView.dataArrayCurrentIndex = 0; | ||
o._currentView.titleBarButtons = null; | ||
return o; | ||
} | ||
t.getForNewInstance = n; | ||
function r(e) { | ||
function o(e) { | ||
let t = Default.getObject(e, {}); | ||
@@ -336,3 +341,5 @@ t.data = Default.getObject(t.data, null); | ||
t.showArrayIndexBrackets = Default.getBoolean(t.showArrayIndexBrackets, true); | ||
t = o(t); | ||
t.showOpeningClosingCurlyBraces = Default.getBoolean(t.showOpeningClosingCurlyBraces, false); | ||
t.showOpeningClosingSquaredBrackets = Default.getBoolean(t.showOpeningClosingSquaredBrackets, false); | ||
t = r(t); | ||
t = l(t); | ||
@@ -344,4 +351,4 @@ t = i(t); | ||
} | ||
t.get = r; | ||
function o(e) { | ||
t.get = o; | ||
function r(e) { | ||
e.title = Default.getObject(e.title, {}); | ||
@@ -369,2 +376,3 @@ e.title.text = Default.getString(e.title.text, "JsonTree.js"); | ||
e.ignore.emptyObjects = Default.getBoolean(e.ignore.emptyObjects, true); | ||
e.ignore.undefinedValues = Default.getBoolean(e.ignore.undefinedValues, false); | ||
return e; | ||
@@ -404,2 +412,4 @@ } | ||
e.events.onSymbolRender = Default.getFunction(e.events.onSymbolRender, null); | ||
e.events.onCopyJsonReplacer = Default.getFunction(e.events.onCopyJsonReplacer, null); | ||
e.events.onUndefinedRender = Default.getFunction(e.events.onUndefinedRender, null); | ||
return e; | ||
@@ -489,7 +499,7 @@ } | ||
let n = t ? window.addEventListener : window.removeEventListener; | ||
let r = t ? document.addEventListener : document.removeEventListener; | ||
let o = t ? document.addEventListener : document.removeEventListener; | ||
n("mousemove", (() => { | ||
l(e); | ||
})); | ||
r("scroll", (() => { | ||
o("scroll", (() => { | ||
l(e); | ||
@@ -499,11 +509,11 @@ })); | ||
e.assignToEvents = n; | ||
function r(e, t, n) { | ||
function o(e, t, n) { | ||
if (e !== null) { | ||
e.onmousemove = e => { | ||
o(e, t, n); | ||
r(e, t, n); | ||
}; | ||
} | ||
} | ||
e.add = r; | ||
function o(e, t, n) { | ||
e.add = o; | ||
function r(e, t, n) { | ||
DomElement.cancelBubble(e); | ||
@@ -517,3 +527,3 @@ l(t); | ||
} | ||
e.show = o; | ||
e.show = r; | ||
function l(e) { | ||
@@ -541,6 +551,6 @@ if (Is.defined(e._currentView.tooltip)) { | ||
const t = document.getElementsByTagName(e[n]); | ||
const r = [].slice.call(t); | ||
const o = r.length; | ||
for (let e = 0; e < o; e++) { | ||
if (!renderElement(r[e])) { | ||
const o = [].slice.call(t); | ||
const r = o.length; | ||
for (let e = 0; e < r; e++) { | ||
if (!renderElement(o[e])) { | ||
break; | ||
@@ -556,5 +566,5 @@ } | ||
if (Is.definedString(n)) { | ||
const r = getObjectFromString(n); | ||
if (r.parsed && Is.definedObject(r.object)) { | ||
renderControl(Binding.Options.getForNewInstance(r.object, e)); | ||
const o = getObjectFromString(n); | ||
if (o.parsed && Is.definedObject(o.object)) { | ||
renderControl(Binding.Options.getForNewInstance(o.object, e)); | ||
} else { | ||
@@ -623,6 +633,10 @@ if (!_configuration.safeMode) { | ||
let n = null; | ||
let o = jsonStringifyReplacer; | ||
if (Is.definedFunction(e.events.onCopyJsonReplacer)) { | ||
o = e.events.onCopyJsonReplacer; | ||
} | ||
if (e.copyOnlyCurrentPage && e.showArrayItemsAsSeparateObjects) { | ||
n = JSON.stringify(t[e._currentView.dataArrayCurrentIndex], jsonStringifyReplacer, e.copyIndentSpaces); | ||
n = JSON.stringify(t[e._currentView.dataArrayCurrentIndex], o, e.copyIndentSpaces); | ||
} else { | ||
n = JSON.stringify(t, jsonStringifyReplacer, e.copyIndentSpaces); | ||
n = JSON.stringify(t, o, e.copyIndentSpaces); | ||
} | ||
@@ -657,6 +671,6 @@ navigator.clipboard.writeText(n); | ||
} | ||
const r = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "next", _configuration.text.nextButtonSymbolText); | ||
ToolTip.add(r, e, _configuration.text.nextButtonText); | ||
const o = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "next", _configuration.text.nextButtonSymbolText); | ||
ToolTip.add(o, e, _configuration.text.nextButtonText); | ||
if (e._currentView.dataArrayCurrentIndex < t.length - 1) { | ||
r.onclick = () => { | ||
o.onclick = () => { | ||
e._currentView.dataArrayCurrentIndex++; | ||
@@ -667,3 +681,3 @@ renderControlContainer(e); | ||
} else { | ||
r.disabled = true; | ||
o.disabled = true; | ||
} | ||
@@ -697,77 +711,71 @@ } else { | ||
} | ||
function renderObject(e, t, n, r = false) { | ||
const o = DomElement.create(e, "div", "object-type-title"); | ||
const l = DomElement.create(e, "div", "object-type-contents"); | ||
const i = t.showArrowToggles ? DomElement.create(o, "div", "down-arrow") : null; | ||
const a = renderObjectValues(i, l, t, n); | ||
if (a === 0 && t.ignore.emptyObjects) { | ||
e.removeChild(o); | ||
e.removeChild(l); | ||
} else { | ||
const e = DomElement.createWithHTML(o, "span", t.showValueColors ? "object" : "", _configuration.text.objectText); | ||
if (r && t.showArrayItemsAsSeparateObjects) { | ||
let n = t.useZeroIndexingForArrays ? t._currentView.dataArrayCurrentIndex.toString() : (t._currentView.dataArrayCurrentIndex + 1).toString(); | ||
function renderObject(e, t, n, o = false) { | ||
const r = getObjectPropertyNames(n, t); | ||
const l = r.length; | ||
if (l !== 0 || !t.ignore.emptyObjects) { | ||
const i = DomElement.create(e, "div", "object-type-title"); | ||
const a = DomElement.create(e, "div", "object-type-contents"); | ||
const s = t.showArrowToggles ? DomElement.create(i, "div", "down-arrow") : null; | ||
const u = DomElement.createWithHTML(i, "span", t.showValueColors ? "object" : "", _configuration.text.objectText); | ||
let c = null; | ||
if (o && t.showArrayItemsAsSeparateObjects) { | ||
let e = t.useZeroIndexingForArrays ? t._currentView.dataArrayCurrentIndex.toString() : (t._currentView.dataArrayCurrentIndex + 1).toString(); | ||
if (t.showArrayIndexBrackets) { | ||
n = `[${n}]:`; | ||
e = `[${e}]:`; | ||
} | ||
DomElement.createWithHTML(o, "span", t.showValueColors ? "object data-array-index" : "data-array-index", n, e); | ||
DomElement.createWithHTML(i, "span", t.showValueColors ? "object data-array-index" : "data-array-index", e, u); | ||
} | ||
if (t.showCounts && a > 0) { | ||
DomElement.createWithHTML(o, "span", t.showValueColors ? "object count" : "count", `{${a}}`); | ||
if (t.showCounts && l > 0) { | ||
DomElement.createWithHTML(i, "span", t.showValueColors ? "object count" : "count", `{${l}}`); | ||
} | ||
if (t.showOpeningClosingCurlyBraces) { | ||
c = DomElement.createWithHTML(i, "span", "opening-symbol", "{"); | ||
} | ||
renderObjectValues(s, null, a, t, n, r, c, false, true); | ||
} | ||
} | ||
function renderArray(e, t, n) { | ||
const r = DomElement.create(e, "div", "object-type-title"); | ||
const o = DomElement.create(e, "div", "object-type-contents"); | ||
const l = t.showArrowToggles ? DomElement.create(r, "div", "down-arrow") : null; | ||
DomElement.createWithHTML(r, "span", t.showValueColors ? "array" : "", _configuration.text.arrayText); | ||
renderArrayValues(l, o, t, n); | ||
const o = DomElement.create(e, "div", "object-type-title"); | ||
const r = DomElement.create(e, "div", "object-type-contents"); | ||
const l = t.showArrowToggles ? DomElement.create(o, "div", "down-arrow") : null; | ||
let i = null; | ||
DomElement.createWithHTML(o, "span", t.showValueColors ? "array" : "", _configuration.text.arrayText); | ||
if (t.showCounts) { | ||
DomElement.createWithHTML(r, "span", t.showValueColors ? "array count" : "count", `[${n.length}]`); | ||
DomElement.createWithHTML(o, "span", t.showValueColors ? "array count" : "count", `[${n.length}]`); | ||
} | ||
if (t.showOpeningClosingCurlyBraces) { | ||
i = DomElement.createWithHTML(o, "span", "opening-symbol", "["); | ||
} | ||
renderArrayValues(l, null, r, t, n, i, false, true); | ||
} | ||
function renderObjectValues(e, t, n, r) { | ||
let o = 0; | ||
let l = []; | ||
for (let e in r) { | ||
if (r.hasOwnProperty(e)) { | ||
l.push(e); | ||
function renderObjectValues(e, t, n, o, r, l, i, a, s) { | ||
const u = l.length; | ||
for (let e = 0; e < u; e++) { | ||
const t = l[e]; | ||
if (r.hasOwnProperty(t)) { | ||
renderValue(n, o, t, r[t], e === u - 1); | ||
} | ||
} | ||
if (n.sortPropertyNames) { | ||
let e = new Intl.Collator(void 0, { | ||
numeric: true, | ||
sensitivity: "base" | ||
}); | ||
l = l.sort(e.compare); | ||
if (!n.sortPropertyNamesInAlphabeticalOrder) { | ||
l = l.reverse(); | ||
} | ||
if (o.showOpeningClosingCurlyBraces) { | ||
createClosingSymbol(o, n, "}", a, s); | ||
} | ||
const i = l.length; | ||
for (let e = 0; e < i; e++) { | ||
const a = l[e]; | ||
if (r.hasOwnProperty(a)) { | ||
renderValue(t, n, a, r[a], e === i - 1); | ||
o++; | ||
} | ||
} | ||
addArrowEvent(n, e, t); | ||
return o; | ||
addArrowEvent(o, e, t, n, i); | ||
} | ||
function renderArrayValues(e, t, n, r) { | ||
const o = r.length; | ||
if (!n.reverseArrayValues) { | ||
for (let e = 0; e < o; e++) { | ||
renderValue(t, n, getIndexName(n, e, o), r[e], e === o - 1); | ||
function renderArrayValues(e, t, n, o, r, l, i, a) { | ||
const s = r.length; | ||
if (!o.reverseArrayValues) { | ||
for (let e = 0; e < s; e++) { | ||
renderValue(n, o, getIndexName(o, e, s), r[e], e === s - 1); | ||
} | ||
} else { | ||
for (let e = o; e--; ) { | ||
renderValue(t, n, getIndexName(n, e, o), r[e], e === 0); | ||
for (let e = s; e--; ) { | ||
renderValue(n, o, getIndexName(o, e, s), r[e], e === 0); | ||
} | ||
} | ||
addArrowEvent(n, e, t); | ||
if (o.showOpeningClosingCurlyBraces) { | ||
createClosingSymbol(o, n, "]", i, a); | ||
} | ||
addArrowEvent(o, e, t, n, l); | ||
} | ||
function renderValue(e, t, n, r, o) { | ||
function renderValue(e, t, n, o, r) { | ||
const l = DomElement.create(e, "div", "object-type-value"); | ||
@@ -781,3 +789,3 @@ const i = t.showArrowToggles ? DomElement.create(l, "div", "no-arrow") : null; | ||
DomElement.createWithHTML(l, "span", "split", ":"); | ||
if (!Is.defined(r)) { | ||
if (o === null) { | ||
if (!t.ignore.nullValues) { | ||
@@ -790,10 +798,22 @@ a = t.showValueColors ? "null" : ""; | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedFunction(r)) { | ||
} else if (o === void 0) { | ||
if (!t.ignore.undefinedValues) { | ||
a = t.showValueColors ? "undefined" : ""; | ||
s = DomElement.createWithHTML(l, "span", a, "undefined"); | ||
c = "undefined"; | ||
if (Is.definedFunction(t.events.onUndefinedRender)) { | ||
Trigger.customEvent(t.events.onUndefinedRender, s); | ||
} | ||
createComma(t, l, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedFunction(o)) { | ||
if (!t.ignore.functionValues) { | ||
a = t.showValueColors ? "function" : ""; | ||
s = DomElement.createWithHTML(l, "span", a, Default.getFunctionName(r)); | ||
s = DomElement.createWithHTML(l, "span", a, Default.getFunctionName(o)); | ||
c = "function"; | ||
@@ -803,10 +823,10 @@ if (Is.definedFunction(t.events.onFunctionRender)) { | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedBoolean(r)) { | ||
} else if (Is.definedBoolean(o)) { | ||
if (!t.ignore.booleanValues) { | ||
a = t.showValueColors ? "boolean" : ""; | ||
s = DomElement.createWithHTML(l, "span", a, r); | ||
s = DomElement.createWithHTML(l, "span", a, o); | ||
c = "boolean"; | ||
@@ -816,9 +836,9 @@ if (Is.definedFunction(t.events.onBooleanRender)) { | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedDecimal(r)) { | ||
} else if (Is.definedDecimal(o)) { | ||
if (!t.ignore.decimalValues) { | ||
const e = Default.getFixedDecimalPlacesValue(r, t.maximumDecimalPlaces); | ||
const e = Default.getFixedDecimalPlacesValue(o, t.maximumDecimalPlaces); | ||
a = t.showValueColors ? "decimal" : ""; | ||
@@ -830,10 +850,10 @@ s = DomElement.createWithHTML(l, "span", a, e); | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedNumber(r)) { | ||
} else if (Is.definedNumber(o)) { | ||
if (!t.ignore.numberValues) { | ||
a = t.showValueColors ? "number" : ""; | ||
s = DomElement.createWithHTML(l, "span", a, r); | ||
s = DomElement.createWithHTML(l, "span", a, o); | ||
c = "number"; | ||
@@ -843,10 +863,10 @@ if (Is.definedFunction(t.events.onNumberRender)) { | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedBigInt(r)) { | ||
} else if (Is.definedBigInt(o)) { | ||
if (!t.ignore.bigIntValues) { | ||
a = t.showValueColors ? "bigint" : ""; | ||
s = DomElement.createWithHTML(l, "span", a, r); | ||
s = DomElement.createWithHTML(l, "span", a, o); | ||
c = "bigint"; | ||
@@ -856,27 +876,27 @@ if (Is.definedFunction(t.events.onBigIntRender)) { | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedString(r)) { | ||
} else if (Is.definedString(o)) { | ||
if (!t.ignore.stringValues) { | ||
if (t.parse.stringsToBooleans && Is.stringValueBoolean(r)) { | ||
renderValue(e, t, n, r.toString().toLowerCase().trim() === "true", o); | ||
if (t.parse.stringsToBooleans && Is.String.boolean(o)) { | ||
renderValue(e, t, n, o.toString().toLowerCase().trim() === "true", r); | ||
u = true; | ||
} else if (t.parse.stringsToNumbers && !isNaN(r)) { | ||
renderValue(e, t, n, parseFloat(r), o); | ||
} else if (t.parse.stringsToNumbers && !isNaN(o)) { | ||
renderValue(e, t, n, parseFloat(o), r); | ||
u = true; | ||
} else if (t.parse.stringsToDates && Is.stringValueDate(r)) { | ||
renderValue(e, t, n, new Date(r), o); | ||
} else if (t.parse.stringsToDates && Is.String.date(o)) { | ||
renderValue(e, t, n, new Date(o), r); | ||
u = true; | ||
} else { | ||
let e = null; | ||
if (t.showValueColors && t.showStringHexColors && Is.hexColor(r)) { | ||
e = r; | ||
if (t.showValueColors && t.showStringHexColors && Is.String.hexColor(o)) { | ||
e = o; | ||
} else { | ||
if (t.maximumStringLength > 0 && r.length > t.maximumStringLength) { | ||
r = r.substring(0, t.maximumStringLength) + _configuration.text.ellipsisText; | ||
if (t.maximumStringLength > 0 && o.length > t.maximumStringLength) { | ||
o = o.substring(0, t.maximumStringLength) + _configuration.text.ellipsisText; | ||
} | ||
} | ||
const n = t.showStringQuotes ? `"${r}"` : r; | ||
const n = t.showStringQuotes ? `"${o}"` : o; | ||
a = t.showValueColors ? "string" : ""; | ||
@@ -891,3 +911,3 @@ s = DomElement.createWithHTML(l, "span", a, n); | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} | ||
@@ -897,6 +917,6 @@ } else { | ||
} | ||
} else if (Is.definedDate(r)) { | ||
} else if (Is.definedDate(o)) { | ||
if (!t.ignore.dateValues) { | ||
a = t.showValueColors ? "date" : ""; | ||
s = DomElement.createWithHTML(l, "span", a, DateTime.getCustomFormattedDateText(_configuration, r, t.dateTimeFormat)); | ||
s = DomElement.createWithHTML(l, "span", a, DateTime.getCustomFormattedDateText(_configuration, o, t.dateTimeFormat)); | ||
c = "date"; | ||
@@ -906,10 +926,10 @@ if (Is.definedFunction(t.events.onDateRender)) { | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedSymbol(r)) { | ||
} else if (Is.definedSymbol(o)) { | ||
if (!t.ignore.symbolValues) { | ||
a = t.showValueColors ? "symbol" : ""; | ||
s = DomElement.createWithHTML(l, "span", a, r.toString()); | ||
s = DomElement.createWithHTML(l, "span", a, o.toString()); | ||
c = "symbol"; | ||
@@ -919,19 +939,25 @@ if (Is.definedFunction(t.events.onSymbolRender)) { | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} else { | ||
u = true; | ||
} | ||
} else if (Is.definedObject(r) && !Is.definedArray(r)) { | ||
} else if (Is.definedObject(o) && !Is.definedArray(o)) { | ||
if (!t.ignore.objectValues) { | ||
const e = DomElement.create(l, "span", t.showValueColors ? "object" : ""); | ||
const n = DomElement.create(l, "div", "object-type-contents"); | ||
const a = renderObjectValues(i, n, t, r); | ||
if (a === 0 && t.ignore.emptyObjects) { | ||
const e = getObjectPropertyNames(o, t); | ||
const n = e.length; | ||
if (n === 0 && t.ignore.emptyObjects) { | ||
u = true; | ||
} else { | ||
DomElement.createWithHTML(e, "span", "title", _configuration.text.objectText); | ||
if (t.showCounts && a > 0) { | ||
DomElement.createWithHTML(e, "span", "count", `{${a}}`); | ||
const a = DomElement.create(l, "span", t.showValueColors ? "object" : ""); | ||
const s = DomElement.create(l, "div", "object-type-contents"); | ||
let u = null; | ||
DomElement.createWithHTML(a, "span", "title", _configuration.text.objectText); | ||
if (t.showCounts && n > 0) { | ||
DomElement.createWithHTML(a, "span", "count", `{${n}}`); | ||
} | ||
createComma(t, e, o); | ||
if (t.showOpeningClosingCurlyBraces) { | ||
u = DomElement.createWithHTML(a, "span", "opening-symbol", "{"); | ||
} | ||
let d = createComma(t, a, r); | ||
renderObjectValues(i, d, s, t, o, e, u, true, r); | ||
c = "object"; | ||
@@ -942,12 +968,16 @@ } | ||
} | ||
} else if (Is.definedArray(r)) { | ||
} else if (Is.definedArray(o)) { | ||
if (!t.ignore.arrayValues) { | ||
const e = DomElement.create(l, "span", t.showValueColors ? "array" : ""); | ||
const n = DomElement.create(l, "div", "object-type-contents"); | ||
let a = null; | ||
DomElement.createWithHTML(e, "span", "title", _configuration.text.arrayText); | ||
if (t.showCounts) { | ||
DomElement.createWithHTML(e, "span", "count", `[${r.length}]`); | ||
DomElement.createWithHTML(e, "span", "count", `[${o.length}]`); | ||
} | ||
createComma(t, e, o); | ||
renderArrayValues(i, n, t, r); | ||
if (t.showOpeningClosingCurlyBraces) { | ||
a = DomElement.createWithHTML(e, "span", "opening-symbol", "["); | ||
} | ||
let s = createComma(t, e, r); | ||
renderArrayValues(i, s, n, t, o, a, true, r); | ||
c = "array"; | ||
@@ -960,3 +990,3 @@ } else { | ||
a = t.showValueColors ? "unknown" : ""; | ||
s = DomElement.createWithHTML(l, "span", a, r.toString()); | ||
s = DomElement.createWithHTML(l, "span", a, o.toString()); | ||
c = "unknown"; | ||
@@ -966,3 +996,3 @@ if (Is.definedFunction(t.events.onUnknownRender)) { | ||
} | ||
createComma(t, l, o); | ||
createComma(t, l, r); | ||
} else { | ||
@@ -976,10 +1006,10 @@ u = true; | ||
if (Is.defined(s)) { | ||
addValueClickEvent(t, s, r, c); | ||
addValueClickEvent(t, s, o, c); | ||
} | ||
} | ||
} | ||
function addValueClickEvent(e, t, n, r) { | ||
function addValueClickEvent(e, t, n, o) { | ||
if (Is.definedFunction(e.events.onValueClick)) { | ||
t.onclick = () => { | ||
Trigger.customEvent(e.events.onValueClick, n, r); | ||
Trigger.customEvent(e.events.onValueClick, n, o); | ||
}; | ||
@@ -990,18 +1020,35 @@ } else { | ||
} | ||
function addArrowEvent(e, t, n) { | ||
function addArrowEvent(e, t, n, o, r) { | ||
if (Is.defined(t)) { | ||
const l = () => { | ||
o.style.display = "none"; | ||
t.className = "right-arrow"; | ||
if (Is.defined(r)) { | ||
r.style.display = "none"; | ||
} | ||
if (Is.defined(n)) { | ||
n.style.display = "inline-block"; | ||
} | ||
}; | ||
const i = () => { | ||
o.style.display = "block"; | ||
t.className = "down-arrow"; | ||
if (Is.defined(r)) { | ||
r.style.display = "inline-block"; | ||
} | ||
if (Is.defined(n)) { | ||
n.style.display = "none"; | ||
} | ||
}; | ||
t.onclick = () => { | ||
if (t.className === "down-arrow") { | ||
n.style.display = "none"; | ||
t.className = "right-arrow"; | ||
l(); | ||
} else { | ||
n.style.display = "block"; | ||
t.className = "down-arrow"; | ||
i(); | ||
} | ||
}; | ||
if (e.showAllAsClosed) { | ||
n.style.display = "none"; | ||
t.className = "right-arrow"; | ||
l(); | ||
} else { | ||
t.className = "down-arrow"; | ||
i(); | ||
} | ||
@@ -1011,16 +1058,45 @@ } | ||
function createComma(e, t, n) { | ||
let o = null; | ||
if (e.showCommas && !n) { | ||
DomElement.createWithHTML(t, "span", "comma", ","); | ||
o = DomElement.createWithHTML(t, "span", "comma", ","); | ||
} | ||
return o; | ||
} | ||
function getIndexName(e, t, n) { | ||
let r = e.useZeroIndexingForArrays ? t.toString() : (t + 1).toString(); | ||
let o = e.useZeroIndexingForArrays ? t.toString() : (t + 1).toString(); | ||
if (!e.addArrayIndexPadding) { | ||
r = Str.padNumber(parseInt(r), n.toString().length); | ||
o = Str.padNumber(parseInt(o), n.toString().length); | ||
} | ||
if (e.showArrayIndexBrackets) { | ||
r = `[${r}]`; | ||
o = `[${o}]`; | ||
} | ||
return r; | ||
return o; | ||
} | ||
function getObjectPropertyNames(e, t) { | ||
let n = []; | ||
for (let t in e) { | ||
if (e.hasOwnProperty(t)) { | ||
n.push(t); | ||
} | ||
} | ||
if (t.sortPropertyNames) { | ||
let e = new Intl.Collator(void 0, { | ||
numeric: true, | ||
sensitivity: "base" | ||
}); | ||
n = n.sort(e.compare); | ||
if (!t.sortPropertyNamesInAlphabeticalOrder) { | ||
n = n.reverse(); | ||
} | ||
} | ||
return n; | ||
} | ||
function createClosingSymbol(e, t, n, o, r) { | ||
let l = DomElement.create(t, "div", "closing-symbol"); | ||
if (o) { | ||
DomElement.create(l, "div", "no-arrow"); | ||
} | ||
DomElement.createWithHTML(l, "div", "object-type-end", n); | ||
createComma(e, l, r); | ||
} | ||
function makeAreaDroppable(e, t) { | ||
@@ -1041,6 +1117,6 @@ if (t.fileDroppingEnabled) { | ||
const n = e.length; | ||
for (let r = 0; r < n; r++) { | ||
const n = e[r]; | ||
const o = n.name.split(".").pop().toLowerCase(); | ||
if (o === "json") { | ||
for (let o = 0; o < n; o++) { | ||
const n = e[o]; | ||
const r = n.name.split(".").pop().toLowerCase(); | ||
if (r === "json") { | ||
importFromJson(n, t); | ||
@@ -1052,6 +1128,6 @@ } | ||
const n = new FileReader; | ||
let r = null; | ||
let o = null; | ||
n.onloadend = () => { | ||
t._currentView.dataArrayCurrentIndex = 0; | ||
t.data = r; | ||
t.data = o; | ||
renderControlContainer(t); | ||
@@ -1063,3 +1139,3 @@ Trigger.customEvent(t.events.onSetJson, t._currentView.element); | ||
if (t.parsed && Is.definedObject(t.object)) { | ||
r = t.object; | ||
o = t.object; | ||
} | ||
@@ -1152,7 +1228,7 @@ }; | ||
} | ||
const r = _elements_Data[e]; | ||
r._currentView.dataArrayCurrentIndex = 0; | ||
r.data = n; | ||
renderControlContainer(r); | ||
Trigger.customEvent(r.events.onSetJson, r._currentView.element); | ||
const o = _elements_Data[e]; | ||
o._currentView.dataArrayCurrentIndex = 0; | ||
o.data = n; | ||
renderControlContainer(o); | ||
Trigger.customEvent(o.events.onSetJson, o._currentView.element); | ||
} | ||
@@ -1188,5 +1264,5 @@ return _public; | ||
const n = _configuration; | ||
for (let r in e) { | ||
if (e.hasOwnProperty(r) && _configuration.hasOwnProperty(r) && n[r] !== e[r]) { | ||
n[r] = e[r]; | ||
for (let o in e) { | ||
if (e.hasOwnProperty(o) && _configuration.hasOwnProperty(o) && n[o] !== e[o]) { | ||
n[o] = e[o]; | ||
t = true; | ||
@@ -1211,3 +1287,3 @@ } | ||
getVersion: function() { | ||
return "2.3.0"; | ||
return "2.4.0"; | ||
} | ||
@@ -1214,0 +1290,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
"use strict";var Is,Default,DomElement,Str,Str2,DateTime,Constants,Binding,Config,Trigger,ToolTip;(e=>{function t(e){return null!=e&&""!==e.toString()}function n(e){return t(e)&&"object"==typeof e}function o(e){return n(e)&&e instanceof Array}e.defined=t,e.definedObject=n,e.definedBoolean=function(e){return t(e)&&"boolean"==typeof e},e.definedString=function(e){return t(e)&&"string"==typeof e},e.definedFunction=function(e){return t(e)&&"function"==typeof e},e.definedNumber=function(e){return t(e)&&"number"==typeof e},e.definedBigInt=function(e){return t(e)&&"bigint"==typeof e},e.definedArray=o,e.definedDate=function(e){return n(e)&&e instanceof Date},e.definedDecimal=function(e){return t(e)&&"number"==typeof e&&e%1!=0},e.definedSymbol=function(e){return t(e)&&"symbol"==typeof e},e.invalidOptionArray=function(e,t=1){return!o(e)||e.length<t},e.hexColor=function(e){let t=e.length>=2&&e.length<=7;return t&&"#"===e[0]&&(t=isNaN(+e.substring(1,e.length-1))),t},e.stringValueBoolean=function(e){return"true"===e.toString().toLowerCase().trim()||"false"===e.toString().toLowerCase().trim()},e.stringValueDate=function(e){return!isNaN(+new Date(e))}})(Is||(Is={})),(e=>{function t(e,t){return Is.definedArray(e)?e:t}e.getAnyString=function(e,t){return"string"==typeof e?e:t},e.getString=function(e,t){return Is.definedString(e)?e:t},e.getBoolean=function(e,t){return Is.definedBoolean(e)?e:t},e.getNumber=function(e,t){return Is.definedNumber(e)?e:t},e.getFunction=function(e,t){return Is.definedFunction(e)?e:t},e.getArray=t,e.getObject=function(e,t){return Is.definedObject(e)?e:t},e.getStringOrArray=function(e,n){let o=n;if(Is.definedString(e)){const t=e.toString().split(" ");0===t.length?e=n:o=t}else o=t(e,n);return o},e.getFixedDecimalPlacesValue=function(e,t){var n;const o=new RegExp(`^-?\\d+(?:.\\d{0,${t||-1}})?`);return(null==(n=e.toString().match(o))?void 0:n[0])||""},e.getFunctionName=function(e){let t;const n=e.toString().split("(")[0].split(" ");return t=2===n.length?n[1]:n[0],t+="()",t}})(Default||(Default={})),(e=>{function t(e,t,n="",o=null){const r=t.toLowerCase();let l="text"===r?document.createTextNode(""):document.createElement(r);return Is.defined(n)&&(l.className=n),Is.defined(o)?e.insertBefore(l,o):e.appendChild(l),l}function n(){const e=document.documentElement;return{left:e.scrollLeft-(e.clientLeft||0),top:e.scrollTop-(e.clientTop||0)}}e.create=t,e.createWithHTML=function(e,n,o,r,l=null){const a=t(e,n,o,l);return a.innerHTML=r,a},e.addClass=function(e,t){e.classList.add(t)},e.cancelBubble=function(e){e.preventDefault(),e.stopPropagation()},e.getScrollPosition=n,e.showElementAtMousePosition=function(e,t){let o=e.pageX,r=e.pageY;const l=n();t.style.display="block",o+t.offsetWidth>window.innerWidth?o-=t.offsetWidth:o++,r+t.offsetHeight>window.innerHeight?r-=t.offsetHeight:r++,o<l.left&&(o=e.pageX+1),r<l.top&&(r=e.pageY+1),t.style.left=`${o}px`,t.style.top=`${r}px`}})(DomElement||(DomElement={})),Str2=Str||(Str={}),Str2.newGuid=function(){const e=[];for(let t=0;t<32;t++){8!==t&&12!==t&&16!==t&&20!==t||e.push("-");const n=Math.floor(16*Math.random()).toString(16);e.push(n)}return e.join("")},Str2.padNumber=function(e,t=1){const n=e.toString();let o=n;if(n.length<t){const e=t-n.length+1;o=Array(e).join("0")+n}return o},(e=>{function t(e){return e.getDay()-1<0?6:e.getDay()-1}function n(e,t){let n=e.text.thText;return 31===t||21===t||1===t?n=e.text.stText:22===t||2===t?n=e.text.ndText:23!==t&&3!==t||(n=e.text.rdText),n}e.getWeekdayNumber=t,e.getDayOrdinal=n,e.getCustomFormattedDateText=function(e,o,r){let l=r;const a=t(o);return l=l.replace("{hh}",Str.padNumber(o.getHours(),2)),l=l.replace("{h}",o.getHours().toString()),l=l.replace("{MM}",Str.padNumber(o.getMinutes(),2)),l=l.replace("{M}",o.getMinutes().toString()),l=l.replace("{ss}",Str.padNumber(o.getSeconds(),2)),l=l.replace("{s}",o.getSeconds().toString()),l=l.replace("{dddd}",e.text.dayNames[a]),l=l.replace("{ddd}",e.text.dayNamesAbbreviated[a]),l=l.replace("{dd}",Str.padNumber(o.getDate())),l=l.replace("{d}",o.getDate().toString()),l=l.replace("{o}",n(e,o.getDate())),l=l.replace("{mmmm}",e.text.monthNames[o.getMonth()]),l=l.replace("{mmm}",e.text.monthNamesAbbreviated[o.getMonth()]),l=l.replace("{mm}",Str.padNumber(o.getMonth()+1)),l=l.replace("{m}",(o.getMonth()+1).toString()),l=l.replace("{yyyy}",o.getFullYear().toString()),l=l.replace("{yyy}",o.getFullYear().toString().substring(1)),l=l.replace("{yy}",o.getFullYear().toString().substring(2)),l=l.replace("{y}",Number.parseInt(o.getFullYear().toString().substring(2)).toString()),l}})(DateTime||(DateTime={})),(Constants||(Constants={})).JSONTREE_JS_ATTRIBUTE_NAME="data-jsontree-js",(e=>{let t;var n;(n=t=e.Options||(e.Options={})).getForNewInstance=function(t,n){const o=e.Options.get(t);return o._currentView={},o._currentView.element=n,o._currentView.dataArrayCurrentIndex=0,o._currentView.titleBarButtons=null,o},n.get=function(e){let t=Default.getObject(e,{});return t.data=Default.getObject(t.data,null),t.showCounts=Default.getBoolean(t.showCounts,!0),t.useZeroIndexingForArrays=Default.getBoolean(t.useZeroIndexingForArrays,!0),t.dateTimeFormat=Default.getString(t.dateTimeFormat,"{dd}{o} {mmmm} {yyyy} {hh}:{MM}:{ss}"),t.showArrowToggles=Default.getBoolean(t.showArrowToggles,!0),t.showStringQuotes=Default.getBoolean(t.showStringQuotes,!0),t.showAllAsClosed=Default.getBoolean(t.showAllAsClosed,!1),t.sortPropertyNames=Default.getBoolean(t.sortPropertyNames,!0),t.sortPropertyNamesInAlphabeticalOrder=Default.getBoolean(t.sortPropertyNamesInAlphabeticalOrder,!0),t.showCommas=Default.getBoolean(t.showCommas,!1),t.reverseArrayValues=Default.getBoolean(t.reverseArrayValues,!1),t.addArrayIndexPadding=Default.getBoolean(t.addArrayIndexPadding,!1),t.showValueColors=Default.getBoolean(t.showValueColors,!0),t.maximumDecimalPlaces=Default.getNumber(t.maximumDecimalPlaces,2),t.maximumStringLength=Default.getNumber(t.maximumStringLength,0),t.showStringHexColors=Default.getBoolean(t.showStringHexColors,!1),t.showArrayItemsAsSeparateObjects=Default.getBoolean(t.showArrayItemsAsSeparateObjects,!1),t.copyOnlyCurrentPage=Default.getBoolean(t.copyOnlyCurrentPage,!1),t.fileDroppingEnabled=Default.getBoolean(t.fileDroppingEnabled,!0),t.copyIndentSpaces=Default.getNumber(t.copyIndentSpaces,2),t.showArrayIndexBrackets=Default.getBoolean(t.showArrayIndexBrackets,!0),t=function(e){return e.title=Default.getObject(e.title,{}),e.title.text=Default.getString(e.title.text,"JsonTree.js"),e.title.show=Default.getBoolean(e.title.show,!0),e.title.showTreeControls=Default.getBoolean(e.title.showTreeControls,!0),e.title.showCopyButton=Default.getBoolean(e.title.showCopyButton,!0),e}(t),t=function(e){return e.ignore=Default.getObject(e.ignore,{}),e.ignore.nullValues=Default.getBoolean(e.ignore.nullValues,!1),e.ignore.functionValues=Default.getBoolean(e.ignore.functionValues,!1),e.ignore.unknownValues=Default.getBoolean(e.ignore.unknownValues,!1),e.ignore.booleanValues=Default.getBoolean(e.ignore.booleanValues,!1),e.ignore.decimalValues=Default.getBoolean(e.ignore.decimalValues,!1),e.ignore.numberValues=Default.getBoolean(e.ignore.numberValues,!1),e.ignore.stringValues=Default.getBoolean(e.ignore.stringValues,!1),e.ignore.dateValues=Default.getBoolean(e.ignore.dateValues,!1),e.ignore.objectValues=Default.getBoolean(e.ignore.objectValues,!1),e.ignore.arrayValues=Default.getBoolean(e.ignore.arrayValues,!1),e.ignore.bigIntValues=Default.getBoolean(e.ignore.bigIntValues,!1),e.ignore.symbolValues=Default.getBoolean(e.ignore.symbolValues,!1),e.ignore.emptyObjects=Default.getBoolean(e.ignore.emptyObjects,!0),e}(t),t=function(e){return e.tooltip=Default.getObject(e.tooltip,{}),e.tooltip.delay=Default.getNumber(e.tooltip.delay,750),e}(t),t=function(e){return e.parse=Default.getObject(e.parse,{}),e.parse.stringsToDates=Default.getBoolean(e.parse.stringsToDates,!1),e.parse.stringsToBooleans=Default.getBoolean(e.parse.stringsToBooleans,!1),e.parse.stringsToNumbers=Default.getBoolean(e.parse.stringsToNumbers,!1),e}(t),t=function(e){return e.events=Default.getObject(e.events,{}),e.events.onBeforeRender=Default.getFunction(e.events.onBeforeRender,null),e.events.onRenderComplete=Default.getFunction(e.events.onRenderComplete,null),e.events.onValueClick=Default.getFunction(e.events.onValueClick,null),e.events.onRefresh=Default.getFunction(e.events.onRefresh,null),e.events.onCopyAll=Default.getFunction(e.events.onCopyAll,null),e.events.onOpenAll=Default.getFunction(e.events.onOpenAll,null),e.events.onCloseAll=Default.getFunction(e.events.onCloseAll,null),e.events.onDestroy=Default.getFunction(e.events.onDestroy,null),e.events.onBooleanRender=Default.getFunction(e.events.onBooleanRender,null),e.events.onDecimalRender=Default.getFunction(e.events.onDecimalRender,null),e.events.onNumberRender=Default.getFunction(e.events.onNumberRender,null),e.events.onBigIntRender=Default.getFunction(e.events.onBigIntRender,null),e.events.onStringRender=Default.getFunction(e.events.onStringRender,null),e.events.onDateRender=Default.getFunction(e.events.onDateRender,null),e.events.onFunctionRender=Default.getFunction(e.events.onFunctionRender,null),e.events.onNullRender=Default.getFunction(e.events.onNullRender,null),e.events.onUnknownRender=Default.getFunction(e.events.onUnknownRender,null),e.events.onSymbolRender=Default.getFunction(e.events.onSymbolRender,null),e}(t),t}})(Binding||(Binding={})),(e=>{let t;(t=e.Options||(e.Options={})).get=function(e=null){let t=Default.getObject(e,{});return t.safeMode=Default.getBoolean(t.safeMode,!0),t.domElementTypes=Default.getStringOrArray(t.domElementTypes,["*"]),t=function(e){return e.text=Default.getObject(e.text,{}),e.text.objectText=Default.getAnyString(e.text.objectText,"object"),e.text.arrayText=Default.getAnyString(e.text.arrayText,"array"),e.text.closeAllButtonText=Default.getAnyString(e.text.closeAllButtonText,"Close All"),e.text.openAllButtonText=Default.getAnyString(e.text.openAllButtonText,"Open All"),e.text.copyAllButtonText=Default.getAnyString(e.text.copyAllButtonText,"Copy All"),e.text.objectErrorText=Default.getAnyString(e.text.objectErrorText,"Errors in object: {{error_1}}, {{error_2}}"),e.text.attributeNotValidErrorText=Default.getAnyString(e.text.attributeNotValidErrorText,"The attribute '{{attribute_name}}' is not a valid object."),e.text.attributeNotSetErrorText=Default.getAnyString(e.text.attributeNotSetErrorText,"The attribute '{{attribute_name}}' has not been set correctly."),e.text.stText=Default.getAnyString(e.text.stText,"st"),e.text.ndText=Default.getAnyString(e.text.ndText,"nd"),e.text.rdText=Default.getAnyString(e.text.rdText,"rd"),e.text.thText=Default.getAnyString(e.text.thText,"th"),e.text.ellipsisText=Default.getAnyString(e.text.ellipsisText,"..."),e.text.closeAllButtonSymbolText=Default.getAnyString(e.text.closeAllButtonSymbolText,"↑"),e.text.openAllButtonSymbolText=Default.getAnyString(e.text.openAllButtonSymbolText,"↓"),e.text.copyAllButtonSymbolText=Default.getAnyString(e.text.copyAllButtonSymbolText,"❐"),e.text.backButtonText=Default.getAnyString(e.text.backButtonText,"Back"),e.text.nextButtonText=Default.getAnyString(e.text.nextButtonText,"Next"),e.text.backButtonSymbolText=Default.getAnyString(e.text.backButtonSymbolText,"←"),e.text.nextButtonSymbolText=Default.getAnyString(e.text.nextButtonSymbolText,"→"),e.text.noJsonToViewText=Default.getAnyString(e.text.noJsonToViewText,"There is currently no JSON to view."),Is.invalidOptionArray(e.text.dayNames,7)&&(e.text.dayNames=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]),Is.invalidOptionArray(e.text.dayNamesAbbreviated,7)&&(e.text.dayNamesAbbreviated=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]),Is.invalidOptionArray(e.text.monthNames,12)&&(e.text.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"]),Is.invalidOptionArray(e.text.monthNamesAbbreviated,12)&&(e.text.monthNamesAbbreviated=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),e}(t),t}})(Config||(Config={})),(Trigger||(Trigger={})).customEvent=function(e,...t){let n=null;return Is.definedFunction(e)&&(n=e.apply(null,[].slice.call(t,0))),n},(e=>{function t(e,t=!0){let n=t?window.addEventListener:window.removeEventListener,r=t?document.addEventListener:document.removeEventListener;n("mousemove",(()=>{o(e)})),r("scroll",(()=>{o(e)}))}function n(e,t,n){DomElement.cancelBubble(e),o(t),t._currentView.tooltipTimerId=setTimeout((()=>{t._currentView.tooltip.innerHTML=n,t._currentView.tooltip.style.display="block",DomElement.showElementAtMousePosition(e,t._currentView.tooltip)}),t.tooltip.delay)}function o(e){Is.defined(e._currentView.tooltip)&&(0!==e._currentView.tooltipTimerId&&(clearTimeout(e._currentView.tooltipTimerId),e._currentView.tooltipTimerId=0),"none"!==e._currentView.tooltip.style.display&&(e._currentView.tooltip.style.display="none"))}e.renderControl=function(e){Is.defined(e._currentView.tooltip)||(e._currentView.tooltip=DomElement.create(document.body,"div","jsontree-js-tooltip"),e._currentView.tooltip.style.display="none",t(e))},e.assignToEvents=t,e.add=function(e,t,o){null!==e&&(e.onmousemove=e=>{n(e,t,o)})},e.show=n,e.hide=o})(ToolTip||(ToolTip={})),(()=>{let _configuration={},_elements_Data={};function render(){const e=_configuration.domElementTypes,t=e.length;for(let n=0;n<t;n++){const t=document.getElementsByTagName(e[n]),o=[].slice.call(t),r=o.length;for(let e=0;e<r&&renderElement(o[e]);e++);}}function renderElement(e){let t=!0;if(Is.defined(e)&&e.hasAttribute(Constants.JSONTREE_JS_ATTRIBUTE_NAME)){const n=e.getAttribute(Constants.JSONTREE_JS_ATTRIBUTE_NAME);if(Is.definedString(n)){const o=getObjectFromString(n);o.parsed&&Is.definedObject(o.object)?renderControl(Binding.Options.getForNewInstance(o.object,e)):_configuration.safeMode||(console.error(_configuration.text.attributeNotValidErrorText.replace("{{attribute_name}}",Constants.JSONTREE_JS_ATTRIBUTE_NAME)),t=!1)}else _configuration.safeMode||(console.error(_configuration.text.attributeNotSetErrorText.replace("{{attribute_name}}",Constants.JSONTREE_JS_ATTRIBUTE_NAME)),t=!1)}return t}function renderControl(e){Trigger.customEvent(e.events.onBeforeRender,e._currentView.element),ToolTip.renderControl(e),Is.definedString(e._currentView.element.id)||(e._currentView.element.id=Str.newGuid()),e._currentView.element.className="json-tree-js",e._currentView.element.removeAttribute(Constants.JSONTREE_JS_ATTRIBUTE_NAME),_elements_Data.hasOwnProperty(e._currentView.element.id)||(_elements_Data[e._currentView.element.id]=e),renderControlContainer(e),Trigger.customEvent(e.events.onRenderComplete,e._currentView.element)}function renderControlContainer(e){let t=_elements_Data[e._currentView.element.id].data;ToolTip.hide(e),e._currentView.element.innerHTML="",renderControlTitleBar(e,t);const n=DomElement.create(e._currentView.element,"div","contents");makeAreaDroppable(n,e),e.showArrayItemsAsSeparateObjects&&Is.definedArray(t)&&(t=t[e._currentView.dataArrayCurrentIndex]),Is.definedObject(t)&&!Is.definedArray(t)?renderObject(n,e,t,!0):Is.definedArray(t)&&renderArray(n,e,t),""===n.innerHTML?(DomElement.createWithHTML(n,"span","no-json-text",_configuration.text.noJsonToViewText),e._currentView.titleBarButtons.style.display="none"):e._currentView.titleBarButtons.style.display="block"}function renderControlTitleBar(e,t){if(e.title.show||e.title.showTreeControls||e.title.showCopyButton){const n=DomElement.create(e._currentView.element,"div","title-bar");if(e._currentView.titleBarButtons=DomElement.create(n,"div","controls"),e.title.show&&DomElement.createWithHTML(n,"div","title",e.title.text,e._currentView.titleBarButtons),e.title.showCopyButton){const n=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","copy-all",_configuration.text.copyAllButtonSymbolText);ToolTip.add(n,e,_configuration.text.copyAllButtonText),n.onclick=()=>{let n=null;n=e.copyOnlyCurrentPage&&e.showArrayItemsAsSeparateObjects?JSON.stringify(t[e._currentView.dataArrayCurrentIndex],jsonStringifyReplacer,e.copyIndentSpaces):JSON.stringify(t,jsonStringifyReplacer,e.copyIndentSpaces),navigator.clipboard.writeText(n),Trigger.customEvent(e.events.onCopyAll,n)}}if(e.title.showTreeControls){const t=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","openAll",_configuration.text.openAllButtonSymbolText);ToolTip.add(t,e,_configuration.text.openAllButtonText);const n=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","closeAll",_configuration.text.closeAllButtonSymbolText);ToolTip.add(n,e,_configuration.text.closeAllButtonText),t.onclick=()=>{openAllNodes(e)},n.onclick=()=>{closeAllNodes(e)}}if(e.showArrayItemsAsSeparateObjects&&Is.definedArray(t)&&t.length>1){const n=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","back",_configuration.text.backButtonSymbolText);ToolTip.add(n,e,_configuration.text.backButtonText),e._currentView.dataArrayCurrentIndex>0?n.onclick=()=>{e._currentView.dataArrayCurrentIndex--,renderControlContainer(e),Trigger.customEvent(e.events.onBackPage,e._currentView.element)}:n.disabled=!0;const o=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","next",_configuration.text.nextButtonSymbolText);ToolTip.add(o,e,_configuration.text.nextButtonText),e._currentView.dataArrayCurrentIndex<t.length-1?o.onclick=()=>{e._currentView.dataArrayCurrentIndex++,renderControlContainer(e),Trigger.customEvent(e.events.onNextPage,e._currentView.element)}:o.disabled=!0}else Is.definedArray(t)&&(e.showArrayItemsAsSeparateObjects=!1)}}function jsonStringifyReplacer(e,t){return Is.definedBigInt(t)||Is.definedSymbol(t)?t=t.toString():Is.definedFunction(t)&&(t=Default.getFunctionName(t)),t}function openAllNodes(e){e.showAllAsClosed=!1,renderControlContainer(e),Trigger.customEvent(e.events.onOpenAll,e._currentView.element)}function closeAllNodes(e){e.showAllAsClosed=!0,renderControlContainer(e),Trigger.customEvent(e.events.onCloseAll,e._currentView.element)}function renderObject(e,t,n,o=!1){const r=DomElement.create(e,"div","object-type-title"),l=DomElement.create(e,"div","object-type-contents"),a=renderObjectValues(t.showArrowToggles?DomElement.create(r,"div","down-arrow"):null,l,t,n);if(0===a&&t.ignore.emptyObjects)e.removeChild(r),e.removeChild(l);else{const e=DomElement.createWithHTML(r,"span",t.showValueColors?"object":"",_configuration.text.objectText);if(o&&t.showArrayItemsAsSeparateObjects){let n=t.useZeroIndexingForArrays?t._currentView.dataArrayCurrentIndex.toString():(t._currentView.dataArrayCurrentIndex+1).toString();t.showArrayIndexBrackets&&(n=`[${n}]:`),DomElement.createWithHTML(r,"span",t.showValueColors?"object data-array-index":"data-array-index",n,e)}t.showCounts&&a>0&&DomElement.createWithHTML(r,"span",t.showValueColors?"object count":"count",`{${a}}`)}}function renderArray(e,t,n){const o=DomElement.create(e,"div","object-type-title"),r=DomElement.create(e,"div","object-type-contents"),l=t.showArrowToggles?DomElement.create(o,"div","down-arrow"):null;DomElement.createWithHTML(o,"span",t.showValueColors?"array":"",_configuration.text.arrayText),renderArrayValues(l,r,t,n),t.showCounts&&DomElement.createWithHTML(o,"span",t.showValueColors?"array count":"count",`[${n.length}]`)}function renderObjectValues(e,t,n,o){let r=0,l=[];for(let e in o)o.hasOwnProperty(e)&&l.push(e);if(n.sortPropertyNames){let e=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});l=l.sort(e.compare),n.sortPropertyNamesInAlphabeticalOrder||(l=l.reverse())}const a=l.length;for(let e=0;e<a;e++){const i=l[e];o.hasOwnProperty(i)&&(renderValue(t,n,i,o[i],e===a-1),r++)}return addArrowEvent(n,e,t),r}function renderArrayValues(e,t,n,o){const r=o.length;if(n.reverseArrayValues)for(let e=r;e--;)renderValue(t,n,getIndexName(n,e,r),o[e],0===e);else for(let e=0;e<r;e++)renderValue(t,n,getIndexName(n,e,r),o[e],e===r-1);addArrowEvent(n,e,t)}function renderValue(e,t,n,o,r){const l=DomElement.create(e,"div","object-type-value"),a=t.showArrowToggles?DomElement.create(l,"div","no-arrow"):null;let i=null,s=null,u=!1,c=null;if(DomElement.createWithHTML(l,"span","title",n),DomElement.createWithHTML(l,"span","split",":"),Is.defined(o))if(Is.definedFunction(o))t.ignore.functionValues?u=!0:(i=t.showValueColors?"function":"",s=DomElement.createWithHTML(l,"span",i,Default.getFunctionName(o)),c="function",Is.definedFunction(t.events.onFunctionRender)&&Trigger.customEvent(t.events.onFunctionRender,s),createComma(t,l,r));else if(Is.definedBoolean(o))t.ignore.booleanValues?u=!0:(i=t.showValueColors?"boolean":"",s=DomElement.createWithHTML(l,"span",i,o),c="boolean",Is.definedFunction(t.events.onBooleanRender)&&Trigger.customEvent(t.events.onBooleanRender,s),createComma(t,l,r));else if(Is.definedDecimal(o))if(t.ignore.decimalValues)u=!0;else{const e=Default.getFixedDecimalPlacesValue(o,t.maximumDecimalPlaces);i=t.showValueColors?"decimal":"",s=DomElement.createWithHTML(l,"span",i,e),c="decimal",Is.definedFunction(t.events.onDecimalRender)&&Trigger.customEvent(t.events.onDecimalRender,s),createComma(t,l,r)}else if(Is.definedNumber(o))t.ignore.numberValues?u=!0:(i=t.showValueColors?"number":"",s=DomElement.createWithHTML(l,"span",i,o),c="number",Is.definedFunction(t.events.onNumberRender)&&Trigger.customEvent(t.events.onNumberRender,s),createComma(t,l,r));else if(Is.definedBigInt(o))t.ignore.bigIntValues?u=!0:(i=t.showValueColors?"bigint":"",s=DomElement.createWithHTML(l,"span",i,o),c="bigint",Is.definedFunction(t.events.onBigIntRender)&&Trigger.customEvent(t.events.onBigIntRender,s),createComma(t,l,r));else if(Is.definedString(o))if(t.ignore.stringValues)u=!0;else if(t.parse.stringsToBooleans&&Is.stringValueBoolean(o))renderValue(e,t,n,"true"===o.toString().toLowerCase().trim(),r),u=!0;else if(t.parse.stringsToNumbers&&!isNaN(o))renderValue(e,t,n,parseFloat(o),r),u=!0;else if(t.parse.stringsToDates&&Is.stringValueDate(o))renderValue(e,t,n,new Date(o),r),u=!0;else{let e=null;t.showValueColors&&t.showStringHexColors&&Is.hexColor(o)?e=o:t.maximumStringLength>0&&o.length>t.maximumStringLength&&(o=o.substring(0,t.maximumStringLength)+_configuration.text.ellipsisText);const n=t.showStringQuotes?`"${o}"`:o;i=t.showValueColors?"string":"",s=DomElement.createWithHTML(l,"span",i,n),c="string",Is.definedString(e)&&(s.style.color=e),Is.definedFunction(t.events.onStringRender)&&Trigger.customEvent(t.events.onStringRender,s),createComma(t,l,r)}else if(Is.definedDate(o))t.ignore.dateValues?u=!0:(i=t.showValueColors?"date":"",s=DomElement.createWithHTML(l,"span",i,DateTime.getCustomFormattedDateText(_configuration,o,t.dateTimeFormat)),c="date",Is.definedFunction(t.events.onDateRender)&&Trigger.customEvent(t.events.onDateRender,s),createComma(t,l,r));else if(Is.definedSymbol(o))t.ignore.symbolValues?u=!0:(i=t.showValueColors?"symbol":"",s=DomElement.createWithHTML(l,"span",i,o.toString()),c="symbol",Is.definedFunction(t.events.onSymbolRender)&&Trigger.customEvent(t.events.onSymbolRender,s),createComma(t,l,r));else if(Is.definedObject(o)&&!Is.definedArray(o))if(t.ignore.objectValues)u=!0;else{const e=DomElement.create(l,"span",t.showValueColors?"object":""),n=renderObjectValues(a,DomElement.create(l,"div","object-type-contents"),t,o);0===n&&t.ignore.emptyObjects?u=!0:(DomElement.createWithHTML(e,"span","title",_configuration.text.objectText),t.showCounts&&n>0&&DomElement.createWithHTML(e,"span","count",`{${n}}`),createComma(t,e,r),c="object")}else if(Is.definedArray(o))if(t.ignore.arrayValues)u=!0;else{const e=DomElement.create(l,"span",t.showValueColors?"array":""),n=DomElement.create(l,"div","object-type-contents");DomElement.createWithHTML(e,"span","title",_configuration.text.arrayText),t.showCounts&&DomElement.createWithHTML(e,"span","count",`[${o.length}]`),createComma(t,e,r),renderArrayValues(a,n,t,o),c="array"}else t.ignore.unknownValues?u=!0:(i=t.showValueColors?"unknown":"",s=DomElement.createWithHTML(l,"span",i,o.toString()),c="unknown",Is.definedFunction(t.events.onUnknownRender)&&Trigger.customEvent(t.events.onUnknownRender,s),createComma(t,l,r));else t.ignore.nullValues?u=!0:(i=t.showValueColors?"null":"",s=DomElement.createWithHTML(l,"span",i,"null"),c="null",Is.definedFunction(t.events.onNullRender)&&Trigger.customEvent(t.events.onNullRender,s),createComma(t,l,r));u?e.removeChild(l):Is.defined(s)&&addValueClickEvent(t,s,o,c)}function addValueClickEvent(e,t,n,o){Is.definedFunction(e.events.onValueClick)?t.onclick=()=>{Trigger.customEvent(e.events.onValueClick,n,o)}:DomElement.addClass(t,"no-hover")}function addArrowEvent(e,t,n){Is.defined(t)&&(t.onclick=()=>{"down-arrow"===t.className?(n.style.display="none",t.className="right-arrow"):(n.style.display="block",t.className="down-arrow")},e.showAllAsClosed?(n.style.display="none",t.className="right-arrow"):t.className="down-arrow")}function createComma(e,t,n){e.showCommas&&!n&&DomElement.createWithHTML(t,"span","comma",",")}function getIndexName(e,t,n){let o=e.useZeroIndexingForArrays?t.toString():(t+1).toString();return e.addArrayIndexPadding||(o=Str.padNumber(parseInt(o),n.toString().length)),e.showArrayIndexBrackets&&(o=`[${o}]`),o}function makeAreaDroppable(e,t){t.fileDroppingEnabled&&(e.ondragover=DomElement.cancelBubble,e.ondragenter=DomElement.cancelBubble,e.ondragleave=DomElement.cancelBubble,e.ondrop=e=>{DomElement.cancelBubble(e),Is.defined(window.FileReader)&&e.dataTransfer.files.length>0&&importFromFiles(e.dataTransfer.files,t)})}function importFromFiles(e,t){const n=e.length;for(let o=0;o<n;o++){const n=e[o];"json"===n.name.split(".").pop().toLowerCase()&&importFromJson(n,t)}}function importFromJson(e,t){const n=new FileReader;let o=null;n.onloadend=()=>{t._currentView.dataArrayCurrentIndex=0,t.data=o,renderControlContainer(t),Trigger.customEvent(t.events.onSetJson,t._currentView.element)},n.onload=e=>{const t=getObjectFromString(e.target.result);t.parsed&&Is.definedObject(t.object)&&(o=t.object)},n.readAsText(e)}function getObjectFromString(objectString){const result={parsed:!0,object:null};try{Is.definedString(objectString)&&(result.object=JSON.parse(objectString))}catch(e1){try{result.object=eval(`(${objectString})`),Is.definedFunction(result.object)&&(result.object=result.object())}catch(e){_configuration.safeMode||(console.error(_configuration.text.objectErrorText.replace("{{error_1}}",e1.message).replace("{{error_2}}",e.message)),result.parsed=!1),result.object=null}}return result}function destroyElement(e){e._currentView.element.innerHTML="",e._currentView.element.className="",ToolTip.assignToEvents(e,!1),Trigger.customEvent(e.events.onDestroy,e._currentView.element)}const _public={refresh:function(e){if(Is.definedString(e)&&_elements_Data.hasOwnProperty(e)){const t=_elements_Data[e];renderControlContainer(t),Trigger.customEvent(t.events.onRefresh,t._currentView.element)}return _public},refreshAll:function(){for(let e in _elements_Data)if(_elements_Data.hasOwnProperty(e)){const t=_elements_Data[e];renderControlContainer(t),Trigger.customEvent(t.events.onRefresh,t._currentView.element)}return _public},render:function(e,t){return Is.definedObject(e)&&Is.definedObject(t)&&renderControl(Binding.Options.getForNewInstance(t,e)),_public},renderAll:function(){return render(),_public},openAll:function(e){return Is.definedString(e)&&_elements_Data.hasOwnProperty(e)&&openAllNodes(_elements_Data[e]),_public},closeAll:function(e){return Is.definedString(e)&&_elements_Data.hasOwnProperty(e)&&closeAllNodes(_elements_Data[e]),_public},setJson:function(e,t){if(Is.definedString(e)&&Is.defined(t)&&_elements_Data.hasOwnProperty(e)){let n=null;if(Is.definedString(t)){const e=getObjectFromString(t);e.parsed&&(n=e.object)}else n=t;const o=_elements_Data[e];o._currentView.dataArrayCurrentIndex=0,o.data=n,renderControlContainer(o),Trigger.customEvent(o.events.onSetJson,o._currentView.element)}return _public},getJson:function(e){let t=null;return Is.definedString(e)&&_elements_Data.hasOwnProperty(e)&&(t=_elements_Data[e].data),t},destroy:function(e){return Is.definedString(e)&&_elements_Data.hasOwnProperty(e)&&(destroyElement(_elements_Data[e]),delete _elements_Data[e]),_public},destroyAll:function(){for(let e in _elements_Data)_elements_Data.hasOwnProperty(e)&&destroyElement(_elements_Data[e]);return _elements_Data={},_public},setConfiguration:function(e){if(Is.definedObject(e)){let t=!1;const n=_configuration;for(let o in e)e.hasOwnProperty(o)&&_configuration.hasOwnProperty(o)&&n[o]!==e[o]&&(n[o]=e[o],t=!0);t&&(_configuration=Config.Options.get(n))}return _public},getIds:function(){const e=[];for(let t in _elements_Data)_elements_Data.hasOwnProperty(t)&&e.push(t);return e},getVersion:function(){return"2.3.0"}};_configuration=Config.Options.get(),document.addEventListener("DOMContentLoaded",(function(){render()})),Is.defined(window.$jsontree)||(window.$jsontree=_public)})(); | ||
"use strict";var Is,Default,DomElement,Str,Str2,DateTime,Constants,Binding,Config,Trigger,ToolTip;(e=>{let t;var n;function o(e){return null!=e&&""!==e.toString()}function r(e){return o(e)&&"object"==typeof e}function l(e){return r(e)&&e instanceof Array}(n=t=e.String||(e.String={})).hexColor=function(e){let t=e.length>=2&&e.length<=7;return t&&"#"===e[0]&&(t=isNaN(+e.substring(1,e.length-1))),t},n.boolean=function(e){return"true"===e.toString().toLowerCase().trim()||"false"===e.toString().toLowerCase().trim()},n.date=function(e){return!isNaN(+new Date(e))},e.defined=o,e.definedObject=r,e.definedBoolean=function(e){return o(e)&&"boolean"==typeof e},e.definedString=function(e){return o(e)&&"string"==typeof e},e.definedFunction=function(e){return o(e)&&"function"==typeof e},e.definedNumber=function(e){return o(e)&&"number"==typeof e},e.definedBigInt=function(e){return o(e)&&"bigint"==typeof e},e.definedArray=l,e.definedDate=function(e){return r(e)&&e instanceof Date},e.definedDecimal=function(e){return o(e)&&"number"==typeof e&&e%1!=0},e.definedSymbol=function(e){return o(e)&&"symbol"==typeof e},e.invalidOptionArray=function(e,t=1){return!l(e)||e.length<t}})(Is||(Is={})),(e=>{function t(e,t){return Is.definedArray(e)?e:t}e.getAnyString=function(e,t){return"string"==typeof e?e:t},e.getString=function(e,t){return Is.definedString(e)?e:t},e.getBoolean=function(e,t){return Is.definedBoolean(e)?e:t},e.getNumber=function(e,t){return Is.definedNumber(e)?e:t},e.getFunction=function(e,t){return Is.definedFunction(e)?e:t},e.getArray=t,e.getObject=function(e,t){return Is.definedObject(e)?e:t},e.getStringOrArray=function(e,n){let o=n;if(Is.definedString(e)){const t=e.toString().split(" ");0===t.length?e=n:o=t}else o=t(e,n);return o},e.getFixedDecimalPlacesValue=function(e,t){var n;const o=new RegExp(`^-?\\d+(?:.\\d{0,${t||-1}})?`);return(null==(n=e.toString().match(o))?void 0:n[0])||""},e.getFunctionName=function(e){let t;const n=e.toString().split("(")[0].split(" ");return t=2===n.length?n[1]:n[0],t+="()",t}})(Default||(Default={})),(e=>{function t(e,t,n="",o=null){const r=t.toLowerCase();let l="text"===r?document.createTextNode(""):document.createElement(r);return Is.defined(n)&&(l.className=n),Is.defined(o)?e.insertBefore(l,o):e.appendChild(l),l}function n(){const e=document.documentElement;return{left:e.scrollLeft-(e.clientLeft||0),top:e.scrollTop-(e.clientTop||0)}}e.create=t,e.createWithHTML=function(e,n,o,r,l=null){const i=t(e,n,o,l);return i.innerHTML=r,i},e.addClass=function(e,t){e.classList.add(t)},e.cancelBubble=function(e){e.preventDefault(),e.stopPropagation()},e.getScrollPosition=n,e.showElementAtMousePosition=function(e,t){let o=e.pageX,r=e.pageY;const l=n();t.style.display="block",o+t.offsetWidth>window.innerWidth?o-=t.offsetWidth:o++,r+t.offsetHeight>window.innerHeight?r-=t.offsetHeight:r++,o<l.left&&(o=e.pageX+1),r<l.top&&(r=e.pageY+1),t.style.left=`${o}px`,t.style.top=`${r}px`}})(DomElement||(DomElement={})),Str2=Str||(Str={}),Str2.newGuid=function(){const e=[];for(let t=0;t<32;t++){8!==t&&12!==t&&16!==t&&20!==t||e.push("-");const n=Math.floor(16*Math.random()).toString(16);e.push(n)}return e.join("")},Str2.padNumber=function(e,t=1){const n=e.toString();let o=n;if(n.length<t){const e=t-n.length+1;o=Array(e).join("0")+n}return o},(e=>{function t(e){return e.getDay()-1<0?6:e.getDay()-1}function n(e,t){let n=e.text.thText;return 31===t||21===t||1===t?n=e.text.stText:22===t||2===t?n=e.text.ndText:23!==t&&3!==t||(n=e.text.rdText),n}e.getWeekdayNumber=t,e.getDayOrdinal=n,e.getCustomFormattedDateText=function(e,o,r){let l=r;const i=t(o);return l=l.replace("{hh}",Str.padNumber(o.getHours(),2)),l=l.replace("{h}",o.getHours().toString()),l=l.replace("{MM}",Str.padNumber(o.getMinutes(),2)),l=l.replace("{M}",o.getMinutes().toString()),l=l.replace("{ss}",Str.padNumber(o.getSeconds(),2)),l=l.replace("{s}",o.getSeconds().toString()),l=l.replace("{ff}",Str.padNumber(o.getMilliseconds(),3)),l=l.replace("{f}",o.getMilliseconds().toString()),l=l.replace("{dddd}",e.text.dayNames[i]),l=l.replace("{ddd}",e.text.dayNamesAbbreviated[i]),l=l.replace("{dd}",Str.padNumber(o.getDate())),l=l.replace("{d}",o.getDate().toString()),l=l.replace("{o}",n(e,o.getDate())),l=l.replace("{mmmm}",e.text.monthNames[o.getMonth()]),l=l.replace("{mmm}",e.text.monthNamesAbbreviated[o.getMonth()]),l=l.replace("{mm}",Str.padNumber(o.getMonth()+1)),l=l.replace("{m}",(o.getMonth()+1).toString()),l=l.replace("{yyyy}",o.getFullYear().toString()),l=l.replace("{yyy}",o.getFullYear().toString().substring(1)),l=l.replace("{yy}",o.getFullYear().toString().substring(2)),l=l.replace("{y}",Number.parseInt(o.getFullYear().toString().substring(2)).toString()),l}})(DateTime||(DateTime={})),(Constants||(Constants={})).JSONTREE_JS_ATTRIBUTE_NAME="data-jsontree-js",(e=>{let t;var n;(n=t=e.Options||(e.Options={})).getForNewInstance=function(t,n){const o=e.Options.get(t);return o._currentView={},o._currentView.element=n,o._currentView.dataArrayCurrentIndex=0,o._currentView.titleBarButtons=null,o},n.get=function(e){let t=Default.getObject(e,{});return t.data=Default.getObject(t.data,null),t.showCounts=Default.getBoolean(t.showCounts,!0),t.useZeroIndexingForArrays=Default.getBoolean(t.useZeroIndexingForArrays,!0),t.dateTimeFormat=Default.getString(t.dateTimeFormat,"{dd}{o} {mmmm} {yyyy} {hh}:{MM}:{ss}"),t.showArrowToggles=Default.getBoolean(t.showArrowToggles,!0),t.showStringQuotes=Default.getBoolean(t.showStringQuotes,!0),t.showAllAsClosed=Default.getBoolean(t.showAllAsClosed,!1),t.sortPropertyNames=Default.getBoolean(t.sortPropertyNames,!0),t.sortPropertyNamesInAlphabeticalOrder=Default.getBoolean(t.sortPropertyNamesInAlphabeticalOrder,!0),t.showCommas=Default.getBoolean(t.showCommas,!1),t.reverseArrayValues=Default.getBoolean(t.reverseArrayValues,!1),t.addArrayIndexPadding=Default.getBoolean(t.addArrayIndexPadding,!1),t.showValueColors=Default.getBoolean(t.showValueColors,!0),t.maximumDecimalPlaces=Default.getNumber(t.maximumDecimalPlaces,2),t.maximumStringLength=Default.getNumber(t.maximumStringLength,0),t.showStringHexColors=Default.getBoolean(t.showStringHexColors,!1),t.showArrayItemsAsSeparateObjects=Default.getBoolean(t.showArrayItemsAsSeparateObjects,!1),t.copyOnlyCurrentPage=Default.getBoolean(t.copyOnlyCurrentPage,!1),t.fileDroppingEnabled=Default.getBoolean(t.fileDroppingEnabled,!0),t.copyIndentSpaces=Default.getNumber(t.copyIndentSpaces,2),t.showArrayIndexBrackets=Default.getBoolean(t.showArrayIndexBrackets,!0),t.showOpeningClosingCurlyBraces=Default.getBoolean(t.showOpeningClosingCurlyBraces,!1),t.showOpeningClosingSquaredBrackets=Default.getBoolean(t.showOpeningClosingSquaredBrackets,!1),t=function(e){return e.title=Default.getObject(e.title,{}),e.title.text=Default.getString(e.title.text,"JsonTree.js"),e.title.show=Default.getBoolean(e.title.show,!0),e.title.showTreeControls=Default.getBoolean(e.title.showTreeControls,!0),e.title.showCopyButton=Default.getBoolean(e.title.showCopyButton,!0),e}(t),t=function(e){return e.ignore=Default.getObject(e.ignore,{}),e.ignore.nullValues=Default.getBoolean(e.ignore.nullValues,!1),e.ignore.functionValues=Default.getBoolean(e.ignore.functionValues,!1),e.ignore.unknownValues=Default.getBoolean(e.ignore.unknownValues,!1),e.ignore.booleanValues=Default.getBoolean(e.ignore.booleanValues,!1),e.ignore.decimalValues=Default.getBoolean(e.ignore.decimalValues,!1),e.ignore.numberValues=Default.getBoolean(e.ignore.numberValues,!1),e.ignore.stringValues=Default.getBoolean(e.ignore.stringValues,!1),e.ignore.dateValues=Default.getBoolean(e.ignore.dateValues,!1),e.ignore.objectValues=Default.getBoolean(e.ignore.objectValues,!1),e.ignore.arrayValues=Default.getBoolean(e.ignore.arrayValues,!1),e.ignore.bigIntValues=Default.getBoolean(e.ignore.bigIntValues,!1),e.ignore.symbolValues=Default.getBoolean(e.ignore.symbolValues,!1),e.ignore.emptyObjects=Default.getBoolean(e.ignore.emptyObjects,!0),e.ignore.undefinedValues=Default.getBoolean(e.ignore.undefinedValues,!1),e}(t),t=function(e){return e.tooltip=Default.getObject(e.tooltip,{}),e.tooltip.delay=Default.getNumber(e.tooltip.delay,750),e}(t),t=function(e){return e.parse=Default.getObject(e.parse,{}),e.parse.stringsToDates=Default.getBoolean(e.parse.stringsToDates,!1),e.parse.stringsToBooleans=Default.getBoolean(e.parse.stringsToBooleans,!1),e.parse.stringsToNumbers=Default.getBoolean(e.parse.stringsToNumbers,!1),e}(t),t=function(e){return e.events=Default.getObject(e.events,{}),e.events.onBeforeRender=Default.getFunction(e.events.onBeforeRender,null),e.events.onRenderComplete=Default.getFunction(e.events.onRenderComplete,null),e.events.onValueClick=Default.getFunction(e.events.onValueClick,null),e.events.onRefresh=Default.getFunction(e.events.onRefresh,null),e.events.onCopyAll=Default.getFunction(e.events.onCopyAll,null),e.events.onOpenAll=Default.getFunction(e.events.onOpenAll,null),e.events.onCloseAll=Default.getFunction(e.events.onCloseAll,null),e.events.onDestroy=Default.getFunction(e.events.onDestroy,null),e.events.onBooleanRender=Default.getFunction(e.events.onBooleanRender,null),e.events.onDecimalRender=Default.getFunction(e.events.onDecimalRender,null),e.events.onNumberRender=Default.getFunction(e.events.onNumberRender,null),e.events.onBigIntRender=Default.getFunction(e.events.onBigIntRender,null),e.events.onStringRender=Default.getFunction(e.events.onStringRender,null),e.events.onDateRender=Default.getFunction(e.events.onDateRender,null),e.events.onFunctionRender=Default.getFunction(e.events.onFunctionRender,null),e.events.onNullRender=Default.getFunction(e.events.onNullRender,null),e.events.onUnknownRender=Default.getFunction(e.events.onUnknownRender,null),e.events.onSymbolRender=Default.getFunction(e.events.onSymbolRender,null),e.events.onCopyJsonReplacer=Default.getFunction(e.events.onCopyJsonReplacer,null),e.events.onUndefinedRender=Default.getFunction(e.events.onUndefinedRender,null),e}(t),t}})(Binding||(Binding={})),(e=>{let t;(t=e.Options||(e.Options={})).get=function(e=null){let t=Default.getObject(e,{});return t.safeMode=Default.getBoolean(t.safeMode,!0),t.domElementTypes=Default.getStringOrArray(t.domElementTypes,["*"]),t=function(e){return e.text=Default.getObject(e.text,{}),e.text.objectText=Default.getAnyString(e.text.objectText,"object"),e.text.arrayText=Default.getAnyString(e.text.arrayText,"array"),e.text.closeAllButtonText=Default.getAnyString(e.text.closeAllButtonText,"Close All"),e.text.openAllButtonText=Default.getAnyString(e.text.openAllButtonText,"Open All"),e.text.copyAllButtonText=Default.getAnyString(e.text.copyAllButtonText,"Copy All"),e.text.objectErrorText=Default.getAnyString(e.text.objectErrorText,"Errors in object: {{error_1}}, {{error_2}}"),e.text.attributeNotValidErrorText=Default.getAnyString(e.text.attributeNotValidErrorText,"The attribute '{{attribute_name}}' is not a valid object."),e.text.attributeNotSetErrorText=Default.getAnyString(e.text.attributeNotSetErrorText,"The attribute '{{attribute_name}}' has not been set correctly."),e.text.stText=Default.getAnyString(e.text.stText,"st"),e.text.ndText=Default.getAnyString(e.text.ndText,"nd"),e.text.rdText=Default.getAnyString(e.text.rdText,"rd"),e.text.thText=Default.getAnyString(e.text.thText,"th"),e.text.ellipsisText=Default.getAnyString(e.text.ellipsisText,"..."),e.text.closeAllButtonSymbolText=Default.getAnyString(e.text.closeAllButtonSymbolText,"↑"),e.text.openAllButtonSymbolText=Default.getAnyString(e.text.openAllButtonSymbolText,"↓"),e.text.copyAllButtonSymbolText=Default.getAnyString(e.text.copyAllButtonSymbolText,"❐"),e.text.backButtonText=Default.getAnyString(e.text.backButtonText,"Back"),e.text.nextButtonText=Default.getAnyString(e.text.nextButtonText,"Next"),e.text.backButtonSymbolText=Default.getAnyString(e.text.backButtonSymbolText,"←"),e.text.nextButtonSymbolText=Default.getAnyString(e.text.nextButtonSymbolText,"→"),e.text.noJsonToViewText=Default.getAnyString(e.text.noJsonToViewText,"There is currently no JSON to view."),Is.invalidOptionArray(e.text.dayNames,7)&&(e.text.dayNames=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]),Is.invalidOptionArray(e.text.dayNamesAbbreviated,7)&&(e.text.dayNamesAbbreviated=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]),Is.invalidOptionArray(e.text.monthNames,12)&&(e.text.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"]),Is.invalidOptionArray(e.text.monthNamesAbbreviated,12)&&(e.text.monthNamesAbbreviated=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),e}(t),t}})(Config||(Config={})),(Trigger||(Trigger={})).customEvent=function(e,...t){let n=null;return Is.definedFunction(e)&&(n=e.apply(null,[].slice.call(t,0))),n},(e=>{function t(e,t=!0){let n=t?window.addEventListener:window.removeEventListener,r=t?document.addEventListener:document.removeEventListener;n("mousemove",(()=>{o(e)})),r("scroll",(()=>{o(e)}))}function n(e,t,n){DomElement.cancelBubble(e),o(t),t._currentView.tooltipTimerId=setTimeout((()=>{t._currentView.tooltip.innerHTML=n,t._currentView.tooltip.style.display="block",DomElement.showElementAtMousePosition(e,t._currentView.tooltip)}),t.tooltip.delay)}function o(e){Is.defined(e._currentView.tooltip)&&(0!==e._currentView.tooltipTimerId&&(clearTimeout(e._currentView.tooltipTimerId),e._currentView.tooltipTimerId=0),"none"!==e._currentView.tooltip.style.display&&(e._currentView.tooltip.style.display="none"))}e.renderControl=function(e){Is.defined(e._currentView.tooltip)||(e._currentView.tooltip=DomElement.create(document.body,"div","jsontree-js-tooltip"),e._currentView.tooltip.style.display="none",t(e))},e.assignToEvents=t,e.add=function(e,t,o){null!==e&&(e.onmousemove=e=>{n(e,t,o)})},e.show=n,e.hide=o})(ToolTip||(ToolTip={})),(()=>{let _configuration={},_elements_Data={};function render(){const e=_configuration.domElementTypes,t=e.length;for(let n=0;n<t;n++){const t=document.getElementsByTagName(e[n]),o=[].slice.call(t),r=o.length;for(let e=0;e<r&&renderElement(o[e]);e++);}}function renderElement(e){let t=!0;if(Is.defined(e)&&e.hasAttribute(Constants.JSONTREE_JS_ATTRIBUTE_NAME)){const n=e.getAttribute(Constants.JSONTREE_JS_ATTRIBUTE_NAME);if(Is.definedString(n)){const o=getObjectFromString(n);o.parsed&&Is.definedObject(o.object)?renderControl(Binding.Options.getForNewInstance(o.object,e)):_configuration.safeMode||(console.error(_configuration.text.attributeNotValidErrorText.replace("{{attribute_name}}",Constants.JSONTREE_JS_ATTRIBUTE_NAME)),t=!1)}else _configuration.safeMode||(console.error(_configuration.text.attributeNotSetErrorText.replace("{{attribute_name}}",Constants.JSONTREE_JS_ATTRIBUTE_NAME)),t=!1)}return t}function renderControl(e){Trigger.customEvent(e.events.onBeforeRender,e._currentView.element),ToolTip.renderControl(e),Is.definedString(e._currentView.element.id)||(e._currentView.element.id=Str.newGuid()),e._currentView.element.className="json-tree-js",e._currentView.element.removeAttribute(Constants.JSONTREE_JS_ATTRIBUTE_NAME),_elements_Data.hasOwnProperty(e._currentView.element.id)||(_elements_Data[e._currentView.element.id]=e),renderControlContainer(e),Trigger.customEvent(e.events.onRenderComplete,e._currentView.element)}function renderControlContainer(e){let t=_elements_Data[e._currentView.element.id].data;ToolTip.hide(e),e._currentView.element.innerHTML="",renderControlTitleBar(e,t);const n=DomElement.create(e._currentView.element,"div","contents");makeAreaDroppable(n,e),e.showArrayItemsAsSeparateObjects&&Is.definedArray(t)&&(t=t[e._currentView.dataArrayCurrentIndex]),Is.definedObject(t)&&!Is.definedArray(t)?renderObject(n,e,t,!0):Is.definedArray(t)&&renderArray(n,e,t),""===n.innerHTML?(DomElement.createWithHTML(n,"span","no-json-text",_configuration.text.noJsonToViewText),e._currentView.titleBarButtons.style.display="none"):e._currentView.titleBarButtons.style.display="block"}function renderControlTitleBar(e,t){if(e.title.show||e.title.showTreeControls||e.title.showCopyButton){const n=DomElement.create(e._currentView.element,"div","title-bar");if(e._currentView.titleBarButtons=DomElement.create(n,"div","controls"),e.title.show&&DomElement.createWithHTML(n,"div","title",e.title.text,e._currentView.titleBarButtons),e.title.showCopyButton){const n=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","copy-all",_configuration.text.copyAllButtonSymbolText);ToolTip.add(n,e,_configuration.text.copyAllButtonText),n.onclick=()=>{let n=null,o=jsonStringifyReplacer;Is.definedFunction(e.events.onCopyJsonReplacer)&&(o=e.events.onCopyJsonReplacer),n=e.copyOnlyCurrentPage&&e.showArrayItemsAsSeparateObjects?JSON.stringify(t[e._currentView.dataArrayCurrentIndex],o,e.copyIndentSpaces):JSON.stringify(t,o,e.copyIndentSpaces),navigator.clipboard.writeText(n),Trigger.customEvent(e.events.onCopyAll,n)}}if(e.title.showTreeControls){const t=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","openAll",_configuration.text.openAllButtonSymbolText);ToolTip.add(t,e,_configuration.text.openAllButtonText);const n=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","closeAll",_configuration.text.closeAllButtonSymbolText);ToolTip.add(n,e,_configuration.text.closeAllButtonText),t.onclick=()=>{openAllNodes(e)},n.onclick=()=>{closeAllNodes(e)}}if(e.showArrayItemsAsSeparateObjects&&Is.definedArray(t)&&t.length>1){const n=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","back",_configuration.text.backButtonSymbolText);ToolTip.add(n,e,_configuration.text.backButtonText),e._currentView.dataArrayCurrentIndex>0?n.onclick=()=>{e._currentView.dataArrayCurrentIndex--,renderControlContainer(e),Trigger.customEvent(e.events.onBackPage,e._currentView.element)}:n.disabled=!0;const o=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","next",_configuration.text.nextButtonSymbolText);ToolTip.add(o,e,_configuration.text.nextButtonText),e._currentView.dataArrayCurrentIndex<t.length-1?o.onclick=()=>{e._currentView.dataArrayCurrentIndex++,renderControlContainer(e),Trigger.customEvent(e.events.onNextPage,e._currentView.element)}:o.disabled=!0}else Is.definedArray(t)&&(e.showArrayItemsAsSeparateObjects=!1)}}function jsonStringifyReplacer(e,t){return Is.definedBigInt(t)||Is.definedSymbol(t)?t=t.toString():Is.definedFunction(t)&&(t=Default.getFunctionName(t)),t}function openAllNodes(e){e.showAllAsClosed=!1,renderControlContainer(e),Trigger.customEvent(e.events.onOpenAll,e._currentView.element)}function closeAllNodes(e){e.showAllAsClosed=!0,renderControlContainer(e),Trigger.customEvent(e.events.onCloseAll,e._currentView.element)}function renderObject(e,t,n,o=!1){const r=getObjectPropertyNames(n,t),l=r.length;if(0!==l||!t.ignore.emptyObjects){const i=DomElement.create(e,"div","object-type-title"),a=DomElement.create(e,"div","object-type-contents"),s=t.showArrowToggles?DomElement.create(i,"div","down-arrow"):null,u=DomElement.createWithHTML(i,"span",t.showValueColors?"object":"",_configuration.text.objectText);let c=null;if(o&&t.showArrayItemsAsSeparateObjects){let e=t.useZeroIndexingForArrays?t._currentView.dataArrayCurrentIndex.toString():(t._currentView.dataArrayCurrentIndex+1).toString();t.showArrayIndexBrackets&&(e=`[${e}]:`),DomElement.createWithHTML(i,"span",t.showValueColors?"object data-array-index":"data-array-index",e,u)}t.showCounts&&l>0&&DomElement.createWithHTML(i,"span",t.showValueColors?"object count":"count",`{${l}}`),t.showOpeningClosingCurlyBraces&&(c=DomElement.createWithHTML(i,"span","opening-symbol","{")),renderObjectValues(s,null,a,t,n,r,c,!1,!0)}}function renderArray(e,t,n){const o=DomElement.create(e,"div","object-type-title"),r=DomElement.create(e,"div","object-type-contents"),l=t.showArrowToggles?DomElement.create(o,"div","down-arrow"):null;let i=null;DomElement.createWithHTML(o,"span",t.showValueColors?"array":"",_configuration.text.arrayText),t.showCounts&&DomElement.createWithHTML(o,"span",t.showValueColors?"array count":"count",`[${n.length}]`),t.showOpeningClosingCurlyBraces&&(i=DomElement.createWithHTML(o,"span","opening-symbol","[")),renderArrayValues(l,null,r,t,n,i,!1,!0)}function renderObjectValues(e,t,n,o,r,l,i,a,s){const u=l.length;for(let e=0;e<u;e++){const t=l[e];r.hasOwnProperty(t)&&renderValue(n,o,t,r[t],e===u-1)}o.showOpeningClosingCurlyBraces&&createClosingSymbol(o,n,"}",a,s),addArrowEvent(o,e,t,n,i)}function renderArrayValues(e,t,n,o,r,l,i,a){const s=r.length;if(o.reverseArrayValues)for(let e=s;e--;)renderValue(n,o,getIndexName(o,e,s),r[e],0===e);else for(let e=0;e<s;e++)renderValue(n,o,getIndexName(o,e,s),r[e],e===s-1);o.showOpeningClosingCurlyBraces&&createClosingSymbol(o,n,"]",i,a),addArrowEvent(o,e,t,n,l)}function renderValue(e,t,n,o,r){const l=DomElement.create(e,"div","object-type-value"),i=t.showArrowToggles?DomElement.create(l,"div","no-arrow"):null;let a=null,s=null,u=!1,c=null;if(DomElement.createWithHTML(l,"span","title",n),DomElement.createWithHTML(l,"span","split",":"),null===o)t.ignore.nullValues?u=!0:(a=t.showValueColors?"null":"",s=DomElement.createWithHTML(l,"span",a,"null"),c="null",Is.definedFunction(t.events.onNullRender)&&Trigger.customEvent(t.events.onNullRender,s),createComma(t,l,r));else if(void 0===o)t.ignore.undefinedValues?u=!0:(a=t.showValueColors?"undefined":"",s=DomElement.createWithHTML(l,"span",a,"undefined"),c="undefined",Is.definedFunction(t.events.onUndefinedRender)&&Trigger.customEvent(t.events.onUndefinedRender,s),createComma(t,l,r));else if(Is.definedFunction(o))t.ignore.functionValues?u=!0:(a=t.showValueColors?"function":"",s=DomElement.createWithHTML(l,"span",a,Default.getFunctionName(o)),c="function",Is.definedFunction(t.events.onFunctionRender)&&Trigger.customEvent(t.events.onFunctionRender,s),createComma(t,l,r));else if(Is.definedBoolean(o))t.ignore.booleanValues?u=!0:(a=t.showValueColors?"boolean":"",s=DomElement.createWithHTML(l,"span",a,o),c="boolean",Is.definedFunction(t.events.onBooleanRender)&&Trigger.customEvent(t.events.onBooleanRender,s),createComma(t,l,r));else if(Is.definedDecimal(o))if(t.ignore.decimalValues)u=!0;else{const e=Default.getFixedDecimalPlacesValue(o,t.maximumDecimalPlaces);a=t.showValueColors?"decimal":"",s=DomElement.createWithHTML(l,"span",a,e),c="decimal",Is.definedFunction(t.events.onDecimalRender)&&Trigger.customEvent(t.events.onDecimalRender,s),createComma(t,l,r)}else if(Is.definedNumber(o))t.ignore.numberValues?u=!0:(a=t.showValueColors?"number":"",s=DomElement.createWithHTML(l,"span",a,o),c="number",Is.definedFunction(t.events.onNumberRender)&&Trigger.customEvent(t.events.onNumberRender,s),createComma(t,l,r));else if(Is.definedBigInt(o))t.ignore.bigIntValues?u=!0:(a=t.showValueColors?"bigint":"",s=DomElement.createWithHTML(l,"span",a,o),c="bigint",Is.definedFunction(t.events.onBigIntRender)&&Trigger.customEvent(t.events.onBigIntRender,s),createComma(t,l,r));else if(Is.definedString(o))if(t.ignore.stringValues)u=!0;else if(t.parse.stringsToBooleans&&Is.String.boolean(o))renderValue(e,t,n,"true"===o.toString().toLowerCase().trim(),r),u=!0;else if(t.parse.stringsToNumbers&&!isNaN(o))renderValue(e,t,n,parseFloat(o),r),u=!0;else if(t.parse.stringsToDates&&Is.String.date(o))renderValue(e,t,n,new Date(o),r),u=!0;else{let e=null;t.showValueColors&&t.showStringHexColors&&Is.String.hexColor(o)?e=o:t.maximumStringLength>0&&o.length>t.maximumStringLength&&(o=o.substring(0,t.maximumStringLength)+_configuration.text.ellipsisText);const n=t.showStringQuotes?`"${o}"`:o;a=t.showValueColors?"string":"",s=DomElement.createWithHTML(l,"span",a,n),c="string",Is.definedString(e)&&(s.style.color=e),Is.definedFunction(t.events.onStringRender)&&Trigger.customEvent(t.events.onStringRender,s),createComma(t,l,r)}else if(Is.definedDate(o))t.ignore.dateValues?u=!0:(a=t.showValueColors?"date":"",s=DomElement.createWithHTML(l,"span",a,DateTime.getCustomFormattedDateText(_configuration,o,t.dateTimeFormat)),c="date",Is.definedFunction(t.events.onDateRender)&&Trigger.customEvent(t.events.onDateRender,s),createComma(t,l,r));else if(Is.definedSymbol(o))t.ignore.symbolValues?u=!0:(a=t.showValueColors?"symbol":"",s=DomElement.createWithHTML(l,"span",a,o.toString()),c="symbol",Is.definedFunction(t.events.onSymbolRender)&&Trigger.customEvent(t.events.onSymbolRender,s),createComma(t,l,r));else if(Is.definedObject(o)&&!Is.definedArray(o))if(t.ignore.objectValues)u=!0;else{const e=getObjectPropertyNames(o,t),n=e.length;if(0===n&&t.ignore.emptyObjects)u=!0;else{const a=DomElement.create(l,"span",t.showValueColors?"object":""),s=DomElement.create(l,"div","object-type-contents");let u=null;DomElement.createWithHTML(a,"span","title",_configuration.text.objectText),t.showCounts&&n>0&&DomElement.createWithHTML(a,"span","count",`{${n}}`),t.showOpeningClosingCurlyBraces&&(u=DomElement.createWithHTML(a,"span","opening-symbol","{")),renderObjectValues(i,createComma(t,a,r),s,t,o,e,u,!0,r),c="object"}}else if(Is.definedArray(o))if(t.ignore.arrayValues)u=!0;else{const e=DomElement.create(l,"span",t.showValueColors?"array":""),n=DomElement.create(l,"div","object-type-contents");let a=null;DomElement.createWithHTML(e,"span","title",_configuration.text.arrayText),t.showCounts&&DomElement.createWithHTML(e,"span","count",`[${o.length}]`),t.showOpeningClosingCurlyBraces&&(a=DomElement.createWithHTML(e,"span","opening-symbol","[")),renderArrayValues(i,createComma(t,e,r),n,t,o,a,!0,r),c="array"}else t.ignore.unknownValues?u=!0:(a=t.showValueColors?"unknown":"",s=DomElement.createWithHTML(l,"span",a,o.toString()),c="unknown",Is.definedFunction(t.events.onUnknownRender)&&Trigger.customEvent(t.events.onUnknownRender,s),createComma(t,l,r));u?e.removeChild(l):Is.defined(s)&&addValueClickEvent(t,s,o,c)}function addValueClickEvent(e,t,n,o){Is.definedFunction(e.events.onValueClick)?t.onclick=()=>{Trigger.customEvent(e.events.onValueClick,n,o)}:DomElement.addClass(t,"no-hover")}function addArrowEvent(e,t,n,o,r){if(Is.defined(t)){const l=()=>{o.style.display="none",t.className="right-arrow",Is.defined(r)&&(r.style.display="none"),Is.defined(n)&&(n.style.display="inline-block")},i=()=>{o.style.display="block",t.className="down-arrow",Is.defined(r)&&(r.style.display="inline-block"),Is.defined(n)&&(n.style.display="none")};t.onclick=()=>{"down-arrow"===t.className?l():i()},e.showAllAsClosed?l():i()}}function createComma(e,t,n){let o=null;return e.showCommas&&!n&&(o=DomElement.createWithHTML(t,"span","comma",",")),o}function getIndexName(e,t,n){let o=e.useZeroIndexingForArrays?t.toString():(t+1).toString();return e.addArrayIndexPadding||(o=Str.padNumber(parseInt(o),n.toString().length)),e.showArrayIndexBrackets&&(o=`[${o}]`),o}function getObjectPropertyNames(e,t){let n=[];for(let t in e)e.hasOwnProperty(t)&&n.push(t);if(t.sortPropertyNames){let e=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});n=n.sort(e.compare),t.sortPropertyNamesInAlphabeticalOrder||(n=n.reverse())}return n}function createClosingSymbol(e,t,n,o,r){let l=DomElement.create(t,"div","closing-symbol");o&&DomElement.create(l,"div","no-arrow"),DomElement.createWithHTML(l,"div","object-type-end",n),createComma(e,l,r)}function makeAreaDroppable(e,t){t.fileDroppingEnabled&&(e.ondragover=DomElement.cancelBubble,e.ondragenter=DomElement.cancelBubble,e.ondragleave=DomElement.cancelBubble,e.ondrop=e=>{DomElement.cancelBubble(e),Is.defined(window.FileReader)&&e.dataTransfer.files.length>0&&importFromFiles(e.dataTransfer.files,t)})}function importFromFiles(e,t){const n=e.length;for(let o=0;o<n;o++){const n=e[o];"json"===n.name.split(".").pop().toLowerCase()&&importFromJson(n,t)}}function importFromJson(e,t){const n=new FileReader;let o=null;n.onloadend=()=>{t._currentView.dataArrayCurrentIndex=0,t.data=o,renderControlContainer(t),Trigger.customEvent(t.events.onSetJson,t._currentView.element)},n.onload=e=>{const t=getObjectFromString(e.target.result);t.parsed&&Is.definedObject(t.object)&&(o=t.object)},n.readAsText(e)}function getObjectFromString(objectString){const result={parsed:!0,object:null};try{Is.definedString(objectString)&&(result.object=JSON.parse(objectString))}catch(e1){try{result.object=eval(`(${objectString})`),Is.definedFunction(result.object)&&(result.object=result.object())}catch(e){_configuration.safeMode||(console.error(_configuration.text.objectErrorText.replace("{{error_1}}",e1.message).replace("{{error_2}}",e.message)),result.parsed=!1),result.object=null}}return result}function destroyElement(e){e._currentView.element.innerHTML="",e._currentView.element.className="",ToolTip.assignToEvents(e,!1),Trigger.customEvent(e.events.onDestroy,e._currentView.element)}const _public={refresh:function(e){if(Is.definedString(e)&&_elements_Data.hasOwnProperty(e)){const t=_elements_Data[e];renderControlContainer(t),Trigger.customEvent(t.events.onRefresh,t._currentView.element)}return _public},refreshAll:function(){for(let e in _elements_Data)if(_elements_Data.hasOwnProperty(e)){const t=_elements_Data[e];renderControlContainer(t),Trigger.customEvent(t.events.onRefresh,t._currentView.element)}return _public},render:function(e,t){return Is.definedObject(e)&&Is.definedObject(t)&&renderControl(Binding.Options.getForNewInstance(t,e)),_public},renderAll:function(){return render(),_public},openAll:function(e){return Is.definedString(e)&&_elements_Data.hasOwnProperty(e)&&openAllNodes(_elements_Data[e]),_public},closeAll:function(e){return Is.definedString(e)&&_elements_Data.hasOwnProperty(e)&&closeAllNodes(_elements_Data[e]),_public},setJson:function(e,t){if(Is.definedString(e)&&Is.defined(t)&&_elements_Data.hasOwnProperty(e)){let n=null;if(Is.definedString(t)){const e=getObjectFromString(t);e.parsed&&(n=e.object)}else n=t;const o=_elements_Data[e];o._currentView.dataArrayCurrentIndex=0,o.data=n,renderControlContainer(o),Trigger.customEvent(o.events.onSetJson,o._currentView.element)}return _public},getJson:function(e){let t=null;return Is.definedString(e)&&_elements_Data.hasOwnProperty(e)&&(t=_elements_Data[e].data),t},destroy:function(e){return Is.definedString(e)&&_elements_Data.hasOwnProperty(e)&&(destroyElement(_elements_Data[e]),delete _elements_Data[e]),_public},destroyAll:function(){for(let e in _elements_Data)_elements_Data.hasOwnProperty(e)&&destroyElement(_elements_Data[e]);return _elements_Data={},_public},setConfiguration:function(e){if(Is.definedObject(e)){let t=!1;const n=_configuration;for(let o in e)e.hasOwnProperty(o)&&_configuration.hasOwnProperty(o)&&n[o]!==e[o]&&(n[o]=e[o],t=!0);t&&(_configuration=Config.Options.get(n))}return _public},getIds:function(){const e=[];for(let t in _elements_Data)_elements_Data.hasOwnProperty(t)&&e.push(t);return e},getVersion:function(){return"2.4.0"}};_configuration=Config.Options.get(),document.addEventListener("DOMContentLoaded",(function(){render()})),Is.defined(window.$jsontree)||(window.$jsontree=_public)})(); |
@@ -5,3 +5,3 @@ { | ||
"description": "A lightweight JavaScript library that generates customizable tree views to better visualize JSON data.", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"homepage": "https://www.william-troup.com/jsontree-js/", | ||
@@ -43,5 +43,5 @@ "author": { | ||
"devDependencies": { | ||
"@swc/core": "^1.7.5", | ||
"@swc/core": "^1.7.6", | ||
"sass": "^1.77.8", | ||
"terser": "^5.31.3", | ||
"terser": "^5.31.4", | ||
"tsup": "^8.2.4", | ||
@@ -48,0 +48,0 @@ "typescript": "^5.5.4" |
@@ -5,4 +5,4 @@ <h1 align="center"> | ||
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=JsonTree.js%2C%20a%20free%20JavaScript%json%20treeview&url=https://github.com/williamtroup/JsonTree.js&hashtags=javascript,treeview,json) | ||
[![npm](https://img.shields.io/badge/npmjs-v2.3.0-blue)](https://www.npmjs.com/package/jjsontree.js) | ||
[![nuget](https://img.shields.io/badge/nuget-v2.3.0-purple)](https://www.nuget.org/packages/jJsonTree.js/) | ||
[![npm](https://img.shields.io/badge/npmjs-v2.4.0-blue)](https://www.npmjs.com/package/jjsontree.js) | ||
[![nuget](https://img.shields.io/badge/nuget-v2.4.0-purple)](https://www.nuget.org/packages/jJsonTree.js/) | ||
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/JsonTree.js/blob/main/LICENSE.txt) | ||
@@ -14,3 +14,3 @@ [![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/JsonTree.js/discussions) | ||
> <p align="center">🔗 A lightweight JavaScript library that generates customizable tree views to better visualize JSON data.</p> | ||
> <p align="center">v2.3.0</p> | ||
> <p align="center">v2.4.0</p> | ||
<br /> | ||
@@ -28,3 +28,3 @@ | ||
- Fully styled in CSS/SASS, fully responsive, and compatible with the Bootstrap library! | ||
- Full CSS theme support (using :root variables). | ||
- Full CSS theme support (using :root variables), with dark and light themes. | ||
- 11 types supported by default (with unknown type support). | ||
@@ -68,2 +68,3 @@ - Fully configurable per DOM element! | ||
- `function` Functions | ||
- `undefined` Undefined | ||
- `any` Unknown | ||
@@ -92,4 +93,4 @@ <br> | ||
```markdown | ||
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@2.3.0/dist/jsontree.min.js | ||
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@2.3.0/dist/jsontree.js.min.css | ||
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@2.4.0/dist/jsontree.min.js | ||
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@2.4.0/dist/jsontree.js.min.css | ||
``` | ||
@@ -96,0 +97,0 @@ <br> |
@@ -7,3 +7,3 @@ /** | ||
* @file jsontree.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -175,8 +175,13 @@ * @license MIT License | ||
let copyData: string = null!; | ||
let replaceFunction: any = jsonStringifyReplacer; | ||
if ( Is.definedFunction( bindingOptions.events!.onCopyJsonReplacer ) ) { | ||
replaceFunction = bindingOptions.events!.onCopyJsonReplacer!; | ||
} | ||
if ( bindingOptions.copyOnlyCurrentPage && bindingOptions.showArrayItemsAsSeparateObjects ) { | ||
copyData = JSON.stringify( data[ bindingOptions._currentView.dataArrayCurrentIndex ], jsonStringifyReplacer, bindingOptions.copyIndentSpaces ); | ||
copyData = JSON.stringify( data[ bindingOptions._currentView.dataArrayCurrentIndex ], replaceFunction, bindingOptions.copyIndentSpaces ); | ||
} | ||
else { | ||
copyData = JSON.stringify( data, jsonStringifyReplacer, bindingOptions.copyIndentSpaces ); | ||
copyData = JSON.stringify( data, replaceFunction, bindingOptions.copyIndentSpaces ); | ||
} | ||
@@ -284,13 +289,11 @@ | ||
function renderObject( container: HTMLElement, bindingOptions: BindingOptions, data: any, showPagingIndex: boolean = false ) : void { | ||
const objectTypeTitle: HTMLElement = DomElement.create( container, "div", "object-type-title" ); | ||
const objectTypeContents: HTMLElement = DomElement.create( container, "div", "object-type-contents" ); | ||
const arrow: HTMLElement = bindingOptions.showArrowToggles ? DomElement.create( objectTypeTitle, "div", "down-arrow" ) : null!; | ||
const propertyCount: number = renderObjectValues( arrow, objectTypeContents, bindingOptions, data ); | ||
const propertyNames: string[] = getObjectPropertyNames( data, bindingOptions ); | ||
const propertyCount: number = propertyNames.length; | ||
if ( propertyCount === 0 && bindingOptions.ignore!.emptyObjects ) { | ||
container.removeChild( objectTypeTitle ); | ||
container.removeChild( objectTypeContents ); | ||
} else { | ||
if ( propertyCount !== 0 || !bindingOptions.ignore!.emptyObjects ) { | ||
const objectTypeTitle: HTMLElement = DomElement.create( container, "div", "object-type-title" ); | ||
const objectTypeContents: HTMLElement = DomElement.create( container, "div", "object-type-contents" ); | ||
const arrow: HTMLElement = bindingOptions.showArrowToggles ? DomElement.create( objectTypeTitle, "div", "down-arrow" ) : null!; | ||
const titleText: HTMLSpanElement = DomElement.createWithHTML( objectTypeTitle, "span", bindingOptions.showValueColors ? "object" : Char.empty, _configuration.text!.objectText! ) as HTMLSpanElement; | ||
let openingBrace: HTMLSpanElement = null!; | ||
@@ -310,2 +313,8 @@ if ( showPagingIndex && bindingOptions.showArrayItemsAsSeparateObjects ) { | ||
} | ||
if ( bindingOptions.showOpeningClosingCurlyBraces ) { | ||
openingBrace = DomElement.createWithHTML( objectTypeTitle, "span", "opening-symbol", "{" ) as HTMLSpanElement | ||
} | ||
renderObjectValues( arrow, null!, objectTypeContents, bindingOptions, data, propertyNames, openingBrace, false, true ); | ||
} | ||
@@ -318,52 +327,36 @@ } | ||
const arrow: HTMLElement = bindingOptions.showArrowToggles ? DomElement.create( objectTypeTitle, "div", "down-arrow" ) : null!; | ||
let openingBracket: HTMLSpanElement = null!; | ||
DomElement.createWithHTML( objectTypeTitle, "span", bindingOptions.showValueColors ? "array" : Char.empty, _configuration.text!.arrayText! ); | ||
renderArrayValues( arrow, objectTypeContents, bindingOptions, data ); | ||
if ( bindingOptions.showCounts ) { | ||
DomElement.createWithHTML( objectTypeTitle, "span", bindingOptions.showValueColors ? "array count" : "count", `[${data.length}]` ); | ||
} | ||
} | ||
function renderObjectValues( arrow: HTMLElement, objectTypeContents: HTMLElement, bindingOptions: BindingOptions, data: any ) : number { | ||
let propertyCount: number = 0; | ||
let properties: string[] = []; | ||
for ( let key in data ) { | ||
if ( data.hasOwnProperty( key ) ) { | ||
properties.push( key ); | ||
} | ||
if ( bindingOptions.showOpeningClosingCurlyBraces ) { | ||
openingBracket = DomElement.createWithHTML( objectTypeTitle, "span", "opening-symbol", "[" ) as HTMLSpanElement | ||
} | ||
if ( bindingOptions.sortPropertyNames ) { | ||
let collator: Intl.Collator = new Intl.Collator( undefined, { | ||
numeric: true, | ||
sensitivity: "base" | ||
} ); | ||
renderArrayValues( arrow, null!, objectTypeContents, bindingOptions, data, openingBracket, false, true ); | ||
} | ||
properties = properties.sort( collator.compare ); | ||
function renderObjectValues( arrow: HTMLElement, coma: HTMLSpanElement, objectTypeContents: HTMLElement, bindingOptions: BindingOptions, data: any, propertyNames: string[], openingBrace: HTMLSpanElement, addNoArrowToClosingSymbol: boolean, isLastItem: boolean ) : void { | ||
const propertiesLength: number = propertyNames.length; | ||
if ( !bindingOptions.sortPropertyNamesInAlphabeticalOrder ) { | ||
properties = properties.reverse(); | ||
} | ||
} | ||
const propertiesLength: number = properties.length; | ||
for ( let propertyIndex: number = 0; propertyIndex < propertiesLength; propertyIndex++ ) { | ||
const propertyName: string = properties[ propertyIndex ]; | ||
const propertyName: string = propertyNames[ propertyIndex ]; | ||
if ( data.hasOwnProperty( propertyName ) ) { | ||
renderValue( objectTypeContents, bindingOptions, propertyName, data[ propertyName ], propertyIndex === propertiesLength - 1 ); | ||
propertyCount++; | ||
} | ||
} | ||
addArrowEvent( bindingOptions, arrow, objectTypeContents ); | ||
if ( bindingOptions.showOpeningClosingCurlyBraces ) { | ||
createClosingSymbol( bindingOptions, objectTypeContents, "}", addNoArrowToClosingSymbol, isLastItem ); | ||
} | ||
return propertyCount; | ||
addArrowEvent( bindingOptions, arrow, coma, objectTypeContents, openingBrace ); | ||
} | ||
function renderArrayValues( arrow: HTMLElement, objectTypeContents: HTMLElement, bindingOptions: BindingOptions, data: any ) : void { | ||
function renderArrayValues( arrow: HTMLElement, coma: HTMLSpanElement, objectTypeContents: HTMLElement, bindingOptions: BindingOptions, data: any, openingBracket: HTMLSpanElement, addNoArrowToClosingSymbol: boolean, isLastItem: boolean ) : void { | ||
const dataLength: number = data.length; | ||
@@ -382,3 +375,7 @@ | ||
addArrowEvent( bindingOptions, arrow, objectTypeContents ); | ||
if ( bindingOptions.showOpeningClosingCurlyBraces ) { | ||
createClosingSymbol( bindingOptions, objectTypeContents, "]", addNoArrowToClosingSymbol, isLastItem ); | ||
} | ||
addArrowEvent( bindingOptions, arrow, coma, objectTypeContents, openingBracket ); | ||
} | ||
@@ -397,3 +394,3 @@ | ||
if ( !Is.defined( value ) ) { | ||
if ( value === null ) { | ||
if ( !bindingOptions.ignore!.nullValues ) { | ||
@@ -414,2 +411,18 @@ valueClass = bindingOptions.showValueColors ? "null" : Char.empty; | ||
} else if ( value === undefined ) { | ||
if ( !bindingOptions.ignore!.undefinedValues ) { | ||
valueClass = bindingOptions.showValueColors ? "undefined" : Char.empty; | ||
valueElement = DomElement.createWithHTML( objectTypeValue, "span", valueClass, "undefined" ); | ||
type = DataType.undefined; | ||
if ( Is.definedFunction( bindingOptions.events!.onUndefinedRender ) ) { | ||
Trigger.customEvent( bindingOptions.events!.onUndefinedRender!, valueElement ); | ||
} | ||
createComma( bindingOptions, objectTypeValue, isLastItem ); | ||
} else { | ||
ignored = true; | ||
} | ||
} else if ( Is.definedFunction( value ) ) { | ||
@@ -499,3 +512,3 @@ if ( !bindingOptions.ignore!.functionValues ) { | ||
if ( !bindingOptions.ignore!.stringValues ) { | ||
if ( bindingOptions.parse!.stringsToBooleans && Is.stringValueBoolean( value ) ) { | ||
if ( bindingOptions.parse!.stringsToBooleans && Is.String.boolean( value ) ) { | ||
renderValue( container, bindingOptions, name, value.toString().toLowerCase().trim() === "true", isLastItem ); | ||
@@ -508,3 +521,3 @@ ignored = true; | ||
} else if ( bindingOptions.parse!.stringsToDates && Is.stringValueDate( value ) ) { | ||
} else if ( bindingOptions.parse!.stringsToDates && Is.String.date( value ) ) { | ||
renderValue( container, bindingOptions, name, new Date( value ), isLastItem ); | ||
@@ -516,3 +529,3 @@ ignored = true; | ||
if ( bindingOptions.showValueColors && bindingOptions.showStringHexColors && Is.hexColor( value ) ) { | ||
if ( bindingOptions.showValueColors && bindingOptions.showStringHexColors && Is.String.hexColor( value ) ) { | ||
color = value; | ||
@@ -581,5 +594,4 @@ | ||
if ( !bindingOptions.ignore!.objectValues ) { | ||
const objectTitle: HTMLElement = DomElement.create( objectTypeValue, "span", bindingOptions.showValueColors ? "object" : Char.empty ); | ||
const objectTypeContents: HTMLElement = DomElement.create( objectTypeValue, "div", "object-type-contents" ); | ||
const propertyCount: number = renderObjectValues( arrow, objectTypeContents, bindingOptions, value ); | ||
const propertyNames: string[] = getObjectPropertyNames( value, bindingOptions ); | ||
const propertyCount: number = propertyNames.length; | ||
@@ -590,2 +602,6 @@ if ( propertyCount === 0 && bindingOptions.ignore!.emptyObjects ) { | ||
const objectTitle: HTMLElement = DomElement.create( objectTypeValue, "span", bindingOptions.showValueColors ? "object" : Char.empty ); | ||
const objectTypeContents: HTMLElement = DomElement.create( objectTypeValue, "div", "object-type-contents" ); | ||
let openingBrace: HTMLSpanElement = null!; | ||
DomElement.createWithHTML( objectTitle, "span", "title", _configuration.text!.objectText! ); | ||
@@ -596,4 +612,10 @@ | ||
} | ||
if ( bindingOptions.showOpeningClosingCurlyBraces ) { | ||
openingBrace = DomElement.createWithHTML( objectTitle, "span", "opening-symbol", "{" ) as HTMLSpanElement | ||
} | ||
createComma( bindingOptions, objectTitle, isLastItem ); | ||
let coma: HTMLSpanElement = createComma( bindingOptions, objectTitle, isLastItem ); | ||
renderObjectValues( arrow, coma, objectTypeContents, bindingOptions, value, propertyNames, openingBrace, true, isLastItem ); | ||
@@ -612,2 +634,3 @@ type = DataType.object; | ||
const arrayTypeContents: HTMLElement = DomElement.create( objectTypeValue, "div", "object-type-contents" ); | ||
let openingBracket: HTMLSpanElement = null!; | ||
@@ -620,5 +643,10 @@ DomElement.createWithHTML( arrayTitle, "span", "title", _configuration.text!.arrayText! ); | ||
createComma( bindingOptions, arrayTitle, isLastItem ); | ||
renderArrayValues( arrow, arrayTypeContents, bindingOptions, value ); | ||
if ( bindingOptions.showOpeningClosingCurlyBraces ) { | ||
openingBracket = DomElement.createWithHTML( arrayTitle, "span", "opening-symbol", "[" ) as HTMLSpanElement | ||
} | ||
let coma: HTMLSpanElement = createComma( bindingOptions, arrayTitle, isLastItem ); | ||
renderArrayValues( arrow, coma, arrayTypeContents, bindingOptions, value, openingBracket, true, isLastItem ); | ||
type = DataType.array; | ||
@@ -668,11 +696,35 @@ | ||
function addArrowEvent( bindingOptions: BindingOptions, arrow: HTMLElement, objectTypeContents: HTMLElement ) : void { | ||
function addArrowEvent( bindingOptions: BindingOptions, arrow: HTMLElement, coma: HTMLSpanElement, objectTypeContents: HTMLElement, openingSymbol: HTMLSpanElement ) : void { | ||
if ( Is.defined( arrow ) ) { | ||
const hideFunc: Function = () => { | ||
objectTypeContents.style.display = "none"; | ||
arrow.className = "right-arrow"; | ||
if ( Is.defined( openingSymbol ) ) { | ||
openingSymbol.style.display = "none"; | ||
} | ||
if ( Is.defined( coma ) ) { | ||
coma.style.display = "inline-block"; | ||
} | ||
}; | ||
const showFunc: Function = () => { | ||
objectTypeContents.style.display = "block"; | ||
arrow.className = "down-arrow"; | ||
if ( Is.defined( openingSymbol ) ) { | ||
openingSymbol.style.display = "inline-block"; | ||
} | ||
if ( Is.defined( coma ) ) { | ||
coma.style.display = "none"; | ||
} | ||
}; | ||
arrow.onclick = () => { | ||
if ( arrow.className === "down-arrow" ) { | ||
objectTypeContents.style.display = "none"; | ||
arrow.className = "right-arrow"; | ||
hideFunc(); | ||
} else { | ||
objectTypeContents.style.display = "block"; | ||
arrow.className = "down-arrow"; | ||
showFunc(); | ||
} | ||
@@ -682,6 +734,5 @@ }; | ||
if ( bindingOptions.showAllAsClosed ) { | ||
objectTypeContents.style.display = "none"; | ||
arrow.className = "right-arrow"; | ||
hideFunc(); | ||
} else { | ||
arrow.className = "down-arrow"; | ||
showFunc(); | ||
} | ||
@@ -691,6 +742,10 @@ } | ||
function createComma( bindingOptions: BindingOptions, objectTypeValue: HTMLElement, isLastItem: boolean ) : void { | ||
function createComma( bindingOptions: BindingOptions, objectTypeValue: HTMLElement, isLastItem: boolean ) : HTMLSpanElement { | ||
let result: HTMLSpanElement = null!; | ||
if ( bindingOptions.showCommas && !isLastItem ) { | ||
DomElement.createWithHTML( objectTypeValue, "span", "comma", "," ); | ||
result = DomElement.createWithHTML( objectTypeValue, "span", "comma", "," ) as HTMLSpanElement; | ||
} | ||
return result; | ||
} | ||
@@ -712,3 +767,40 @@ | ||
function getObjectPropertyNames( data: any, bindingOptions: BindingOptions ) : string[] { | ||
let properties: string[] = []; | ||
for ( let key in data ) { | ||
if ( data.hasOwnProperty( key ) ) { | ||
properties.push( key ); | ||
} | ||
} | ||
if ( bindingOptions.sortPropertyNames ) { | ||
let collator: Intl.Collator = new Intl.Collator( undefined, { | ||
numeric: true, | ||
sensitivity: "base" | ||
} ); | ||
properties = properties.sort( collator.compare ); | ||
if ( !bindingOptions.sortPropertyNamesInAlphabeticalOrder ) { | ||
properties = properties.reverse(); | ||
} | ||
} | ||
return properties; | ||
} | ||
function createClosingSymbol( bindingOptions: BindingOptions, container: HTMLElement, symbol: string, addNoArrow: boolean, isLastItem: boolean ) : void { | ||
let symbolContainer: HTMLElement = DomElement.create( container, "div", "closing-symbol" ); | ||
if ( addNoArrow ) { | ||
DomElement.create( symbolContainer, "div", "no-arrow" ); | ||
} | ||
DomElement.createWithHTML( symbolContainer, "div", "object-type-end", symbol ); | ||
createComma( bindingOptions, symbolContainer, isLastItem ) | ||
} | ||
/* | ||
@@ -1014,3 +1106,3 @@ * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
getVersion: function () : string { | ||
return "2.3.0"; | ||
return "2.4.0"; | ||
} | ||
@@ -1017,0 +1109,0 @@ }; |
@@ -7,3 +7,3 @@ /** | ||
* @file api.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -10,0 +10,0 @@ * @license MIT License |
@@ -7,3 +7,3 @@ /** | ||
* @file tooltip.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -10,0 +10,0 @@ * @license MIT License |
@@ -7,3 +7,3 @@ /** | ||
* @file trigger.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -10,0 +10,0 @@ * @license MIT License |
@@ -7,3 +7,3 @@ /** | ||
* @file constant.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -10,0 +10,0 @@ * @license MIT License |
@@ -7,3 +7,3 @@ /** | ||
* @file datetime.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -50,2 +50,5 @@ * @license MIT License | ||
result = result.replace( "{s}", date.getSeconds().toString() ); | ||
result = result.replace( "{ff}", Str.padNumber( date.getMilliseconds(), 3 ) ); | ||
result = result.replace( "{f}", date.getMilliseconds().toString() ); | ||
@@ -52,0 +55,0 @@ result = result.replace( "{dddd}", configuration.text!.dayNames![ weekDayNumber ] ); |
@@ -7,3 +7,3 @@ /** | ||
* @file default.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -10,0 +10,0 @@ * @license MIT License |
@@ -7,3 +7,3 @@ /** | ||
* @file enum.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -36,2 +36,3 @@ * @license MIT License | ||
unknown = "unknown", | ||
undefined = "undefined", | ||
} |
@@ -7,3 +7,3 @@ /** | ||
* @file is.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -19,2 +19,22 @@ * @license MIT License | ||
export namespace Is { | ||
export namespace String { | ||
export function hexColor( value: string ) : boolean { | ||
let valid: boolean = value.length >= 2 && value.length <= 7; | ||
if ( valid && value[ 0 ] === Char.hash ) { | ||
valid = isNaN( +value.substring( 1, value.length - 1 ) ); | ||
} | ||
return valid; | ||
} | ||
export function boolean( object: string ) : boolean { | ||
return object.toString().toLowerCase().trim() === "true" || object.toString().toLowerCase().trim() === "false"; | ||
} | ||
export function date( dateTimeString: string ) { | ||
return !isNaN( +new Date( dateTimeString ) ); | ||
} | ||
} | ||
export function defined( value: any ) : boolean { | ||
@@ -67,20 +87,2 @@ return value !== null && value !== undefined && value.toString() !== Char.empty; | ||
} | ||
export function hexColor( value: string ) : boolean { | ||
let valid: boolean = value.length >= 2 && value.length <= 7; | ||
if ( valid && value[ 0 ] === Char.hash ) { | ||
valid = isNaN( +value.substring( 1, value.length - 1 ) ); | ||
} | ||
return valid; | ||
} | ||
export function stringValueBoolean( object: string ) : boolean { | ||
return object.toString().toLowerCase().trim() === "true" || object.toString().toLowerCase().trim() === "false"; | ||
} | ||
export function stringValueDate( dateTimeString: string ) { | ||
return !isNaN( +new Date( dateTimeString ) ); | ||
} | ||
} |
@@ -7,3 +7,3 @@ /** | ||
* @file str.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -10,0 +10,0 @@ * @license MIT License |
@@ -7,3 +7,3 @@ /** | ||
* @file dom.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -10,0 +10,0 @@ * @license MIT License |
@@ -7,3 +7,3 @@ /** | ||
* @file binding.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -16,5 +16,5 @@ * @license MIT License | ||
import { | ||
BindingOptionsCurrentView, | ||
BindingOptionsParse, | ||
BindingOptionsTooltip, | ||
type BindingOptionsCurrentView, | ||
type BindingOptionsParse, | ||
type BindingOptionsTooltip, | ||
type BindingOptions, | ||
@@ -63,2 +63,4 @@ type BindingOptionsEvents, | ||
options.showArrayIndexBrackets = Default.getBoolean( options.showArrayIndexBrackets, true ); | ||
options.showOpeningClosingCurlyBraces = Default.getBoolean( options.showOpeningClosingCurlyBraces, false ); | ||
options.showOpeningClosingSquaredBrackets = Default.getBoolean( options.showOpeningClosingSquaredBrackets, false ); | ||
@@ -99,2 +101,3 @@ options = getTitle( options ); | ||
options.ignore!.emptyObjects = Default.getBoolean( options.ignore!.emptyObjects, true ); | ||
options.ignore!.undefinedValues = Default.getBoolean( options.ignore!.undefinedValues, false ); | ||
@@ -140,2 +143,4 @@ return options; | ||
options.events!.onSymbolRender = Default.getFunction( options.events!.onSymbolRender, null! ); | ||
options.events!.onCopyJsonReplacer = Default.getFunction( options.events!.onCopyJsonReplacer, null! ); | ||
options.events!.onUndefinedRender = Default.getFunction( options.events!.onUndefinedRender, null! ); | ||
@@ -142,0 +147,0 @@ return options; |
@@ -7,3 +7,3 @@ /** | ||
* @file config.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -15,3 +15,3 @@ * @license MIT License | ||
import { ConfigurationText, type Configuration } from "../type"; | ||
import { type ConfigurationText, type Configuration } from "../type"; | ||
import { Default } from "../data/default"; | ||
@@ -18,0 +18,0 @@ import { Is } from "../data/is"; |
@@ -7,3 +7,3 @@ /** | ||
* @file type.ts | ||
* @version v2.3.0 | ||
* @version v2.4.0 | ||
* @author Bunoon | ||
@@ -77,2 +77,4 @@ * @license MIT License | ||
showArrayIndexBrackets?: boolean; | ||
showOpeningClosingCurlyBraces?: boolean; | ||
showOpeningClosingSquaredBrackets?: boolean; | ||
title?: BindingOptionsTitle; | ||
@@ -120,2 +122,3 @@ ignore?: BindingOptionsIgnore; | ||
emptyObjects?: boolean; | ||
undefinedValues?: boolean; | ||
}; | ||
@@ -146,5 +149,7 @@ | ||
onSymbolRender?: ( element: HTMLElement ) => void; | ||
onUndefinedRender?: ( element: HTMLElement ) => void; | ||
onBackPage?: ( element: HTMLElement ) => void; | ||
onNextPage?: ( element: HTMLElement ) => void; | ||
onSetJson?: ( element: HTMLElement ) => void; | ||
onCopyJsonReplacer?: ( key: string, value: any ) => any; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
548874
33
4870
168