@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
package/cjs/value.js
CHANGED
|
@@ -17,8 +17,10 @@ var _meta = require("./comps/meta");
|
|
|
17
17
|
var _copied = require("./copied");
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
19
|
var _excluded = ["children", "style"],
|
|
20
|
-
_excluded2 = ["
|
|
21
|
-
_excluded3 = ["
|
|
20
|
+
_excluded2 = ["children", "length", "style"],
|
|
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"],
|
|
23
|
+
_excluded5 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
|
|
22
24
|
var Line = function Line(props) {
|
|
23
25
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _objectSpread2["default"])({}, props));
|
|
24
26
|
};
|
|
@@ -78,9 +80,11 @@ var Colon = function Colon(_ref) {
|
|
|
78
80
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
79
81
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
80
82
|
className: "w-rjv-colon",
|
|
81
|
-
style: (0, _objectSpread2["default"])({
|
|
83
|
+
style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
82
84
|
paddingRight: 3
|
|
83
|
-
}, style)
|
|
85
|
+
}, style), {}, {
|
|
86
|
+
color: 'var(--w-rjv-colon-color, var(--w-rjv-color))'
|
|
87
|
+
})
|
|
84
88
|
}, props), {}, {
|
|
85
89
|
children: children
|
|
86
90
|
}));
|
|
@@ -93,6 +97,10 @@ function getValueString(value) {
|
|
|
93
97
|
if (typeof value === 'number') {
|
|
94
98
|
type = isFloat(value) ? 'float' : 'number';
|
|
95
99
|
content = value.toString();
|
|
100
|
+
if (isNaN(value)) {
|
|
101
|
+
type = 'NaN';
|
|
102
|
+
content = 'NaN';
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
if (typeof value === 'boolean') {
|
|
98
106
|
type = 'boolean';
|
|
@@ -127,6 +135,55 @@ function getValueString(value) {
|
|
|
127
135
|
content: content
|
|
128
136
|
};
|
|
129
137
|
}
|
|
138
|
+
var RenderShortenTextValue = function RenderShortenTextValue(_ref2) {
|
|
139
|
+
var children = _ref2.children,
|
|
140
|
+
length = _ref2.length,
|
|
141
|
+
style = _ref2.style,
|
|
142
|
+
rest = (0, _objectWithoutProperties2["default"])(_ref2, _excluded2);
|
|
143
|
+
var childrenStr = children;
|
|
144
|
+
var _useState = (0, _react.useState)(length && childrenStr.length >= length),
|
|
145
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
146
|
+
shorten = _useState2[0],
|
|
147
|
+
setShorten = _useState2[1];
|
|
148
|
+
var click = function click() {
|
|
149
|
+
console.log(shorten);
|
|
150
|
+
if (length && childrenStr.length <= length) return setShorten(false);
|
|
151
|
+
setShorten(!shorten);
|
|
152
|
+
};
|
|
153
|
+
var text = shorten ? "".concat(childrenStr.slice(0, length), "...") : childrenStr;
|
|
154
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderStringValue, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, rest), {}, {
|
|
155
|
+
style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, style), {}, {
|
|
156
|
+
cursor: 'pointer'
|
|
157
|
+
}),
|
|
158
|
+
onClick: click,
|
|
159
|
+
children: text
|
|
160
|
+
}));
|
|
161
|
+
};
|
|
162
|
+
RenderShortenTextValue.displayName = 'JVR.RenderShortenTextValue';
|
|
163
|
+
var RenderStringValue = function RenderStringValue(_ref3) {
|
|
164
|
+
var color = _ref3.color,
|
|
165
|
+
style = _ref3.style,
|
|
166
|
+
isURL = _ref3.isURL,
|
|
167
|
+
href = _ref3.href,
|
|
168
|
+
children = _ref3.children,
|
|
169
|
+
rest = (0, _objectWithoutProperties2["default"])(_ref3, _excluded3);
|
|
170
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
171
|
+
color: color,
|
|
172
|
+
style: style
|
|
173
|
+
}, rest), {}, {
|
|
174
|
+
className: "w-rjv-value",
|
|
175
|
+
children: [isURL && /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
176
|
+
href: href,
|
|
177
|
+
style: {
|
|
178
|
+
color: color
|
|
179
|
+
},
|
|
180
|
+
target: "_blank",
|
|
181
|
+
rel: "noopener noreferrer",
|
|
182
|
+
children: children
|
|
183
|
+
}), !isURL && children]
|
|
184
|
+
}));
|
|
185
|
+
};
|
|
186
|
+
RenderStringValue.displayName = 'JVR.RenderStringValue';
|
|
130
187
|
function ValueView(props) {
|
|
131
188
|
var _typeMap$type;
|
|
132
189
|
var value = props.value,
|
|
@@ -145,7 +202,8 @@ function ValueView(props) {
|
|
|
145
202
|
enableClipboard = props.enableClipboard,
|
|
146
203
|
displayObjectSize = props.displayObjectSize,
|
|
147
204
|
displayDataTypes = props.displayDataTypes,
|
|
148
|
-
|
|
205
|
+
shortenTextAfterLength = props.shortenTextAfterLength,
|
|
206
|
+
reset = (0, _objectWithoutProperties2["default"])(props, _excluded4);
|
|
149
207
|
var color = '';
|
|
150
208
|
var style = {};
|
|
151
209
|
var _getValueString = getValueString(value),
|
|
@@ -160,7 +218,7 @@ function ValueView(props) {
|
|
|
160
218
|
fontWeight: 'bold'
|
|
161
219
|
};
|
|
162
220
|
}
|
|
163
|
-
if (value === undefined) {
|
|
221
|
+
if (value === undefined || type === 'NaN') {
|
|
164
222
|
typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
|
|
165
223
|
}
|
|
166
224
|
var isURL = value instanceof URL;
|
|
@@ -168,10 +226,10 @@ function ValueView(props) {
|
|
|
168
226
|
typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
|
|
169
227
|
}
|
|
170
228
|
color = ((_typeMap$type = typeMap[type]) === null || _typeMap$type === void 0 ? void 0 : _typeMap$type.color) || '';
|
|
171
|
-
var
|
|
172
|
-
|
|
173
|
-
showTools =
|
|
174
|
-
setShowTools =
|
|
229
|
+
var _useState3 = (0, _react.useState)(false),
|
|
230
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
231
|
+
showTools = _useState4[0],
|
|
232
|
+
setShowTools = _useState4[1];
|
|
175
233
|
var tools = (0, _react.useMemo)(function () {
|
|
176
234
|
return enableClipboard && showTools && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copied.Copied, {
|
|
177
235
|
show: showTools,
|
|
@@ -211,24 +269,24 @@ function ValueView(props) {
|
|
|
211
269
|
content: content,
|
|
212
270
|
children: content
|
|
213
271
|
});
|
|
214
|
-
var valueView =
|
|
272
|
+
var valueView = shortenTextAfterLength && type === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderShortenTextValue, {
|
|
273
|
+
color: color,
|
|
274
|
+
href: isURL ? value.href : '',
|
|
275
|
+
style: style,
|
|
276
|
+
isURL: isURL,
|
|
277
|
+
length: shortenTextAfterLength,
|
|
278
|
+
children: content
|
|
279
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderStringValue, {
|
|
215
280
|
color: color,
|
|
281
|
+
href: isURL ? value.href : '',
|
|
216
282
|
style: style,
|
|
217
|
-
|
|
218
|
-
children:
|
|
219
|
-
href: value.href,
|
|
220
|
-
style: {
|
|
221
|
-
color: color
|
|
222
|
-
},
|
|
223
|
-
target: "_blank",
|
|
224
|
-
rel: "noopener noreferrer",
|
|
225
|
-
children: content
|
|
226
|
-
}) : content
|
|
283
|
+
isURL: isURL,
|
|
284
|
+
children: content
|
|
227
285
|
});
|
|
228
286
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, eventProps), {}, {
|
|
229
287
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
|
|
230
288
|
ref: null,
|
|
231
|
-
children: [renderKey, /*#__PURE__*/(0, _jsxRuntime.jsx)(Colon, {}), typeView, valueView, tools]
|
|
289
|
+
children: [renderKey, /*#__PURE__*/(0, _jsxRuntime.jsx)(Colon, {}), typeView, reView ? reView : valueView, tools]
|
|
232
290
|
}))
|
|
233
291
|
}));
|
|
234
292
|
}
|
|
@@ -250,14 +308,14 @@ function ValueView(props) {
|
|
|
250
308
|
}));
|
|
251
309
|
}
|
|
252
310
|
ValueView.displayName = 'JVR.ValueView';
|
|
253
|
-
var Label = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
254
|
-
var children =
|
|
255
|
-
color =
|
|
256
|
-
fontSize =
|
|
257
|
-
opacity =
|
|
258
|
-
paddingRight =
|
|
259
|
-
style =
|
|
260
|
-
reset = (0, _objectWithoutProperties2["default"])(
|
|
311
|
+
var Label = /*#__PURE__*/(0, _react.forwardRef)(function (_ref4, ref) {
|
|
312
|
+
var children = _ref4.children,
|
|
313
|
+
color = _ref4.color,
|
|
314
|
+
fontSize = _ref4.fontSize,
|
|
315
|
+
opacity = _ref4.opacity,
|
|
316
|
+
paddingRight = _ref4.paddingRight,
|
|
317
|
+
style = _ref4.style,
|
|
318
|
+
reset = (0, _objectWithoutProperties2["default"])(_ref4, _excluded5);
|
|
261
319
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
262
320
|
style: (0, _objectSpread2["default"])({
|
|
263
321
|
color: color,
|
package/dark.d.ts
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
1
|
declare module '@uiw/react-json-view/dark' {
|
|
2
|
-
export const darkTheme:
|
|
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 darkTheme: import('react').CSSProperties;
|
|
19
3
|
}
|
|
@@ -6,6 +6,7 @@ import { DeleteIcon } from './icon/delete';
|
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
export function CountInfoExtra(props) {
|
|
9
|
+
var _ref, _ref2;
|
|
9
10
|
var {
|
|
10
11
|
visible,
|
|
11
12
|
showTools,
|
|
@@ -20,8 +21,8 @@ export function CountInfoExtra(props) {
|
|
|
20
21
|
onDelete
|
|
21
22
|
} = props;
|
|
22
23
|
if (!visible || !showTools) return null;
|
|
23
|
-
var click =
|
|
24
|
-
|
|
24
|
+
var click = function click(_x) {
|
|
25
|
+
return (_ref = _ref || _asyncToGenerator(function* (event) {
|
|
25
26
|
event.stopPropagation();
|
|
26
27
|
var keyOrValue = 'AddKeyOrValue';
|
|
27
28
|
var isArray = Array.isArray(value);
|
|
@@ -35,13 +36,10 @@ export function CountInfoExtra(props) {
|
|
|
35
36
|
setValue(result);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}();
|
|
43
|
-
var deleteHandle = /*#__PURE__*/function () {
|
|
44
|
-
var _ref2 = _asyncToGenerator(function* (event) {
|
|
39
|
+
})).apply(this, arguments);
|
|
40
|
+
};
|
|
41
|
+
var deleteHandle = function deleteHandle(_x2) {
|
|
42
|
+
return (_ref2 = _ref2 || _asyncToGenerator(function* (event) {
|
|
45
43
|
event.stopPropagation();
|
|
46
44
|
if (onDelete && (keyName || typeof keyName === 'number') && parentValue) {
|
|
47
45
|
var maybeDelete = yield onDelete(keyName, value, parentValue, {
|
|
@@ -57,11 +55,8 @@ export function CountInfoExtra(props) {
|
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return _ref2.apply(this, arguments);
|
|
63
|
-
};
|
|
64
|
-
}();
|
|
58
|
+
})).apply(this, arguments);
|
|
59
|
+
};
|
|
65
60
|
return /*#__PURE__*/_jsxs(Fragment, {
|
|
66
61
|
children: [editable && onAdd && /*#__PURE__*/_jsx(AddIcon, {
|
|
67
62
|
onClick: click
|
package/esm/editor/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { JsonViewProps } from '../';
|
|
3
3
|
import type { CountInfoExtraProps } from './countInfoExtra';
|
|
4
|
-
export interface JsonViewEditorProps<T extends object> extends JsonViewProps<T> {
|
|
4
|
+
export interface JsonViewEditorProps<T extends object> extends Omit<JsonViewProps<T>, 'shortenTextAfterLength'> {
|
|
5
5
|
/**
|
|
6
6
|
* When a callback function is passed in, edit functionality is enabled. The callback is invoked before edits are completed.
|
|
7
7
|
* @returns {boolean} Returning false from onEdit will prevent the change from being made.
|
package/esm/editor/objectKey.js
CHANGED
|
@@ -7,6 +7,7 @@ import { useHighlight } from '../semicolon';
|
|
|
7
7
|
import { Label } from '../value';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
export var ObjectKey = props => {
|
|
10
|
+
var _ref;
|
|
10
11
|
var {
|
|
11
12
|
className,
|
|
12
13
|
value,
|
|
@@ -42,8 +43,8 @@ export var ObjectKey = props => {
|
|
|
42
43
|
(_$edit$current = $edit.current) == null || _$edit$current.focus();
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
|
-
var blur =
|
|
46
|
-
|
|
46
|
+
var blur = function blur() {
|
|
47
|
+
return (_ref = _ref || _asyncToGenerator(function* () {
|
|
47
48
|
if ($edit.current) {
|
|
48
49
|
var _$edit$current2;
|
|
49
50
|
if (onEdit) {
|
|
@@ -65,11 +66,8 @@ export var ObjectKey = props => {
|
|
|
65
66
|
(_$edit$current2 = $edit.current) == null || _$edit$current2.focus();
|
|
66
67
|
}
|
|
67
68
|
setEditable(false);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return _ref.apply(this, arguments);
|
|
71
|
-
};
|
|
72
|
-
}();
|
|
69
|
+
})).apply(this, arguments);
|
|
70
|
+
};
|
|
73
71
|
var focus = () => {
|
|
74
72
|
if ($edit.current) {
|
|
75
73
|
var _$edit$current3;
|
package/esm/editor/value.js
CHANGED
|
@@ -21,7 +21,7 @@ var Quotes = _ref => {
|
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
23
|
export function ReValue(props) {
|
|
24
|
-
var _typeMap$typeStr;
|
|
24
|
+
var _ref2, _typeMap$typeStr, _ref3;
|
|
25
25
|
var {
|
|
26
26
|
type,
|
|
27
27
|
value,
|
|
@@ -65,8 +65,8 @@ export function ReValue(props) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
var blur =
|
|
69
|
-
|
|
68
|
+
var blur = function blur() {
|
|
69
|
+
return (_ref2 = _ref2 || _asyncToGenerator(function* () {
|
|
70
70
|
if (!editableValue) return;
|
|
71
71
|
setEditable(false);
|
|
72
72
|
if ($edit.current) {
|
|
@@ -123,11 +123,8 @@ export function ReValue(props) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
return _ref2.apply(this, arguments);
|
|
129
|
-
};
|
|
130
|
-
}();
|
|
126
|
+
})).apply(this, arguments);
|
|
127
|
+
};
|
|
131
128
|
var defaultStyle = {
|
|
132
129
|
minWidth: 34,
|
|
133
130
|
minHeight: 18,
|
|
@@ -155,8 +152,8 @@ export function ReValue(props) {
|
|
|
155
152
|
if (typeStr === 'null' || typeStr === 'undefined') {
|
|
156
153
|
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
157
154
|
}
|
|
158
|
-
var deleteHandle =
|
|
159
|
-
|
|
155
|
+
var deleteHandle = function deleteHandle(_x) {
|
|
156
|
+
return (_ref3 = _ref3 || _asyncToGenerator(function* (evn) {
|
|
160
157
|
evn.stopPropagation();
|
|
161
158
|
if (data && keyName && keyName in data && setValue && onDelete) {
|
|
162
159
|
var maybeDelete = yield onDelete(keyName, value, parentValue, {
|
|
@@ -167,11 +164,8 @@ export function ReValue(props) {
|
|
|
167
164
|
setValue(_extends({}, data));
|
|
168
165
|
}
|
|
169
166
|
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
return _ref3.apply(this, arguments);
|
|
173
|
-
};
|
|
174
|
-
}();
|
|
167
|
+
})).apply(this, arguments);
|
|
168
|
+
};
|
|
175
169
|
return /*#__PURE__*/_jsxs(Fragment, {
|
|
176
170
|
children: [displayDataTypes && typeView, /*#__PURE__*/_jsx(Quotes, {
|
|
177
171
|
style: style,
|
package/esm/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { MetaProps } from './comps/meta';
|
|
|
7
7
|
import type { CountInfoExtraProps } from './editor/countInfoExtra';
|
|
8
8
|
export * from './node';
|
|
9
9
|
export * from './value';
|
|
10
|
+
export * from './semicolon';
|
|
10
11
|
export interface CountInfoProps {
|
|
11
12
|
count: number;
|
|
12
13
|
level: number;
|
|
@@ -32,6 +33,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
32
33
|
displayDataTypes?: boolean;
|
|
33
34
|
/** When set to `true`, `objects` and `arrays` are labeled with size @default true */
|
|
34
35
|
displayObjectSize?: boolean;
|
|
36
|
+
/** Shorten long JSON strings, Set to `0` to disable this feature @default 20 */
|
|
37
|
+
shortenTextAfterLength?: number;
|
|
35
38
|
/** Define the root node name. @default undefined */
|
|
36
39
|
keyName?: string | number;
|
|
37
40
|
/** The user can copy objects and arrays to clipboard by clicking on the clipboard icon. @default true */
|
package/esm/index.js
CHANGED
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", "namespace", "onCopied", "onExpand", "parentValue", "setParentValue"];
|
|
3
|
+
var _excluded = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "shortenTextAfterLength", "collapsed", "level", "keyid", "quotes", "namespace", "onCopied", "onExpand", "parentValue", "setParentValue"];
|
|
4
4
|
import { Fragment, useId, cloneElement, useState, useEffect, forwardRef } from 'react';
|
|
5
5
|
import { ValueView, Colon, Label, Line, typeMap } from './value';
|
|
6
6
|
import { TriangleArrow } from './arrow/TriangleArrow';
|
|
@@ -46,6 +46,7 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
46
46
|
highlightUpdates = true,
|
|
47
47
|
objectSortKeys = false,
|
|
48
48
|
indentWidth = 15,
|
|
49
|
+
shortenTextAfterLength = 20,
|
|
49
50
|
collapsed,
|
|
50
51
|
level = 1,
|
|
51
52
|
keyid = 'root',
|
|
@@ -93,6 +94,7 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
93
94
|
displayDataTypes,
|
|
94
95
|
displayObjectSize,
|
|
95
96
|
enableClipboard,
|
|
97
|
+
shortenTextAfterLength,
|
|
96
98
|
level: level + 1,
|
|
97
99
|
parentValue: value,
|
|
98
100
|
indentWidth,
|
package/esm/theme/dark.d.ts
CHANGED
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
'--w-rjv-color': string;
|
|
4
|
-
'--w-rjv-background-color': string;
|
|
5
|
-
'--w-rjv-line-color': string;
|
|
6
|
-
'--w-rjv-arrow-color': string;
|
|
7
|
-
'--w-rjv-edit-color': string;
|
|
8
|
-
'--w-rjv-info-color': string;
|
|
9
|
-
'--w-rjv-update-color': string;
|
|
10
|
-
'--w-rjv-copied-color': string;
|
|
11
|
-
'--w-rjv-copied-success-color': string;
|
|
12
|
-
'--w-rjv-curlybraces-color': string;
|
|
13
|
-
'--w-rjv-brackets-color': string;
|
|
14
|
-
'--w-rjv-type-string-color': string;
|
|
15
|
-
'--w-rjv-type-int-color': string;
|
|
16
|
-
'--w-rjv-type-float-color': string;
|
|
17
|
-
'--w-rjv-type-bigint-color': string;
|
|
18
|
-
'--w-rjv-type-boolean-color': string;
|
|
19
|
-
'--w-rjv-type-date-color': string;
|
|
20
|
-
'--w-rjv-type-url-color': string;
|
|
21
|
-
'--w-rjv-type-null-color': string;
|
|
22
|
-
'--w-rjv-type-nan-color': string;
|
|
23
|
-
'--w-rjv-type-undefined-color': string;
|
|
24
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const darkTheme: import("react").CSSProperties;
|
package/esm/theme/dark.js
CHANGED
|
@@ -19,6 +19,6 @@ export var darkTheme = {
|
|
|
19
19
|
'--w-rjv-type-date-color': '#586e75',
|
|
20
20
|
'--w-rjv-type-url-color': '#649bd8',
|
|
21
21
|
'--w-rjv-type-null-color': '#d33682',
|
|
22
|
-
'--w-rjv-type-nan-color': '#
|
|
22
|
+
'--w-rjv-type-nan-color': '#076678',
|
|
23
23
|
'--w-rjv-type-undefined-color': '#586e75'
|
|
24
24
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var githubDarkTheme = {
|
|
2
|
+
'--w-rjv-font-family': 'monospace',
|
|
3
|
+
'--w-rjv-color': '#79c0ff',
|
|
4
|
+
'--w-rjv-background-color': '#0d1117',
|
|
5
|
+
'--w-rjv-line-color': '#94949480',
|
|
6
|
+
'--w-rjv-arrow-color': '#ccc',
|
|
7
|
+
'--w-rjv-edit-color': 'var(--w-rjv-color)',
|
|
8
|
+
'--w-rjv-info-color': '#7b7b7b',
|
|
9
|
+
'--w-rjv-update-color': '#ebcb8b',
|
|
10
|
+
'--w-rjv-copied-color': '#79c0ff',
|
|
11
|
+
'--w-rjv-copied-success-color': '#28a745',
|
|
12
|
+
'--w-rjv-curlybraces-color': '#8b949e',
|
|
13
|
+
'--w-rjv-colon-color': '#c9d1d9',
|
|
14
|
+
'--w-rjv-brackets-color': '#8b949e',
|
|
15
|
+
'--w-rjv-type-string-color': '#a5d6ff',
|
|
16
|
+
'--w-rjv-type-int-color': '#79c0ff',
|
|
17
|
+
'--w-rjv-type-float-color': '#79c0ff',
|
|
18
|
+
'--w-rjv-type-bigint-color': '#79c0ff',
|
|
19
|
+
'--w-rjv-type-boolean-color': '#ffab70',
|
|
20
|
+
'--w-rjv-type-date-color': '#79c0ff',
|
|
21
|
+
'--w-rjv-type-url-color': '#4facff',
|
|
22
|
+
'--w-rjv-type-null-color': '#ff7b72',
|
|
23
|
+
'--w-rjv-type-nan-color': '#859900',
|
|
24
|
+
'--w-rjv-type-undefined-color': '#79c0ff'
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var githubLightTheme = {
|
|
2
|
+
'--w-rjv-font-family': 'monospace',
|
|
3
|
+
'--w-rjv-color': '#6f42c1',
|
|
4
|
+
'--w-rjv-background-color': '#ffffff',
|
|
5
|
+
'--w-rjv-line-color': '#ddd',
|
|
6
|
+
'--w-rjv-arrow-color': '#6e7781',
|
|
7
|
+
'--w-rjv-edit-color': 'var(--w-rjv-color)',
|
|
8
|
+
'--w-rjv-info-color': '#0000004d',
|
|
9
|
+
'--w-rjv-update-color': '#ebcb8b',
|
|
10
|
+
'--w-rjv-copied-color': '#002b36',
|
|
11
|
+
'--w-rjv-copied-success-color': '#28a745',
|
|
12
|
+
'--w-rjv-curlybraces-color': '#6a737d',
|
|
13
|
+
'--w-rjv-colon-color': '#24292e',
|
|
14
|
+
'--w-rjv-brackets-color': '#6a737d',
|
|
15
|
+
'--w-rjv-type-string-color': '#032f62',
|
|
16
|
+
'--w-rjv-type-int-color': '#005cc5',
|
|
17
|
+
'--w-rjv-type-float-color': '#005cc5',
|
|
18
|
+
'--w-rjv-type-bigint-color': '#005cc5',
|
|
19
|
+
'--w-rjv-type-boolean-color': '#d73a49',
|
|
20
|
+
'--w-rjv-type-date-color': '#005cc5',
|
|
21
|
+
'--w-rjv-type-url-color': '#0969da',
|
|
22
|
+
'--w-rjv-type-null-color': '#d73a49',
|
|
23
|
+
'--w-rjv-type-nan-color': '#859900',
|
|
24
|
+
'--w-rjv-type-undefined-color': '#005cc5'
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var gruvboxTheme = {
|
|
2
|
+
'--w-rjv-font-family': 'monospace',
|
|
3
|
+
'--w-rjv-color': '#3c3836',
|
|
4
|
+
'--w-rjv-background-color': '#fbf1c7',
|
|
5
|
+
'--w-rjv-line-color': '#ebdbb2',
|
|
6
|
+
'--w-rjv-arrow-color': 'var(--w-rjv-color)',
|
|
7
|
+
'--w-rjv-edit-color': 'var(--w-rjv-color)',
|
|
8
|
+
'--w-rjv-info-color': '#0000004d',
|
|
9
|
+
'--w-rjv-update-color': '#ebcb8b',
|
|
10
|
+
'--w-rjv-copied-color': '#002b36',
|
|
11
|
+
'--w-rjv-copied-success-color': '#28a745',
|
|
12
|
+
'--w-rjv-curlybraces-color': '#236a7c',
|
|
13
|
+
'--w-rjv-colon-color': '#002b36',
|
|
14
|
+
'--w-rjv-brackets-color': '#236a7c',
|
|
15
|
+
'--w-rjv-type-string-color': '#3c3836',
|
|
16
|
+
'--w-rjv-type-int-color': '#8f3f71',
|
|
17
|
+
'--w-rjv-type-float-color': '#8f3f71',
|
|
18
|
+
'--w-rjv-type-bigint-color': '#8f3f71',
|
|
19
|
+
'--w-rjv-type-boolean-color': '#8f3f71',
|
|
20
|
+
'--w-rjv-type-date-color': '#076678',
|
|
21
|
+
'--w-rjv-type-url-color': '#0969da',
|
|
22
|
+
'--w-rjv-type-null-color': '#076678',
|
|
23
|
+
'--w-rjv-type-nan-color': '#076678',
|
|
24
|
+
'--w-rjv-type-undefined-color': '#076678'
|
|
25
|
+
};
|
package/esm/theme/light.d.ts
CHANGED
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
'--w-rjv-color': string;
|
|
4
|
-
'--w-rjv-background-color': string;
|
|
5
|
-
'--w-rjv-line-color': string;
|
|
6
|
-
'--w-rjv-arrow-color': string;
|
|
7
|
-
'--w-rjv-edit-color': string;
|
|
8
|
-
'--w-rjv-info-color': string;
|
|
9
|
-
'--w-rjv-update-color': string;
|
|
10
|
-
'--w-rjv-copied-color': string;
|
|
11
|
-
'--w-rjv-copied-success-color': string;
|
|
12
|
-
'--w-rjv-curlybraces-color': string;
|
|
13
|
-
'--w-rjv-brackets-color': string;
|
|
14
|
-
'--w-rjv-type-string-color': string;
|
|
15
|
-
'--w-rjv-type-int-color': string;
|
|
16
|
-
'--w-rjv-type-float-color': string;
|
|
17
|
-
'--w-rjv-type-bigint-color': string;
|
|
18
|
-
'--w-rjv-type-boolean-color': string;
|
|
19
|
-
'--w-rjv-type-date-color': string;
|
|
20
|
-
'--w-rjv-type-url-color': string;
|
|
21
|
-
'--w-rjv-type-null-color': string;
|
|
22
|
-
'--w-rjv-type-nan-color': string;
|
|
23
|
-
'--w-rjv-type-undefined-color': string;
|
|
24
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const lightTheme: import("react").CSSProperties;
|
package/esm/theme/light.js
CHANGED
|
@@ -10,6 +10,7 @@ export var lightTheme = {
|
|
|
10
10
|
'--w-rjv-copied-color': '#002b36',
|
|
11
11
|
'--w-rjv-copied-success-color': '#28a745',
|
|
12
12
|
'--w-rjv-curlybraces-color': '#236a7c',
|
|
13
|
+
'--w-rjv-colon-color': '#002b36',
|
|
13
14
|
'--w-rjv-brackets-color': '#236a7c',
|
|
14
15
|
'--w-rjv-type-string-color': '#cb4b16',
|
|
15
16
|
'--w-rjv-type-int-color': '#268bd2',
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var monokaiTheme = {
|
|
2
|
+
'--w-rjv-font-family': 'monospace',
|
|
3
|
+
'--w-rjv-color': '#E6DB74',
|
|
4
|
+
'--w-rjv-background-color': '#272822',
|
|
5
|
+
'--w-rjv-line-color': '#3e3d32',
|
|
6
|
+
'--w-rjv-arrow-color': '#f8f8f2',
|
|
7
|
+
'--w-rjv-edit-color': 'var(--w-rjv-color)',
|
|
8
|
+
'--w-rjv-info-color': '#cecece4d',
|
|
9
|
+
'--w-rjv-update-color': '#5f5600',
|
|
10
|
+
'--w-rjv-copied-color': '#E6DB74',
|
|
11
|
+
'--w-rjv-copied-success-color': '#28a745',
|
|
12
|
+
'--w-rjv-curlybraces-color': '#f8f8f2',
|
|
13
|
+
'--w-rjv-colon-color': '#f8f8f2',
|
|
14
|
+
'--w-rjv-brackets-color': '#f8f8f2',
|
|
15
|
+
'--w-rjv-type-string-color': '#E6DB74',
|
|
16
|
+
'--w-rjv-type-int-color': '#AE81FF',
|
|
17
|
+
'--w-rjv-type-float-color': '#AE81FF',
|
|
18
|
+
'--w-rjv-type-bigint-color': '#AE81FF',
|
|
19
|
+
'--w-rjv-type-boolean-color': '#AE81FF',
|
|
20
|
+
'--w-rjv-type-date-color': '#fd9720c7',
|
|
21
|
+
'--w-rjv-type-url-color': '#55a3ff',
|
|
22
|
+
'--w-rjv-type-null-color': '#FA2672',
|
|
23
|
+
'--w-rjv-type-nan-color': '#FD971F',
|
|
24
|
+
'--w-rjv-type-undefined-color': '#FD971F'
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export var nordTheme = {
|
|
2
|
+
'--w-rjv-font-family': 'monospace',
|
|
3
|
+
'--w-rjv-color': '#88c0d0',
|
|
4
|
+
'--w-rjv-background-color': '#2e3440',
|
|
5
|
+
'--w-rjv-line-color': '#4c566a',
|
|
6
|
+
'--w-rjv-arrow-color': 'var(--w-rjv-color)',
|
|
7
|
+
'--w-rjv-edit-color': 'var(--w-rjv-color)',
|
|
8
|
+
'--w-rjv-info-color': '#c7c7c74d',
|
|
9
|
+
'--w-rjv-update-color': '#88c0cf75',
|
|
10
|
+
'--w-rjv-copied-color': '#119cc0',
|
|
11
|
+
'--w-rjv-copied-success-color': '#28a745',
|
|
12
|
+
'--w-rjv-curlybraces-color': '#8fbcbb',
|
|
13
|
+
'--w-rjv-colon-color': '#6d9fac',
|
|
14
|
+
'--w-rjv-brackets-color': '#8fbcbb',
|
|
15
|
+
'--w-rjv-type-string-color': '#a3be8c',
|
|
16
|
+
'--w-rjv-type-int-color': '#b48ead',
|
|
17
|
+
'--w-rjv-type-float-color': '#859900',
|
|
18
|
+
'--w-rjv-type-bigint-color': '#b48ead',
|
|
19
|
+
'--w-rjv-type-boolean-color': '#d08770',
|
|
20
|
+
'--w-rjv-type-date-color': '#41a2c2',
|
|
21
|
+
'--w-rjv-type-url-color': '#5e81ac',
|
|
22
|
+
'--w-rjv-type-null-color': '#5e81ac',
|
|
23
|
+
'--w-rjv-type-nan-color': '#859900',
|
|
24
|
+
'--w-rjv-type-undefined-color': '#586e75'
|
|
25
|
+
};
|