react-json-formatter
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -19,8 +19,23 @@ import React from 'react'; | ||
} | ||
interface JsonClassName { | ||
booleanClassName?: string; | ||
braceClassName?: string; | ||
bracketClassName?: string; | ||
className?: string; | ||
commaClassName?: string; | ||
falseClassName?: string; | ||
nullClassName?: string; | ||
numberClassName?: string; | ||
propertyClassName?: string; | ||
stringClassName?: string; | ||
tabSpaceClassName?: string; | ||
trueClassName?: string; | ||
} | ||
interface JsonFormatterProps { | ||
json: string; | ||
jsonClassName?: JsonClassName; | ||
jsonStyle?: JsonStyle; | ||
tabWith?: number; | ||
} | ||
export declare function JsonFormatter({ json, tabWith, jsonStyle }: JsonFormatterProps): JSX.Element; | ||
export default function JsonFormatter({ json, tabWith, jsonStyle: { booleanStyle, braceStyle, bracketStyle, commaStyle, falseStyle, nullStyle, numberStyle, propertyStyle, stringStyle, style, tabSpaceStyle, trueStyle }, jsonClassName: { booleanClassName, braceClassName, bracketClassName, className, commaClassName, falseClassName, nullClassName, numberClassName, propertyClassName, stringClassName, tabSpaceClassName, trueClassName } }: JsonFormatterProps): JSX.Element; | ||
export {}; |
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = _interopDefault(require('react')); | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
@@ -27,13 +28,65 @@ function _extends() { | ||
tabWith = _ref$tabWith === void 0 ? 2 : _ref$tabWith, | ||
_ref$jsonStyle = _ref.jsonStyle, | ||
jsonStyle = _ref$jsonStyle === void 0 ? {} : _ref$jsonStyle; | ||
var jsonObject = JSON.parse(json); | ||
var repeatTabSpace = function repeatTabSpace(times) { | ||
_ref$jsonStyle = _ref.jsonStyle; | ||
_ref$jsonStyle = _ref$jsonStyle === void 0 ? {} : _ref$jsonStyle; | ||
var _ref$jsonStyle$boolea = _ref$jsonStyle.booleanStyle, | ||
booleanStyle = _ref$jsonStyle$boolea === void 0 ? {} : _ref$jsonStyle$boolea, | ||
_ref$jsonStyle$braceS = _ref$jsonStyle.braceStyle, | ||
braceStyle = _ref$jsonStyle$braceS === void 0 ? {} : _ref$jsonStyle$braceS, | ||
_ref$jsonStyle$bracke = _ref$jsonStyle.bracketStyle, | ||
bracketStyle = _ref$jsonStyle$bracke === void 0 ? {} : _ref$jsonStyle$bracke, | ||
_ref$jsonStyle$commaS = _ref$jsonStyle.commaStyle, | ||
commaStyle = _ref$jsonStyle$commaS === void 0 ? {} : _ref$jsonStyle$commaS, | ||
_ref$jsonStyle$falseS = _ref$jsonStyle.falseStyle, | ||
falseStyle = _ref$jsonStyle$falseS === void 0 ? {} : _ref$jsonStyle$falseS, | ||
_ref$jsonStyle$nullSt = _ref$jsonStyle.nullStyle, | ||
nullStyle = _ref$jsonStyle$nullSt === void 0 ? {} : _ref$jsonStyle$nullSt, | ||
_ref$jsonStyle$number = _ref$jsonStyle.numberStyle, | ||
numberStyle = _ref$jsonStyle$number === void 0 ? {} : _ref$jsonStyle$number, | ||
_ref$jsonStyle$proper = _ref$jsonStyle.propertyStyle, | ||
propertyStyle = _ref$jsonStyle$proper === void 0 ? {} : _ref$jsonStyle$proper, | ||
_ref$jsonStyle$string = _ref$jsonStyle.stringStyle, | ||
stringStyle = _ref$jsonStyle$string === void 0 ? {} : _ref$jsonStyle$string, | ||
_ref$jsonStyle$style = _ref$jsonStyle.style, | ||
style = _ref$jsonStyle$style === void 0 ? {} : _ref$jsonStyle$style, | ||
_ref$jsonStyle$tabSpa = _ref$jsonStyle.tabSpaceStyle, | ||
tabSpaceStyle = _ref$jsonStyle$tabSpa === void 0 ? {} : _ref$jsonStyle$tabSpa, | ||
_ref$jsonStyle$trueSt = _ref$jsonStyle.trueStyle, | ||
trueStyle = _ref$jsonStyle$trueSt === void 0 ? {} : _ref$jsonStyle$trueSt, | ||
_ref$jsonClassName = _ref.jsonClassName; | ||
_ref$jsonClassName = _ref$jsonClassName === void 0 ? {} : _ref$jsonClassName; | ||
var _ref$jsonClassName$bo = _ref$jsonClassName.booleanClassName, | ||
booleanClassName = _ref$jsonClassName$bo === void 0 ? '' : _ref$jsonClassName$bo, | ||
_ref$jsonClassName$br = _ref$jsonClassName.braceClassName, | ||
braceClassName = _ref$jsonClassName$br === void 0 ? '' : _ref$jsonClassName$br, | ||
_ref$jsonClassName$br2 = _ref$jsonClassName.bracketClassName, | ||
bracketClassName = _ref$jsonClassName$br2 === void 0 ? '' : _ref$jsonClassName$br2, | ||
_ref$jsonClassName$cl = _ref$jsonClassName.className, | ||
className = _ref$jsonClassName$cl === void 0 ? '' : _ref$jsonClassName$cl, | ||
_ref$jsonClassName$co = _ref$jsonClassName.commaClassName, | ||
commaClassName = _ref$jsonClassName$co === void 0 ? '' : _ref$jsonClassName$co, | ||
_ref$jsonClassName$fa = _ref$jsonClassName.falseClassName, | ||
falseClassName = _ref$jsonClassName$fa === void 0 ? '' : _ref$jsonClassName$fa, | ||
_ref$jsonClassName$nu = _ref$jsonClassName.nullClassName, | ||
nullClassName = _ref$jsonClassName$nu === void 0 ? '' : _ref$jsonClassName$nu, | ||
_ref$jsonClassName$nu2 = _ref$jsonClassName.numberClassName, | ||
numberClassName = _ref$jsonClassName$nu2 === void 0 ? '' : _ref$jsonClassName$nu2, | ||
_ref$jsonClassName$pr = _ref$jsonClassName.propertyClassName, | ||
propertyClassName = _ref$jsonClassName$pr === void 0 ? '' : _ref$jsonClassName$pr, | ||
_ref$jsonClassName$st = _ref$jsonClassName.stringClassName, | ||
stringClassName = _ref$jsonClassName$st === void 0 ? '' : _ref$jsonClassName$st, | ||
_ref$jsonClassName$ta = _ref$jsonClassName.tabSpaceClassName, | ||
tabSpaceClassName = _ref$jsonClassName$ta === void 0 ? '' : _ref$jsonClassName$ta, | ||
_ref$jsonClassName$tr = _ref$jsonClassName.trueClassName, | ||
trueClassName = _ref$jsonClassName$tr === void 0 ? '' : _ref$jsonClassName$tr; | ||
var jsonObject = React.useMemo(function () { | ||
return JSON.parse(json); | ||
}, [json]); | ||
var repeatTabSpace = React.useCallback(function (times) { | ||
var repeatedTabSpace = []; | ||
for (var i = 0; i < times; i++) { | ||
repeatedTabSpace.push(React.createElement("span", { | ||
repeatedTabSpace.push(React__default.createElement("span", { | ||
className: tabSpaceClassName, | ||
key: i, | ||
style: jsonStyle.tabSpaceStyle | ||
style: tabSpaceStyle | ||
}, '\xa0'.repeat(tabWith || 4))); | ||
@@ -43,12 +96,12 @@ } | ||
return repeatedTabSpace; | ||
}; | ||
}, [tabSpaceClassName, tabSpaceStyle, tabWith]); | ||
var categorize = React.useCallback(function (data) { | ||
var TabSpaceRepeatTimes = 0; | ||
var TabSpaceRepeatTimes = 0; | ||
function categorize(data) { | ||
switch (Object.prototype.toString.call(data)) { | ||
case '[object Number]': | ||
{ | ||
var dataJSX = React.createElement("span", { | ||
style: jsonStyle.numberStyle | ||
var dataJSX = React__default.createElement("span", { | ||
className: numberClassName, | ||
style: numberStyle | ||
}, data); | ||
@@ -60,4 +113,5 @@ return dataJSX; | ||
{ | ||
var _dataJSX = React.createElement("span", { | ||
style: jsonStyle.stringStyle | ||
var _dataJSX = React__default.createElement("span", { | ||
className: stringClassName, | ||
style: stringStyle | ||
}, "\"" + data + "\""); | ||
@@ -70,6 +124,8 @@ | ||
{ | ||
var _dataJSX2 = data ? React.createElement("span", { | ||
style: _extends({}, jsonStyle.booleanStyle, jsonStyle.trueStyle) | ||
}, "true") : React.createElement("span", { | ||
style: _extends({}, jsonStyle.booleanStyle, jsonStyle.trueStyle) | ||
var _dataJSX2 = data ? React__default.createElement("span", { | ||
className: booleanClassName + " " + trueClassName, | ||
style: _extends({}, booleanStyle, trueStyle) | ||
}, "true") : React__default.createElement("span", { | ||
className: booleanClassName + " " + falseClassName, | ||
style: _extends({}, booleanStyle, falseStyle) | ||
}, "false"); | ||
@@ -84,7 +140,8 @@ | ||
_dataJSX3.push(React.createElement(React.Fragment, { | ||
_dataJSX3.push(React__default.createElement(React__default.Fragment, { | ||
key: '{' | ||
}, React.createElement("span", { | ||
style: jsonStyle.braceStyle | ||
}, '{'), React.createElement("br", null))); | ||
}, React__default.createElement("span", { | ||
className: braceClassName, | ||
style: braceStyle | ||
}, '{'), React__default.createElement("br", null))); | ||
@@ -94,14 +151,16 @@ var keys = Object.keys(data); | ||
Object.keys(data).forEach(function (key, index) { | ||
_dataJSX3.push(React.createElement(React.Fragment, { | ||
_dataJSX3.push(React__default.createElement(React__default.Fragment, { | ||
key: index | ||
}, repeatTabSpace(TabSpaceRepeatTimes), React.createElement("span", { | ||
style: jsonStyle.propertyStyle | ||
}, "\"" + key + "\": "), categorize(data[key]), index !== keys.length - 1 && React.createElement("span", null, ","), React.createElement("br", null))); | ||
}, repeatTabSpace(TabSpaceRepeatTimes), React__default.createElement("span", { | ||
className: propertyClassName, | ||
style: propertyStyle | ||
}, "\"" + key + "\": "), categorize(data[key]), index !== keys.length - 1 && React__default.createElement("span", null, ","), React__default.createElement("br", null))); | ||
}); | ||
TabSpaceRepeatTimes -= 1; | ||
_dataJSX3.push(React.createElement(React.Fragment, { | ||
_dataJSX3.push(React__default.createElement(React__default.Fragment, { | ||
key: '}' | ||
}, repeatTabSpace(TabSpaceRepeatTimes), React.createElement("span", { | ||
style: jsonStyle.braceStyle | ||
}, repeatTabSpace(TabSpaceRepeatTimes), React__default.createElement("span", { | ||
className: braceClassName, | ||
style: braceStyle | ||
}, '}'))); | ||
@@ -116,7 +175,8 @@ | ||
_dataJSX4.push(React.createElement(React.Fragment, { | ||
_dataJSX4.push(React__default.createElement(React__default.Fragment, { | ||
key: '[' | ||
}, React.createElement("span", { | ||
style: jsonStyle.bracketStyle | ||
}, "["), React.createElement("br", null))); | ||
}, React__default.createElement("span", { | ||
className: bracketClassName, | ||
style: bracketStyle | ||
}, "["), React__default.createElement("br", null))); | ||
@@ -126,7 +186,8 @@ TabSpaceRepeatTimes += 1; | ||
for (var i = 0; i < data.length; i++) { | ||
_dataJSX4.push(React.createElement(React.Fragment, { | ||
_dataJSX4.push(React__default.createElement(React__default.Fragment, { | ||
key: i | ||
}, repeatTabSpace(TabSpaceRepeatTimes), categorize(data[i]), i === data.length - 1 ? null : React.createElement("span", { | ||
style: jsonStyle.commaStyle | ||
}, ","), React.createElement("br", null))); | ||
}, repeatTabSpace(TabSpaceRepeatTimes), categorize(data[i]), i === data.length - 1 ? null : React__default.createElement("span", { | ||
className: commaClassName, | ||
style: commaStyle | ||
}, ","), React__default.createElement("br", null))); | ||
} | ||
@@ -136,6 +197,7 @@ | ||
_dataJSX4.push(React.createElement(React.Fragment, { | ||
_dataJSX4.push(React__default.createElement(React__default.Fragment, { | ||
key: ']' | ||
}, repeatTabSpace(TabSpaceRepeatTimes), React.createElement("span", { | ||
style: jsonStyle.bracketStyle | ||
}, repeatTabSpace(TabSpaceRepeatTimes), React__default.createElement("span", { | ||
className: bracketClassName, | ||
style: bracketStyle | ||
}, "]"))); | ||
@@ -148,4 +210,5 @@ | ||
{ | ||
var _dataJSX5 = React.createElement("span", { | ||
style: jsonStyle.nullStyle | ||
var _dataJSX5 = React__default.createElement("span", { | ||
className: nullClassName, | ||
style: nullStyle | ||
}, "null"); | ||
@@ -157,12 +220,15 @@ | ||
default: | ||
return React.createElement("span", null, "type error"); | ||
return React__default.createElement("span", null, "type error"); | ||
} | ||
} | ||
return React.createElement("div", { | ||
style: jsonStyle.style | ||
}, React.createElement("div", null, categorize(jsonObject))); | ||
}, [booleanClassName, booleanStyle, braceClassName, braceStyle, bracketClassName, bracketStyle, commaClassName, commaStyle, falseClassName, falseStyle, nullClassName, nullStyle, numberClassName, numberStyle, propertyClassName, propertyStyle, repeatTabSpace, stringClassName, stringStyle, trueClassName, trueStyle]); | ||
var result = React.useMemo(function () { | ||
return categorize(jsonObject); | ||
}, [categorize, jsonObject]); | ||
return React__default.createElement("div", { | ||
className: className, | ||
style: style | ||
}, React__default.createElement("div", null, result)); | ||
} | ||
exports.JsonFormatter = JsonFormatter; | ||
module.exports = JsonFormatter; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import React from 'react'; | ||
import React, { useMemo, useCallback } from 'react'; | ||
@@ -25,7 +25,58 @@ function _extends() { | ||
tabWith = _ref$tabWith === void 0 ? 2 : _ref$tabWith, | ||
_ref$jsonStyle = _ref.jsonStyle, | ||
jsonStyle = _ref$jsonStyle === void 0 ? {} : _ref$jsonStyle; | ||
var jsonObject = JSON.parse(json); | ||
var repeatTabSpace = function repeatTabSpace(times) { | ||
_ref$jsonStyle = _ref.jsonStyle; | ||
_ref$jsonStyle = _ref$jsonStyle === void 0 ? {} : _ref$jsonStyle; | ||
var _ref$jsonStyle$boolea = _ref$jsonStyle.booleanStyle, | ||
booleanStyle = _ref$jsonStyle$boolea === void 0 ? {} : _ref$jsonStyle$boolea, | ||
_ref$jsonStyle$braceS = _ref$jsonStyle.braceStyle, | ||
braceStyle = _ref$jsonStyle$braceS === void 0 ? {} : _ref$jsonStyle$braceS, | ||
_ref$jsonStyle$bracke = _ref$jsonStyle.bracketStyle, | ||
bracketStyle = _ref$jsonStyle$bracke === void 0 ? {} : _ref$jsonStyle$bracke, | ||
_ref$jsonStyle$commaS = _ref$jsonStyle.commaStyle, | ||
commaStyle = _ref$jsonStyle$commaS === void 0 ? {} : _ref$jsonStyle$commaS, | ||
_ref$jsonStyle$falseS = _ref$jsonStyle.falseStyle, | ||
falseStyle = _ref$jsonStyle$falseS === void 0 ? {} : _ref$jsonStyle$falseS, | ||
_ref$jsonStyle$nullSt = _ref$jsonStyle.nullStyle, | ||
nullStyle = _ref$jsonStyle$nullSt === void 0 ? {} : _ref$jsonStyle$nullSt, | ||
_ref$jsonStyle$number = _ref$jsonStyle.numberStyle, | ||
numberStyle = _ref$jsonStyle$number === void 0 ? {} : _ref$jsonStyle$number, | ||
_ref$jsonStyle$proper = _ref$jsonStyle.propertyStyle, | ||
propertyStyle = _ref$jsonStyle$proper === void 0 ? {} : _ref$jsonStyle$proper, | ||
_ref$jsonStyle$string = _ref$jsonStyle.stringStyle, | ||
stringStyle = _ref$jsonStyle$string === void 0 ? {} : _ref$jsonStyle$string, | ||
_ref$jsonStyle$style = _ref$jsonStyle.style, | ||
style = _ref$jsonStyle$style === void 0 ? {} : _ref$jsonStyle$style, | ||
_ref$jsonStyle$tabSpa = _ref$jsonStyle.tabSpaceStyle, | ||
tabSpaceStyle = _ref$jsonStyle$tabSpa === void 0 ? {} : _ref$jsonStyle$tabSpa, | ||
_ref$jsonStyle$trueSt = _ref$jsonStyle.trueStyle, | ||
trueStyle = _ref$jsonStyle$trueSt === void 0 ? {} : _ref$jsonStyle$trueSt, | ||
_ref$jsonClassName = _ref.jsonClassName; | ||
_ref$jsonClassName = _ref$jsonClassName === void 0 ? {} : _ref$jsonClassName; | ||
var _ref$jsonClassName$bo = _ref$jsonClassName.booleanClassName, | ||
booleanClassName = _ref$jsonClassName$bo === void 0 ? '' : _ref$jsonClassName$bo, | ||
_ref$jsonClassName$br = _ref$jsonClassName.braceClassName, | ||
braceClassName = _ref$jsonClassName$br === void 0 ? '' : _ref$jsonClassName$br, | ||
_ref$jsonClassName$br2 = _ref$jsonClassName.bracketClassName, | ||
bracketClassName = _ref$jsonClassName$br2 === void 0 ? '' : _ref$jsonClassName$br2, | ||
_ref$jsonClassName$cl = _ref$jsonClassName.className, | ||
className = _ref$jsonClassName$cl === void 0 ? '' : _ref$jsonClassName$cl, | ||
_ref$jsonClassName$co = _ref$jsonClassName.commaClassName, | ||
commaClassName = _ref$jsonClassName$co === void 0 ? '' : _ref$jsonClassName$co, | ||
_ref$jsonClassName$fa = _ref$jsonClassName.falseClassName, | ||
falseClassName = _ref$jsonClassName$fa === void 0 ? '' : _ref$jsonClassName$fa, | ||
_ref$jsonClassName$nu = _ref$jsonClassName.nullClassName, | ||
nullClassName = _ref$jsonClassName$nu === void 0 ? '' : _ref$jsonClassName$nu, | ||
_ref$jsonClassName$nu2 = _ref$jsonClassName.numberClassName, | ||
numberClassName = _ref$jsonClassName$nu2 === void 0 ? '' : _ref$jsonClassName$nu2, | ||
_ref$jsonClassName$pr = _ref$jsonClassName.propertyClassName, | ||
propertyClassName = _ref$jsonClassName$pr === void 0 ? '' : _ref$jsonClassName$pr, | ||
_ref$jsonClassName$st = _ref$jsonClassName.stringClassName, | ||
stringClassName = _ref$jsonClassName$st === void 0 ? '' : _ref$jsonClassName$st, | ||
_ref$jsonClassName$ta = _ref$jsonClassName.tabSpaceClassName, | ||
tabSpaceClassName = _ref$jsonClassName$ta === void 0 ? '' : _ref$jsonClassName$ta, | ||
_ref$jsonClassName$tr = _ref$jsonClassName.trueClassName, | ||
trueClassName = _ref$jsonClassName$tr === void 0 ? '' : _ref$jsonClassName$tr; | ||
var jsonObject = useMemo(function () { | ||
return JSON.parse(json); | ||
}, [json]); | ||
var repeatTabSpace = useCallback(function (times) { | ||
var repeatedTabSpace = []; | ||
@@ -35,4 +86,5 @@ | ||
repeatedTabSpace.push(React.createElement("span", { | ||
className: tabSpaceClassName, | ||
key: i, | ||
style: jsonStyle.tabSpaceStyle | ||
style: tabSpaceStyle | ||
}, '\xa0'.repeat(tabWith || 4))); | ||
@@ -42,7 +94,6 @@ } | ||
return repeatedTabSpace; | ||
}; | ||
}, [tabSpaceClassName, tabSpaceStyle, tabWith]); | ||
var categorize = useCallback(function (data) { | ||
var TabSpaceRepeatTimes = 0; | ||
var TabSpaceRepeatTimes = 0; | ||
function categorize(data) { | ||
switch (Object.prototype.toString.call(data)) { | ||
@@ -52,3 +103,4 @@ case '[object Number]': | ||
var dataJSX = React.createElement("span", { | ||
style: jsonStyle.numberStyle | ||
className: numberClassName, | ||
style: numberStyle | ||
}, data); | ||
@@ -61,3 +113,4 @@ return dataJSX; | ||
var _dataJSX = React.createElement("span", { | ||
style: jsonStyle.stringStyle | ||
className: stringClassName, | ||
style: stringStyle | ||
}, "\"" + data + "\""); | ||
@@ -71,5 +124,7 @@ | ||
var _dataJSX2 = data ? React.createElement("span", { | ||
style: _extends({}, jsonStyle.booleanStyle, jsonStyle.trueStyle) | ||
className: booleanClassName + " " + trueClassName, | ||
style: _extends({}, booleanStyle, trueStyle) | ||
}, "true") : React.createElement("span", { | ||
style: _extends({}, jsonStyle.booleanStyle, jsonStyle.trueStyle) | ||
className: booleanClassName + " " + falseClassName, | ||
style: _extends({}, booleanStyle, falseStyle) | ||
}, "false"); | ||
@@ -87,3 +142,4 @@ | ||
}, React.createElement("span", { | ||
style: jsonStyle.braceStyle | ||
className: braceClassName, | ||
style: braceStyle | ||
}, '{'), React.createElement("br", null))); | ||
@@ -97,3 +153,4 @@ | ||
}, repeatTabSpace(TabSpaceRepeatTimes), React.createElement("span", { | ||
style: jsonStyle.propertyStyle | ||
className: propertyClassName, | ||
style: propertyStyle | ||
}, "\"" + key + "\": "), categorize(data[key]), index !== keys.length - 1 && React.createElement("span", null, ","), React.createElement("br", null))); | ||
@@ -106,3 +163,4 @@ }); | ||
}, repeatTabSpace(TabSpaceRepeatTimes), React.createElement("span", { | ||
style: jsonStyle.braceStyle | ||
className: braceClassName, | ||
style: braceStyle | ||
}, '}'))); | ||
@@ -120,3 +178,4 @@ | ||
}, React.createElement("span", { | ||
style: jsonStyle.bracketStyle | ||
className: bracketClassName, | ||
style: bracketStyle | ||
}, "["), React.createElement("br", null))); | ||
@@ -130,3 +189,4 @@ | ||
}, repeatTabSpace(TabSpaceRepeatTimes), categorize(data[i]), i === data.length - 1 ? null : React.createElement("span", { | ||
style: jsonStyle.commaStyle | ||
className: commaClassName, | ||
style: commaStyle | ||
}, ","), React.createElement("br", null))); | ||
@@ -140,3 +200,4 @@ } | ||
}, repeatTabSpace(TabSpaceRepeatTimes), React.createElement("span", { | ||
style: jsonStyle.bracketStyle | ||
className: bracketClassName, | ||
style: bracketStyle | ||
}, "]"))); | ||
@@ -150,3 +211,4 @@ | ||
var _dataJSX5 = React.createElement("span", { | ||
style: jsonStyle.nullStyle | ||
className: nullClassName, | ||
style: nullStyle | ||
}, "null"); | ||
@@ -160,10 +222,13 @@ | ||
} | ||
} | ||
}, [booleanClassName, booleanStyle, braceClassName, braceStyle, bracketClassName, bracketStyle, commaClassName, commaStyle, falseClassName, falseStyle, nullClassName, nullStyle, numberClassName, numberStyle, propertyClassName, propertyStyle, repeatTabSpace, stringClassName, stringStyle, trueClassName, trueStyle]); | ||
var result = useMemo(function () { | ||
return categorize(jsonObject); | ||
}, [categorize, jsonObject]); | ||
return React.createElement("div", { | ||
style: jsonStyle.style | ||
}, React.createElement("div", null, categorize(jsonObject))); | ||
className: className, | ||
style: style | ||
}, React.createElement("div", null, result)); | ||
} | ||
export { JsonFormatter }; | ||
export default JsonFormatter; | ||
//# sourceMappingURL=index.modern.js.map |
{ | ||
"name": "react-json-formatter", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Formatting json data to JSX of React", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -88,8 +88,6 @@ # react-json-formatter | ||
## style | ||
## styles | ||
Use the Object jsonStyle to control the style of formatted JSON. | ||
Use the Object `jsonStyle` to control the style of formatted JSON. | ||
- from the 0.2.0 version, NOT support for className. | ||
| style | part | | ||
@@ -111,2 +109,22 @@ | ------------- | ----------------------------------------- | | ||
## ClassNames | ||
Use the Object `jsonClassName` to add the className to formatted JSON. | ||
| style | part | | ||
| ----------------- | ----------------------------------------- | | ||
| propertyClassName | The properties of Object. | | ||
| colonClassName | The colons of Object. | | ||
| className | The whole parts of the formatted JSON. | | ||
| tabSpaceClassName | The space of the tabs at Object or Array. | | ||
| numberClassName | The numbers in JSON. | | ||
| stringClassName | The strings in JSON. | | ||
| booleanClassName | Both boolean values in JSON. | | ||
| trueClassName | The boolean values of true in JSON. | | ||
| falseClassName | The boolean values of false in JSON. | | ||
| nullClassName | The null values in JSON | | ||
| commaClassName | The commas used in Array and Object | | ||
| braceClassName | The braces of Object. | | ||
| bracketClassName | The brackets of Array. | | ||
## Contributing | ||
@@ -113,0 +131,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
53221
429
135
0