@uiw/react-json-view 1.3.0 → 1.5.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 +155 -13
- package/cjs/comps/ellipsis.d.ts +5 -0
- package/cjs/comps/ellipsis.js +32 -0
- package/cjs/comps/meta.d.ts +8 -0
- package/cjs/comps/meta.js +38 -0
- package/cjs/copied.js +5 -4
- package/cjs/editor/icon/edit.d.ts +4 -0
- package/cjs/editor/icon/edit.js +30 -0
- package/cjs/editor/index.d.ts +16 -0
- package/cjs/editor/index.js +48 -0
- package/cjs/editor/objectKey.d.ts +11 -0
- package/cjs/editor/objectKey.js +138 -0
- package/cjs/editor/value.d.ts +14 -0
- package/cjs/editor/value.js +165 -0
- package/cjs/index.d.ts +5 -1
- package/cjs/node.d.ts +0 -19
- package/cjs/node.js +68 -168
- package/cjs/semicolon.d.ts +21 -0
- package/cjs/semicolon.js +113 -0
- package/cjs/theme/dark.d.ts +2 -0
- package/cjs/theme/dark.js +2 -0
- package/cjs/theme/light.d.ts +2 -0
- package/cjs/theme/light.js +2 -0
- package/cjs/tools.d.ts +10 -0
- package/cjs/tools.js +24 -0
- package/cjs/value.d.ts +20 -5
- package/cjs/value.js +67 -28
- package/editor.d.ts +16 -0
- package/esm/comps/ellipsis.d.ts +5 -0
- package/esm/comps/ellipsis.js +26 -0
- package/esm/comps/meta.d.ts +8 -0
- package/esm/comps/meta.js +31 -0
- package/esm/copied.js +5 -4
- package/esm/editor/icon/edit.d.ts +4 -0
- package/esm/editor/icon/edit.js +24 -0
- package/esm/editor/index.d.ts +16 -0
- package/esm/editor/index.js +37 -0
- package/esm/editor/objectKey.d.ts +11 -0
- package/esm/editor/objectKey.js +122 -0
- package/esm/editor/value.d.ts +14 -0
- package/esm/editor/value.js +150 -0
- package/esm/index.d.ts +5 -1
- package/esm/node.d.ts +0 -19
- package/esm/node.js +49 -156
- package/esm/semicolon.d.ts +21 -0
- package/esm/semicolon.js +104 -0
- package/esm/theme/dark.d.ts +2 -0
- package/esm/theme/dark.js +2 -0
- package/esm/theme/light.d.ts +2 -0
- package/esm/theme/light.js +2 -0
- package/esm/tools.d.ts +10 -0
- package/esm/tools.js +20 -0
- package/esm/value.d.ts +20 -5
- package/esm/value.js +67 -28
- package/package.json +7 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { LabelProps } from './value';
|
|
3
|
+
import { JsonViewProps } from './';
|
|
4
|
+
export declare function usePrevious<T>(value: T): T | undefined;
|
|
5
|
+
interface UseHighlight {
|
|
6
|
+
value: any;
|
|
7
|
+
highlightUpdates?: boolean;
|
|
8
|
+
highlightContainer: React.MutableRefObject<HTMLSpanElement | null>;
|
|
9
|
+
}
|
|
10
|
+
export declare function useHighlight({ value, highlightUpdates, highlightContainer }: UseHighlight): void;
|
|
11
|
+
export interface SemicolonProps extends LabelProps {
|
|
12
|
+
highlightUpdates?: boolean;
|
|
13
|
+
keyName?: string | number;
|
|
14
|
+
parentName?: string | number;
|
|
15
|
+
quotes?: JsonViewProps<object>['quotes'];
|
|
16
|
+
value?: object;
|
|
17
|
+
label?: string;
|
|
18
|
+
render?: (props: SemicolonProps) => React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export declare const Semicolon: FC<PropsWithChildren<SemicolonProps>>;
|
|
21
|
+
export {};
|
package/esm/semicolon.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["children", "render", "color", "value", "className", "keyName", "highlightUpdates", "quotes", "style", "parentName"];
|
|
4
|
+
import { useMemo, useRef, useEffect } from 'react';
|
|
5
|
+
import { Label } from './value';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export function usePrevious(value) {
|
|
8
|
+
var ref = useRef();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
ref.current = value;
|
|
11
|
+
});
|
|
12
|
+
return ref.current;
|
|
13
|
+
}
|
|
14
|
+
export function useHighlight(_ref) {
|
|
15
|
+
var {
|
|
16
|
+
value,
|
|
17
|
+
highlightUpdates,
|
|
18
|
+
highlightContainer
|
|
19
|
+
} = _ref;
|
|
20
|
+
var prevValue = usePrevious(value);
|
|
21
|
+
var isHighlight = useMemo(() => {
|
|
22
|
+
if (!highlightUpdates || prevValue === undefined) return false;
|
|
23
|
+
// highlight if value type changed
|
|
24
|
+
if (typeof value !== typeof prevValue) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === 'number') {
|
|
28
|
+
// notice: NaN !== NaN
|
|
29
|
+
if (isNaN(value) && isNaN(prevValue)) return false;
|
|
30
|
+
return value !== prevValue;
|
|
31
|
+
}
|
|
32
|
+
// highlight if isArray changed
|
|
33
|
+
if (Array.isArray(value) !== Array.isArray(prevValue)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
// not highlight object/function
|
|
37
|
+
// deep compare they will be slow
|
|
38
|
+
if (typeof value === 'object' || typeof value === 'function') {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// highlight if not equal
|
|
43
|
+
if (value !== prevValue) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}, [highlightUpdates, value]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (highlightContainer && highlightContainer.current && isHighlight && 'animate' in highlightContainer.current) {
|
|
50
|
+
highlightContainer.current.animate([{
|
|
51
|
+
backgroundColor: 'var(--w-rjv-update-color, #ebcb8b)'
|
|
52
|
+
}, {
|
|
53
|
+
backgroundColor: ''
|
|
54
|
+
}], {
|
|
55
|
+
duration: 1000,
|
|
56
|
+
easing: 'ease-in'
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}, [isHighlight, value, highlightContainer]);
|
|
60
|
+
}
|
|
61
|
+
export var Semicolon = _ref2 => {
|
|
62
|
+
var {
|
|
63
|
+
render,
|
|
64
|
+
color,
|
|
65
|
+
value,
|
|
66
|
+
className = 'w-rjv-object-key',
|
|
67
|
+
keyName,
|
|
68
|
+
highlightUpdates,
|
|
69
|
+
quotes,
|
|
70
|
+
style,
|
|
71
|
+
parentName
|
|
72
|
+
} = _ref2,
|
|
73
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
74
|
+
var highlightContainer = useRef(null);
|
|
75
|
+
var content = typeof keyName === 'string' ? "" + quotes + keyName + quotes : keyName;
|
|
76
|
+
if (render) {
|
|
77
|
+
return render(_extends({
|
|
78
|
+
className
|
|
79
|
+
}, props, {
|
|
80
|
+
value,
|
|
81
|
+
style: _extends({}, style, {
|
|
82
|
+
color
|
|
83
|
+
}),
|
|
84
|
+
parentName,
|
|
85
|
+
keyName,
|
|
86
|
+
quotes,
|
|
87
|
+
label: keyName,
|
|
88
|
+
children: content
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
;
|
|
92
|
+
useHighlight({
|
|
93
|
+
value,
|
|
94
|
+
highlightUpdates,
|
|
95
|
+
highlightContainer
|
|
96
|
+
});
|
|
97
|
+
return /*#__PURE__*/_jsx(Label, _extends({
|
|
98
|
+
className: className,
|
|
99
|
+
color: color
|
|
100
|
+
}, props, {
|
|
101
|
+
ref: highlightContainer,
|
|
102
|
+
children: content
|
|
103
|
+
}));
|
|
104
|
+
};
|
package/esm/theme/dark.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const darkTheme: {
|
|
|
4
4
|
'--w-rjv-background-color': string;
|
|
5
5
|
'--w-rjv-line-color': string;
|
|
6
6
|
'--w-rjv-arrow-color': string;
|
|
7
|
+
'--w-rjv-edit-color': string;
|
|
7
8
|
'--w-rjv-info-color': string;
|
|
8
9
|
'--w-rjv-update-color': string;
|
|
9
10
|
'--w-rjv-copied-color': string;
|
|
@@ -16,6 +17,7 @@ export declare const darkTheme: {
|
|
|
16
17
|
'--w-rjv-type-bigint-color': string;
|
|
17
18
|
'--w-rjv-type-boolean-color': string;
|
|
18
19
|
'--w-rjv-type-date-color': string;
|
|
20
|
+
'--w-rjv-type-url-color': string;
|
|
19
21
|
'--w-rjv-type-null-color': string;
|
|
20
22
|
'--w-rjv-type-nan-color': string;
|
|
21
23
|
'--w-rjv-type-undefined-color': string;
|
package/esm/theme/dark.js
CHANGED
|
@@ -4,6 +4,7 @@ export var darkTheme = {
|
|
|
4
4
|
'--w-rjv-background-color': '#202020',
|
|
5
5
|
'--w-rjv-line-color': '#323232',
|
|
6
6
|
'--w-rjv-arrow-color': 'var(--w-rjv-color)',
|
|
7
|
+
'--w-rjv-edit-color': 'var(--w-rjv-color)',
|
|
7
8
|
'--w-rjv-info-color': '#656565',
|
|
8
9
|
'--w-rjv-update-color': '#ebcb8b',
|
|
9
10
|
'--w-rjv-copied-color': '#0184a6',
|
|
@@ -16,6 +17,7 @@ export var darkTheme = {
|
|
|
16
17
|
'--w-rjv-type-bigint-color': '#268bd2',
|
|
17
18
|
'--w-rjv-type-boolean-color': '#2aa198',
|
|
18
19
|
'--w-rjv-type-date-color': '#586e75',
|
|
20
|
+
'--w-rjv-type-url-color': '#649bd8',
|
|
19
21
|
'--w-rjv-type-null-color': '#d33682',
|
|
20
22
|
'--w-rjv-type-nan-color': '#859900',
|
|
21
23
|
'--w-rjv-type-undefined-color': '#586e75'
|
package/esm/theme/light.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const lightTheme: {
|
|
|
4
4
|
'--w-rjv-background-color': string;
|
|
5
5
|
'--w-rjv-line-color': string;
|
|
6
6
|
'--w-rjv-arrow-color': string;
|
|
7
|
+
'--w-rjv-edit-color': string;
|
|
7
8
|
'--w-rjv-info-color': string;
|
|
8
9
|
'--w-rjv-update-color': string;
|
|
9
10
|
'--w-rjv-copied-color': string;
|
|
@@ -16,6 +17,7 @@ export declare const lightTheme: {
|
|
|
16
17
|
'--w-rjv-type-bigint-color': string;
|
|
17
18
|
'--w-rjv-type-boolean-color': string;
|
|
18
19
|
'--w-rjv-type-date-color': string;
|
|
20
|
+
'--w-rjv-type-url-color': string;
|
|
19
21
|
'--w-rjv-type-null-color': string;
|
|
20
22
|
'--w-rjv-type-nan-color': string;
|
|
21
23
|
'--w-rjv-type-undefined-color': string;
|
package/esm/theme/light.js
CHANGED
|
@@ -4,6 +4,7 @@ export var lightTheme = {
|
|
|
4
4
|
'--w-rjv-background-color': '#ffffff',
|
|
5
5
|
'--w-rjv-line-color': '#ebebeb',
|
|
6
6
|
'--w-rjv-arrow-color': 'var(--w-rjv-color)',
|
|
7
|
+
'--w-rjv-edit-color': 'var(--w-rjv-color)',
|
|
7
8
|
'--w-rjv-info-color': '#0000004d',
|
|
8
9
|
'--w-rjv-update-color': '#ebcb8b',
|
|
9
10
|
'--w-rjv-copied-color': '#002b36',
|
|
@@ -16,6 +17,7 @@ export var lightTheme = {
|
|
|
16
17
|
'--w-rjv-type-bigint-color': '#268bd2',
|
|
17
18
|
'--w-rjv-type-boolean-color': '#2aa198',
|
|
18
19
|
'--w-rjv-type-date-color': '#586e75',
|
|
20
|
+
'--w-rjv-type-url-color': '#0969da',
|
|
19
21
|
'--w-rjv-type-null-color': '#d33682',
|
|
20
22
|
'--w-rjv-type-nan-color': '#859900',
|
|
21
23
|
'--w-rjv-type-undefined-color': '#586e75'
|
package/esm/tools.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JsonViewProps } from './';
|
|
2
|
+
interface ToolsProps<T extends object> {
|
|
3
|
+
enableClipboard?: boolean;
|
|
4
|
+
value?: T | {};
|
|
5
|
+
onCopied?: JsonViewProps<T>['onCopied'];
|
|
6
|
+
components?: JsonViewProps<T>['components'];
|
|
7
|
+
showTools?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function Tools<T extends object>(props: ToolsProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
package/esm/tools.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Fragment } from "react";
|
|
2
|
+
import { Copied } from './copied';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export function Tools(props) {
|
|
5
|
+
var {
|
|
6
|
+
enableClipboard,
|
|
7
|
+
value,
|
|
8
|
+
showTools,
|
|
9
|
+
components,
|
|
10
|
+
onCopied
|
|
11
|
+
} = props;
|
|
12
|
+
return /*#__PURE__*/_jsx(Fragment, {
|
|
13
|
+
children: enableClipboard && /*#__PURE__*/_jsx(Copied, {
|
|
14
|
+
show: showTools,
|
|
15
|
+
text: value,
|
|
16
|
+
onCopied: onCopied,
|
|
17
|
+
render: components == null ? void 0 : components.copied
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
}
|
package/esm/value.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
|
-
import { MetaProps } from './
|
|
2
|
+
import { MetaProps } from './comps/meta';
|
|
3
|
+
import { JsonViewProps } from './';
|
|
3
4
|
export declare const Line: FC<PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>>;
|
|
5
|
+
export declare const isFloat: (n: number) => boolean;
|
|
4
6
|
export declare const typeMap: {
|
|
5
7
|
string: {
|
|
6
8
|
color: string;
|
|
@@ -26,6 +28,10 @@ export declare const typeMap: {
|
|
|
26
28
|
color: string;
|
|
27
29
|
label: string;
|
|
28
30
|
};
|
|
31
|
+
url: {
|
|
32
|
+
color: string;
|
|
33
|
+
label: string;
|
|
34
|
+
};
|
|
29
35
|
null: {
|
|
30
36
|
color: string;
|
|
31
37
|
label: string;
|
|
@@ -40,20 +46,29 @@ export declare const typeMap: {
|
|
|
40
46
|
};
|
|
41
47
|
};
|
|
42
48
|
export declare const Colon: FC<PropsWithChildren<React.HTMLAttributes<HTMLSpanElement>>>;
|
|
43
|
-
export interface ValueViewProps<T> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
|
|
44
|
-
keyName?: string;
|
|
45
|
-
value?:
|
|
49
|
+
export interface ValueViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
|
|
50
|
+
keyName?: string | number;
|
|
51
|
+
value?: unknown;
|
|
46
52
|
displayDataTypes: boolean;
|
|
47
53
|
displayObjectSize: boolean;
|
|
48
54
|
enableClipboard: boolean;
|
|
49
55
|
indentWidth: number;
|
|
56
|
+
quotes?: JsonViewProps<T>['quotes'];
|
|
50
57
|
renderKey?: JSX.Element;
|
|
51
58
|
renderBraces?: MetaProps['render'];
|
|
52
59
|
renderValue?: (props: React.HTMLAttributes<HTMLSpanElement> & {
|
|
53
60
|
type: TypeProps['type'];
|
|
61
|
+
value?: unknown;
|
|
62
|
+
visible?: boolean;
|
|
63
|
+
quotes?: JsonViewProps<T>['quotes'];
|
|
64
|
+
keyName?: ValueViewProps<T>['keyName'];
|
|
54
65
|
}) => JSX.Element;
|
|
55
66
|
}
|
|
56
|
-
export declare function
|
|
67
|
+
export declare function getValueString<T>(value: T): {
|
|
68
|
+
type: "string" | "number" | "bigint" | "boolean" | "undefined" | "date" | "url" | "float" | "null" | "NaN";
|
|
69
|
+
content: string;
|
|
70
|
+
};
|
|
71
|
+
export declare function ValueView<T extends object>(props: ValueViewProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
57
72
|
export interface LabelProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
58
73
|
color?: string;
|
|
59
74
|
fontSize?: number;
|
package/esm/value.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
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", "renderValue", "renderBraces", "enableClipboard", "displayObjectSize", "displayDataTypes"],
|
|
4
|
+
_excluded2 = ["value", "keyName", "indentWidth", "renderKey", "quotes", "renderValue", "renderBraces", "enableClipboard", "displayObjectSize", "displayDataTypes"],
|
|
5
5
|
_excluded3 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
|
|
6
6
|
import { Fragment, forwardRef, useState } from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { CountInfo } from './node';
|
|
8
|
+
import { Meta } from './comps/meta';
|
|
8
9
|
import { Copied } from './copied';
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
export var Line = props => /*#__PURE__*/_jsx("div", _extends({}, props));
|
|
12
|
-
var isFloat = n => Number(n) === n && n % 1 !== 0 || isNaN(n);
|
|
13
|
+
export var isFloat = n => Number(n) === n && n % 1 !== 0 || isNaN(n);
|
|
13
14
|
export var typeMap = {
|
|
14
15
|
string: {
|
|
15
16
|
color: 'var(--w-rjv-type-string-color, #cb4b16)',
|
|
@@ -35,6 +36,10 @@ export var typeMap = {
|
|
|
35
36
|
color: 'var(--w-rjv-type-date-color, #586e75)',
|
|
36
37
|
label: 'date'
|
|
37
38
|
},
|
|
39
|
+
url: {
|
|
40
|
+
color: 'var(--w-rjv-type-url-color, #0969da)',
|
|
41
|
+
label: 'URL'
|
|
42
|
+
},
|
|
38
43
|
null: {
|
|
39
44
|
color: 'var(--w-rjv-type-null-color, #d33682)',
|
|
40
45
|
label: 'null'
|
|
@@ -63,23 +68,9 @@ export var Colon = _ref => {
|
|
|
63
68
|
children: children
|
|
64
69
|
}));
|
|
65
70
|
};
|
|
66
|
-
export function
|
|
67
|
-
var _typeMap$type;
|
|
68
|
-
var {
|
|
69
|
-
value,
|
|
70
|
-
indentWidth,
|
|
71
|
-
renderKey,
|
|
72
|
-
renderValue,
|
|
73
|
-
renderBraces,
|
|
74
|
-
enableClipboard,
|
|
75
|
-
displayObjectSize,
|
|
76
|
-
displayDataTypes
|
|
77
|
-
} = props,
|
|
78
|
-
reset = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
71
|
+
export function getValueString(value) {
|
|
79
72
|
var type = typeof value;
|
|
80
73
|
var content = '';
|
|
81
|
-
var color = '';
|
|
82
|
-
var style = {};
|
|
83
74
|
if (typeof value === 'number') {
|
|
84
75
|
type = isFloat(value) ? 'float' : 'number';
|
|
85
76
|
content = value.toString();
|
|
@@ -92,29 +83,65 @@ export function ValueView(props) {
|
|
|
92
83
|
type = 'date';
|
|
93
84
|
content = value.toString();
|
|
94
85
|
}
|
|
95
|
-
var typeView = /*#__PURE__*/_jsx(Type, {
|
|
96
|
-
type: type
|
|
97
|
-
});
|
|
98
86
|
if (value === null) {
|
|
99
87
|
type = 'null';
|
|
100
88
|
content = ("" + value).toLocaleUpperCase();
|
|
101
|
-
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
102
|
-
style = {
|
|
103
|
-
fontWeight: 'bold'
|
|
104
|
-
};
|
|
105
89
|
}
|
|
106
90
|
if (value === undefined) {
|
|
107
91
|
type = 'undefined';
|
|
108
92
|
content = String(value);
|
|
109
|
-
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
110
93
|
}
|
|
111
94
|
if (typeof value === 'bigint') {
|
|
112
95
|
type = 'bigint';
|
|
113
96
|
content = value + "n";
|
|
114
97
|
}
|
|
98
|
+
var isURL = value instanceof URL;
|
|
99
|
+
if (isURL) {
|
|
100
|
+
type = 'url';
|
|
101
|
+
content = "\"" + value.href + "\"";
|
|
102
|
+
}
|
|
115
103
|
if (typeof value === 'string') {
|
|
116
104
|
content = "\"" + value + "\"";
|
|
117
105
|
}
|
|
106
|
+
return {
|
|
107
|
+
type,
|
|
108
|
+
content
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export function ValueView(props) {
|
|
112
|
+
var _typeMap$type;
|
|
113
|
+
var {
|
|
114
|
+
value,
|
|
115
|
+
keyName,
|
|
116
|
+
indentWidth,
|
|
117
|
+
renderKey,
|
|
118
|
+
quotes,
|
|
119
|
+
renderValue,
|
|
120
|
+
renderBraces,
|
|
121
|
+
enableClipboard,
|
|
122
|
+
displayObjectSize,
|
|
123
|
+
displayDataTypes
|
|
124
|
+
} = props,
|
|
125
|
+
reset = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
126
|
+
var color = '';
|
|
127
|
+
var style = {};
|
|
128
|
+
var {
|
|
129
|
+
type,
|
|
130
|
+
content
|
|
131
|
+
} = getValueString(value);
|
|
132
|
+
var typeView = /*#__PURE__*/_jsx(Type, {
|
|
133
|
+
type: type
|
|
134
|
+
});
|
|
135
|
+
if (value === null) {
|
|
136
|
+
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
137
|
+
style = {
|
|
138
|
+
fontWeight: 'bold'
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (value === undefined) {
|
|
142
|
+
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
143
|
+
}
|
|
144
|
+
var isURL = value instanceof URL;
|
|
118
145
|
if (!displayDataTypes) {
|
|
119
146
|
typeView = /*#__PURE__*/_jsx(Fragment, {});
|
|
120
147
|
}
|
|
@@ -141,14 +168,26 @@ export function ValueView(props) {
|
|
|
141
168
|
color
|
|
142
169
|
}, style),
|
|
143
170
|
type,
|
|
171
|
+
value,
|
|
172
|
+
quotes,
|
|
173
|
+
keyName,
|
|
174
|
+
visible: showTools,
|
|
144
175
|
content,
|
|
145
|
-
children:
|
|
176
|
+
children: content
|
|
146
177
|
});
|
|
147
178
|
var valueView = reView ? reView : /*#__PURE__*/_jsx(Label, {
|
|
148
179
|
color: color,
|
|
149
180
|
style: style,
|
|
150
181
|
className: "w-rjv-value",
|
|
151
|
-
children:
|
|
182
|
+
children: isURL ? /*#__PURE__*/_jsx("a", {
|
|
183
|
+
href: value.href,
|
|
184
|
+
style: {
|
|
185
|
+
color
|
|
186
|
+
},
|
|
187
|
+
target: "_blank",
|
|
188
|
+
rel: "noopener noreferrer",
|
|
189
|
+
children: content
|
|
190
|
+
}) : content
|
|
152
191
|
});
|
|
153
192
|
return /*#__PURE__*/_jsx(Line, _extends({}, eventProps, {
|
|
154
193
|
children: /*#__PURE__*/_jsxs(Label, _extends({}, reset, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-json-view",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "JSON viewer for react.",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"types": "./cjs/index.d.ts",
|
|
13
13
|
"require": "./cjs/index.js"
|
|
14
14
|
},
|
|
15
|
+
"./editor": {
|
|
16
|
+
"import": "./esm/editor/index.js",
|
|
17
|
+
"types": "./cjs/editor/index.d.ts",
|
|
18
|
+
"require": "./cjs/editor/index.js"
|
|
19
|
+
},
|
|
15
20
|
"./light": {
|
|
16
21
|
"import": "./esm/theme/light.js",
|
|
17
22
|
"types": "./cjs/theme/light.d.ts",
|
|
@@ -45,6 +50,7 @@
|
|
|
45
50
|
"react-dom": ">=18.0.0"
|
|
46
51
|
},
|
|
47
52
|
"files": [
|
|
53
|
+
"editor.d.ts",
|
|
48
54
|
"dark.d.ts",
|
|
49
55
|
"light.d.ts",
|
|
50
56
|
"triangle-arrow.d.ts",
|