@uiw/react-json-view 2.0.0-alpha.30 → 2.0.0-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -12
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +3 -1
- package/cjs/store.d.ts +1 -0
- package/cjs/types/index.js +7 -4
- package/esm/index.d.ts +2 -0
- package/esm/index.js +3 -1
- package/esm/store.d.ts +1 -0
- package/esm/types/index.js +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,20 +19,19 @@ A React component for displaying and editing javascript arrays and JSON objects.
|
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
🎨
|
|
24
|
-
🌒
|
|
25
|
-
📦 Zero
|
|
26
|
-
📋
|
|
27
|
-
✏️
|
|
28
|
-
♻️
|
|
22
|
+
🚀 **Improved with TypeScript** – Better code hints for a smoother development experience.
|
|
23
|
+
🎨 **Customizable Themes** – Supports theme customization & [`online editing`](https://uiwjs.github.io/react-json-view/#online-editing-theme).
|
|
24
|
+
🌒 **Dark/Light Mode** – Seamless switching between themes.
|
|
25
|
+
📦 **Zero Dependencies** – Lightweight and efficient.
|
|
26
|
+
📋 **Clipboard Support** – Easily copy JSON data.
|
|
27
|
+
✏️ **Editable & Extendable** – Supports editing and adding new properties.
|
|
28
|
+
♻️ **Update Highlighting** – Option to highlight changes.
|
|
29
29
|
|
|
30
|
-
The
|
|
31
|
-
|
|
32
|
-
- [x] Complete all features of displaying JSON in v1.
|
|
33
|
-
- [ ] Add editing functionality to v2.
|
|
34
|
-
- [x] Add test cases to v2.
|
|
30
|
+
The latest version [**v2**](https://uiwjs.github.io/react-json-view/) features a redesigned API for better maintainability, a more flexible component customization system, and fully customizable rendering, making it more aligned with React’s component model. 📖 Check out the [v2 documentation](https://uiwjs.github.io/react-json-view/) and [examples](https://uiwjs.github.io/react-json-view/).
|
|
35
31
|
|
|
32
|
+
- [x] Fully implemented all v1 JSON display features.
|
|
33
|
+
- [ ] Adding editing functionality to v2.
|
|
34
|
+
- [x] Added comprehensive test cases for v2.
|
|
36
35
|
|
|
37
36
|
## Quick Start
|
|
38
37
|
|
|
@@ -888,6 +887,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
888
887
|
highlightUpdates?: boolean;
|
|
889
888
|
/** Shorten long JSON strings, Set to `0` to disable this feature @default 30 */
|
|
890
889
|
shortenTextAfterLength?: number;
|
|
890
|
+
/** When the text exceeds the length, `...` will be displayed. Currently, this `...` can be customized. @default "..." */
|
|
891
|
+
stringEllipsis?: number;
|
|
891
892
|
/** Callback function for when a treeNode is expanded or collapsed */
|
|
892
893
|
onExpand?: (props: { expand: boolean; value?: T; keyid: string; keyName?: string | number }) => void;
|
|
893
894
|
/** Fires event when you copy */
|
package/cjs/index.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
58
58
|
highlightUpdates?: boolean;
|
|
59
59
|
/** Shorten long JSON strings, Set to `0` to disable this feature @default 30 */
|
|
60
60
|
shortenTextAfterLength?: number;
|
|
61
|
+
/** When the text exceeds the length, `...` will be displayed. Currently, this `...` can be customized. @default "..." */
|
|
62
|
+
stringEllipsis?: number;
|
|
61
63
|
/** Callback function for when a treeNode is expanded or collapsed */
|
|
62
64
|
onExpand?: (props: {
|
|
63
65
|
expand: boolean;
|
package/cjs/index.js
CHANGED
|
@@ -110,7 +110,7 @@ Object.keys(_symbol).forEach(function (key) {
|
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
|
-
var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied"];
|
|
113
|
+
var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "stringEllipsis", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied"];
|
|
114
114
|
var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
115
115
|
var _props$className = props.className,
|
|
116
116
|
className = _props$className === void 0 ? '' : _props$className,
|
|
@@ -125,6 +125,7 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
125
125
|
displayObjectSize = _props$displayObjectS === void 0 ? true : _props$displayObjectS,
|
|
126
126
|
_props$shortenTextAft = props.shortenTextAfterLength,
|
|
127
127
|
shortenTextAfterLength = _props$shortenTextAft === void 0 ? 30 : _props$shortenTextAft,
|
|
128
|
+
stringEllipsis = props.stringEllipsis,
|
|
128
129
|
_props$highlightUpdat = props.highlightUpdates,
|
|
129
130
|
highlightUpdates = _props$highlightUpdat === void 0 ? true : _props$highlightUpdat,
|
|
130
131
|
_props$enableClipboar = props.enableClipboard,
|
|
@@ -154,6 +155,7 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
154
155
|
collapsed: collapsed,
|
|
155
156
|
enableClipboard: enableClipboard,
|
|
156
157
|
shortenTextAfterLength: shortenTextAfterLength,
|
|
158
|
+
stringEllipsis: stringEllipsis,
|
|
157
159
|
highlightUpdates: highlightUpdates,
|
|
158
160
|
onCopied: onCopied,
|
|
159
161
|
onExpand: onExpand
|
package/cjs/store.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface InitialState<T extends object> {
|
|
|
9
9
|
objectSortKeys?: JsonViewProps<T>['objectSortKeys'];
|
|
10
10
|
displayObjectSize?: JsonViewProps<T>['displayObjectSize'];
|
|
11
11
|
shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
|
|
12
|
+
stringEllipsis?: JsonViewProps<T>['stringEllipsis'];
|
|
12
13
|
enableClipboard?: JsonViewProps<T>['enableClipboard'];
|
|
13
14
|
highlightUpdates?: JsonViewProps<T>['highlightUpdates'];
|
|
14
15
|
collapsed?: JsonViewProps<T>['collapsed'];
|
package/cjs/types/index.js
CHANGED
|
@@ -98,7 +98,9 @@ var TypeString = exports.TypeString = function TypeString(_ref3) {
|
|
|
98
98
|
displayDataTypes = _useTypesStore3.displayDataTypes;
|
|
99
99
|
var _useStore = (0, _store.useStore)(),
|
|
100
100
|
_useStore$shortenText = _useStore.shortenTextAfterLength,
|
|
101
|
-
length = _useStore$shortenText === void 0 ? 30 : _useStore$shortenText
|
|
101
|
+
length = _useStore$shortenText === void 0 ? 30 : _useStore$shortenText,
|
|
102
|
+
_useStore$stringEllip = _useStore.stringEllipsis,
|
|
103
|
+
stringEllipsis = _useStore$stringEllip === void 0 ? '...' : _useStore$stringEllip;
|
|
102
104
|
var as = Str.as,
|
|
103
105
|
render = Str.render,
|
|
104
106
|
reset = (0, _objectWithoutProperties2["default"])(Str, _excluded3);
|
|
@@ -122,7 +124,7 @@ var TypeString = exports.TypeString = function TypeString(_ref3) {
|
|
|
122
124
|
};
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
|
-
var text = shorten ? "".concat(childrenStr.slice(0, length)
|
|
127
|
+
var text = shorten ? "".concat(childrenStr.slice(0, length)).concat(stringEllipsis) : childrenStr;
|
|
126
128
|
var isRender = render && typeof render === 'function';
|
|
127
129
|
var type = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
|
|
128
130
|
style: style
|
|
@@ -131,9 +133,10 @@ var TypeString = exports.TypeString = function TypeString(_ref3) {
|
|
|
131
133
|
value: children,
|
|
132
134
|
keyName: keyName
|
|
133
135
|
});
|
|
136
|
+
var cls = shorten ? 'w-rjv-value w-rjv-value-short' : 'w-rjv-value';
|
|
134
137
|
var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
|
|
135
138
|
children: text,
|
|
136
|
-
className:
|
|
139
|
+
className: cls
|
|
137
140
|
}), {
|
|
138
141
|
type: 'value',
|
|
139
142
|
value: children,
|
|
@@ -144,7 +147,7 @@ var TypeString = exports.TypeString = function TypeString(_ref3) {
|
|
|
144
147
|
style: style
|
|
145
148
|
}))), child || /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
146
149
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.ValueQuote, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
|
|
147
|
-
className:
|
|
150
|
+
className: cls,
|
|
148
151
|
children: text
|
|
149
152
|
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.ValueQuote, {})]
|
|
150
153
|
})]
|
package/esm/index.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
58
58
|
highlightUpdates?: boolean;
|
|
59
59
|
/** Shorten long JSON strings, Set to `0` to disable this feature @default 30 */
|
|
60
60
|
shortenTextAfterLength?: number;
|
|
61
|
+
/** When the text exceeds the length, `...` will be displayed. Currently, this `...` can be customized. @default "..." */
|
|
62
|
+
stringEllipsis?: number;
|
|
61
63
|
/** Callback function for when a treeNode is expanded or collapsed */
|
|
62
64
|
onExpand?: (props: {
|
|
63
65
|
expand: boolean;
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied"];
|
|
3
|
+
var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "stringEllipsis", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied"];
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { Provider } from './store';
|
|
6
6
|
import { Container } from './Container';
|
|
@@ -49,6 +49,7 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
49
49
|
indentWidth = 15,
|
|
50
50
|
displayObjectSize = true,
|
|
51
51
|
shortenTextAfterLength = 30,
|
|
52
|
+
stringEllipsis,
|
|
52
53
|
highlightUpdates = true,
|
|
53
54
|
enableClipboard = true,
|
|
54
55
|
displayDataTypes = true,
|
|
@@ -75,6 +76,7 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
75
76
|
collapsed,
|
|
76
77
|
enableClipboard,
|
|
77
78
|
shortenTextAfterLength,
|
|
79
|
+
stringEllipsis,
|
|
78
80
|
highlightUpdates,
|
|
79
81
|
onCopied,
|
|
80
82
|
onExpand
|
package/esm/store.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface InitialState<T extends object> {
|
|
|
9
9
|
objectSortKeys?: JsonViewProps<T>['objectSortKeys'];
|
|
10
10
|
displayObjectSize?: JsonViewProps<T>['displayObjectSize'];
|
|
11
11
|
shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
|
|
12
|
+
stringEllipsis?: JsonViewProps<T>['stringEllipsis'];
|
|
12
13
|
enableClipboard?: JsonViewProps<T>['enableClipboard'];
|
|
13
14
|
highlightUpdates?: JsonViewProps<T>['highlightUpdates'];
|
|
14
15
|
collapsed?: JsonViewProps<T>['collapsed'];
|
package/esm/types/index.js
CHANGED
|
@@ -98,7 +98,8 @@ export var TypeString = _ref3 => {
|
|
|
98
98
|
displayDataTypes
|
|
99
99
|
} = useTypesStore();
|
|
100
100
|
var {
|
|
101
|
-
shortenTextAfterLength: length = 30
|
|
101
|
+
shortenTextAfterLength: length = 30,
|
|
102
|
+
stringEllipsis = '...'
|
|
102
103
|
} = useStore();
|
|
103
104
|
var {
|
|
104
105
|
as,
|
|
@@ -120,7 +121,7 @@ export var TypeString = _ref3 => {
|
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
var text = shorten ? childrenStr.slice(0, length) +
|
|
124
|
+
var text = shorten ? "" + childrenStr.slice(0, length) + stringEllipsis : childrenStr;
|
|
124
125
|
var isRender = render && typeof render === 'function';
|
|
125
126
|
var type = isRender && render(_extends({}, reset, {
|
|
126
127
|
style
|
|
@@ -129,9 +130,10 @@ export var TypeString = _ref3 => {
|
|
|
129
130
|
value: children,
|
|
130
131
|
keyName
|
|
131
132
|
});
|
|
133
|
+
var cls = shorten ? 'w-rjv-value w-rjv-value-short' : 'w-rjv-value';
|
|
132
134
|
var child = isRender && render(_extends({}, reset, {
|
|
133
135
|
children: text,
|
|
134
|
-
className:
|
|
136
|
+
className: cls
|
|
135
137
|
}), {
|
|
136
138
|
type: 'value',
|
|
137
139
|
value: children,
|
|
@@ -142,7 +144,7 @@ export var TypeString = _ref3 => {
|
|
|
142
144
|
style: style
|
|
143
145
|
}))), child || /*#__PURE__*/_jsxs(Fragment, {
|
|
144
146
|
children: [/*#__PURE__*/_jsx(ValueQuote, {}), /*#__PURE__*/_jsx(Comp, _extends({}, reset, {
|
|
145
|
-
className:
|
|
147
|
+
className: cls,
|
|
146
148
|
children: text
|
|
147
149
|
})), /*#__PURE__*/_jsx(ValueQuote, {})]
|
|
148
150
|
})]
|