Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jjsontree.js

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jjsontree.js - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

277

dist/jsontree.esm.js

@@ -46,10 +46,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;

e.definedFunction = i;
function l(e) {
function a(e) {
return t(e) && typeof e === "number";
}
e.definedNumber = l;
function a(e) {
e.definedNumber = a;
function l(e) {
return n(e) && e instanceof Array;
}
e.definedArray = a;
e.definedArray = l;
function s(e) {

@@ -64,3 +64,3 @@ return n(e) && e instanceof Date;

function c(e, t = 1) {
return !a(e) || e.length < t;
return !l(e) || e.length < t;
}

@@ -108,10 +108,10 @@ e.invalidOptionArray = c;

e.getFunction = i;
function l(e, t) {
function a(e, t) {
return Is.definedArray(e) ? e : t;
}
e.getArray = l;
function a(e, t) {
e.getArray = a;
function l(e, t) {
return Is.definedObject(e) ? e : t;
}
e.getObject = a;
e.getObject = l;
function s(e, t) {

@@ -127,3 +127,3 @@ let n = t;

} else {
n = l(e, t);
n = a(e, t);
}

@@ -167,18 +167,18 @@ return n;

const i = o === "text";
let l = i ? document.createTextNode("") : document.createElement(o);
let a = i ? document.createTextNode("") : document.createElement(o);
if (Is.defined(n)) {
l.className = n;
a.className = n;
}
if (Is.defined(r)) {
e.insertBefore(l, r);
e.insertBefore(a, r);
} else {
e.appendChild(l);
e.appendChild(a);
}
return l;
return a;
}
e.create = t;
function n(e, n, r, o, i = null) {
const l = t(e, n, r, i);
l.innerHTML = o;
return l;
const a = t(e, n, r, i);
a.innerHTML = o;
return a;
}

@@ -190,2 +190,7 @@ e.createWithHTML = n;

e.addClass = r;
function o(e) {
e.preventDefault();
e.stopPropagation();
}
e.cancelBubble = o;
})(DomElement || (DomElement = {}));

@@ -253,3 +258,3 @@ }

let i = o;
const l = t(r);
const a = t(r);
i = i.replace("{hh}", Str.padNumber(r.getHours(), 2));

@@ -261,4 +266,4 @@ i = i.replace("{h}", r.getHours().toString());

i = i.replace("{s}", r.getSeconds().toString());
i = i.replace("{dddd}", e.text.dayNames[l]);
i = i.replace("{ddd}", e.text.dayNamesAbbreviated[l]);
i = i.replace("{dddd}", e.text.dayNames[a]);
i = i.replace("{ddd}", e.text.dayNamesAbbreviated[a]);
i = i.replace("{dd}", Str.padNumber(r.getDate()));

@@ -278,2 +283,6 @@ i = i.replace("{d}", r.getDate().toString());

e.getCustomFormattedDateText = r;
function o(e) {
return !isNaN(+new Date(e));
}
e.isDateValid = o;
})(DateTime || (DateTime = {}));

@@ -308,2 +317,3 @@ }

r._currentView.dataArrayCurrentIndex = 0;
r._currentView.titleBarButtons = null;
return r;

@@ -332,5 +342,8 @@ }

t.copyOnlyCurrentPage = Default.getBoolean(t.copyOnlyCurrentPage, false);
t.fileDroppingEnabled = Default.getBoolean(t.fileDroppingEnabled, true);
t.parseStringsToDates = Default.getBoolean(t.parseStringsToDates, false);
t.copyIndentSpaces = Default.getNumber(t.copyIndentSpaces, 2);
t = o(t);
t = i(t);
t = l(t);
t = a(t);
return t;

@@ -361,3 +374,3 @@ }

}
function l(e) {
function a(e) {
e.events = Default.getObject(e.events, {});

@@ -427,2 +440,3 @@ e.events.onBeforeRender = Default.getFunction(e.events.onBeforeRender, null);

e.text.nextButtonSymbolText = Default.getAnyString(e.text.nextButtonSymbolText, "→");
e.text.noJsonToViewText = Default.getAnyString(e.text.noJsonToViewText, "There is currently no JSON to view.");
if (Is.invalidOptionArray(e.text.dayNames, 7)) {

@@ -535,10 +549,18 @@ e.text.dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ];

renderControlTitleBar(e, t);
if (e.showArrayItemsAsSeparateObjects) {
const n = DomElement.create(e._currentView.element, "div", "contents");
makeAreaDroppable(n, e);
if (e.showArrayItemsAsSeparateObjects && Is.definedArray(t)) {
t = t[e._currentView.dataArrayCurrentIndex];
}
if (Is.definedObject(t) && !Is.definedArray(t)) {
renderObject(e._currentView.element, e, t, true);
renderObject(n, e, t, true);
} else if (Is.definedArray(t)) {
renderArray(e._currentView.element, e, t);
renderArray(n, e, t);
}
if (n.innerHTML === "") {
DomElement.createWithHTML(n, "span", "no-json-text", _configuration.text.noJsonToViewText);
e._currentView.titleBarButtons.style.display = "none";
} else {
e._currentView.titleBarButtons.style.display = "block";
}
}

@@ -548,24 +570,24 @@ function renderControlTitleBar(e, t) {

const n = DomElement.create(e._currentView.element, "div", "title-bar");
const r = DomElement.create(n, "div", "controls");
e._currentView.titleBarButtons = DomElement.create(n, "div", "controls");
if (e.title.show) {
DomElement.createWithHTML(n, "div", "title", e.title.text, r);
DomElement.createWithHTML(n, "div", "title", e.title.text, e._currentView.titleBarButtons);
}
if (e.title.showCopyButton) {
const t = DomElement.createWithHTML(r, "button", "copy-all", _configuration.text.copyAllButtonSymbolText);
t.title = _configuration.text.copyAllButtonText;
t.onclick = () => {
let t = null;
const n = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "copy-all", _configuration.text.copyAllButtonSymbolText);
n.title = _configuration.text.copyAllButtonText;
n.onclick = () => {
let n = null;
if (e.copyOnlyCurrentPage && e.showArrayItemsAsSeparateObjects) {
t = JSON.stringify(_elements_Data[e._currentView.element.id].data[e._currentView.dataArrayCurrentIndex], null, 2);
n = JSON.stringify(t[e._currentView.dataArrayCurrentIndex], null, e.copyIndentSpaces);
} else {
t = JSON.stringify(_elements_Data[e._currentView.element.id].data, null, 2);
n = JSON.stringify(t, null, e.copyIndentSpaces);
}
navigator.clipboard.writeText(t);
Trigger.customEvent(e.events.onCopyAll, t);
navigator.clipboard.writeText(n);
Trigger.customEvent(e.events.onCopyAll, n);
};
}
if (e.title.showTreeControls) {
const t = DomElement.createWithHTML(r, "button", "openAll", _configuration.text.openAllButtonSymbolText);
const t = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "openAll", _configuration.text.openAllButtonSymbolText);
t.title = _configuration.text.openAllButtonText;
const n = DomElement.createWithHTML(r, "button", "closeAll", _configuration.text.closeAllButtonSymbolText);
const n = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "closeAll", _configuration.text.closeAllButtonSymbolText);
n.title = _configuration.text.closeAllButtonText;

@@ -580,3 +602,3 @@ t.onclick = () => {

if (e.showArrayItemsAsSeparateObjects && Is.definedArray(t) && t.length > 1) {
const n = DomElement.createWithHTML(r, "button", "back", _configuration.text.backButtonSymbolText);
const n = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "back", _configuration.text.backButtonSymbolText);
n.title = _configuration.text.backButtonText;

@@ -587,2 +609,3 @@ if (e._currentView.dataArrayCurrentIndex > 0) {

renderControlContainer(e);
Trigger.customEvent(e.events.onBackPage, e._currentView.element);
};

@@ -592,14 +615,17 @@ } else {

}
const o = DomElement.createWithHTML(r, "button", "next", _configuration.text.nextButtonSymbolText);
o.title = _configuration.text.nextButtonText;
const r = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "next", _configuration.text.nextButtonSymbolText);
r.title = _configuration.text.nextButtonText;
if (e._currentView.dataArrayCurrentIndex < t.length - 1) {
o.onclick = () => {
r.onclick = () => {
e._currentView.dataArrayCurrentIndex++;
renderControlContainer(e);
Trigger.customEvent(e.events.onNextPage, e._currentView.element);
};
} else {
o.disabled = true;
r.disabled = true;
}
} else {
e.showArrayItemsAsSeparateObjects = false;
if (Is.definedArray(t)) {
e.showArrayItemsAsSeparateObjects = false;
}
}

@@ -621,4 +647,4 @@ }

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);
const a = t.showArrowToggles ? DomElement.create(o, "div", "down-arrow") : null;
const l = renderObjectValues(a, i, t, n);
const s = DomElement.createWithHTML(o, "span", t.showValueColors ? "object" : "", _configuration.text.objectText);

@@ -629,4 +655,4 @@ if (r && t.showArrayItemsAsSeparateObjects) {

}
if (t.showCounts && a > 0) {
DomElement.createWithHTML(o, "span", t.showValueColors ? "object count" : "count", `{${a}}`);
if (t.showCounts && l > 0) {
DomElement.createWithHTML(o, "span", t.showValueColors ? "object count" : "count", `{${l}}`);
}

@@ -658,7 +684,7 @@ }

}
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);
const a = i.length;
for (let e = 0; e < a; e++) {
const l = i[e];
if (r.hasOwnProperty(l)) {
renderValue(t, n, l, r[l], e === a - 1);
o++;

@@ -685,4 +711,4 @@ }

const i = DomElement.create(e, "div", "object-type-value");
const l = t.showArrowToggles ? DomElement.create(i, "div", "no-arrow") : null;
let a = null;
const a = t.showArrowToggles ? DomElement.create(i, "div", "no-arrow") : null;
let l = null;
let s = null;

@@ -696,4 +722,4 @@ let u = false;

if (!t.ignore.nullValues) {
a = t.showValueColors ? "null" : "";
s = DomElement.createWithHTML(i, "span", a, "null");
l = t.showValueColors ? "null" : "";
s = DomElement.createWithHTML(i, "span", l, "null");
d = false;

@@ -709,4 +735,4 @@ if (Is.definedFunction(t.events.onNullRender)) {

if (!t.ignore.functionValues) {
a = t.showValueColors ? "function" : "";
s = DomElement.createWithHTML(i, "span", a, Default.getFunctionName(r));
l = t.showValueColors ? "function" : "";
s = DomElement.createWithHTML(i, "span", l, Default.getFunctionName(r));
c = "function";

@@ -722,4 +748,4 @@ if (Is.definedFunction(t.events.onFunctionRender)) {

if (!t.ignore.booleanValues) {
a = t.showValueColors ? "boolean" : "";
s = DomElement.createWithHTML(i, "span", a, r);
l = t.showValueColors ? "boolean" : "";
s = DomElement.createWithHTML(i, "span", l, r);
c = "boolean";

@@ -736,4 +762,4 @@ if (Is.definedFunction(t.events.onBooleanRender)) {

const e = Default.getFixedDecimalPlacesValue(r, t.maximumDecimalPlaces);
a = t.showValueColors ? "decimal" : "";
s = DomElement.createWithHTML(i, "span", a, e);
l = t.showValueColors ? "decimal" : "";
s = DomElement.createWithHTML(i, "span", l, e);
c = "decimal";

@@ -749,4 +775,4 @@ if (Is.definedFunction(t.events.onDecimalRender)) {

if (!t.ignore.numberValues) {
a = t.showValueColors ? "number" : "";
s = DomElement.createWithHTML(i, "span", a, r);
l = t.showValueColors ? "number" : "";
s = DomElement.createWithHTML(i, "span", l, r);
c = "number";

@@ -762,21 +788,26 @@ if (Is.definedFunction(t.events.onNumberRender)) {

if (!t.ignore.stringValues) {
let e = null;
if (t.showValueColors && t.showStringHexColors && Is.hexColor(r)) {
e = r;
if (t.parseStringsToDates && DateTime.isDateValid(r)) {
renderValue(e, t, n, new Date(r), o);
u = true;
} else {
if (t.maximumStringLength > 0 && r.length > t.maximumStringLength) {
r = r.substring(0, t.maximumStringLength) + _configuration.text.ellipsisText;
let e = null;
if (t.showValueColors && t.showStringHexColors && Is.hexColor(r)) {
e = r;
} else {
if (t.maximumStringLength > 0 && r.length > t.maximumStringLength) {
r = r.substring(0, t.maximumStringLength) + _configuration.text.ellipsisText;
}
}
const n = t.showStringQuotes ? `"${r}"` : r;
l = t.showValueColors ? "string" : "";
s = DomElement.createWithHTML(i, "span", l, n);
c = "string";
if (Is.definedString(e)) {
s.style.color = e;
}
if (Is.definedFunction(t.events.onStringRender)) {
Trigger.customEvent(t.events.onStringRender, s);
}
createComma(t, i, o);
}
const n = t.showStringQuotes ? `"${r}"` : r;
a = t.showValueColors ? "string" : "";
s = DomElement.createWithHTML(i, "span", a, n);
c = "string";
if (Is.definedString(e)) {
s.style.color = e;
}
if (Is.definedFunction(t.events.onStringRender)) {
Trigger.customEvent(t.events.onStringRender, s);
}
createComma(t, i, o);
} else {

@@ -787,4 +818,4 @@ u = true;

if (!t.ignore.dateValues) {
a = t.showValueColors ? "date" : "";
s = DomElement.createWithHTML(i, "span", a, DateTime.getCustomFormattedDateText(_configuration, r, t.dateTimeFormat));
l = t.showValueColors ? "date" : "";
s = DomElement.createWithHTML(i, "span", l, DateTime.getCustomFormattedDateText(_configuration, r, t.dateTimeFormat));
c = "date";

@@ -802,6 +833,6 @@ if (Is.definedFunction(t.events.onDateRender)) {

const n = DomElement.create(i, "div", "object-type-contents");
const a = renderObjectValues(l, n, t, r);
const l = renderObjectValues(a, n, t, r);
DomElement.createWithHTML(e, "span", "title", _configuration.text.objectText);
if (t.showCounts && a > 0) {
DomElement.createWithHTML(e, "span", "count", `{${a}}`);
if (t.showCounts && l > 0) {
DomElement.createWithHTML(e, "span", "count", `{${l}}`);
}

@@ -822,3 +853,3 @@ createComma(t, e, o);

createComma(t, e, o);
renderArrayValues(l, n, t, r);
renderArrayValues(a, n, t, r);
c = "array";

@@ -830,4 +861,4 @@ } else {

if (!t.ignore.unknownValues) {
a = t.showValueColors ? "unknown" : "";
s = DomElement.createWithHTML(i, "span", a, r.toString());
l = t.showValueColors ? "unknown" : "";
s = DomElement.createWithHTML(i, "span", l, r.toString());
c = "unknown";

@@ -890,2 +921,42 @@ if (Is.definedFunction(t.events.onUnknownRender)) {

}
function makeAreaDroppable(e, t) {
if (t.fileDroppingEnabled) {
e.ondragover = DomElement.cancelBubble;
e.ondragenter = DomElement.cancelBubble;
e.ondragleave = DomElement.cancelBubble;
e.ondrop = e => {
DomElement.cancelBubble(e);
if (Is.defined(window.FileReader) && e.dataTransfer.files.length > 0) {
importFromFiles(e.dataTransfer.files, t);
}
};
}
}
function importFromFiles(e, t) {
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") {
importFromJson(n, t);
}
}
}
function importFromJson(e, t) {
const n = new FileReader;
let r = null;
n.onloadend = () => {
t._currentView.dataArrayCurrentIndex = 0;
t.data = r;
renderControlContainer(t);
Trigger.customEvent(t.events.onSetJson, t._currentView.element);
};
n.onload = e => {
const t = getObjectFromString(e.target.result);
if (t.parsed && Is.definedObject(t.object)) {
r = t.object;
}
};
n.readAsText(e);
}
function getObjectFromString(objectString) {

@@ -962,2 +1033,28 @@ const result = {

},
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);
if (e.parsed) {
n = e.object;
}
} else {
n = t;
}
const r = _elements_Data[e];
r._currentView.dataArrayCurrentIndex = 0;
r.data = n;
renderControlContainer(r);
Trigger.customEvent(r.events.onSetJson, r._currentView.element);
}
return _public;
},
getJson: function(e) {
let t = null;
if (Is.definedString(e) && _elements_Data.hasOwnProperty(e)) {
t = _elements_Data[e].data;
}
return t;
},
destroy: function(e) {

@@ -1005,3 +1102,3 @@ if (Is.definedString(e) && _elements_Data.hasOwnProperty(e)) {

getVersion: function() {
return "2.1.0";
return "2.2.0";
}

@@ -1008,0 +1105,0 @@ };

@@ -151,2 +151,7 @@ "use strict";

e.addClass = r;
function o(e) {
e.preventDefault();
e.stopPropagation();
}
e.cancelBubble = o;
})(DomElement || (DomElement = {}));

@@ -225,2 +230,6 @@

e.getCustomFormattedDateText = r;
function o(e) {
return !isNaN(+new Date(e));
}
e.isDateValid = o;
})(DateTime || (DateTime = {}));

@@ -244,2 +253,3 @@

r._currentView.dataArrayCurrentIndex = 0;
r._currentView.titleBarButtons = null;
return r;

@@ -268,2 +278,5 @@ }

t.copyOnlyCurrentPage = Default.getBoolean(t.copyOnlyCurrentPage, false);
t.fileDroppingEnabled = Default.getBoolean(t.fileDroppingEnabled, true);
t.parseStringsToDates = Default.getBoolean(t.parseStringsToDates, false);
t.copyIndentSpaces = Default.getNumber(t.copyIndentSpaces, 2);
t = o(t);

@@ -355,2 +368,3 @@ t = l(t);

e.text.nextButtonSymbolText = Default.getAnyString(e.text.nextButtonSymbolText, "→");
e.text.noJsonToViewText = Default.getAnyString(e.text.noJsonToViewText, "There is currently no JSON to view.");
if (Is.invalidOptionArray(e.text.dayNames, 7)) {

@@ -443,10 +457,18 @@ e.text.dayNames = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ];

renderControlTitleBar(e, t);
if (e.showArrayItemsAsSeparateObjects) {
const n = DomElement.create(e._currentView.element, "div", "contents");
makeAreaDroppable(n, e);
if (e.showArrayItemsAsSeparateObjects && Is.definedArray(t)) {
t = t[e._currentView.dataArrayCurrentIndex];
}
if (Is.definedObject(t) && !Is.definedArray(t)) {
renderObject(e._currentView.element, e, t, true);
renderObject(n, e, t, true);
} else if (Is.definedArray(t)) {
renderArray(e._currentView.element, e, t);
renderArray(n, e, t);
}
if (n.innerHTML === "") {
DomElement.createWithHTML(n, "span", "no-json-text", _configuration.text.noJsonToViewText);
e._currentView.titleBarButtons.style.display = "none";
} else {
e._currentView.titleBarButtons.style.display = "block";
}
}

@@ -456,24 +478,24 @@ function renderControlTitleBar(e, t) {

const n = DomElement.create(e._currentView.element, "div", "title-bar");
const r = DomElement.create(n, "div", "controls");
e._currentView.titleBarButtons = DomElement.create(n, "div", "controls");
if (e.title.show) {
DomElement.createWithHTML(n, "div", "title", e.title.text, r);
DomElement.createWithHTML(n, "div", "title", e.title.text, e._currentView.titleBarButtons);
}
if (e.title.showCopyButton) {
const t = DomElement.createWithHTML(r, "button", "copy-all", _configuration.text.copyAllButtonSymbolText);
t.title = _configuration.text.copyAllButtonText;
t.onclick = () => {
let t = null;
const n = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "copy-all", _configuration.text.copyAllButtonSymbolText);
n.title = _configuration.text.copyAllButtonText;
n.onclick = () => {
let n = null;
if (e.copyOnlyCurrentPage && e.showArrayItemsAsSeparateObjects) {
t = JSON.stringify(_elements_Data[e._currentView.element.id].data[e._currentView.dataArrayCurrentIndex], null, 2);
n = JSON.stringify(t[e._currentView.dataArrayCurrentIndex], null, e.copyIndentSpaces);
} else {
t = JSON.stringify(_elements_Data[e._currentView.element.id].data, null, 2);
n = JSON.stringify(t, null, e.copyIndentSpaces);
}
navigator.clipboard.writeText(t);
Trigger.customEvent(e.events.onCopyAll, t);
navigator.clipboard.writeText(n);
Trigger.customEvent(e.events.onCopyAll, n);
};
}
if (e.title.showTreeControls) {
const t = DomElement.createWithHTML(r, "button", "openAll", _configuration.text.openAllButtonSymbolText);
const t = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "openAll", _configuration.text.openAllButtonSymbolText);
t.title = _configuration.text.openAllButtonText;
const n = DomElement.createWithHTML(r, "button", "closeAll", _configuration.text.closeAllButtonSymbolText);
const n = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "closeAll", _configuration.text.closeAllButtonSymbolText);
n.title = _configuration.text.closeAllButtonText;

@@ -488,3 +510,3 @@ t.onclick = () => {

if (e.showArrayItemsAsSeparateObjects && Is.definedArray(t) && t.length > 1) {
const n = DomElement.createWithHTML(r, "button", "back", _configuration.text.backButtonSymbolText);
const n = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "back", _configuration.text.backButtonSymbolText);
n.title = _configuration.text.backButtonText;

@@ -495,2 +517,3 @@ if (e._currentView.dataArrayCurrentIndex > 0) {

renderControlContainer(e);
Trigger.customEvent(e.events.onBackPage, e._currentView.element);
};

@@ -500,14 +523,17 @@ } else {

}
const o = DomElement.createWithHTML(r, "button", "next", _configuration.text.nextButtonSymbolText);
o.title = _configuration.text.nextButtonText;
const r = DomElement.createWithHTML(e._currentView.titleBarButtons, "button", "next", _configuration.text.nextButtonSymbolText);
r.title = _configuration.text.nextButtonText;
if (e._currentView.dataArrayCurrentIndex < t.length - 1) {
o.onclick = () => {
r.onclick = () => {
e._currentView.dataArrayCurrentIndex++;
renderControlContainer(e);
Trigger.customEvent(e.events.onNextPage, e._currentView.element);
};
} else {
o.disabled = true;
r.disabled = true;
}
} else {
e.showArrayItemsAsSeparateObjects = false;
if (Is.definedArray(t)) {
e.showArrayItemsAsSeparateObjects = false;
}
}

@@ -661,21 +687,26 @@ }

if (!t.ignore.stringValues) {
let e = null;
if (t.showValueColors && t.showStringHexColors && Is.hexColor(r)) {
e = r;
if (t.parseStringsToDates && DateTime.isDateValid(r)) {
renderValue(e, t, n, new Date(r), o);
u = true;
} else {
if (t.maximumStringLength > 0 && r.length > t.maximumStringLength) {
r = r.substring(0, t.maximumStringLength) + _configuration.text.ellipsisText;
let e = null;
if (t.showValueColors && t.showStringHexColors && Is.hexColor(r)) {
e = r;
} else {
if (t.maximumStringLength > 0 && r.length > t.maximumStringLength) {
r = r.substring(0, t.maximumStringLength) + _configuration.text.ellipsisText;
}
}
const n = t.showStringQuotes ? `"${r}"` : r;
i = t.showValueColors ? "string" : "";
s = DomElement.createWithHTML(l, "span", i, n);
c = "string";
if (Is.definedString(e)) {
s.style.color = e;
}
if (Is.definedFunction(t.events.onStringRender)) {
Trigger.customEvent(t.events.onStringRender, s);
}
createComma(t, l, o);
}
const n = t.showStringQuotes ? `"${r}"` : r;
i = t.showValueColors ? "string" : "";
s = DomElement.createWithHTML(l, "span", i, n);
c = "string";
if (Is.definedString(e)) {
s.style.color = e;
}
if (Is.definedFunction(t.events.onStringRender)) {
Trigger.customEvent(t.events.onStringRender, s);
}
createComma(t, l, o);
} else {

@@ -785,2 +816,42 @@ u = true;

}
function makeAreaDroppable(e, t) {
if (t.fileDroppingEnabled) {
e.ondragover = DomElement.cancelBubble;
e.ondragenter = DomElement.cancelBubble;
e.ondragleave = DomElement.cancelBubble;
e.ondrop = e => {
DomElement.cancelBubble(e);
if (Is.defined(window.FileReader) && e.dataTransfer.files.length > 0) {
importFromFiles(e.dataTransfer.files, t);
}
};
}
}
function importFromFiles(e, t) {
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") {
importFromJson(n, t);
}
}
}
function importFromJson(e, t) {
const n = new FileReader;
let r = null;
n.onloadend = () => {
t._currentView.dataArrayCurrentIndex = 0;
t.data = r;
renderControlContainer(t);
Trigger.customEvent(t.events.onSetJson, t._currentView.element);
};
n.onload = e => {
const t = getObjectFromString(e.target.result);
if (t.parsed && Is.definedObject(t.object)) {
r = t.object;
}
};
n.readAsText(e);
}
function getObjectFromString(objectString) {

@@ -857,2 +928,28 @@ const result = {

},
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);
if (e.parsed) {
n = e.object;
}
} else {
n = t;
}
const r = _elements_Data[e];
r._currentView.dataArrayCurrentIndex = 0;
r.data = n;
renderControlContainer(r);
Trigger.customEvent(r.events.onSetJson, r._currentView.element);
}
return _public;
},
getJson: function(e) {
let t = null;
if (Is.definedString(e) && _elements_Data.hasOwnProperty(e)) {
t = _elements_Data[e].data;
}
return t;
},
destroy: function(e) {

@@ -900,3 +997,3 @@ if (Is.definedString(e) && _elements_Data.hasOwnProperty(e)) {

getVersion: function() {
return "2.1.0";
return "2.2.0";
}

@@ -903,0 +1000,0 @@ };

@@ -1,1 +0,1 @@

"use strict";var Is,Default,DomElement,Str,Str2,DateTime,Constants,Binding,Config,Trigger;(e=>{function t(e){return null!=e&&""!==e.toString()}function n(e){return t(e)&&"object"==typeof e}function r(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.definedArray=r,e.definedDate=function(e){return n(e)&&e instanceof Date},e.definedDecimal=function(e){return t(e)&&"number"==typeof e&&e%1!=0},e.invalidOptionArray=function(e,t=1){return!r(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}})(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 r=n;if(Is.definedString(e)){const t=e.toString().split(" ");0===t.length?e=n:r=t}else r=t(e,n);return r},e.getFixedDecimalPlacesValue=function(e,t){var n;const r=new RegExp(`^-?\\d+(?:.\\d{0,${t||-1}})?`);return(null==(n=e.toString().match(r))?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="",r=null){const o=t.toLowerCase();let l="text"===o?document.createTextNode(""):document.createElement(o);return Is.defined(n)&&(l.className=n),Is.defined(r)?e.insertBefore(l,r):e.appendChild(l),l}e.create=t,e.createWithHTML=function(e,n,r,o,l=null){const a=t(e,n,r,l);return a.innerHTML=o,a},e.addClass=function(e,t){e.classList.add(t)}})(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 r=n;if(n.length<t){const e=t-n.length+1;r=Array(e).join("0")+n}return r},(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,r,o){let l=o;const a=t(r);return 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()),l=l.replace("{dddd}",e.text.dayNames[a]),l=l.replace("{ddd}",e.text.dayNamesAbbreviated[a]),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}})(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 r=e.Options.get(t);return r._currentView={},r._currentView.element=n,r._currentView.dataArrayCurrentIndex=0,r},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=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}(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.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}(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,"→"),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},(()=>{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]),r=[].slice.call(t),o=r.length;for(let e=0;e<o&&renderElement(r[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 r=getObjectFromString(n);r.parsed&&Is.definedObject(r.object)?renderControl(Binding.Options.getForNewInstance(r.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),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;e._currentView.element.innerHTML="",renderControlTitleBar(e,t),e.showArrayItemsAsSeparateObjects&&(t=t[e._currentView.dataArrayCurrentIndex]),Is.definedObject(t)&&!Is.definedArray(t)?renderObject(e._currentView.element,e,t,!0):Is.definedArray(t)&&renderArray(e._currentView.element,e,t)}function renderControlTitleBar(e,t){if(e.title.show||e.title.showTreeControls||e.title.showCopyButton){const n=DomElement.create(e._currentView.element,"div","title-bar"),r=DomElement.create(n,"div","controls");if(e.title.show&&DomElement.createWithHTML(n,"div","title",e.title.text,r),e.title.showCopyButton){const t=DomElement.createWithHTML(r,"button","copy-all",_configuration.text.copyAllButtonSymbolText);t.title=_configuration.text.copyAllButtonText,t.onclick=()=>{let t=null;t=e.copyOnlyCurrentPage&&e.showArrayItemsAsSeparateObjects?JSON.stringify(_elements_Data[e._currentView.element.id].data[e._currentView.dataArrayCurrentIndex],null,2):JSON.stringify(_elements_Data[e._currentView.element.id].data,null,2),navigator.clipboard.writeText(t),Trigger.customEvent(e.events.onCopyAll,t)}}if(e.title.showTreeControls){const t=DomElement.createWithHTML(r,"button","openAll",_configuration.text.openAllButtonSymbolText);t.title=_configuration.text.openAllButtonText;const n=DomElement.createWithHTML(r,"button","closeAll",_configuration.text.closeAllButtonSymbolText);n.title=_configuration.text.closeAllButtonText,t.onclick=()=>{openAllNodes(e)},n.onclick=()=>{closeAllNodes(e)}}if(e.showArrayItemsAsSeparateObjects&&Is.definedArray(t)&&t.length>1){const n=DomElement.createWithHTML(r,"button","back",_configuration.text.backButtonSymbolText);n.title=_configuration.text.backButtonText,e._currentView.dataArrayCurrentIndex>0?n.onclick=()=>{e._currentView.dataArrayCurrentIndex--,renderControlContainer(e)}:n.disabled=!0;const o=DomElement.createWithHTML(r,"button","next",_configuration.text.nextButtonSymbolText);o.title=_configuration.text.nextButtonText,e._currentView.dataArrayCurrentIndex<t.length-1?o.onclick=()=>{e._currentView.dataArrayCurrentIndex++,renderControlContainer(e)}:o.disabled=!0}else e.showArrayItemsAsSeparateObjects=!1}}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,r=!1){const o=DomElement.create(e,"div","object-type-title"),l=DomElement.create(e,"div","object-type-contents"),a=renderObjectValues(t.showArrowToggles?DomElement.create(o,"div","down-arrow"):null,l,t,n),i=DomElement.createWithHTML(o,"span",t.showValueColors?"object":"",_configuration.text.objectText);if(r&&t.showArrayItemsAsSeparateObjects){let e=t.useZeroIndexingForArrays?t._currentView.dataArrayCurrentIndex.toString():(t._currentView.dataArrayCurrentIndex+1).toString();DomElement.createWithHTML(o,"span",t.showValueColors?"object data-array-index":"data-array-index",`[${e}]:`,i)}t.showCounts&&a>0&&DomElement.createWithHTML(o,"span",t.showValueColors?"object count":"count",`{${a}}`)}function renderArray(e,t,n){const r=DomElement.create(e,"div","object-type-title"),o=DomElement.create(e,"div","object-type-contents"),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),t.showCounts&&DomElement.createWithHTML(r,"span",t.showValueColors?"array count":"count",`[${n.length}]`)}function renderObjectValues(e,t,n,r){let o=0,l=[];for(let e in r)r.hasOwnProperty(e)&&l.push(e);n.sortPropertyNames&&(l=l.sort(),n.sortPropertyNamesInAlphabeticalOrder||(l=l.reverse()));const a=l.length;for(let e=0;e<a;e++){const i=l[e];r.hasOwnProperty(i)&&(renderValue(t,n,i,r[i],e===a-1),o++)}return addArrowEvent(n,e,t),o}function renderArrayValues(e,t,n,r){const o=r.length;if(n.reverseArrayValues)for(let e=o;e--;)renderValue(t,n,getIndexName(n,e,o),r[e],0===e);else for(let e=0;e<o;e++)renderValue(t,n,getIndexName(n,e,o),r[e],e===o-1);addArrowEvent(n,e,t)}function renderValue(e,t,n,r,o){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,d=!0;if(DomElement.createWithHTML(l,"span","title",n),DomElement.createWithHTML(l,"span","split",":"),Is.defined(r))if(Is.definedFunction(r))t.ignore.functionValues?u=!0:(i=t.showValueColors?"function":"",s=DomElement.createWithHTML(l,"span",i,Default.getFunctionName(r)),c="function",Is.definedFunction(t.events.onFunctionRender)&&Trigger.customEvent(t.events.onFunctionRender,s),createComma(t,l,o));else if(Is.definedBoolean(r))t.ignore.booleanValues?u=!0:(i=t.showValueColors?"boolean":"",s=DomElement.createWithHTML(l,"span",i,r),c="boolean",Is.definedFunction(t.events.onBooleanRender)&&Trigger.customEvent(t.events.onBooleanRender,s),createComma(t,l,o));else if(Is.definedDecimal(r))if(t.ignore.decimalValues)u=!0;else{const e=Default.getFixedDecimalPlacesValue(r,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,o)}else if(Is.definedNumber(r))t.ignore.numberValues?u=!0:(i=t.showValueColors?"number":"",s=DomElement.createWithHTML(l,"span",i,r),c="number",Is.definedFunction(t.events.onNumberRender)&&Trigger.customEvent(t.events.onNumberRender,s),createComma(t,l,o));else if(Is.definedString(r))if(t.ignore.stringValues)u=!0;else{let e=null;t.showValueColors&&t.showStringHexColors&&Is.hexColor(r)?e=r:t.maximumStringLength>0&&r.length>t.maximumStringLength&&(r=r.substring(0,t.maximumStringLength)+_configuration.text.ellipsisText);const n=t.showStringQuotes?`"${r}"`:r;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,o)}else if(Is.definedDate(r))t.ignore.dateValues?u=!0:(i=t.showValueColors?"date":"",s=DomElement.createWithHTML(l,"span",i,DateTime.getCustomFormattedDateText(_configuration,r,t.dateTimeFormat)),c="date",Is.definedFunction(t.events.onDateRender)&&Trigger.customEvent(t.events.onDateRender,s),createComma(t,l,o));else if(Is.definedObject(r)&&!Is.definedArray(r))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,r);DomElement.createWithHTML(e,"span","title",_configuration.text.objectText),t.showCounts&&n>0&&DomElement.createWithHTML(e,"span","count",`{${n}}`),createComma(t,e,o),c="object"}else if(Is.definedArray(r))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",`[${r.length}]`),createComma(t,e,o),renderArrayValues(a,n,t,r),c="array"}else t.ignore.unknownValues?u=!0:(i=t.showValueColors?"unknown":"",s=DomElement.createWithHTML(l,"span",i,r.toString()),c="unknown",Is.definedFunction(t.events.onUnknownRender)&&Trigger.customEvent(t.events.onUnknownRender,s),createComma(t,l,o));else t.ignore.nullValues?u=!0:(i=t.showValueColors?"null":"",s=DomElement.createWithHTML(l,"span",i,"null"),d=!1,Is.definedFunction(t.events.onNullRender)&&Trigger.customEvent(t.events.onNullRender,s),createComma(t,l,o));u?e.removeChild(l):Is.defined(s)&&addValueClickEvent(t,s,r,c,d)}function addValueClickEvent(e,t,n,r,o){o&&Is.definedFunction(e.events.onValueClick)?t.onclick=()=>{Trigger.customEvent(e.events.onValueClick,n,r)}: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 r=e.useZeroIndexingForArrays?t.toString():(t+1).toString();return e.addArrayIndexPadding||(r=Str.padNumber(parseInt(r),n.toString().length)),`[${r}]`}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="",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},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 r in e)e.hasOwnProperty(r)&&_configuration.hasOwnProperty(r)&&n[r]!==e[r]&&(n[r]=e[r],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.1.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;(e=>{function t(e){return null!=e&&""!==e.toString()}function n(e){return t(e)&&"object"==typeof e}function r(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.definedArray=r,e.definedDate=function(e){return n(e)&&e instanceof Date},e.definedDecimal=function(e){return t(e)&&"number"==typeof e&&e%1!=0},e.invalidOptionArray=function(e,t=1){return!r(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}})(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 r=n;if(Is.definedString(e)){const t=e.toString().split(" ");0===t.length?e=n:r=t}else r=t(e,n);return r},e.getFixedDecimalPlacesValue=function(e,t){var n;const r=new RegExp(`^-?\\d+(?:.\\d{0,${t||-1}})?`);return(null==(n=e.toString().match(r))?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="",r=null){const o=t.toLowerCase();let l="text"===o?document.createTextNode(""):document.createElement(o);return Is.defined(n)&&(l.className=n),Is.defined(r)?e.insertBefore(l,r):e.appendChild(l),l}e.create=t,e.createWithHTML=function(e,n,r,o,l=null){const a=t(e,n,r,l);return a.innerHTML=o,a},e.addClass=function(e,t){e.classList.add(t)},e.cancelBubble=function(e){e.preventDefault(),e.stopPropagation()}})(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 r=n;if(n.length<t){const e=t-n.length+1;r=Array(e).join("0")+n}return r},(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,r,o){let l=o;const a=t(r);return 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()),l=l.replace("{dddd}",e.text.dayNames[a]),l=l.replace("{ddd}",e.text.dayNamesAbbreviated[a]),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},e.isDateValid=function(e){return!isNaN(+new Date(e))}})(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 r=e.Options.get(t);return r._currentView={},r._currentView.element=n,r._currentView.dataArrayCurrentIndex=0,r._currentView.titleBarButtons=null,r},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.parseStringsToDates=Default.getBoolean(t.parseStringsToDates,!1),t.copyIndentSpaces=Default.getNumber(t.copyIndentSpaces,2),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}(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.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}(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},(()=>{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]),r=[].slice.call(t),o=r.length;for(let e=0;e<o&&renderElement(r[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 r=getObjectFromString(n);r.parsed&&Is.definedObject(r.object)?renderControl(Binding.Options.getForNewInstance(r.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),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;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);n.title=_configuration.text.copyAllButtonText,n.onclick=()=>{let n=null;n=e.copyOnlyCurrentPage&&e.showArrayItemsAsSeparateObjects?JSON.stringify(t[e._currentView.dataArrayCurrentIndex],null,e.copyIndentSpaces):JSON.stringify(t,null,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);t.title=_configuration.text.openAllButtonText;const n=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","closeAll",_configuration.text.closeAllButtonSymbolText);n.title=_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);n.title=_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 r=DomElement.createWithHTML(e._currentView.titleBarButtons,"button","next",_configuration.text.nextButtonSymbolText);r.title=_configuration.text.nextButtonText,e._currentView.dataArrayCurrentIndex<t.length-1?r.onclick=()=>{e._currentView.dataArrayCurrentIndex++,renderControlContainer(e),Trigger.customEvent(e.events.onNextPage,e._currentView.element)}:r.disabled=!0}else Is.definedArray(t)&&(e.showArrayItemsAsSeparateObjects=!1)}}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,r=!1){const o=DomElement.create(e,"div","object-type-title"),l=DomElement.create(e,"div","object-type-contents"),a=renderObjectValues(t.showArrowToggles?DomElement.create(o,"div","down-arrow"):null,l,t,n),i=DomElement.createWithHTML(o,"span",t.showValueColors?"object":"",_configuration.text.objectText);if(r&&t.showArrayItemsAsSeparateObjects){let e=t.useZeroIndexingForArrays?t._currentView.dataArrayCurrentIndex.toString():(t._currentView.dataArrayCurrentIndex+1).toString();DomElement.createWithHTML(o,"span",t.showValueColors?"object data-array-index":"data-array-index",`[${e}]:`,i)}t.showCounts&&a>0&&DomElement.createWithHTML(o,"span",t.showValueColors?"object count":"count",`{${a}}`)}function renderArray(e,t,n){const r=DomElement.create(e,"div","object-type-title"),o=DomElement.create(e,"div","object-type-contents"),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),t.showCounts&&DomElement.createWithHTML(r,"span",t.showValueColors?"array count":"count",`[${n.length}]`)}function renderObjectValues(e,t,n,r){let o=0,l=[];for(let e in r)r.hasOwnProperty(e)&&l.push(e);n.sortPropertyNames&&(l=l.sort(),n.sortPropertyNamesInAlphabeticalOrder||(l=l.reverse()));const a=l.length;for(let e=0;e<a;e++){const i=l[e];r.hasOwnProperty(i)&&(renderValue(t,n,i,r[i],e===a-1),o++)}return addArrowEvent(n,e,t),o}function renderArrayValues(e,t,n,r){const o=r.length;if(n.reverseArrayValues)for(let e=o;e--;)renderValue(t,n,getIndexName(n,e,o),r[e],0===e);else for(let e=0;e<o;e++)renderValue(t,n,getIndexName(n,e,o),r[e],e===o-1);addArrowEvent(n,e,t)}function renderValue(e,t,n,r,o){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,d=!0;if(DomElement.createWithHTML(l,"span","title",n),DomElement.createWithHTML(l,"span","split",":"),Is.defined(r))if(Is.definedFunction(r))t.ignore.functionValues?u=!0:(i=t.showValueColors?"function":"",s=DomElement.createWithHTML(l,"span",i,Default.getFunctionName(r)),c="function",Is.definedFunction(t.events.onFunctionRender)&&Trigger.customEvent(t.events.onFunctionRender,s),createComma(t,l,o));else if(Is.definedBoolean(r))t.ignore.booleanValues?u=!0:(i=t.showValueColors?"boolean":"",s=DomElement.createWithHTML(l,"span",i,r),c="boolean",Is.definedFunction(t.events.onBooleanRender)&&Trigger.customEvent(t.events.onBooleanRender,s),createComma(t,l,o));else if(Is.definedDecimal(r))if(t.ignore.decimalValues)u=!0;else{const e=Default.getFixedDecimalPlacesValue(r,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,o)}else if(Is.definedNumber(r))t.ignore.numberValues?u=!0:(i=t.showValueColors?"number":"",s=DomElement.createWithHTML(l,"span",i,r),c="number",Is.definedFunction(t.events.onNumberRender)&&Trigger.customEvent(t.events.onNumberRender,s),createComma(t,l,o));else if(Is.definedString(r))if(t.ignore.stringValues)u=!0;else if(t.parseStringsToDates&&DateTime.isDateValid(r))renderValue(e,t,n,new Date(r),o),u=!0;else{let e=null;t.showValueColors&&t.showStringHexColors&&Is.hexColor(r)?e=r:t.maximumStringLength>0&&r.length>t.maximumStringLength&&(r=r.substring(0,t.maximumStringLength)+_configuration.text.ellipsisText);const n=t.showStringQuotes?`"${r}"`:r;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,o)}else if(Is.definedDate(r))t.ignore.dateValues?u=!0:(i=t.showValueColors?"date":"",s=DomElement.createWithHTML(l,"span",i,DateTime.getCustomFormattedDateText(_configuration,r,t.dateTimeFormat)),c="date",Is.definedFunction(t.events.onDateRender)&&Trigger.customEvent(t.events.onDateRender,s),createComma(t,l,o));else if(Is.definedObject(r)&&!Is.definedArray(r))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,r);DomElement.createWithHTML(e,"span","title",_configuration.text.objectText),t.showCounts&&n>0&&DomElement.createWithHTML(e,"span","count",`{${n}}`),createComma(t,e,o),c="object"}else if(Is.definedArray(r))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",`[${r.length}]`),createComma(t,e,o),renderArrayValues(a,n,t,r),c="array"}else t.ignore.unknownValues?u=!0:(i=t.showValueColors?"unknown":"",s=DomElement.createWithHTML(l,"span",i,r.toString()),c="unknown",Is.definedFunction(t.events.onUnknownRender)&&Trigger.customEvent(t.events.onUnknownRender,s),createComma(t,l,o));else t.ignore.nullValues?u=!0:(i=t.showValueColors?"null":"",s=DomElement.createWithHTML(l,"span",i,"null"),d=!1,Is.definedFunction(t.events.onNullRender)&&Trigger.customEvent(t.events.onNullRender,s),createComma(t,l,o));u?e.removeChild(l):Is.defined(s)&&addValueClickEvent(t,s,r,c,d)}function addValueClickEvent(e,t,n,r,o){o&&Is.definedFunction(e.events.onValueClick)?t.onclick=()=>{Trigger.customEvent(e.events.onValueClick,n,r)}: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 r=e.useZeroIndexingForArrays?t.toString():(t+1).toString();return e.addArrayIndexPadding||(r=Str.padNumber(parseInt(r),n.toString().length)),`[${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 r=0;r<n;r++){const n=e[r];"json"===n.name.split(".").pop().toLowerCase()&&importFromJson(n,t)}}function importFromJson(e,t){const n=new FileReader;let r=null;n.onloadend=()=>{t._currentView.dataArrayCurrentIndex=0,t.data=r,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)&&(r=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="",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 r=_elements_Data[e];r._currentView.dataArrayCurrentIndex=0,r.data=n,renderControlContainer(r),Trigger.customEvent(r.events.onSetJson,r._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 r in e)e.hasOwnProperty(r)&&_configuration.hasOwnProperty(r)&&n[r]!==e[r]&&(n[r]=e[r],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.2.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.1.0",
"version": "2.2.0",
"homepage": "https://www.william-troup.com/jsontree-js/",

@@ -43,8 +43,8 @@ "author": {

"devDependencies": {
"@swc/core": "^1.7.0",
"@swc/core": "^1.7.5",
"sass": "^1.77.8",
"terser": "^5.31.3",
"tsup": "^8.2.0",
"typescript": "^5.5.3"
"tsup": "^8.2.4",
"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.1.0-blue)](https://www.npmjs.com/package/jjsontree.js)
[![nuget](https://img.shields.io/badge/nuget-v2.1.0-purple)](https://www.nuget.org/packages/jJsonTree.js/)
[![npm](https://img.shields.io/badge/npmjs-v2.2.0-blue)](https://www.npmjs.com/package/jjsontree.js)
[![nuget](https://img.shields.io/badge/nuget-v2.2.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.1.0</p>
> <p align="center">v2.2.0</p>
<br />

@@ -30,6 +30,7 @@

- Fully configurable per DOM element!
- Close/Open all.
- Clickable values!
- Close/Open all nodes.
- Clickable values via custom triggers!
- Custom value rendering.
- Array paging support (show array objects on different pages)!
- Drag & Drop JSON files support!
<br />

@@ -71,4 +72,4 @@ <br />

```markdown
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@2.1.0/dist/jsontree.min.js
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@2.1.0/dist/jsontree.js.min.css
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@2.2.0/dist/jsontree.min.js
https://cdn.jsdelivr.net/gh/williamtroup/JsonTree.js@2.2.0/dist/jsontree.js.min.css
```

@@ -75,0 +76,0 @@ <br>

@@ -7,3 +7,3 @@ /**

* @file jsontree.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -123,3 +123,7 @@ * @license MIT License

if ( bindingOptions.showArrayItemsAsSeparateObjects ) {
const contents: HTMLElement = DomElement.create( bindingOptions._currentView.element, "div", "contents" );
makeAreaDroppable( contents, bindingOptions );
if ( bindingOptions.showArrayItemsAsSeparateObjects && Is.definedArray( data ) ) {
data = data[ bindingOptions._currentView.dataArrayCurrentIndex ];

@@ -129,6 +133,15 @@ }

if ( Is.definedObject( data ) && !Is.definedArray( data ) ) {
renderObject( bindingOptions._currentView.element, bindingOptions, data, true );
renderObject( contents, bindingOptions, data, true );
} else if ( Is.definedArray( data ) ) {
renderArray( bindingOptions._currentView.element, bindingOptions, data );
renderArray( contents, bindingOptions, data );
}
if ( contents.innerHTML === Char.empty ) {
DomElement.createWithHTML( contents, "span", "no-json-text", _configuration.text!.noJsonToViewText! );
bindingOptions._currentView.titleBarButtons.style.display = "none";
} else {
bindingOptions._currentView.titleBarButtons.style.display = "block";
}
}

@@ -146,10 +159,11 @@

const titleBar: HTMLElement = DomElement.create( bindingOptions._currentView.element, "div", "title-bar" );
const controls: HTMLElement = DomElement.create( titleBar, "div", "controls" );
bindingOptions._currentView.titleBarButtons = DomElement.create( titleBar, "div", "controls" );
if ( bindingOptions.title!.show ) {
DomElement.createWithHTML( titleBar, "div", "title", bindingOptions.title!.text!, controls );
DomElement.createWithHTML( titleBar, "div", "title", bindingOptions.title!.text!, bindingOptions._currentView.titleBarButtons );
}
if ( bindingOptions.title!.showCopyButton ) {
const copy: HTMLButtonElement = DomElement.createWithHTML( controls, "button", "copy-all", _configuration.text!.copyAllButtonSymbolText! ) as HTMLButtonElement;
const copy: HTMLButtonElement = DomElement.createWithHTML( bindingOptions._currentView.titleBarButtons, "button", "copy-all", _configuration.text!.copyAllButtonSymbolText! ) as HTMLButtonElement;
copy.title = _configuration.text!.copyAllButtonText!

@@ -161,6 +175,6 @@

if ( bindingOptions.copyOnlyCurrentPage && bindingOptions.showArrayItemsAsSeparateObjects ) {
copyData = JSON.stringify( _elements_Data[ bindingOptions._currentView.element.id ].data[ bindingOptions._currentView.dataArrayCurrentIndex ], null, 2 );
copyData = JSON.stringify( data[ bindingOptions._currentView.dataArrayCurrentIndex ], null, bindingOptions.copyIndentSpaces );
}
else {
copyData = JSON.stringify( _elements_Data[ bindingOptions._currentView.element.id ].data, null, 2 );
copyData = JSON.stringify( data, null, bindingOptions.copyIndentSpaces );
}

@@ -175,6 +189,6 @@

if ( bindingOptions.title!.showTreeControls ) {
const openAll: HTMLButtonElement = DomElement.createWithHTML( controls, "button", "openAll", _configuration.text!.openAllButtonSymbolText! ) as HTMLButtonElement;
const openAll: HTMLButtonElement = DomElement.createWithHTML( bindingOptions._currentView.titleBarButtons, "button", "openAll", _configuration.text!.openAllButtonSymbolText! ) as HTMLButtonElement;
openAll.title = _configuration.text!.openAllButtonText!
const closeAll: HTMLButtonElement = DomElement.createWithHTML( controls, "button", "closeAll", _configuration.text!.closeAllButtonSymbolText! ) as HTMLButtonElement;
const closeAll: HTMLButtonElement = DomElement.createWithHTML( bindingOptions._currentView.titleBarButtons, "button", "closeAll", _configuration.text!.closeAllButtonSymbolText! ) as HTMLButtonElement;
closeAll.title = _configuration.text!.closeAllButtonText!

@@ -192,3 +206,3 @@

if ( bindingOptions.showArrayItemsAsSeparateObjects && Is.definedArray( data ) && data.length > 1 ) {
const back: HTMLButtonElement = DomElement.createWithHTML( controls, "button", "back", _configuration.text!.backButtonSymbolText! ) as HTMLButtonElement;
const back: HTMLButtonElement = DomElement.createWithHTML( bindingOptions._currentView.titleBarButtons, "button", "back", _configuration.text!.backButtonSymbolText! ) as HTMLButtonElement;
back.title = _configuration.text!.backButtonText!

@@ -201,2 +215,3 @@

renderControlContainer( bindingOptions );
Trigger.customEvent( bindingOptions.events!.onBackPage!, bindingOptions._currentView.element );
};

@@ -208,3 +223,3 @@

const next: HTMLButtonElement = DomElement.createWithHTML( controls, "button", "next", _configuration.text!.nextButtonSymbolText! ) as HTMLButtonElement;
const next: HTMLButtonElement = DomElement.createWithHTML( bindingOptions._currentView.titleBarButtons, "button", "next", _configuration.text!.nextButtonSymbolText! ) as HTMLButtonElement;
next.title = _configuration.text!.nextButtonText!

@@ -217,2 +232,3 @@

renderControlContainer( bindingOptions );
Trigger.customEvent( bindingOptions.events!.onNextPage!, bindingOptions._currentView.element );
};

@@ -225,3 +241,6 @@

} else {
bindingOptions.showArrayItemsAsSeparateObjects = false;
if ( Is.definedArray( data ) ) {
bindingOptions.showArrayItemsAsSeparateObjects = false;
}
}

@@ -432,28 +451,34 @@ }

if ( !bindingOptions.ignore!.stringValues ) {
let color: string = null!;
if ( bindingOptions.parseStringsToDates && DateTime.isDateValid( value ) ) {
renderValue( container, bindingOptions, name, new Date( value ), isLastItem );
ignored = true;
if ( bindingOptions.showValueColors && bindingOptions.showStringHexColors && Is.hexColor( value ) ) {
color = value;
} else {
if ( bindingOptions.maximumStringLength! > 0 && value.length > bindingOptions.maximumStringLength! ) {
value = value.substring( 0, bindingOptions.maximumStringLength ) + _configuration.text!.ellipsisText;
}
}
let color: string = null!;
const newStringValue: string = bindingOptions.showStringQuotes ? `\"${value}\"` : value;
if ( bindingOptions.showValueColors && bindingOptions.showStringHexColors && Is.hexColor( value ) ) {
color = value;
valueClass = bindingOptions.showValueColors ? "string" : Char.empty;
valueElement = DomElement.createWithHTML( objectTypeValue, "span", valueClass, newStringValue );
type = "string";
if ( Is.definedString( color ) ) {
valueElement.style.color = color;
}
} else {
if ( bindingOptions.maximumStringLength! > 0 && value.length > bindingOptions.maximumStringLength! ) {
value = value.substring( 0, bindingOptions.maximumStringLength ) + _configuration.text!.ellipsisText;
}
}
if ( Is.definedFunction( bindingOptions.events!.onStringRender ) ) {
Trigger.customEvent( bindingOptions.events!.onStringRender!, valueElement );
const newStringValue: string = bindingOptions.showStringQuotes ? `\"${value}\"` : value;
valueClass = bindingOptions.showValueColors ? "string" : Char.empty;
valueElement = DomElement.createWithHTML( objectTypeValue, "span", valueClass, newStringValue );
type = "string";
if ( Is.definedString( color ) ) {
valueElement.style.color = color;
}
if ( Is.definedFunction( bindingOptions.events!.onStringRender ) ) {
Trigger.customEvent( bindingOptions.events!.onStringRender!, valueElement );
}
createComma( bindingOptions, objectTypeValue, isLastItem );
}
createComma( bindingOptions, objectTypeValue, isLastItem );

@@ -599,2 +624,61 @@ } else {

* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Drop Files
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
function makeAreaDroppable( element: HTMLElement, bindingOptions: BindingOptions ) : void {
if ( bindingOptions.fileDroppingEnabled ) {
element.ondragover = DomElement.cancelBubble;
element.ondragenter = DomElement.cancelBubble;
element.ondragleave = DomElement.cancelBubble;
element.ondrop = ( e: DragEvent ) => {
DomElement.cancelBubble( e );
if ( Is.defined( window.FileReader ) && e.dataTransfer!.files.length > 0 ) {
importFromFiles( e.dataTransfer!.files, bindingOptions );
}
};
}
}
function importFromFiles( files: FileList, bindingOptions: BindingOptions ) : void {
const filesLength: number = files.length;
for ( let fileIndex: number = 0; fileIndex < filesLength; fileIndex++ ) {
const file: File = files[ fileIndex ];
const fileExtension: string = file!.name!.split( "." )!.pop()!.toLowerCase();
if ( fileExtension === "json" ) {
importFromJson( file, bindingOptions );
}
}
}
function importFromJson( file: File, bindingOptions: BindingOptions ) : void {
const reader: FileReader = new FileReader();
let renderData: any = null as any;
reader.onloadend = () => {
bindingOptions._currentView.dataArrayCurrentIndex = 0;
bindingOptions.data = renderData;
renderControlContainer( bindingOptions );
Trigger.customEvent( bindingOptions.events!.onSetJson!, bindingOptions._currentView.element );
};
reader.onload = ( e: ProgressEvent<FileReader> ) => {
const json: StringToJson = getObjectFromString( e.target!.result );
if ( json.parsed && Is.definedObject( json.object ) ) {
renderData = json.object;
}
};
reader.readAsText( file );
}
/*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Default Parameter/Option Handling

@@ -721,2 +805,46 @@ * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Public API Functions: Manage Data
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
setJson: function ( elementId: string, json: any ) : PublicApi {
if ( Is.definedString( elementId ) && Is.defined( json ) && _elements_Data.hasOwnProperty( elementId ) ) {
let jsonObject: any = null;
if ( Is.definedString( json ) ) {
const jsonResult: StringToJson = getObjectFromString( json );
if ( jsonResult.parsed ) {
jsonObject = jsonResult.object;
}
} else {
jsonObject = json;
}
const bindingOptions: BindingOptions = _elements_Data[ elementId ];
bindingOptions._currentView.dataArrayCurrentIndex = 0;
bindingOptions.data = jsonObject;
renderControlContainer( bindingOptions );
Trigger.customEvent( bindingOptions.events!.onSetJson!, bindingOptions._currentView.element );
}
return _public;
},
getJson: function ( elementId: string ) : any {
let result: any = null;
if ( Is.definedString( elementId ) && _elements_Data.hasOwnProperty( elementId ) ) {
result = _elements_Data[ elementId ].data;
}
return result;
},
/*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Public API Functions: Destroying

@@ -795,3 +923,3 @@ * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

getVersion: function () : string {
return "2.1.0";
return "2.2.0";
}

@@ -798,0 +926,0 @@ };

@@ -7,3 +7,3 @@ /**

* @file api.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -104,2 +104,37 @@ * @license MIT License

* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Public API Functions: Manage Data
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
/**
* setJson().
*
* Sets the JSON data currently being displayed.
*
* @public
* @fires onSetJson
*
* @param {string} elementId The JsonTree.js element ID that should be updated.
* @param {any} json The JSON that should be shown in the display (can be a string, or object).
*
* @returns {Object} The JsonTree.js class instance.
*/
setJson: ( elementId: string, json: any ) => PublicApi;
/**
* getJson().
*
* Returns the JSON data currently being displayed.
*
* @public
*
* @param {string} elementId The JsonTree.js element ID.
*
* @returns {any} The JSON that is being displayed.
*/
getJson: ( elementId: string ) => any;
/*
* ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
* Public API Functions: Destroying

@@ -106,0 +141,0 @@ * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

@@ -7,3 +7,3 @@ /**

* @file trigger.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -10,0 +10,0 @@ * @license MIT License

@@ -7,3 +7,3 @@ /**

* @file constant.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -16,3 +16,3 @@ * @license MIT License

export namespace Constants {
export const JSONTREE_JS_ATTRIBUTE_NAME = "data-jsontree-js";
export const JSONTREE_JS_ATTRIBUTE_NAME: string = "data-jsontree-js";
}

@@ -7,3 +7,3 @@ /**

* @file datetime.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -70,2 +70,6 @@ * @license MIT License

}
export function isDateValid( dateTimeString: string ) {
return !isNaN( +new Date( dateTimeString ) );
}
}

@@ -7,3 +7,3 @@ /**

* @file default.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -10,0 +10,0 @@ * @license MIT License

@@ -7,3 +7,3 @@ /**

* @file enum.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -10,0 +10,0 @@ * @license MIT License

@@ -7,3 +7,3 @@ /**

* @file is.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -10,0 +10,0 @@ * @license MIT License

@@ -7,3 +7,3 @@ /**

* @file str.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -10,0 +10,0 @@ * @license MIT License

@@ -7,3 +7,3 @@ /**

* @file dom.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -49,2 +49,7 @@ * @license MIT License

}
export function cancelBubble( e: Event ) : void {
e.preventDefault();
e.stopPropagation();
}
}

@@ -7,3 +7,3 @@ /**

* @file binding.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -32,2 +32,3 @@ * @license MIT License

bindingOptions._currentView.dataArrayCurrentIndex = 0;
bindingOptions._currentView.titleBarButtons = null!;

@@ -57,2 +58,5 @@ return bindingOptions;

options.copyOnlyCurrentPage = Default.getBoolean( options.copyOnlyCurrentPage, false );
options.fileDroppingEnabled = Default.getBoolean( options.fileDroppingEnabled, true );
options.parseStringsToDates = Default.getBoolean( options.parseStringsToDates, false );
options.copyIndentSpaces = Default.getNumber( options.copyIndentSpaces, 2 );

@@ -59,0 +63,0 @@ options = getTitle( options );

@@ -7,3 +7,3 @@ /**

* @file config.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -54,3 +54,4 @@ * @license MIT License

configuration.text!.nextButtonSymbolText = Default.getAnyString( configuration.text!.nextButtonSymbolText, "→" );
configuration.text!.noJsonToViewText = Default.getAnyString( configuration.text!.noJsonToViewText, "There is currently no JSON to view." );
if ( Is.invalidOptionArray( configuration.text!.dayNames, 7 ) ) {

@@ -57,0 +58,0 @@ configuration.text!.dayNames = [

@@ -7,3 +7,3 @@ /**

* @file type.ts
* @version v2.1.0
* @version v2.2.0
* @author Bunoon

@@ -46,2 +46,3 @@ * @license MIT License

nextButtonSymbolText?: string;
noJsonToViewText?: string;
};

@@ -67,4 +68,7 @@

showStringHexColors?: boolean;
showArrayItemsAsSeparateObjects: boolean;
copyOnlyCurrentPage: boolean;
showArrayItemsAsSeparateObjects?: boolean;
copyOnlyCurrentPage?: boolean;
fileDroppingEnabled?: boolean;
parseStringsToDates?: boolean;
copyIndentSpaces?: number;
title?: BindingOptionsTitle;

@@ -78,2 +82,3 @@ ignore?: BindingOptionsIgnore;

dataArrayCurrentIndex: number;
titleBarButtons: HTMLElement;
};

@@ -118,2 +123,5 @@

onUnknownRender?: ( element: HTMLElement ) => void;
onBackPage?: ( element: HTMLElement ) => void;
onNextPage?: ( element: HTMLElement ) => void;
onSetJson?: ( element: HTMLElement ) => void;
};

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc