@uiw/react-json-view 1.11.0 → 1.12.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 +4 -1
- package/cjs/editor/value.js +4 -1
- package/cjs/index.js +2 -1
- package/cjs/node.d.ts +2 -0
- package/cjs/node.js +24 -10
- package/cjs/value.d.ts +10 -1
- package/cjs/value.js +11 -6
- package/esm/editor/value.js +4 -1
- package/esm/index.js +2 -1
- package/esm/node.d.ts +2 -0
- package/esm/node.js +23 -11
- package/esm/value.d.ts +10 -1
- package/esm/value.js +10 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -190,6 +190,7 @@ const object = {
|
|
|
190
190
|
null: null,
|
|
191
191
|
undefined,
|
|
192
192
|
timer: 0,
|
|
193
|
+
nan: NaN,
|
|
193
194
|
url: new URL('https://example.com'),
|
|
194
195
|
date: new Date('Tue Sep 13 2022 14:07:44 GMT-0500 (Central Daylight Time)'),
|
|
195
196
|
array: [19, 100.86, 'test', NaN, Infinity],
|
|
@@ -228,9 +229,11 @@ const customTheme = {
|
|
|
228
229
|
'--w-rjv-type-boolean-color': '#559bd4',
|
|
229
230
|
'--w-rjv-type-date-color': '#586e75',
|
|
230
231
|
'--w-rjv-type-url-color': '#0969da',
|
|
231
|
-
'--w-rjv-type-null-color': '#d33682',
|
|
232
232
|
'--w-rjv-type-nan-color': '#859900',
|
|
233
233
|
'--w-rjv-type-undefined-color': '#586e75',
|
|
234
|
+
'--w-rjv-type-null-color': '#d33682',
|
|
235
|
+
'--w-rjv-type-set-color': '#268bd2',
|
|
236
|
+
'--w-rjv-type-map-color': '#268bd2',
|
|
234
237
|
};
|
|
235
238
|
|
|
236
239
|
export default function Demo() {
|
package/cjs/editor/value.js
CHANGED
|
@@ -121,6 +121,9 @@ function ReValue(props) {
|
|
|
121
121
|
} else if (typeof text === 'string' && /^(null)$/gi.test(text)) {
|
|
122
122
|
text = null;
|
|
123
123
|
_typeStr = 'null';
|
|
124
|
+
} else if (typeof text === 'string' && /^(NaN)$/gi.test(text)) {
|
|
125
|
+
text = NaN;
|
|
126
|
+
_typeStr = 'NaN';
|
|
124
127
|
} else if (typeof text === 'string' && /^(undefined)$/gi.test(text)) {
|
|
125
128
|
text = undefined;
|
|
126
129
|
_typeStr = 'undefined';
|
|
@@ -183,7 +186,7 @@ function ReValue(props) {
|
|
|
183
186
|
var typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Type, {
|
|
184
187
|
type: typeStr
|
|
185
188
|
});
|
|
186
|
-
if (typeStr === 'null' || typeStr === 'undefined') {
|
|
189
|
+
if (typeStr === 'null' || typeStr === 'undefined' || type.toLocaleLowerCase() === 'nan') {
|
|
187
190
|
typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
|
|
188
191
|
}
|
|
189
192
|
var deleteHandle = function deleteHandle(_x) {
|
package/cjs/index.js
CHANGED
|
@@ -57,7 +57,8 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
57
57
|
lineHeight: 1.4,
|
|
58
58
|
fontFamily: 'var(--w-rjv-font-family, Menlo, monospace)',
|
|
59
59
|
color: 'var(--w-rjv-color, #002b36)',
|
|
60
|
-
backgroundColor: 'var(--w-rjv-background-color, #00000000)'
|
|
60
|
+
backgroundColor: 'var(--w-rjv-background-color, #00000000)',
|
|
61
|
+
fontSize: 13
|
|
61
62
|
}, style);
|
|
62
63
|
var cls = "w-json-view-container w-rjv ".concat(className || '');
|
|
63
64
|
var keyid = (0, _react.useId)();
|
package/cjs/node.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface RootNodeProps<T extends object> extends JsonViewProps<T> {
|
|
|
7
7
|
keyid?: string;
|
|
8
8
|
level?: number;
|
|
9
9
|
parentValue?: T;
|
|
10
|
+
isSet?: boolean;
|
|
11
|
+
isMap?: boolean;
|
|
10
12
|
namespace?: Array<string | number>;
|
|
11
13
|
setParentValue?: React.Dispatch<React.SetStateAction<T>>;
|
|
12
14
|
}
|
package/cjs/node.js
CHANGED
|
@@ -19,7 +19,7 @@ var _copied = require("./copied");
|
|
|
19
19
|
var _ellipsis = require("./comps/ellipsis");
|
|
20
20
|
var _meta = require("./comps/meta");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
var _excluded = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "shortenTextAfterLength", "collapsed", "level", "keyid", "quotes", "namespace", "onCopied", "onExpand", "parentValue", "setParentValue"];
|
|
22
|
+
var _excluded = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "shortenTextAfterLength", "collapsed", "level", "keyid", "quotes", "namespace", "isSet", "isMap", "onCopied", "onExpand", "parentValue", "setParentValue"];
|
|
23
23
|
function getLength(obj) {
|
|
24
24
|
try {
|
|
25
25
|
return Object.keys(obj).length;
|
|
@@ -72,6 +72,10 @@ var RootNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
72
72
|
quotes = _props$quotes === void 0 ? '"' : _props$quotes,
|
|
73
73
|
_props$namespace = props.namespace,
|
|
74
74
|
namespace = _props$namespace === void 0 ? [] : _props$namespace,
|
|
75
|
+
_props$isSet = props.isSet,
|
|
76
|
+
isSet = _props$isSet === void 0 ? false : _props$isSet,
|
|
77
|
+
_props$isMap = props.isMap,
|
|
78
|
+
isMap = _props$isMap === void 0 ? false : _props$isMap,
|
|
75
79
|
onCopied = props.onCopied,
|
|
76
80
|
onExpand = props.onExpand,
|
|
77
81
|
parentValue = props.parentValue,
|
|
@@ -220,6 +224,10 @@ var RootNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
220
224
|
parentName: keyName,
|
|
221
225
|
color: typeof keyName === 'number' ? _value.typeMap['number'].color : ''
|
|
222
226
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Colon, {})]
|
|
227
|
+
}), isSet && /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Type, {
|
|
228
|
+
type: "Set"
|
|
229
|
+
}), isMap && /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Type, {
|
|
230
|
+
type: "Map"
|
|
223
231
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_meta.Meta, {
|
|
224
232
|
start: true,
|
|
225
233
|
isArray: isArray,
|
|
@@ -250,35 +258,40 @@ var RootNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
250
258
|
key = _ref11[0],
|
|
251
259
|
itemVal = _ref11[1];
|
|
252
260
|
var item = itemVal;
|
|
253
|
-
var
|
|
254
|
-
|
|
261
|
+
var isMySet = item instanceof Set;
|
|
262
|
+
var isMyMap = item instanceof Map;
|
|
263
|
+
var myValue = isMySet ? Array.from(item) : isMyMap ? Object.fromEntries(item) : item;
|
|
264
|
+
var isEmpty = Array.isArray(myValue) && myValue.length === 0 || (0, _typeof2["default"])(myValue) === 'object' && myValue && !(myValue instanceof Date) && Object.keys(myValue).length === 0;
|
|
265
|
+
if ((Array.isArray(myValue) || isMySet || isMyMap) && !isEmpty) {
|
|
255
266
|
var label = isArray ? idx : key;
|
|
256
267
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Line, {
|
|
257
268
|
className: "w-rjv-wrap",
|
|
258
269
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RootNode, (0, _objectSpread2["default"])({
|
|
259
|
-
value:
|
|
270
|
+
value: myValue,
|
|
271
|
+
isSet: isMySet,
|
|
272
|
+
isMap: isMyMap,
|
|
260
273
|
namespace: [].concat((0, _toConsumableArray2["default"])(namespace), [label]),
|
|
261
274
|
keyName: label,
|
|
262
275
|
keyid: keyid + subkeyid + label
|
|
263
276
|
}, subNodeProps))
|
|
264
277
|
}, label + idx);
|
|
265
278
|
}
|
|
266
|
-
if ((0, _typeof2["default"])(
|
|
279
|
+
if ((0, _typeof2["default"])(myValue) === 'object' && myValue && !(myValue instanceof Date) && !isEmpty) {
|
|
267
280
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Line, {
|
|
268
281
|
className: "w-rjv-wrap",
|
|
269
282
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RootNode, (0, _objectSpread2["default"])({
|
|
270
|
-
value:
|
|
283
|
+
value: myValue,
|
|
271
284
|
namespace: [].concat((0, _toConsumableArray2["default"])(namespace), [key]),
|
|
272
285
|
keyName: key,
|
|
273
286
|
keyid: keyid + subkeyid + key
|
|
274
287
|
}, subNodeProps))
|
|
275
288
|
}, key + '' + idx);
|
|
276
289
|
}
|
|
277
|
-
if (typeof
|
|
290
|
+
if (typeof myValue === 'function') {
|
|
278
291
|
return;
|
|
279
292
|
}
|
|
280
293
|
var renderKey = /*#__PURE__*/(0, _jsxRuntime.jsx)(_semicolon.Semicolon, {
|
|
281
|
-
value:
|
|
294
|
+
value: myValue,
|
|
282
295
|
"data-keys": keyid,
|
|
283
296
|
quotes: quotes,
|
|
284
297
|
namespace: [].concat((0, _toConsumableArray2["default"])(namespace), [key]),
|
|
@@ -288,7 +301,7 @@ var RootNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
288
301
|
color: typeof key === 'number' ? _value.typeMap['number'].color : '',
|
|
289
302
|
keyName: key
|
|
290
303
|
});
|
|
291
|
-
var length = Array.isArray(
|
|
304
|
+
var length = Array.isArray(myValue) ? myValue.length : getLength(myValue);
|
|
292
305
|
countInfo = /*#__PURE__*/(0, _jsxRuntime.jsx)(CountInfo, {
|
|
293
306
|
children: length
|
|
294
307
|
});
|
|
@@ -306,7 +319,8 @@ var RootNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
306
319
|
countInfo: countInfo,
|
|
307
320
|
renderKey: renderKey,
|
|
308
321
|
keyName: key,
|
|
309
|
-
|
|
322
|
+
isSet: isSet,
|
|
323
|
+
value: myValue
|
|
310
324
|
}), idx);
|
|
311
325
|
})
|
|
312
326
|
}), expand && /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Line, {
|
package/cjs/value.d.ts
CHANGED
|
@@ -35,6 +35,14 @@ export declare const typeMap: {
|
|
|
35
35
|
color: string;
|
|
36
36
|
label: string;
|
|
37
37
|
};
|
|
38
|
+
Set: {
|
|
39
|
+
color: string;
|
|
40
|
+
label: string;
|
|
41
|
+
};
|
|
42
|
+
Map: {
|
|
43
|
+
color: string;
|
|
44
|
+
label: string;
|
|
45
|
+
};
|
|
38
46
|
NaN: {
|
|
39
47
|
color: string;
|
|
40
48
|
label: string;
|
|
@@ -53,6 +61,7 @@ export interface ValueViewProps<T extends object> extends React.DetailedHTMLProp
|
|
|
53
61
|
displayDataTypes: boolean;
|
|
54
62
|
displayObjectSize: boolean;
|
|
55
63
|
enableClipboard: boolean;
|
|
64
|
+
isSet: boolean;
|
|
56
65
|
indentWidth: number;
|
|
57
66
|
level?: number;
|
|
58
67
|
shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
|
|
@@ -64,7 +73,7 @@ export interface ValueViewProps<T extends object> extends React.DetailedHTMLProp
|
|
|
64
73
|
setValue?: React.Dispatch<React.SetStateAction<T>>;
|
|
65
74
|
}
|
|
66
75
|
export declare function getValueString<T>(value: T): {
|
|
67
|
-
type: "string" | "number" | "bigint" | "boolean" | "undefined" | "date" | "url" | "float" | "null" | "NaN";
|
|
76
|
+
type: "string" | "number" | "bigint" | "boolean" | "undefined" | "date" | "url" | "float" | "null" | "Set" | "Map" | "NaN";
|
|
68
77
|
content: string;
|
|
69
78
|
};
|
|
70
79
|
export declare function ValueView<T extends object>(props: ValueViewProps<T>): import("react/jsx-runtime").JSX.Element;
|
package/cjs/value.js
CHANGED
|
@@ -19,7 +19,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
19
19
|
var _excluded = ["children", "style"],
|
|
20
20
|
_excluded2 = ["children", "length", "style"],
|
|
21
21
|
_excluded3 = ["color", "style", "isURL", "href", "children"],
|
|
22
|
-
_excluded4 = ["value", "parentValue", "setValue", "countInfo", "data", "keyName", "indentWidth", "namespace", "renderKey", "components", "quotes", "level", "enableClipboard", "displayObjectSize", "displayDataTypes", "shortenTextAfterLength"],
|
|
22
|
+
_excluded4 = ["value", "parentValue", "setValue", "countInfo", "data", "keyName", "indentWidth", "isSet", "namespace", "renderKey", "components", "quotes", "level", "enableClipboard", "displayObjectSize", "displayDataTypes", "shortenTextAfterLength"],
|
|
23
23
|
_excluded5 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
|
|
24
24
|
var Line = function Line(props) {
|
|
25
25
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _objectSpread2["default"])({}, props));
|
|
@@ -63,6 +63,14 @@ var typeMap = {
|
|
|
63
63
|
color: 'var(--w-rjv-type-null-color, #d33682)',
|
|
64
64
|
label: 'null'
|
|
65
65
|
},
|
|
66
|
+
Set: {
|
|
67
|
+
color: 'var(--w-rjv-type-set-color, #268bd2)',
|
|
68
|
+
label: 'Set'
|
|
69
|
+
},
|
|
70
|
+
Map: {
|
|
71
|
+
color: 'var(--w-rjv-type-map-color, #268bd2)',
|
|
72
|
+
label: 'Map'
|
|
73
|
+
},
|
|
66
74
|
NaN: {
|
|
67
75
|
color: 'var(--w-rjv-type-nan-color, #859900)',
|
|
68
76
|
label: 'NaN'
|
|
@@ -146,7 +154,6 @@ var RenderShortenTextValue = function RenderShortenTextValue(_ref2) {
|
|
|
146
154
|
shorten = _useState2[0],
|
|
147
155
|
setShorten = _useState2[1];
|
|
148
156
|
var click = function click() {
|
|
149
|
-
console.log(shorten);
|
|
150
157
|
if (length && childrenStr.length <= length) return setShorten(false);
|
|
151
158
|
setShorten(!shorten);
|
|
152
159
|
};
|
|
@@ -193,6 +200,7 @@ function ValueView(props) {
|
|
|
193
200
|
data = props.data,
|
|
194
201
|
keyName = props.keyName,
|
|
195
202
|
indentWidth = props.indentWidth,
|
|
203
|
+
isSet = props.isSet,
|
|
196
204
|
namespace = props.namespace,
|
|
197
205
|
renderKey = props.renderKey,
|
|
198
206
|
_props$components = props.components,
|
|
@@ -218,13 +226,10 @@ function ValueView(props) {
|
|
|
218
226
|
fontWeight: 'bold'
|
|
219
227
|
};
|
|
220
228
|
}
|
|
221
|
-
if (value === undefined || type === '
|
|
229
|
+
if (value === undefined || type.toLocaleLowerCase() === 'nan' || !displayDataTypes) {
|
|
222
230
|
typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
|
|
223
231
|
}
|
|
224
232
|
var isURL = value instanceof URL;
|
|
225
|
-
if (!displayDataTypes) {
|
|
226
|
-
typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
|
|
227
|
-
}
|
|
228
233
|
color = ((_typeMap$type = typeMap[type]) === null || _typeMap$type === void 0 ? void 0 : _typeMap$type.color) || '';
|
|
229
234
|
var _useState3 = (0, _react.useState)(false),
|
|
230
235
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
package/esm/editor/value.js
CHANGED
|
@@ -93,6 +93,9 @@ export function ReValue(props) {
|
|
|
93
93
|
} else if (typeof text === 'string' && /^(null)$/gi.test(text)) {
|
|
94
94
|
text = null;
|
|
95
95
|
_typeStr = 'null';
|
|
96
|
+
} else if (typeof text === 'string' && /^(NaN)$/gi.test(text)) {
|
|
97
|
+
text = NaN;
|
|
98
|
+
_typeStr = 'NaN';
|
|
96
99
|
} else if (typeof text === 'string' && /^(undefined)$/gi.test(text)) {
|
|
97
100
|
text = undefined;
|
|
98
101
|
_typeStr = 'undefined';
|
|
@@ -149,7 +152,7 @@ export function ReValue(props) {
|
|
|
149
152
|
var typeView = /*#__PURE__*/_jsx(Type, {
|
|
150
153
|
type: typeStr
|
|
151
154
|
});
|
|
152
|
-
if (typeStr === 'null' || typeStr === 'undefined') {
|
|
155
|
+
if (typeStr === 'null' || typeStr === 'undefined' || type.toLocaleLowerCase() === 'nan') {
|
|
153
156
|
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
154
157
|
}
|
|
155
158
|
var deleteHandle = function deleteHandle(_x) {
|
package/esm/index.js
CHANGED
|
@@ -19,7 +19,8 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
19
19
|
lineHeight: 1.4,
|
|
20
20
|
fontFamily: 'var(--w-rjv-font-family, Menlo, monospace)',
|
|
21
21
|
color: 'var(--w-rjv-color, #002b36)',
|
|
22
|
-
backgroundColor: 'var(--w-rjv-background-color, #00000000)'
|
|
22
|
+
backgroundColor: 'var(--w-rjv-background-color, #00000000)',
|
|
23
|
+
fontSize: 13
|
|
23
24
|
}, style);
|
|
24
25
|
var cls = "w-json-view-container w-rjv " + (className || '');
|
|
25
26
|
var keyid = useId();
|
package/esm/node.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface RootNodeProps<T extends object> extends JsonViewProps<T> {
|
|
|
7
7
|
keyid?: string;
|
|
8
8
|
level?: number;
|
|
9
9
|
parentValue?: T;
|
|
10
|
+
isSet?: boolean;
|
|
11
|
+
isMap?: boolean;
|
|
10
12
|
namespace?: Array<string | number>;
|
|
11
13
|
setParentValue?: React.Dispatch<React.SetStateAction<T>>;
|
|
12
14
|
}
|
package/esm/node.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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", "shortenTextAfterLength", "collapsed", "level", "keyid", "quotes", "namespace", "onCopied", "onExpand", "parentValue", "setParentValue"];
|
|
3
|
+
var _excluded = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "shortenTextAfterLength", "collapsed", "level", "keyid", "quotes", "namespace", "isSet", "isMap", "onCopied", "onExpand", "parentValue", "setParentValue"];
|
|
4
4
|
import { Fragment, useId, cloneElement, useState, useEffect, forwardRef } from 'react';
|
|
5
|
-
import { ValueView, Colon, Label, Line, typeMap } from './value';
|
|
5
|
+
import { ValueView, Type, Colon, Label, Line, typeMap } from './value';
|
|
6
6
|
import { TriangleArrow } from './arrow/TriangleArrow';
|
|
7
7
|
import { useExpandsStatus, store } from './store';
|
|
8
8
|
import { Semicolon } from './semicolon';
|
|
@@ -52,6 +52,8 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
52
52
|
keyid = 'root',
|
|
53
53
|
quotes = '"',
|
|
54
54
|
namespace = [],
|
|
55
|
+
isSet = false,
|
|
56
|
+
isMap = false,
|
|
55
57
|
onCopied,
|
|
56
58
|
onExpand,
|
|
57
59
|
parentValue,
|
|
@@ -181,6 +183,10 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
181
183
|
parentName: keyName,
|
|
182
184
|
color: typeof keyName === 'number' ? typeMap['number'].color : ''
|
|
183
185
|
}), /*#__PURE__*/_jsx(Colon, {})]
|
|
186
|
+
}), isSet && /*#__PURE__*/_jsx(Type, {
|
|
187
|
+
type: "Set"
|
|
188
|
+
}), isMap && /*#__PURE__*/_jsx(Type, {
|
|
189
|
+
type: "Map"
|
|
184
190
|
}), /*#__PURE__*/_jsx(Meta, {
|
|
185
191
|
start: true,
|
|
186
192
|
isArray: isArray,
|
|
@@ -209,35 +215,40 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
209
215
|
children: entries.length > 0 && [...entries].map((_ref6, idx) => {
|
|
210
216
|
var [key, itemVal] = _ref6;
|
|
211
217
|
var item = itemVal;
|
|
212
|
-
var
|
|
213
|
-
|
|
218
|
+
var isMySet = item instanceof Set;
|
|
219
|
+
var isMyMap = item instanceof Map;
|
|
220
|
+
var myValue = isMySet ? Array.from(item) : isMyMap ? Object.fromEntries(item) : item;
|
|
221
|
+
var isEmpty = Array.isArray(myValue) && myValue.length === 0 || typeof myValue === 'object' && myValue && !(myValue instanceof Date) && Object.keys(myValue).length === 0;
|
|
222
|
+
if ((Array.isArray(myValue) || isMySet || isMyMap) && !isEmpty) {
|
|
214
223
|
var label = isArray ? idx : key;
|
|
215
224
|
return /*#__PURE__*/_jsx(Line, {
|
|
216
225
|
className: "w-rjv-wrap",
|
|
217
226
|
children: /*#__PURE__*/_jsx(RootNode, _extends({
|
|
218
|
-
value:
|
|
227
|
+
value: myValue,
|
|
228
|
+
isSet: isMySet,
|
|
229
|
+
isMap: isMyMap,
|
|
219
230
|
namespace: [...namespace, label],
|
|
220
231
|
keyName: label,
|
|
221
232
|
keyid: keyid + subkeyid + label
|
|
222
233
|
}, subNodeProps))
|
|
223
234
|
}, label + idx);
|
|
224
235
|
}
|
|
225
|
-
if (typeof
|
|
236
|
+
if (typeof myValue === 'object' && myValue && !(myValue instanceof Date) && !isEmpty) {
|
|
226
237
|
return /*#__PURE__*/_jsx(Line, {
|
|
227
238
|
className: "w-rjv-wrap",
|
|
228
239
|
children: /*#__PURE__*/_jsx(RootNode, _extends({
|
|
229
|
-
value:
|
|
240
|
+
value: myValue,
|
|
230
241
|
namespace: [...namespace, key],
|
|
231
242
|
keyName: key,
|
|
232
243
|
keyid: keyid + subkeyid + key
|
|
233
244
|
}, subNodeProps))
|
|
234
245
|
}, key + '' + idx);
|
|
235
246
|
}
|
|
236
|
-
if (typeof
|
|
247
|
+
if (typeof myValue === 'function') {
|
|
237
248
|
return;
|
|
238
249
|
}
|
|
239
250
|
var renderKey = /*#__PURE__*/_jsx(Semicolon, {
|
|
240
|
-
value:
|
|
251
|
+
value: myValue,
|
|
241
252
|
"data-keys": keyid,
|
|
242
253
|
quotes: quotes,
|
|
243
254
|
namespace: [...namespace, key],
|
|
@@ -247,7 +258,7 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
247
258
|
color: typeof key === 'number' ? typeMap['number'].color : '',
|
|
248
259
|
keyName: key
|
|
249
260
|
});
|
|
250
|
-
var length = Array.isArray(
|
|
261
|
+
var length = Array.isArray(myValue) ? myValue.length : getLength(myValue);
|
|
251
262
|
countInfo = /*#__PURE__*/_jsx(CountInfo, {
|
|
252
263
|
children: length
|
|
253
264
|
});
|
|
@@ -265,7 +276,8 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
265
276
|
countInfo: countInfo,
|
|
266
277
|
renderKey: renderKey,
|
|
267
278
|
keyName: key,
|
|
268
|
-
|
|
279
|
+
isSet: isSet,
|
|
280
|
+
value: myValue
|
|
269
281
|
}), idx);
|
|
270
282
|
})
|
|
271
283
|
}), expand && /*#__PURE__*/_jsx(Line, {
|
package/esm/value.d.ts
CHANGED
|
@@ -35,6 +35,14 @@ export declare const typeMap: {
|
|
|
35
35
|
color: string;
|
|
36
36
|
label: string;
|
|
37
37
|
};
|
|
38
|
+
Set: {
|
|
39
|
+
color: string;
|
|
40
|
+
label: string;
|
|
41
|
+
};
|
|
42
|
+
Map: {
|
|
43
|
+
color: string;
|
|
44
|
+
label: string;
|
|
45
|
+
};
|
|
38
46
|
NaN: {
|
|
39
47
|
color: string;
|
|
40
48
|
label: string;
|
|
@@ -53,6 +61,7 @@ export interface ValueViewProps<T extends object> extends React.DetailedHTMLProp
|
|
|
53
61
|
displayDataTypes: boolean;
|
|
54
62
|
displayObjectSize: boolean;
|
|
55
63
|
enableClipboard: boolean;
|
|
64
|
+
isSet: boolean;
|
|
56
65
|
indentWidth: number;
|
|
57
66
|
level?: number;
|
|
58
67
|
shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
|
|
@@ -64,7 +73,7 @@ export interface ValueViewProps<T extends object> extends React.DetailedHTMLProp
|
|
|
64
73
|
setValue?: React.Dispatch<React.SetStateAction<T>>;
|
|
65
74
|
}
|
|
66
75
|
export declare function getValueString<T>(value: T): {
|
|
67
|
-
type: "string" | "number" | "bigint" | "boolean" | "undefined" | "date" | "url" | "float" | "null" | "NaN";
|
|
76
|
+
type: "string" | "number" | "bigint" | "boolean" | "undefined" | "date" | "url" | "float" | "null" | "Set" | "Map" | "NaN";
|
|
68
77
|
content: string;
|
|
69
78
|
};
|
|
70
79
|
export declare function ValueView<T extends object>(props: ValueViewProps<T>): import("react/jsx-runtime").JSX.Element;
|
package/esm/value.js
CHANGED
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
var _excluded = ["children", "style"],
|
|
4
4
|
_excluded2 = ["children", "length", "style"],
|
|
5
5
|
_excluded3 = ["color", "style", "isURL", "href", "children"],
|
|
6
|
-
_excluded4 = ["value", "parentValue", "setValue", "countInfo", "data", "keyName", "indentWidth", "namespace", "renderKey", "components", "quotes", "level", "enableClipboard", "displayObjectSize", "displayDataTypes", "shortenTextAfterLength"],
|
|
6
|
+
_excluded4 = ["value", "parentValue", "setValue", "countInfo", "data", "keyName", "indentWidth", "isSet", "namespace", "renderKey", "components", "quotes", "level", "enableClipboard", "displayObjectSize", "displayDataTypes", "shortenTextAfterLength"],
|
|
7
7
|
_excluded5 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
|
|
8
8
|
import { Fragment, forwardRef, useMemo, useState } from 'react';
|
|
9
9
|
import { Meta } from './comps/meta';
|
|
@@ -46,6 +46,14 @@ export var typeMap = {
|
|
|
46
46
|
color: 'var(--w-rjv-type-null-color, #d33682)',
|
|
47
47
|
label: 'null'
|
|
48
48
|
},
|
|
49
|
+
Set: {
|
|
50
|
+
color: 'var(--w-rjv-type-set-color, #268bd2)',
|
|
51
|
+
label: 'Set'
|
|
52
|
+
},
|
|
53
|
+
Map: {
|
|
54
|
+
color: 'var(--w-rjv-type-map-color, #268bd2)',
|
|
55
|
+
label: 'Map'
|
|
56
|
+
},
|
|
49
57
|
NaN: {
|
|
50
58
|
color: 'var(--w-rjv-type-nan-color, #859900)',
|
|
51
59
|
label: 'NaN'
|
|
@@ -127,7 +135,6 @@ var RenderShortenTextValue = _ref2 => {
|
|
|
127
135
|
var childrenStr = children;
|
|
128
136
|
var [shorten, setShorten] = useState(length && childrenStr.length >= length);
|
|
129
137
|
var click = () => {
|
|
130
|
-
console.log(shorten);
|
|
131
138
|
if (length && childrenStr.length <= length) return setShorten(false);
|
|
132
139
|
setShorten(!shorten);
|
|
133
140
|
};
|
|
@@ -201,13 +208,10 @@ export function ValueView(props) {
|
|
|
201
208
|
fontWeight: 'bold'
|
|
202
209
|
};
|
|
203
210
|
}
|
|
204
|
-
if (value === undefined || type === '
|
|
211
|
+
if (value === undefined || type.toLocaleLowerCase() === 'nan' || !displayDataTypes) {
|
|
205
212
|
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
206
213
|
}
|
|
207
214
|
var isURL = value instanceof URL;
|
|
208
|
-
if (!displayDataTypes) {
|
|
209
|
-
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
210
|
-
}
|
|
211
215
|
color = ((_typeMap$type = typeMap[type]) == null ? void 0 : _typeMap$type.color) || '';
|
|
212
216
|
var [showTools, setShowTools] = useState(false);
|
|
213
217
|
var tools = useMemo(() => enableClipboard && showTools && /*#__PURE__*/_jsx(Copied, {
|