@uiw/react-json-view 1.8.5 → 1.10.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 +33 -9
- package/cjs/editor/countInfoExtra.js +9 -14
- package/cjs/editor/index.d.ts +1 -1
- package/cjs/editor/objectKey.js +5 -7
- package/cjs/editor/value.js +9 -15
- package/cjs/index.d.ts +3 -0
- package/cjs/index.js +12 -0
- package/cjs/node.js +4 -1
- package/cjs/theme/dark.d.ts +2 -24
- package/cjs/theme/dark.js +1 -1
- package/cjs/theme/github.dark.d.ts +2 -0
- package/cjs/theme/github.dark.js +32 -0
- package/cjs/theme/github.light.d.ts +2 -0
- package/cjs/theme/github.light.js +32 -0
- package/cjs/theme/gruvbox.d.ts +2 -0
- package/cjs/theme/gruvbox.js +32 -0
- package/cjs/theme/light.d.ts +2 -24
- package/cjs/theme/light.js +1 -0
- package/cjs/theme/monokai.d.ts +2 -0
- package/cjs/theme/monokai.js +32 -0
- package/cjs/theme/nord.d.ts +2 -0
- package/cjs/theme/nord.js +32 -0
- package/cjs/theme/vscode.d.ts +2 -0
- package/cjs/theme/vscode.js +32 -0
- package/cjs/value.d.ts +1 -0
- package/cjs/value.js +88 -30
- package/dark.d.ts +1 -17
- package/esm/editor/countInfoExtra.js +9 -14
- package/esm/editor/index.d.ts +1 -1
- package/esm/editor/objectKey.js +5 -7
- package/esm/editor/value.js +9 -15
- package/esm/index.d.ts +3 -0
- package/esm/index.js +1 -0
- package/esm/node.js +3 -1
- package/esm/theme/dark.d.ts +2 -24
- package/esm/theme/dark.js +1 -1
- package/esm/theme/github.dark.d.ts +2 -0
- package/esm/theme/github.dark.js +25 -0
- package/esm/theme/github.light.d.ts +2 -0
- package/esm/theme/github.light.js +25 -0
- package/esm/theme/gruvbox.d.ts +2 -0
- package/esm/theme/gruvbox.js +25 -0
- package/esm/theme/light.d.ts +2 -24
- package/esm/theme/light.js +1 -0
- package/esm/theme/monokai.d.ts +2 -0
- package/esm/theme/monokai.js +25 -0
- package/esm/theme/nord.d.ts +2 -0
- package/esm/theme/nord.js +25 -0
- package/esm/theme/vscode.d.ts +2 -0
- package/esm/theme/vscode.js +25 -0
- package/esm/value.d.ts +1 -0
- package/esm/value.js +80 -21
- package/light.d.ts +1 -17
- package/package.json +31 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var vscodeTheme = {
|
|
2
|
+
'--w-rjv-font-family': 'monospace',
|
|
3
|
+
'--w-rjv-color': '#9cdcfe',
|
|
4
|
+
'--w-rjv-background-color': '#1e1e1e',
|
|
5
|
+
'--w-rjv-line-color': '#36334280',
|
|
6
|
+
'--w-rjv-arrow-color': '#838383',
|
|
7
|
+
'--w-rjv-edit-color': 'var(--w-rjv-color)',
|
|
8
|
+
'--w-rjv-info-color': '#9c9c9c7a',
|
|
9
|
+
'--w-rjv-update-color': '#9cdcfe',
|
|
10
|
+
'--w-rjv-copied-color': '#9cdcfe',
|
|
11
|
+
'--w-rjv-copied-success-color': '#28a745',
|
|
12
|
+
'--w-rjv-curlybraces-color': '#d4d4d4',
|
|
13
|
+
'--w-rjv-colon-color': '#d4d4d4',
|
|
14
|
+
'--w-rjv-brackets-color': '#d4d4d4',
|
|
15
|
+
'--w-rjv-type-string-color': '#ce9178',
|
|
16
|
+
'--w-rjv-type-int-color': '#b5cea8',
|
|
17
|
+
'--w-rjv-type-float-color': '#b5cea8',
|
|
18
|
+
'--w-rjv-type-bigint-color': '#b5cea8',
|
|
19
|
+
'--w-rjv-type-boolean-color': '#569cd6',
|
|
20
|
+
'--w-rjv-type-date-color': '#b5cea8',
|
|
21
|
+
'--w-rjv-type-url-color': '#3b89cf',
|
|
22
|
+
'--w-rjv-type-null-color': '#569cd6',
|
|
23
|
+
'--w-rjv-type-nan-color': '#859900',
|
|
24
|
+
'--w-rjv-type-undefined-color': '#569cd6'
|
|
25
|
+
};
|
package/esm/value.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export interface ValueViewProps<T extends object> extends React.DetailedHTMLProp
|
|
|
55
55
|
enableClipboard: boolean;
|
|
56
56
|
indentWidth: number;
|
|
57
57
|
level?: number;
|
|
58
|
+
shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
|
|
58
59
|
namespace?: Array<string | number>;
|
|
59
60
|
quotes?: JsonViewProps<T>['quotes'];
|
|
60
61
|
components?: JsonViewProps<T>['components'];
|
package/esm/value.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
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 = ["
|
|
5
|
-
_excluded3 = ["
|
|
4
|
+
_excluded2 = ["children", "length", "style"],
|
|
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"],
|
|
7
|
+
_excluded5 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
|
|
6
8
|
import { Fragment, forwardRef, useMemo, useState } from 'react';
|
|
7
9
|
import { Meta } from './comps/meta';
|
|
8
10
|
import { Copied } from './copied';
|
|
@@ -63,7 +65,9 @@ export var Colon = _ref => {
|
|
|
63
65
|
className: "w-rjv-colon",
|
|
64
66
|
style: _extends({
|
|
65
67
|
paddingRight: 3
|
|
66
|
-
}, style
|
|
68
|
+
}, style, {
|
|
69
|
+
color: 'var(--w-rjv-colon-color, var(--w-rjv-color))'
|
|
70
|
+
})
|
|
67
71
|
}, props, {
|
|
68
72
|
children: children
|
|
69
73
|
}));
|
|
@@ -75,6 +79,10 @@ export function getValueString(value) {
|
|
|
75
79
|
if (typeof value === 'number') {
|
|
76
80
|
type = isFloat(value) ? 'float' : 'number';
|
|
77
81
|
content = value.toString();
|
|
82
|
+
if (isNaN(value)) {
|
|
83
|
+
type = 'NaN';
|
|
84
|
+
content = 'NaN';
|
|
85
|
+
}
|
|
78
86
|
}
|
|
79
87
|
if (typeof value === 'boolean') {
|
|
80
88
|
type = 'boolean';
|
|
@@ -109,6 +117,56 @@ export function getValueString(value) {
|
|
|
109
117
|
content
|
|
110
118
|
};
|
|
111
119
|
}
|
|
120
|
+
var RenderShortenTextValue = _ref2 => {
|
|
121
|
+
var {
|
|
122
|
+
children,
|
|
123
|
+
length,
|
|
124
|
+
style
|
|
125
|
+
} = _ref2,
|
|
126
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
127
|
+
var childrenStr = children;
|
|
128
|
+
var [shorten, setShorten] = useState(length && childrenStr.length >= length);
|
|
129
|
+
var click = () => {
|
|
130
|
+
console.log(shorten);
|
|
131
|
+
if (length && childrenStr.length <= length) return setShorten(false);
|
|
132
|
+
setShorten(!shorten);
|
|
133
|
+
};
|
|
134
|
+
var text = shorten ? childrenStr.slice(0, length) + "..." : childrenStr;
|
|
135
|
+
return /*#__PURE__*/_jsx(RenderStringValue, _extends({}, rest, {
|
|
136
|
+
style: _extends({}, style, {
|
|
137
|
+
cursor: 'pointer'
|
|
138
|
+
}),
|
|
139
|
+
onClick: click,
|
|
140
|
+
children: text
|
|
141
|
+
}));
|
|
142
|
+
};
|
|
143
|
+
RenderShortenTextValue.displayName = 'JVR.RenderShortenTextValue';
|
|
144
|
+
var RenderStringValue = _ref3 => {
|
|
145
|
+
var {
|
|
146
|
+
color,
|
|
147
|
+
style,
|
|
148
|
+
isURL,
|
|
149
|
+
href,
|
|
150
|
+
children
|
|
151
|
+
} = _ref3,
|
|
152
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
153
|
+
return /*#__PURE__*/_jsxs(Label, _extends({
|
|
154
|
+
color: color,
|
|
155
|
+
style: style
|
|
156
|
+
}, rest, {
|
|
157
|
+
className: "w-rjv-value",
|
|
158
|
+
children: [isURL && /*#__PURE__*/_jsx("a", {
|
|
159
|
+
href: href,
|
|
160
|
+
style: {
|
|
161
|
+
color
|
|
162
|
+
},
|
|
163
|
+
target: "_blank",
|
|
164
|
+
rel: "noopener noreferrer",
|
|
165
|
+
children: children
|
|
166
|
+
}), !isURL && children]
|
|
167
|
+
}));
|
|
168
|
+
};
|
|
169
|
+
RenderStringValue.displayName = 'JVR.RenderStringValue';
|
|
112
170
|
export function ValueView(props) {
|
|
113
171
|
var _typeMap$type;
|
|
114
172
|
var {
|
|
@@ -124,9 +182,10 @@ export function ValueView(props) {
|
|
|
124
182
|
components = {},
|
|
125
183
|
quotes,
|
|
126
184
|
enableClipboard,
|
|
127
|
-
displayDataTypes
|
|
185
|
+
displayDataTypes,
|
|
186
|
+
shortenTextAfterLength
|
|
128
187
|
} = props,
|
|
129
|
-
reset = _objectWithoutPropertiesLoose(props,
|
|
188
|
+
reset = _objectWithoutPropertiesLoose(props, _excluded4);
|
|
130
189
|
var color = '';
|
|
131
190
|
var style = {};
|
|
132
191
|
var {
|
|
@@ -142,7 +201,7 @@ export function ValueView(props) {
|
|
|
142
201
|
fontWeight: 'bold'
|
|
143
202
|
};
|
|
144
203
|
}
|
|
145
|
-
if (value === undefined) {
|
|
204
|
+
if (value === undefined || type === 'NaN') {
|
|
146
205
|
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
147
206
|
}
|
|
148
207
|
var isURL = value instanceof URL;
|
|
@@ -184,24 +243,24 @@ export function ValueView(props) {
|
|
|
184
243
|
content,
|
|
185
244
|
children: content
|
|
186
245
|
});
|
|
187
|
-
var valueView =
|
|
246
|
+
var valueView = shortenTextAfterLength && type === 'string' ? /*#__PURE__*/_jsx(RenderShortenTextValue, {
|
|
188
247
|
color: color,
|
|
248
|
+
href: isURL ? value.href : '',
|
|
189
249
|
style: style,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}) : content
|
|
250
|
+
isURL: isURL,
|
|
251
|
+
length: shortenTextAfterLength,
|
|
252
|
+
children: content
|
|
253
|
+
}) : /*#__PURE__*/_jsx(RenderStringValue, {
|
|
254
|
+
color: color,
|
|
255
|
+
href: isURL ? value.href : '',
|
|
256
|
+
style: style,
|
|
257
|
+
isURL: isURL,
|
|
258
|
+
children: content
|
|
200
259
|
});
|
|
201
260
|
return /*#__PURE__*/_jsx(Line, _extends({}, eventProps, {
|
|
202
261
|
children: /*#__PURE__*/_jsxs(Label, _extends({}, reset, {
|
|
203
262
|
ref: null,
|
|
204
|
-
children: [renderKey, /*#__PURE__*/_jsx(Colon, {}), typeView, valueView, tools]
|
|
263
|
+
children: [renderKey, /*#__PURE__*/_jsx(Colon, {}), typeView, reView ? reView : valueView, tools]
|
|
205
264
|
}))
|
|
206
265
|
}));
|
|
207
266
|
}
|
|
@@ -223,7 +282,7 @@ export function ValueView(props) {
|
|
|
223
282
|
}));
|
|
224
283
|
}
|
|
225
284
|
ValueView.displayName = 'JVR.ValueView';
|
|
226
|
-
export var Label = /*#__PURE__*/forwardRef((
|
|
285
|
+
export var Label = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
227
286
|
var {
|
|
228
287
|
children,
|
|
229
288
|
color,
|
|
@@ -231,8 +290,8 @@ export var Label = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
231
290
|
opacity,
|
|
232
291
|
paddingRight,
|
|
233
292
|
style
|
|
234
|
-
} =
|
|
235
|
-
reset = _objectWithoutPropertiesLoose(
|
|
293
|
+
} = _ref4,
|
|
294
|
+
reset = _objectWithoutPropertiesLoose(_ref4, _excluded5);
|
|
236
295
|
return /*#__PURE__*/_jsx("span", _extends({
|
|
237
296
|
style: _extends({
|
|
238
297
|
color,
|
package/light.d.ts
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
1
|
declare module '@uiw/react-json-view/light' {
|
|
2
|
-
export const lightTheme:
|
|
3
|
-
'--w-rjv-font-family': string;
|
|
4
|
-
'--w-rjv-color': string;
|
|
5
|
-
'--w-rjv-background-color': string;
|
|
6
|
-
'--w-rjv-border-left': string;
|
|
7
|
-
'--w-rjv-arrow-color': string;
|
|
8
|
-
'--w-rjv-info-color': string;
|
|
9
|
-
'--w-rjv-type-string-color': string;
|
|
10
|
-
'--w-rjv-type-int-color': string;
|
|
11
|
-
'--w-rjv-type-float-color': string;
|
|
12
|
-
'--w-rjv-type-bigint-color': string;
|
|
13
|
-
'--w-rjv-type-boolean-color': string;
|
|
14
|
-
'--w-rjv-type-date-color': string;
|
|
15
|
-
'--w-rjv-type-null-color': string;
|
|
16
|
-
'--w-rjv-type-nan-color': string;
|
|
17
|
-
'--w-rjv-type-undefined-color': string;
|
|
18
|
-
};
|
|
2
|
+
export const lightTheme: import('react').CSSProperties;
|
|
19
3
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-json-view",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "JSON viewer for react.",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -27,6 +27,36 @@
|
|
|
27
27
|
"types": "./cjs/theme/dark.d.ts",
|
|
28
28
|
"require": "./cjs/theme/dark.js"
|
|
29
29
|
},
|
|
30
|
+
"./nord": {
|
|
31
|
+
"import": "./esm/theme/nord.js",
|
|
32
|
+
"types": "./cjs/theme/nord.d.ts",
|
|
33
|
+
"require": "./cjs/theme/nord.js"
|
|
34
|
+
},
|
|
35
|
+
"./vscode": {
|
|
36
|
+
"import": "./esm/theme/vscode.js",
|
|
37
|
+
"types": "./cjs/theme/vscode.d.ts",
|
|
38
|
+
"require": "./cjs/theme/vscode.js"
|
|
39
|
+
},
|
|
40
|
+
"./monokai": {
|
|
41
|
+
"import": "./esm/theme/monokai.js",
|
|
42
|
+
"types": "./cjs/theme/monokai.d.ts",
|
|
43
|
+
"require": "./cjs/theme/monokai.js"
|
|
44
|
+
},
|
|
45
|
+
"./gruvbox": {
|
|
46
|
+
"import": "./esm/theme/gruvbox.js",
|
|
47
|
+
"types": "./cjs/theme/gruvbox.d.ts",
|
|
48
|
+
"require": "./cjs/theme/gruvbox.js"
|
|
49
|
+
},
|
|
50
|
+
"./githubLight": {
|
|
51
|
+
"import": "./esm/theme/github.light.js",
|
|
52
|
+
"types": "./cjs/theme/github.light.d.ts",
|
|
53
|
+
"require": "./cjs/theme/github.light.js"
|
|
54
|
+
},
|
|
55
|
+
"./githubDark": {
|
|
56
|
+
"import": "./esm/theme/github.dark.js",
|
|
57
|
+
"types": "./cjs/theme/github.dark.d.ts",
|
|
58
|
+
"require": "./cjs/theme/github.dark.js"
|
|
59
|
+
},
|
|
30
60
|
"./triangle-arrow": {
|
|
31
61
|
"import": "./esm/arrow/TriangleArrow.js",
|
|
32
62
|
"types": "./cjs/arrow/TriangleArrow.d.ts",
|