diff --git a/README.md b/README.md index 4c0f30fe..1e96f935 100755 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ JsonTree.js [![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-v0.1.0-blue)](https://www.npmjs.com/package/jtree.js) -[![nuget](https://img.shields.io/badge/nuget-v0.1.0-purple)](https://www.nuget.org/packages/jJsonTree.js/) +[![npm](https://img.shields.io/badge/npmjs-v0.2.0-blue)](https://www.npmjs.com/package/jtree.js) +[![nuget](https://img.shields.io/badge/nuget-v0.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) [![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/JsonTree.js/discussions) [![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://william-troup.com/) >

🔗 A lightweight JavaScript library that generates customizable tree views to better visualize JSON data.

->

v0.1.0

+>

v0.2.0


![JsonTree.js](docs/images/main.png) diff --git a/README_NUGET.md b/README_NUGET.md index fd8aca03..395f75de 100755 --- a/README_NUGET.md +++ b/README_NUGET.md @@ -1,8 +1,8 @@ -# JsonTree.js v0.1.0 +# JsonTree.js v0.2.0 [![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-v0.1.0-blue)](https://www.npmjs.com/package/jtree.js) -[![nuget](https://img.shields.io/badge/nuget-v0.1.0-purple)](https://www.nuget.org/packages/jJsonTree.js/) +[![npm](https://img.shields.io/badge/npmjs-v0.2.0-blue)](https://www.npmjs.com/package/jtree.js) +[![nuget](https://img.shields.io/badge/nuget-v0.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) [![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/JsonTree.js/discussions) [![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://william-troup.com/) diff --git a/dist/jsontree.js b/dist/jsontree.js index c28f8a0b..6a726285 100755 --- a/dist/jsontree.js +++ b/dist/jsontree.js @@ -1,4 +1,4 @@ -/*! JsonTree.js v0.1.0 | (c) Bunoon 2024 | MIT License */ +/*! JsonTree.js v0.2.0 | (c) Bunoon 2024 | MIT License */ (function() { function render() { var tagTypes = _configuration.domElementTypes; @@ -116,13 +116,16 @@ } if (bindingOptions.sortPropertyNames) { properties = properties.sort(); + if (!bindingOptions.sortPropertyNamesInAlphabeticalOrder) { + properties = properties.reverse(); + } } var propertiesLength = properties.length; var propertyIndex = 0; for (; propertyIndex < propertiesLength; propertyIndex++) { var propertyName = properties[propertyIndex]; if (data.hasOwnProperty(propertyName)) { - renderValue(objectTypeContents, bindingOptions, propertyName, data[propertyName]); + renderValue(objectTypeContents, bindingOptions, propertyName, data[propertyName], propertyIndex === propertiesLength - 1); propertyCount++; } } @@ -134,11 +137,11 @@ var dataIndex = 0; for (; dataIndex < dataLength; dataIndex++) { var name = bindingOptions.useZeroIndexingForArrays ? dataIndex.toString() : (dataIndex + 1).toString(); - renderValue(objectTypeContents, bindingOptions, name, data[dataIndex]); + renderValue(objectTypeContents, bindingOptions, name, data[dataIndex], dataIndex === dataLength - 1); } addArrowEvent(bindingOptions, arrow, objectTypeContents); } - function renderValue(container, bindingOptions, name, value) { + function renderValue(container, bindingOptions, name, value, isLastItem) { var objectTypeValue = createElement(container, "div", "object-type-value"); var arrow = bindingOptions.showArrowToggles ? createElement(objectTypeValue, "div", "no-arrow") : null; var valueElement = null; @@ -146,16 +149,22 @@ createElementWithHTML(objectTypeValue, "span", "split", ":"); if (!isDefined(value)) { valueElement = createElementWithHTML(objectTypeValue, "span", "null", "null"); + createComma(bindingOptions, objectTypeValue, isLastItem); } else if (isDefinedFunction(value)) { valueElement = createElementWithHTML(objectTypeValue, "span", "function", getFunctionName(value)); + createComma(bindingOptions, objectTypeValue, isLastItem); } else if (isDefinedBoolean(value)) { valueElement = createElementWithHTML(objectTypeValue, "span", "boolean", value); + createComma(bindingOptions, objectTypeValue, isLastItem); } else if (isDefinedNumber(value)) { valueElement = createElementWithHTML(objectTypeValue, "span", "number", value); + createComma(bindingOptions, objectTypeValue, isLastItem); } else if (isDefinedString(value)) { valueElement = createElementWithHTML(objectTypeValue, "span", "string", bindingOptions.showStringQuotes ? '"' + value + '"' : value); + createComma(bindingOptions, objectTypeValue, isLastItem); } else if (isDefinedDate(value)) { valueElement = createElementWithHTML(objectTypeValue, "span", "date", getCustomFormattedDateTimeText(value, bindingOptions.dateTimeFormat)); + createComma(bindingOptions, objectTypeValue, isLastItem); } else if (isDefinedObject(value) && !isDefinedArray(value)) { var objectTitle = createElement(objectTypeValue, "span", "object"); var objectTypeContents = createElement(objectTypeValue, "div", "object-type-contents"); @@ -164,6 +173,7 @@ if (bindingOptions.showCounts && propertyCount > 0) { createElementWithHTML(objectTitle, "span", "count", "{" + propertyCount + "}"); } + createComma(bindingOptions, objectTitle, isLastItem); } else if (isDefinedArray(value)) { var arrayTitle = createElement(objectTypeValue, "span", "array"); var arrayTypeContents = createElement(objectTypeValue, "div", "object-type-contents"); @@ -171,6 +181,7 @@ if (bindingOptions.showCounts) { createElementWithHTML(arrayTitle, "span", "count", "[" + value.length + "]"); } + createComma(bindingOptions, arrayTitle, isLastItem); renderArrayValues(arrow, arrayTypeContents, bindingOptions, value); } if (isDefined(valueElement)) { @@ -217,6 +228,11 @@ result = result + "()"; return result; } + function createComma(bindingOptions, objectTypeValue, isLastItem) { + if (bindingOptions.showCommas && !isLastItem) { + createElementWithHTML(objectTypeValue, "span", "comma", ","); + } + } function buildAttributeOptions(newOptions) { var options = !isDefinedObject(newOptions) ? {} : newOptions; options.data = getDefaultObject(options.data, null); @@ -229,6 +245,8 @@ options.showTitleTreeControls = getDefaultBoolean(options.showTitleTreeControls, true); options.showAllAsClosed = getDefaultBoolean(options.showAllAsClosed, false); options.sortPropertyNames = getDefaultBoolean(options.sortPropertyNames, true); + options.sortPropertyNamesInAlphabeticalOrder = getDefaultBoolean(options.sortPropertyNamesInAlphabeticalOrder, true); + options.showCommas = getDefaultBoolean(options.showCommas, false); options = buildAttributeOptionStrings(options); options = buildAttributeOptionCustomTriggers(options); return options; @@ -401,6 +419,16 @@ var _elements_Type = {}; var _string = {empty:"", space:" "}; var _attribute_Name_Options = "data-jsontree-options"; + this.render = function(element, options) { + if (isDefinedObject(element) && isDefinedObject(options)) { + renderControl(renderBindingOptions(options, element)); + } + return this; + }; + this.renderAll = function() { + render(); + return this; + }; this.setConfiguration = function(newConfiguration) { var propertyName; for (propertyName in newConfiguration) { @@ -412,7 +440,7 @@ return this; }; this.getVersion = function() { - return "0.1.0"; + return "0.2.0"; }; (function(documentObject, windowObject, mathObject, jsonObject) { _parameter_Document = documentObject; diff --git a/dist/jsontree.js.css b/dist/jsontree.js.css index 577793e8..10c21be7 100755 --- a/dist/jsontree.js.css +++ b/dist/jsontree.js.css @@ -1,5 +1,5 @@ /* - * JsonTree.js Library v0.1.0 + * JsonTree.js Library v0.2.0 * * Copyright 2024 Bunoon * Released under the MIT License @@ -130,10 +130,15 @@ div.json-tree-js div.title-bar div.title { font-size: 1.2rem; } div.json-tree-js div.title-bar div.controls { - margin-left: calc(var(--json-tree-js-spacing) * 12); + margin-left: calc(var(--json-tree-js-spacing) * 6); flex-grow: 1; text-align: right; } +@media (min-width: 768px) { + div.json-tree-js div.title-bar div.controls { + margin-left: calc(var(--json-tree-js-spacing) * 12); + } +} div.json-tree-js div.title-bar div.controls button { background-color: var(--json-tree-js-button-background-color); border: var(--json-tree-js-border-size) solid var(--json-tree-js-button-border-color); @@ -219,6 +224,10 @@ div.json-tree-js div.object-type-contents div.object-type-value span.function:no cursor: pointer; opacity: 0.7; } +div.json-tree-js div.object-type-contents div.object-type-value span.comma { + color: var(--json-tree-js-color-white); + font-weight: var(--json-tree-js-text-bold-weight); +} div.json-tree-js div.object-type-contents div.object-type-value span.boolean { color: var(--json-tree-js-color-boolean); } diff --git a/dist/jsontree.js.css.map b/dist/jsontree.js.css.map index b2193ce4..d27815f6 100755 --- a/dist/jsontree.js.css.map +++ b/dist/jsontree.js.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["../src/jsontree.js.scss","../src/foundation/_styles.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;EAEI;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA;EACA;EAGA;;;AAIJ;AAAA;AAAA;AAAA;AAAA;AAMA;EC/DI;EACA;EACA;EACA;EACA;EACA;EAUA;EACA;EDkDA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAGJ;ECrEA;EACA;;ADuEI;ECxEJ;EACA;;;AD+EJ;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;EACA;EACA;EACA;;AAGJ;AAAA;EAEI;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;AAAA;EACI;;AAIR;EACI;EACA;EACA;;AAGJ;EACI;EACA;EACA;;;AAKR;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;;AC3IR;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;;AAGJ;EACI;EACA;EACA;;;AD+HZ;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;;AAEA;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;;;AAKZ;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;;;AAKR;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;;AAEA;EACI;EACA;EACA;;AAEA;EACI;EACA;;AAGJ;AAAA;AAAA;AAAA;AAAA;AAAA;EAMI;EACA;;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;EACI;EACA;;AAIR;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;;AAKA;AAAA;EACI;EACA;;;AAQpB;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;EACA;;AAEA;EACI;;AAGJ;EACI","file":"jsontree.js.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../src/jsontree.js.scss","../src/foundation/_styles.scss"],"names":[],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;EAEI;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA;EACA;EAGA;;;AAIJ;AAAA;AAAA;AAAA;AAAA;AAMA;EC/DI;EACA;EACA;EACA;EACA;EACA;EAUA;EACA;EDkDA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;;AAGJ;ECrEA;EACA;;ADuEI;ECxEJ;EACA;;;AD+EJ;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;EACA;EACA;EACA;;AAGJ;AAAA;EAEI;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;AAAA;EACI;;AAIR;EACI;EACA;EACA;;AAGJ;EACI;EACA;EACA;;;AAKR;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;EACA;;AAEA;EACI;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;;AAEA;EALJ;IAMQ;;;AC9IZ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACI;EACA;;AAGJ;EACI;EACA;EACA;;;ADmIZ;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;;AAEA;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;;;AAKZ;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;;;AAKR;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;;AAEA;EACI;EACA;EACA;;AAEA;EACI;EACA;;AAGJ;AAAA;AAAA;AAAA;AAAA;AAAA;EAMI;EACA;;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;EACI;EACA;;AAIR;EACI;EACA;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;;AAKA;AAAA;EACI;EACA;;;AAQpB;AAAA;AAAA;AAAA;AAAA;AAOI;EACI;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;EACA;;AAEA;EACI;;AAGJ;EACI","file":"jsontree.js.css"} \ No newline at end of file diff --git a/dist/jsontree.js.min.css b/dist/jsontree.js.min.css index bed5661c..a675c5c6 100755 --- a/dist/jsontree.js.min.css +++ b/dist/jsontree.js.min.css @@ -1,2 +1,2 @@ -/* JsonTree.js v0.1.0 | (c) Bunoon 2024 | MIT License */ -:root{--json-tree-js-default-font:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue","Noto Sans","Liberation Sans",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--json-tree-js-text-bold-weight:400;--json-tree-js-header-bold-weight:900;--json-tree-js-title-bold-weight:var(--json-tree-js-header-bold-weight);--json-tree-js-text-bold-weight-active:var(--json-tree-js-header-bold-weight);--json-tree-js-color-black:#3b3a3a;--json-tree-js-color-white:#F5F5F5;--json-tree-js-color-snow-white:#F5F5F5;--json-tree-js-color-boolean:red;--json-tree-js-color-number:#666bf9;--json-tree-js-color-string:#78b13f;--json-tree-js-color-date:#a656f5;--json-tree-js-color-array:#F28C28;--json-tree-js-color-object:silver;--json-tree-js-color-null:#BBB;--json-tree-js-color-function:#BBB;--json-tree-js-container-background-color:#22272e;--json-tree-js-container-border-color:#454c56;--json-tree-js-button-background-color:#2d333b;--json-tree-js-button-border-color:var(--json-tree-js-container-border-color);--json-tree-js-button-text-color:var(--json-tree-js-color-white);--json-tree-js-button-background-color-hover:var(--json-tree-js-container-border-color);--json-tree-js-button-text-color-hover:var(--json-tree-js-color-snow-white);--json-tree-js-button-background-color-active:#616b79;--json-tree-js-button-text-color-active:var(--json-tree-js-color-snow-white);--json-tree-js-border-radius:.5rem;--json-tree-js-border-style-scrollbar:inset 0 0 6px var(--json-tree-js-color-dark-gray);--json-tree-js-border-size:.5px;--json-tree-js-spacing:10px;--json-tree-js-spacing-font-size:.85rem;--json-tree-js-transition:all .3s}div.json-tree-js{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;cursor:default;box-sizing:border-box;line-height:normal;font-family:var(--json-tree-js-default-font);display:inline-block;position:relative;border-radius:var(--json-tree-js-border-radius);background-color:var(--json-tree-js-container-background-color);color:var(--json-tree-js-color-white);border:var(--json-tree-js-border-size) solid var(--json-tree-js-container-border-color);padding:var(--json-tree-js-spacing);font-size:var(--json-tree-js-spacing-font-size);font-weight:var(--json-tree-js-text-bold-weight);width:auto;overflow:hidden;margin:0!important}div.json-tree-js div.no-click{pointer-events:none!important}div.json-tree-js *{box-sizing:border-box;line-height:normal}div.json-tree-js *::before,div.json-tree-js *::after{box-sizing:border-box;line-height:normal}div.json-tree-js div.no-arrow{display:inline-block;width:12px;height:8px;margin-right:calc(var(--json-tree-js-spacing))}div.json-tree-js div.down-arrow,div.json-tree-js div.right-arrow{display:inline-block;width:0;height:0;margin-right:calc(var(--json-tree-js-spacing));cursor:pointer;transition:var(--json-tree-js-transition);transition-property:opacity}div.json-tree-js div.down-arrow:hover,div.json-tree-js div.right-arrow:hover{opacity:.7}div.json-tree-js div.down-arrow{border-left:6px solid transparent;border-right:6px solid transparent;border-top:8px solid var(--json-tree-js-color-white)}div.json-tree-js div.right-arrow{border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:12px solid var(--json-tree-js-color-white)}div.json-tree-js div.title-bar{display:flex;margin-bottom:var(--json-tree-js-spacing)}div.json-tree-js div.title-bar div.title{text-align:left;width:auto;font-weight:var(--json-tree-js-title-bold-weight);font-size:1.2rem}div.json-tree-js div.title-bar div.controls{margin-left:calc(var(--json-tree-js-spacing) * 12);flex-grow:1;text-align:right}div.json-tree-js div.title-bar div.controls button{background-color:var(--json-tree-js-button-background-color);border:var(--json-tree-js-border-size) solid var(--json-tree-js-button-border-color);color:var(--json-tree-js-button-text-color);border-radius:var(--json-tree-js-border-radius);padding-top:5px;padding-bottom:5px;padding-left:9px;padding-right:9px;outline:none;transition:var(--json-tree-js-transition)}div.json-tree-js div.title-bar div.controls button:not(.active):active{background:var(--json-tree-js-button-background-color-active)!important;color:var(--json-tree-js-button-text-color-active)!important}div.json-tree-js div.title-bar div.controls button:not(.active):hover{cursor:pointer;background:var(--json-tree-js-button-background-color-hover);color:var(--json-tree-js-button-text-color-hover)}div.json-tree-js div.object-type-title{font-weight:var(--json-tree-js-header-bold-weight)}div.json-tree-js div.object-type-title span.array{color:var(--json-tree-js-color-array)}div.json-tree-js div.object-type-title span.object{color:var(--json-tree-js-color-object)}div.json-tree-js div.object-type-title span.count{margin-left:calc(var(--json-tree-js-spacing) / 2);font-weight:var(--json-tree-js-text-bold-weight)}div.json-tree-js div.object-type-contents{margin-top:calc(var(--json-tree-js-spacing) / 2)}div.json-tree-js div.object-type-contents{margin-left:calc(var(--json-tree-js-spacing) * 2)}div.json-tree-js div.object-type-contents div.object-type-value{white-space:nowrap;overflow:hidden;margin-top:calc(var(--json-tree-js-spacing) / 2)}div.json-tree-js div.object-type-contents div.object-type-value span.split{margin-left:calc(var(--json-tree-js-spacing) / 2);margin-right:calc(var(--json-tree-js-spacing) / 2)}div.json-tree-js div.object-type-contents div.object-type-value span.boolean,div.json-tree-js div.object-type-contents div.object-type-value span.number,div.json-tree-js div.object-type-contents div.object-type-value span.string,div.json-tree-js div.object-type-contents div.object-type-value span.date,div.json-tree-js div.object-type-contents div.object-type-value span.null,div.json-tree-js div.object-type-contents div.object-type-value span.function{transition:var(--json-tree-js-transition);transition-property:opacity}div.json-tree-js div.object-type-contents div.object-type-value span.boolean:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.number:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.string:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.date:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.null:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.function:not(.no-hover):hover{cursor:pointer;opacity:.7}div.json-tree-js div.object-type-contents div.object-type-value span.boolean{color:var(--json-tree-js-color-boolean)}div.json-tree-js div.object-type-contents div.object-type-value span.number{color:var(--json-tree-js-color-number)}div.json-tree-js div.object-type-contents div.object-type-value span.string{color:var(--json-tree-js-color-string)}div.json-tree-js div.object-type-contents div.object-type-value span.date{color:var(--json-tree-js-color-date)}div.json-tree-js div.object-type-contents div.object-type-value span.array{font-weight:var(--json-tree-js-header-bold-weight);color:var(--json-tree-js-color-array)}div.json-tree-js div.object-type-contents div.object-type-value span.object{font-weight:var(--json-tree-js-header-bold-weight);color:var(--json-tree-js-color-object)}div.json-tree-js div.object-type-contents div.object-type-value span.null{color:var(--json-tree-js-color-null);font-style:italic}div.json-tree-js div.object-type-contents div.object-type-value span.function{color:var(--json-tree-js-color-function);font-style:italic}div.json-tree-js div.object-type-contents div.object-type-value span.array span.count,div.json-tree-js div.object-type-contents div.object-type-value span.object span.count{margin-left:calc(var(--json-tree-js-spacing) / 2);font-weight:var(--json-tree-js-text-bold-weight)}.custom-scroll-bars::-webkit-scrollbar{width:12px}.custom-scroll-bars::-webkit-scrollbar-track{-webkit-box-shadow:var(--json-tree-js-border-style-scrollbar);box-shadow:var(--json-tree-js-border-style-scrollbar)}.custom-scroll-bars::-webkit-scrollbar-thumb{-webkit-box-shadow:var(--json-tree-js-border-style-scrollbar);box-shadow:var(--json-tree-js-border-style-scrollbar);background:var(--json-tree-js-color-white)}.custom-scroll-bars::-webkit-scrollbar-thumb:hover{background-color:var(--json-tree-js-color-white)}.custom-scroll-bars::-webkit-scrollbar-thumb:active{background-color:var(--json-tree-js-color-lighter-gray)} \ No newline at end of file +/* JsonTree.js v0.2.0 | (c) Bunoon 2024 | MIT License */ +:root{--json-tree-js-default-font:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue","Noto Sans","Liberation Sans",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--json-tree-js-text-bold-weight:400;--json-tree-js-header-bold-weight:900;--json-tree-js-title-bold-weight:var(--json-tree-js-header-bold-weight);--json-tree-js-text-bold-weight-active:var(--json-tree-js-header-bold-weight);--json-tree-js-color-black:#3b3a3a;--json-tree-js-color-white:#F5F5F5;--json-tree-js-color-snow-white:#F5F5F5;--json-tree-js-color-boolean:red;--json-tree-js-color-number:#666bf9;--json-tree-js-color-string:#78b13f;--json-tree-js-color-date:#a656f5;--json-tree-js-color-array:#F28C28;--json-tree-js-color-object:silver;--json-tree-js-color-null:#BBB;--json-tree-js-color-function:#BBB;--json-tree-js-container-background-color:#22272e;--json-tree-js-container-border-color:#454c56;--json-tree-js-button-background-color:#2d333b;--json-tree-js-button-border-color:var(--json-tree-js-container-border-color);--json-tree-js-button-text-color:var(--json-tree-js-color-white);--json-tree-js-button-background-color-hover:var(--json-tree-js-container-border-color);--json-tree-js-button-text-color-hover:var(--json-tree-js-color-snow-white);--json-tree-js-button-background-color-active:#616b79;--json-tree-js-button-text-color-active:var(--json-tree-js-color-snow-white);--json-tree-js-border-radius:.5rem;--json-tree-js-border-style-scrollbar:inset 0 0 6px var(--json-tree-js-color-dark-gray);--json-tree-js-border-size:.5px;--json-tree-js-spacing:10px;--json-tree-js-spacing-font-size:.85rem;--json-tree-js-transition:all .3s}div.json-tree-js{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;cursor:default;box-sizing:border-box;line-height:normal;font-family:var(--json-tree-js-default-font);display:inline-block;position:relative;border-radius:var(--json-tree-js-border-radius);background-color:var(--json-tree-js-container-background-color);color:var(--json-tree-js-color-white);border:var(--json-tree-js-border-size) solid var(--json-tree-js-container-border-color);padding:var(--json-tree-js-spacing);font-size:var(--json-tree-js-spacing-font-size);font-weight:var(--json-tree-js-text-bold-weight);width:auto;overflow:hidden;margin:0!important}div.json-tree-js div.no-click{pointer-events:none!important}div.json-tree-js *{box-sizing:border-box;line-height:normal}div.json-tree-js *::before,div.json-tree-js *::after{box-sizing:border-box;line-height:normal}div.json-tree-js div.no-arrow{display:inline-block;width:12px;height:8px;margin-right:calc(var(--json-tree-js-spacing))}div.json-tree-js div.down-arrow,div.json-tree-js div.right-arrow{display:inline-block;width:0;height:0;margin-right:calc(var(--json-tree-js-spacing));cursor:pointer;transition:var(--json-tree-js-transition);transition-property:opacity}div.json-tree-js div.down-arrow:hover,div.json-tree-js div.right-arrow:hover{opacity:.7}div.json-tree-js div.down-arrow{border-left:6px solid transparent;border-right:6px solid transparent;border-top:8px solid var(--json-tree-js-color-white)}div.json-tree-js div.right-arrow{border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:12px solid var(--json-tree-js-color-white)}div.json-tree-js div.title-bar{display:flex;margin-bottom:var(--json-tree-js-spacing)}div.json-tree-js div.title-bar div.title{text-align:left;width:auto;font-weight:var(--json-tree-js-title-bold-weight);font-size:1.2rem}div.json-tree-js div.title-bar div.controls{margin-left:calc(var(--json-tree-js-spacing) * 6);flex-grow:1;text-align:right}@media (min-width:768px){div.json-tree-js div.title-bar div.controls{margin-left:calc(var(--json-tree-js-spacing) * 12)}}div.json-tree-js div.title-bar div.controls button{background-color:var(--json-tree-js-button-background-color);border:var(--json-tree-js-border-size) solid var(--json-tree-js-button-border-color);color:var(--json-tree-js-button-text-color);border-radius:var(--json-tree-js-border-radius);padding-top:5px;padding-bottom:5px;padding-left:9px;padding-right:9px;outline:none;transition:var(--json-tree-js-transition)}div.json-tree-js div.title-bar div.controls button:not(.active):active{background:var(--json-tree-js-button-background-color-active)!important;color:var(--json-tree-js-button-text-color-active)!important}div.json-tree-js div.title-bar div.controls button:not(.active):hover{cursor:pointer;background:var(--json-tree-js-button-background-color-hover);color:var(--json-tree-js-button-text-color-hover)}div.json-tree-js div.object-type-title{font-weight:var(--json-tree-js-header-bold-weight)}div.json-tree-js div.object-type-title span.array{color:var(--json-tree-js-color-array)}div.json-tree-js div.object-type-title span.object{color:var(--json-tree-js-color-object)}div.json-tree-js div.object-type-title span.count{margin-left:calc(var(--json-tree-js-spacing) / 2);font-weight:var(--json-tree-js-text-bold-weight)}div.json-tree-js div.object-type-contents{margin-top:calc(var(--json-tree-js-spacing) / 2)}div.json-tree-js div.object-type-contents{margin-left:calc(var(--json-tree-js-spacing) * 2)}div.json-tree-js div.object-type-contents div.object-type-value{white-space:nowrap;overflow:hidden;margin-top:calc(var(--json-tree-js-spacing) / 2)}div.json-tree-js div.object-type-contents div.object-type-value span.split{margin-left:calc(var(--json-tree-js-spacing) / 2);margin-right:calc(var(--json-tree-js-spacing) / 2)}div.json-tree-js div.object-type-contents div.object-type-value span.boolean,div.json-tree-js div.object-type-contents div.object-type-value span.number,div.json-tree-js div.object-type-contents div.object-type-value span.string,div.json-tree-js div.object-type-contents div.object-type-value span.date,div.json-tree-js div.object-type-contents div.object-type-value span.null,div.json-tree-js div.object-type-contents div.object-type-value span.function{transition:var(--json-tree-js-transition);transition-property:opacity}div.json-tree-js div.object-type-contents div.object-type-value span.boolean:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.number:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.string:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.date:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.null:not(.no-hover):hover,div.json-tree-js div.object-type-contents div.object-type-value span.function:not(.no-hover):hover{cursor:pointer;opacity:.7}div.json-tree-js div.object-type-contents div.object-type-value span.comma{color:var(--json-tree-js-color-white);font-weight:var(--json-tree-js-text-bold-weight)}div.json-tree-js div.object-type-contents div.object-type-value span.boolean{color:var(--json-tree-js-color-boolean)}div.json-tree-js div.object-type-contents div.object-type-value span.number{color:var(--json-tree-js-color-number)}div.json-tree-js div.object-type-contents div.object-type-value span.string{color:var(--json-tree-js-color-string)}div.json-tree-js div.object-type-contents div.object-type-value span.date{color:var(--json-tree-js-color-date)}div.json-tree-js div.object-type-contents div.object-type-value span.array{font-weight:var(--json-tree-js-header-bold-weight);color:var(--json-tree-js-color-array)}div.json-tree-js div.object-type-contents div.object-type-value span.object{font-weight:var(--json-tree-js-header-bold-weight);color:var(--json-tree-js-color-object)}div.json-tree-js div.object-type-contents div.object-type-value span.null{color:var(--json-tree-js-color-null);font-style:italic}div.json-tree-js div.object-type-contents div.object-type-value span.function{color:var(--json-tree-js-color-function);font-style:italic}div.json-tree-js div.object-type-contents div.object-type-value span.array span.count,div.json-tree-js div.object-type-contents div.object-type-value span.object span.count{margin-left:calc(var(--json-tree-js-spacing) / 2);font-weight:var(--json-tree-js-text-bold-weight)}.custom-scroll-bars::-webkit-scrollbar{width:12px}.custom-scroll-bars::-webkit-scrollbar-track{-webkit-box-shadow:var(--json-tree-js-border-style-scrollbar);box-shadow:var(--json-tree-js-border-style-scrollbar)}.custom-scroll-bars::-webkit-scrollbar-thumb{-webkit-box-shadow:var(--json-tree-js-border-style-scrollbar);box-shadow:var(--json-tree-js-border-style-scrollbar);background:var(--json-tree-js-color-white)}.custom-scroll-bars::-webkit-scrollbar-thumb:hover{background-color:var(--json-tree-js-color-white)}.custom-scroll-bars::-webkit-scrollbar-thumb:active{background-color:var(--json-tree-js-color-lighter-gray)} \ No newline at end of file diff --git a/dist/jsontree.min.js b/dist/jsontree.min.js index e133da38..e8d70669 100755 --- a/dist/jsontree.min.js +++ b/dist/jsontree.min.js @@ -1,14 +1,15 @@ -/*! JsonTree.js v0.1.0 | (c) Bunoon 2024 | MIT License */ -(function(){function E(a){a.currentView.element.innerHTML=u.empty;T(a);if(q(a.data)&&!z(a.data)){var b=a.currentView.element,d=a.data,c=l(b,"div","object-type-title");b=l(b,"div","object-type-contents");var f=a.showArrowToggles?l(c,"div","down-arrow"):null;d=M(f,b,a,d);h(c,"span","object",g.objectText);a.showCounts&&0n;n++){8!==n&&12!==n&&16!==n&&20!==n||v.push("-");var W=J.floor(16*J.random()).toString(16);v.push(W)}v=v.join(u.empty);y.id=v}e.currentView.element.className="json-tree-js"; -e.currentView.element.removeAttribute("data-jsontree-options");E(e);F(e.onRenderComplete,e.currentView.element)}else g.safeMode||(console.error("The attribute 'data-jsontree-options' is not a valid object."),L=!1);else g.safeMode||(console.error("The attribute 'data-jsontree-options' has not been set correctly."),L=!1)}if(!L)break}}});m(I.$jsontree)||(I.$jsontree=this)})(document,window,Math,JSON)})(); \ No newline at end of file +/*! JsonTree.js v0.2.0 | (c) Bunoon 2024 | MIT License */ +(function(){function H(){for(var a=g.domElementTypes,c=a.length,b=0;bd;d++){8!==d&&12!==d&&16!==d&&20!== +d||b.push("-");var f=D.floor(16*D.random()).toString(16);b.push(f)}b=b.join(u.empty);c.id=b}a.currentView.element.className="json-tree-js";a.currentView.element.removeAttribute("data-jsontree-options");E(a);C(a.onRenderComplete,a.currentView.element)}function E(a){a.currentView.element.innerHTML=u.empty;S(a);if(q(a.data)&&!y(a.data)){var c=a.currentView.element,b=a.data,d=k(c,"div","object-type-title");c=k(c,"div","object-type-contents");var f=a.showArrowToggles?k(d,"div","down-arrow"):null;b=K(f, +c,a,b);h(d,"span","object",g.objectText);a.showCounts&&0 + + ## Version 0.1.0: - Everything :) \ No newline at end of file diff --git a/docs/PUBLIC_FUNCTIONS.md b/docs/PUBLIC_FUNCTIONS.md index 394ea3fa..d17a24d7 100755 --- a/docs/PUBLIC_FUNCTIONS.md +++ b/docs/PUBLIC_FUNCTIONS.md @@ -5,6 +5,26 @@ Below is a list of all the public functions that can be called from the JsonTree
+## Manage Instances: + +### **render( *element*, *options* )**: +Renders an element using the options specified. +
+***Parameter: element***: '*Object*' - The element to render. +
+***Parameter: options***: '*Object*' - The options to use (refer to ["Binding Options"](binding/OPTIONS.md) documentation for properties). +
+***Returns***: '*Object*' - The JsonTree.js class instance. +
+ +### **renderAll()**: +Finds all new elements and renders them. +
+***Returns***: '*Object*' - The JsonTree.js class instance. +
+
+ + ## Configuration: ### **setConfiguration( *newConfiguration* )**: diff --git a/docs/binding/OPTIONS.md b/docs/binding/OPTIONS.md index c9d8b4cb..a9391564 100755 --- a/docs/binding/OPTIONS.md +++ b/docs/binding/OPTIONS.md @@ -1,10 +1,11 @@ # JsonTree.js - Binding Options: Below are all the JSON properties that can be passed in the "data-jsontree-options" binding attribute for a DOM element. +
+
## Standard Options: -
| Type: | Name: | Description: | | --- | --- | --- | @@ -16,20 +17,21 @@ Below are all the JSON properties that can be passed in the "data-jsontree-optio | *boolean* | showStringQuotes | States if quotes should be shown around string values (defaults to true). | | *boolean* | showTitle | States if the title should be shown (defaults to true). | | *boolean* | showTitleTreeControls | States if the tree control button should be shown in the title bar (defaults to true). | -| *boolean* | showAllAsClosed | States if all the notes should be closed when first rendered (defaults to false). | -| *boolean* | sortPropertyNames | States if the property names for an object should be sorted in alphabetical order (defaults to true). | +| *boolean* | showAllAsClosed | States if all the nodes should be closed when first rendered (defaults to false). | +| *boolean* | sortPropertyNames | States if the property names for an object should be sorted (defaults to true). | +| *boolean* | sortPropertyNamesInAlphabeticalOrder | States if the sorted property names for an object should be in alphabetical order (defaults to true). | +| *boolean* | showCommas | States if commas should be shown at the end of each line (defaults to false). | -
+
## String Options: -
| Type: | Name: | Description: | | --- | --- | --- | | *string* | titleText | The text that should be displayed for the "JsonTree.js" title bar label. | -
+
## Binding Example: diff --git a/docs/configuration/OPTIONS.md b/docs/configuration/OPTIONS.md index 1ef8b2ac..24b948e1 100755 --- a/docs/configuration/OPTIONS.md +++ b/docs/configuration/OPTIONS.md @@ -1,8 +1,8 @@ # JsonTree.js - Configuration - Options: Below are all the configuration options that can be passed to the "setConfiguration()" public function. -
-
+
+
### Options: @@ -12,7 +12,7 @@ Below are all the configuration options that can be passed to the "setConfigurat | *boolean* | safeMode | States if safe-mode is enabled (errors will be ignored and logged only, defaults to true). | | *Object* | highlightAllDomElementTypes | The DOM element types to lookup (can be either an array of strings, or a space separated string, and defaults to "*"). | -
+
### Options - Strings: @@ -24,11 +24,10 @@ Below are all the configuration options that can be passed to the "setConfigurat | *string* | closeAllButtonText | The text that should be shown for the "Close All" button text. | | *string* | openAllButtonText | The text that should be shown for the "Open All" button text. | -
+
## Example: -
```markdown