Releases: TexteaInc/json-viewer
json-viewer: v3.1.1
json-viewer: v3.1.0
json-viewer: v3.0.0
3.0.0 (2023-04-25)
For the detail and migration guide, check out the Migrating from v2 to v3
Main Changes
This major focus on providing the ability to customize and extend data types. We also moved MUI to peerdependency to reflect the correct dependency relationship.
Dependencies
Starting from v3, dependencies from Material-UI
are no longer included in the package's dependencies.
Run this to install all the necessary dependencies.
npm install @mui/material @emotion/react @emotion/styled
Browser compatibility
This package was set to support ES5
by default, but it's no longer the case.
Since V3, as this package is using Material-UI
, we have adjusted the browser compatibility to match the Material-UI's one.
Use defineDataType
instead of createDataType
serialize
and deserialize
have been added to datatype to support editing feature on any data type.
As the result, createDataType
has been renamed to defineDataType
and the signature has been changed to accept an object instead of a long list of arguments. For more information, please refer to Defining data types.
- createDataType(
- (value) => typeof value === 'string' && value.startsWith('https://i.imgur.com'),
- (props) => <Image height={50} width={50} src={props.value} alt={props.value} />
- )
+ defineDataType({
+ is: (value) => typeof value === 'string' && value.startsWith('https://i.imgur.com'),
+ Component: (props) => <Image height={50} width={50} src={props.value} alt={props.value} />
+ })
Rename displayObjectSize
to displaySize
displayObjectSize
has been renamed to displaySize
to describe the prop's purpose more accurately.
<JsonViewer
- displayObjectSize={true}
+ displaySize={true}
value={value}
/>
Now you can provide a function to customize this behavior by returning a boolean based on the value and path.
<JsonViewer
displaySize={(path, value) => {
if (Array.isArray(value)) return false
if (value instanceof Map) return true
return true
}}
value={value}
/>
Expose built-in type for extending
For more information, check Extend Built-in Data Types.
Features
- dropping
createDataType
and change the signature of EditorComponent to only accept string - expose
defineEasyType
for easier customization (d727adb) - expose built-in type (ed64769)
- rename
displayObjectSize
todisplaySize
(2e5739c)