@uiw/react-json-view 1.7.0 → 1.8.0
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 +32 -7
- package/cjs/editor/countInfoExtra.d.ts +10 -2
- package/cjs/editor/countInfoExtra.js +50 -6
- package/cjs/editor/icon/add.js +3 -3
- package/cjs/editor/icon/delete.d.ts +4 -0
- package/cjs/editor/icon/delete.js +30 -0
- package/cjs/editor/index.d.ts +10 -2
- package/cjs/editor/index.js +5 -2
- package/cjs/editor/value.d.ts +3 -0
- package/cjs/editor/value.js +126 -64
- package/cjs/node.d.ts +2 -0
- package/cjs/node.js +20 -10
- package/cjs/value.d.ts +13 -7
- package/cjs/value.js +6 -2
- package/editor.d.ts +5 -0
- package/esm/editor/countInfoExtra.d.ts +10 -2
- package/esm/editor/countInfoExtra.js +37 -6
- package/esm/editor/icon/add.js +3 -3
- package/esm/editor/icon/delete.d.ts +4 -0
- package/esm/editor/icon/delete.js +24 -0
- package/esm/editor/index.d.ts +10 -2
- package/esm/editor/index.js +6 -3
- package/esm/editor/value.d.ts +3 -0
- package/esm/editor/value.js +94 -59
- package/esm/node.d.ts +2 -0
- package/esm/node.js +13 -4
- package/esm/value.d.ts +13 -7
- package/esm/value.js +6 -2
- package/package.json +1 -1
package/esm/node.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 = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "collapsed", "level", "keyid", "quotes", "onCopied", "onExpand"];
|
|
3
|
+
var _excluded = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "collapsed", "level", "keyid", "quotes", "onCopied", "onExpand", "parentValue", "setParentValue"];
|
|
4
4
|
import { Fragment, useId, cloneElement, useState, useEffect } from 'react';
|
|
5
5
|
import { ValueView, Colon, Label, Line, typeMap } from './value';
|
|
6
6
|
import { TriangleArrow } from './arrow/TriangleArrow';
|
|
@@ -43,7 +43,9 @@ export function RooNode(props) {
|
|
|
43
43
|
keyid = 'root',
|
|
44
44
|
quotes = '"',
|
|
45
45
|
onCopied,
|
|
46
|
-
onExpand
|
|
46
|
+
onExpand,
|
|
47
|
+
parentValue,
|
|
48
|
+
setParentValue
|
|
47
49
|
} = props,
|
|
48
50
|
reset = _objectWithoutPropertiesLoose(props, _excluded);
|
|
49
51
|
var isArray = Array.isArray(value);
|
|
@@ -63,6 +65,7 @@ export function RooNode(props) {
|
|
|
63
65
|
});
|
|
64
66
|
!expand ? store.expand(keyid) : store.collapse(keyid);
|
|
65
67
|
};
|
|
68
|
+
var [valueData, setValueData] = useState(value);
|
|
66
69
|
var subNodeProps = {
|
|
67
70
|
components,
|
|
68
71
|
indentWidth,
|
|
@@ -73,6 +76,8 @@ export function RooNode(props) {
|
|
|
73
76
|
onCopied,
|
|
74
77
|
onExpand,
|
|
75
78
|
collapsed,
|
|
79
|
+
parentValue: value,
|
|
80
|
+
setParentValue: setValueData,
|
|
76
81
|
quotes,
|
|
77
82
|
level: level + 1,
|
|
78
83
|
style: {
|
|
@@ -84,7 +89,9 @@ export function RooNode(props) {
|
|
|
84
89
|
displayObjectSize,
|
|
85
90
|
enableClipboard,
|
|
86
91
|
indentWidth,
|
|
92
|
+
data: valueData,
|
|
87
93
|
quotes,
|
|
94
|
+
setValue: setValueData,
|
|
88
95
|
renderBraces: components.braces,
|
|
89
96
|
renderValue: components.value
|
|
90
97
|
};
|
|
@@ -102,7 +109,6 @@ export function RooNode(props) {
|
|
|
102
109
|
eventProps.onMouseEnter = () => setShowTools(true);
|
|
103
110
|
eventProps.onMouseLeave = () => setShowTools(false);
|
|
104
111
|
}
|
|
105
|
-
var [valueData, setValueData] = useState(value);
|
|
106
112
|
useEffect(() => setValueData(value), [value]);
|
|
107
113
|
var nameKeys = isArray ? Object.keys(valueData).map(m => Number(m)) : Object.keys(valueData);
|
|
108
114
|
|
|
@@ -165,8 +171,11 @@ export function RooNode(props) {
|
|
|
165
171
|
count: nameKeys.length,
|
|
166
172
|
level,
|
|
167
173
|
showTools,
|
|
174
|
+
keyName,
|
|
168
175
|
visible: expand,
|
|
169
176
|
value: valueData,
|
|
177
|
+
parentValue,
|
|
178
|
+
setParentValue,
|
|
170
179
|
setValue: setValueData
|
|
171
180
|
}), enableClipboard && /*#__PURE__*/_jsx(Copied, {
|
|
172
181
|
show: showTools,
|
|
@@ -180,7 +189,7 @@ export function RooNode(props) {
|
|
|
180
189
|
borderLeft: 'var(--w-rjv-border-left-width, 1px) var(--w-rjv-line-style, solid) var(--w-rjv-line-color, #ebebeb)',
|
|
181
190
|
marginLeft: 6
|
|
182
191
|
},
|
|
183
|
-
children: entries.length > 0 && entries.map((_ref6, idx) => {
|
|
192
|
+
children: entries.length > 0 && [...entries].map((_ref6, idx) => {
|
|
184
193
|
var [key, itemVal] = _ref6;
|
|
185
194
|
var item = itemVal;
|
|
186
195
|
var renderKey = /*#__PURE__*/_jsx(Semicolon, {
|
package/esm/value.d.ts
CHANGED
|
@@ -46,9 +46,19 @@ export declare const typeMap: {
|
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
export declare const Colon: FC<PropsWithChildren<React.HTMLAttributes<HTMLSpanElement>>>;
|
|
49
|
+
interface RenderValueProps<T extends object> extends React.HTMLAttributes<HTMLSpanElement> {
|
|
50
|
+
type: TypeProps['type'];
|
|
51
|
+
value?: unknown;
|
|
52
|
+
data?: T;
|
|
53
|
+
visible?: boolean;
|
|
54
|
+
quotes?: JsonViewProps<T>['quotes'];
|
|
55
|
+
setValue?: React.Dispatch<React.SetStateAction<T>>;
|
|
56
|
+
keyName?: ValueViewProps<T>['keyName'];
|
|
57
|
+
}
|
|
49
58
|
export interface ValueViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
|
|
50
59
|
keyName?: string | number;
|
|
51
60
|
value?: unknown;
|
|
61
|
+
data?: T;
|
|
52
62
|
displayDataTypes: boolean;
|
|
53
63
|
displayObjectSize: boolean;
|
|
54
64
|
enableClipboard: boolean;
|
|
@@ -57,13 +67,8 @@ export interface ValueViewProps<T extends object> extends React.DetailedHTMLProp
|
|
|
57
67
|
quotes?: JsonViewProps<T>['quotes'];
|
|
58
68
|
renderKey?: JSX.Element;
|
|
59
69
|
renderBraces?: MetaProps['render'];
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
value?: unknown;
|
|
63
|
-
visible?: boolean;
|
|
64
|
-
quotes?: JsonViewProps<T>['quotes'];
|
|
65
|
-
keyName?: ValueViewProps<T>['keyName'];
|
|
66
|
-
}) => JSX.Element;
|
|
70
|
+
setValue?: React.Dispatch<React.SetStateAction<T>>;
|
|
71
|
+
renderValue?: (props: RenderValueProps<T>) => JSX.Element;
|
|
67
72
|
}
|
|
68
73
|
export declare function getValueString<T>(value: T): {
|
|
69
74
|
type: "string" | "number" | "bigint" | "boolean" | "undefined" | "date" | "url" | "float" | "null" | "NaN";
|
|
@@ -81,3 +86,4 @@ export interface TypeProps extends React.DetailedHTMLProps<React.HTMLAttributes<
|
|
|
81
86
|
type: keyof typeof typeMap;
|
|
82
87
|
}
|
|
83
88
|
export declare const Type: FC<PropsWithChildren<TypeProps>>;
|
|
89
|
+
export {};
|
package/esm/value.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
var _excluded = ["children", "style"],
|
|
4
|
-
_excluded2 = ["value", "keyName", "indentWidth", "renderKey", "quotes", "level", "renderValue", "renderBraces", "enableClipboard", "displayObjectSize", "displayDataTypes"],
|
|
4
|
+
_excluded2 = ["value", "setValue", "data", "keyName", "indentWidth", "renderKey", "quotes", "level", "renderValue", "renderBraces", "enableClipboard", "displayObjectSize", "displayDataTypes"],
|
|
5
5
|
_excluded3 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
|
|
6
6
|
import { Fragment, forwardRef, useState } from 'react';
|
|
7
7
|
import { CountInfo } from './node';
|
|
@@ -38,7 +38,7 @@ export var typeMap = {
|
|
|
38
38
|
},
|
|
39
39
|
url: {
|
|
40
40
|
color: 'var(--w-rjv-type-url-color, #0969da)',
|
|
41
|
-
label: '
|
|
41
|
+
label: 'url'
|
|
42
42
|
},
|
|
43
43
|
null: {
|
|
44
44
|
color: 'var(--w-rjv-type-null-color, #d33682)',
|
|
@@ -112,6 +112,8 @@ export function ValueView(props) {
|
|
|
112
112
|
var _typeMap$type;
|
|
113
113
|
var {
|
|
114
114
|
value,
|
|
115
|
+
setValue,
|
|
116
|
+
data,
|
|
115
117
|
keyName,
|
|
116
118
|
indentWidth,
|
|
117
119
|
renderKey,
|
|
@@ -169,6 +171,8 @@ export function ValueView(props) {
|
|
|
169
171
|
}, style),
|
|
170
172
|
type,
|
|
171
173
|
value,
|
|
174
|
+
setValue,
|
|
175
|
+
data,
|
|
172
176
|
quotes,
|
|
173
177
|
keyName,
|
|
174
178
|
visible: showTools,
|