@uiw/react-json-view 2.0.0-alpha.34 → 2.0.0-alpha.36
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 +8 -4
- package/basic.d.ts +2 -1
- package/cjs/Container.js +3 -1
- package/cjs/comps/KeyValues.js +11 -6
- package/cjs/comps/NestedClose.d.ts +2 -3
- package/cjs/comps/NestedClose.js +23 -10
- package/cjs/comps/NestedOpen.js +10 -8
- package/cjs/index.d.ts +8 -5
- package/cjs/store.d.ts +2 -2
- package/cjs/symbol/index.d.ts +2 -2
- package/cjs/theme/basic.d.ts +2 -1
- package/cjs/theme/dark.d.ts +2 -1
- package/cjs/theme/github.dark.d.ts +2 -1
- package/cjs/theme/github.light.d.ts +2 -1
- package/cjs/theme/gruvbox.d.ts +2 -1
- package/cjs/theme/light.d.ts +2 -1
- package/cjs/theme/monokai.d.ts +2 -1
- package/cjs/theme/nord.d.ts +2 -1
- package/cjs/theme/vscode.d.ts +2 -1
- package/cjs/types/index.d.ts +1 -1
- package/dark.d.ts +2 -1
- package/esm/Container.js +3 -1
- package/esm/comps/KeyValues.js +10 -5
- package/esm/comps/NestedClose.d.ts +2 -3
- package/esm/comps/NestedClose.js +21 -9
- package/esm/comps/NestedOpen.js +9 -7
- package/esm/index.d.ts +8 -5
- package/esm/store.d.ts +2 -2
- package/esm/symbol/index.d.ts +2 -2
- package/esm/theme/basic.d.ts +2 -1
- package/esm/theme/dark.d.ts +2 -1
- package/esm/theme/github.dark.d.ts +2 -1
- package/esm/theme/github.light.d.ts +2 -1
- package/esm/theme/gruvbox.d.ts +2 -1
- package/esm/theme/light.d.ts +2 -1
- package/esm/theme/monokai.d.ts +2 -1
- package/esm/theme/nord.d.ts +2 -1
- package/esm/theme/vscode.d.ts +2 -1
- package/esm/types/index.d.ts +1 -1
- package/githubDark.d.ts +2 -1
- package/githubLight.d.ts +2 -1
- package/gruvbox.d.ts +2 -1
- package/light.d.ts +2 -1
- package/monokai.d.ts +2 -1
- package/nord.d.ts +2 -1
- package/package.json +1 -1
- package/vscode.d.ts +2 -1
package/README.md
CHANGED
|
@@ -911,10 +911,7 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
911
911
|
/** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. @default false */
|
|
912
912
|
collapsed?: boolean | number;
|
|
913
913
|
/** Determine whether the node should be expanded on the first render, or you can use collapsed to control the level of expansion (by default, the root is expanded). */
|
|
914
|
-
shouldExpandNodeInitially?:
|
|
915
|
-
isExpanded: boolean,
|
|
916
|
-
props: { value?: T; keys: (number | string)[]; level: number },
|
|
917
|
-
) => boolean;
|
|
914
|
+
shouldExpandNodeInitially?: ShouldExpandNodeInitially<T>;
|
|
918
915
|
/** Whether to highlight updates. @default true */
|
|
919
916
|
highlightUpdates?: boolean;
|
|
920
917
|
/** Shorten long JSON strings, Set to `0` to disable this feature @default 30 */
|
|
@@ -926,6 +923,13 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
926
923
|
/** Fires event when you copy */
|
|
927
924
|
onCopied?: (text: string, value?: T) => void;
|
|
928
925
|
}
|
|
926
|
+
export type ShouldExpandNodeInitially<T extends object> = (isExpanded: boolean, props: {
|
|
927
|
+
keyName?: string | number;
|
|
928
|
+
value?: T;
|
|
929
|
+
parentValue?: T;
|
|
930
|
+
keys: (number | string)[];
|
|
931
|
+
level: number;
|
|
932
|
+
}) => boolean;
|
|
929
933
|
```
|
|
930
934
|
|
|
931
935
|
```ts
|
package/basic.d.ts
CHANGED
package/cjs/Container.js
CHANGED
package/cjs/comps/KeyValues.js
CHANGED
|
@@ -25,31 +25,36 @@ var _useIdCompat = require("../comps/useIdCompat");
|
|
|
25
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
26
|
var KeyValues = exports.KeyValues = function KeyValues(props) {
|
|
27
27
|
var _expands$expandKey;
|
|
28
|
-
var
|
|
28
|
+
var keyName = props.keyName,
|
|
29
|
+
value = props.value,
|
|
29
30
|
_props$expandKey = props.expandKey,
|
|
30
31
|
expandKey = _props$expandKey === void 0 ? '' : _props$expandKey,
|
|
31
32
|
level = props.level,
|
|
32
33
|
_props$keys = props.keys,
|
|
33
|
-
keys = _props$keys === void 0 ? [] : _props$keys
|
|
34
|
+
keys = _props$keys === void 0 ? [] : _props$keys,
|
|
35
|
+
parentValue = props.parentValue;
|
|
34
36
|
var expands = (0, _Expands.useExpandsStore)();
|
|
35
37
|
var _useStore = (0, _store.useStore)(),
|
|
36
38
|
objectSortKeys = _useStore.objectSortKeys,
|
|
37
39
|
indentWidth = _useStore.indentWidth,
|
|
38
40
|
collapsed = _useStore.collapsed,
|
|
39
41
|
shouldExpandNodeInitially = _useStore.shouldExpandNodeInitially;
|
|
40
|
-
var isMyArray = Array.isArray(value);
|
|
41
42
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
42
43
|
var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : defaultExpanded;
|
|
43
|
-
|
|
44
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
44
45
|
value: value,
|
|
45
46
|
keys: keys,
|
|
46
|
-
level: level
|
|
47
|
-
|
|
47
|
+
level: level,
|
|
48
|
+
keyName: keyName,
|
|
49
|
+
parentValue: parentValue
|
|
50
|
+
});
|
|
51
|
+
if (expands[expandKey] === undefined && !!shouldExpand) {
|
|
48
52
|
return null;
|
|
49
53
|
}
|
|
50
54
|
if (isExpanded) {
|
|
51
55
|
return null;
|
|
52
56
|
}
|
|
57
|
+
var isMyArray = Array.isArray(value);
|
|
53
58
|
// object
|
|
54
59
|
var entries = isMyArray ? Object.entries(value).map(function (m) {
|
|
55
60
|
return [Number(m[0]), m[1]];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type SectionElementResult } from '../store/Section';
|
|
2
|
+
interface NestedCloseProps<T extends object> extends SectionElementResult<T> {
|
|
3
3
|
expandKey: string;
|
|
4
4
|
level: number;
|
|
5
|
-
keys?: (string | number)[];
|
|
6
5
|
}
|
|
7
6
|
export declare const NestedClose: {
|
|
8
7
|
<T extends object>(props: NestedCloseProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
package/cjs/comps/NestedClose.js
CHANGED
|
@@ -1,49 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.NestedClose = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
7
9
|
var _store = require("../store");
|
|
8
10
|
var _Expands = require("../store/Expands");
|
|
9
11
|
var _symbol = require("../symbol/");
|
|
10
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
13
|
var NestedClose = exports.NestedClose = function NestedClose(props) {
|
|
12
14
|
var _expands$expandKey;
|
|
13
|
-
var
|
|
15
|
+
var keyName = props.keyName,
|
|
16
|
+
value = props.value,
|
|
14
17
|
expandKey = props.expandKey,
|
|
18
|
+
parentValue = props.parentValue,
|
|
15
19
|
level = props.level,
|
|
16
20
|
_props$keys = props.keys,
|
|
17
21
|
keys = _props$keys === void 0 ? [] : _props$keys;
|
|
18
22
|
var expands = (0, _Expands.useExpandsStore)();
|
|
19
|
-
var isArray = Array.isArray(value);
|
|
20
23
|
var _useStore = (0, _store.useStore)(),
|
|
21
24
|
collapsed = _useStore.collapsed,
|
|
22
25
|
shouldExpandNodeInitially = _useStore.shouldExpandNodeInitially;
|
|
23
|
-
var isMySet = value instanceof Set;
|
|
24
26
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
25
27
|
var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : defaultExpanded;
|
|
26
|
-
var
|
|
27
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
28
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
28
29
|
value: value,
|
|
29
30
|
keys: keys,
|
|
30
|
-
level: level
|
|
31
|
+
level: level,
|
|
32
|
+
keyName: keyName,
|
|
33
|
+
parentValue: parentValue
|
|
31
34
|
});
|
|
32
|
-
if (expands[expandKey] === undefined &&
|
|
35
|
+
if (expands[expandKey] === undefined && !!shouldExpand) {
|
|
33
36
|
return null;
|
|
34
37
|
}
|
|
38
|
+
var len = Object.keys(value).length;
|
|
35
39
|
if (isExpanded || len === 0) {
|
|
36
40
|
return null;
|
|
37
41
|
}
|
|
38
42
|
var style = {
|
|
39
43
|
paddingLeft: 4
|
|
40
44
|
};
|
|
45
|
+
var compProps = {
|
|
46
|
+
keyName: keyName,
|
|
47
|
+
value: value,
|
|
48
|
+
keys: keys,
|
|
49
|
+
parentValue: parentValue
|
|
50
|
+
};
|
|
51
|
+
var isArray = Array.isArray(value);
|
|
52
|
+
var isMySet = value instanceof Set;
|
|
41
53
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
42
54
|
style: style,
|
|
43
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.BracketsClose, {
|
|
44
|
-
isBrackets: isArray || isMySet
|
|
55
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.BracketsClose, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
56
|
+
isBrackets: isArray || isMySet
|
|
57
|
+
}, compProps), {}, {
|
|
45
58
|
isVisiable: true
|
|
46
|
-
})
|
|
59
|
+
}))
|
|
47
60
|
});
|
|
48
61
|
};
|
|
49
62
|
NestedClose.displayName = 'JVR.NestedClose';
|
package/cjs/comps/NestedOpen.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.NestedOpen = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _KeyValues = require("./KeyValues");
|
|
12
12
|
var _Expands = require("../store/Expands");
|
|
13
13
|
var _store = require("../store");
|
|
@@ -34,18 +34,17 @@ var NestedOpen = exports.NestedOpen = function NestedOpen(props) {
|
|
|
34
34
|
onExpand = _useStore.onExpand,
|
|
35
35
|
collapsed = _useStore.collapsed,
|
|
36
36
|
shouldExpandNodeInitially = _useStore.shouldExpandNodeInitially;
|
|
37
|
-
var isArray = Array.isArray(value);
|
|
38
|
-
var isMySet = value instanceof Set;
|
|
39
37
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
40
|
-
var isObject = (0, _typeof2["default"])(value) === 'object';
|
|
41
38
|
var isExpanded = (_expands$expandKey = expands[expandKey]) !== null && _expands$expandKey !== void 0 ? _expands$expandKey : defaultExpanded;
|
|
42
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(
|
|
39
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
43
40
|
value: value,
|
|
44
41
|
keys: keys,
|
|
45
|
-
level: level
|
|
42
|
+
level: level,
|
|
43
|
+
keyName: keyName,
|
|
44
|
+
parentValue: parentValue
|
|
46
45
|
});
|
|
47
|
-
if (expands[expandKey] === undefined && shouldExpandNodeInitially
|
|
48
|
-
isExpanded =
|
|
46
|
+
if (expands[expandKey] === undefined && shouldExpandNodeInitially) {
|
|
47
|
+
isExpanded = !!shouldExpand;
|
|
49
48
|
}
|
|
50
49
|
var click = function click() {
|
|
51
50
|
var opt = {
|
|
@@ -66,6 +65,9 @@ var NestedOpen = exports.NestedOpen = function NestedOpen(props) {
|
|
|
66
65
|
transition: 'all 0.3s'
|
|
67
66
|
};
|
|
68
67
|
var len = Object.keys(value).length;
|
|
68
|
+
var isObject = (0, _typeof2["default"])(value) === 'object';
|
|
69
|
+
var isArray = Array.isArray(value);
|
|
70
|
+
var isMySet = value instanceof Set;
|
|
69
71
|
var showArrow = len !== 0 && (isArray || isMySet || isObject);
|
|
70
72
|
var reset = {
|
|
71
73
|
style: style
|
package/cjs/index.d.ts
CHANGED
|
@@ -31,6 +31,13 @@ export * from './store/ShowTools';
|
|
|
31
31
|
export * from './store/Symbols';
|
|
32
32
|
export * from './store/Types';
|
|
33
33
|
export * from './symbol/';
|
|
34
|
+
export type ShouldExpandNodeInitially<T extends object> = (isExpanded: boolean, props: {
|
|
35
|
+
keyName?: string | number;
|
|
36
|
+
value?: T;
|
|
37
|
+
parentValue?: T;
|
|
38
|
+
keys: (number | string)[];
|
|
39
|
+
level: number;
|
|
40
|
+
}) => boolean;
|
|
34
41
|
export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
35
42
|
/** This property contains your input JSON */
|
|
36
43
|
value?: T;
|
|
@@ -49,11 +56,7 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
49
56
|
/** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. @default false */
|
|
50
57
|
collapsed?: boolean | number;
|
|
51
58
|
/** Determine whether the node should be expanded on the first render, or you can use collapsed to control the level of expansion (by default, the root is expanded). */
|
|
52
|
-
shouldExpandNodeInitially?:
|
|
53
|
-
value?: T;
|
|
54
|
-
keys: (number | string)[];
|
|
55
|
-
level: number;
|
|
56
|
-
}) => boolean;
|
|
59
|
+
shouldExpandNodeInitially?: ShouldExpandNodeInitially<T>;
|
|
57
60
|
/** Whether to highlight updates. @default true */
|
|
58
61
|
highlightUpdates?: boolean;
|
|
59
62
|
/** Shorten long JSON strings, Set to `0` to disable this feature @default 30 */
|
package/cjs/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { PropsWithChildren } from 'react';
|
|
2
|
-
import { JsonViewProps } from './';
|
|
1
|
+
import React, { type PropsWithChildren } from 'react';
|
|
2
|
+
import { type JsonViewProps } from './';
|
|
3
3
|
import { type InitialTypesState, type TagType } from './store/Types';
|
|
4
4
|
export type BlockTagType = keyof JSX.IntrinsicElements;
|
|
5
5
|
export interface InitialState<T extends object> {
|
package/cjs/symbol/index.d.ts
CHANGED
|
@@ -26,12 +26,12 @@ export declare const BracketsOpen: {
|
|
|
26
26
|
} & SymbolsElementResult<K>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
|
|
27
27
|
displayName: string;
|
|
28
28
|
};
|
|
29
|
-
type
|
|
29
|
+
type BracketsProps = {
|
|
30
30
|
isBrackets?: boolean;
|
|
31
31
|
isVisiable?: boolean;
|
|
32
32
|
};
|
|
33
33
|
export declare const BracketsClose: {
|
|
34
|
-
<K extends object>(props:
|
|
34
|
+
<K extends object>(props: BracketsProps & SymbolsElementResult<K>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
|
35
35
|
displayName: string;
|
|
36
36
|
};
|
|
37
37
|
export {};
|
package/cjs/theme/basic.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const basicTheme: CSS.Properties<string | number>;
|
package/cjs/theme/dark.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const darkTheme: CSS.Properties<string | number>;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const githubDarkTheme: CSS.Properties<string | number>;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const githubLightTheme: CSS.Properties<string | number>;
|
package/cjs/theme/gruvbox.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const gruvboxTheme: CSS.Properties<string | number>;
|
package/cjs/theme/light.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const lightTheme: CSS.Properties<string | number>;
|
package/cjs/theme/monokai.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const monokaiTheme: CSS.Properties<string | number>;
|
package/cjs/theme/nord.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const nordTheme: CSS.Properties<string | number>;
|
package/cjs/theme/vscode.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const vscodeTheme: CSS.Properties<string | number>;
|
package/cjs/types/index.d.ts
CHANGED
package/dark.d.ts
CHANGED
package/esm/Container.js
CHANGED
package/esm/comps/KeyValues.js
CHANGED
|
@@ -15,10 +15,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
15
15
|
export var KeyValues = props => {
|
|
16
16
|
var _expands$expandKey;
|
|
17
17
|
var {
|
|
18
|
+
keyName,
|
|
18
19
|
value,
|
|
19
20
|
expandKey = '',
|
|
20
21
|
level,
|
|
21
|
-
keys = []
|
|
22
|
+
keys = [],
|
|
23
|
+
parentValue
|
|
22
24
|
} = props;
|
|
23
25
|
var expands = useExpandsStore();
|
|
24
26
|
var {
|
|
@@ -27,19 +29,22 @@ export var KeyValues = props => {
|
|
|
27
29
|
collapsed,
|
|
28
30
|
shouldExpandNodeInitially
|
|
29
31
|
} = useStore();
|
|
30
|
-
var isMyArray = Array.isArray(value);
|
|
31
32
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
32
33
|
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded;
|
|
33
|
-
|
|
34
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
34
35
|
value,
|
|
35
36
|
keys,
|
|
36
|
-
level
|
|
37
|
-
|
|
37
|
+
level,
|
|
38
|
+
keyName,
|
|
39
|
+
parentValue
|
|
40
|
+
});
|
|
41
|
+
if (expands[expandKey] === undefined && !!shouldExpand) {
|
|
38
42
|
return null;
|
|
39
43
|
}
|
|
40
44
|
if (isExpanded) {
|
|
41
45
|
return null;
|
|
42
46
|
}
|
|
47
|
+
var isMyArray = Array.isArray(value);
|
|
43
48
|
// object
|
|
44
49
|
var entries = isMyArray ? Object.entries(value).map(m => [Number(m[0]), m[1]]) : Object.entries(value);
|
|
45
50
|
if (objectSortKeys) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type SectionElementResult } from '../store/Section';
|
|
2
|
+
interface NestedCloseProps<T extends object> extends SectionElementResult<T> {
|
|
3
3
|
expandKey: string;
|
|
4
4
|
level: number;
|
|
5
|
-
keys?: (string | number)[];
|
|
6
5
|
}
|
|
7
6
|
export declare const NestedClose: {
|
|
8
7
|
<T extends object>(props: NestedCloseProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
package/esm/comps/NestedClose.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import { useStore } from "../store.js";
|
|
2
3
|
import { useExpandsStore } from "../store/Expands.js";
|
|
3
4
|
import { BracketsClose } from "../symbol/index.js";
|
|
@@ -5,41 +6,52 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
6
|
export var NestedClose = props => {
|
|
6
7
|
var _expands$expandKey;
|
|
7
8
|
var {
|
|
9
|
+
keyName,
|
|
8
10
|
value,
|
|
9
11
|
expandKey,
|
|
12
|
+
parentValue,
|
|
10
13
|
level,
|
|
11
14
|
keys = []
|
|
12
15
|
} = props;
|
|
13
16
|
var expands = useExpandsStore();
|
|
14
|
-
var isArray = Array.isArray(value);
|
|
15
17
|
var {
|
|
16
18
|
collapsed,
|
|
17
19
|
shouldExpandNodeInitially
|
|
18
20
|
} = useStore();
|
|
19
|
-
var isMySet = value instanceof Set;
|
|
20
21
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
21
22
|
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded;
|
|
22
|
-
var
|
|
23
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, {
|
|
23
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
24
24
|
value,
|
|
25
25
|
keys,
|
|
26
|
-
level
|
|
26
|
+
level,
|
|
27
|
+
keyName,
|
|
28
|
+
parentValue
|
|
27
29
|
});
|
|
28
|
-
if (expands[expandKey] === undefined &&
|
|
30
|
+
if (expands[expandKey] === undefined && !!shouldExpand) {
|
|
29
31
|
return null;
|
|
30
32
|
}
|
|
33
|
+
var len = Object.keys(value).length;
|
|
31
34
|
if (isExpanded || len === 0) {
|
|
32
35
|
return null;
|
|
33
36
|
}
|
|
34
37
|
var style = {
|
|
35
38
|
paddingLeft: 4
|
|
36
39
|
};
|
|
40
|
+
var compProps = {
|
|
41
|
+
keyName,
|
|
42
|
+
value,
|
|
43
|
+
keys,
|
|
44
|
+
parentValue
|
|
45
|
+
};
|
|
46
|
+
var isArray = Array.isArray(value);
|
|
47
|
+
var isMySet = value instanceof Set;
|
|
37
48
|
return /*#__PURE__*/_jsx("div", {
|
|
38
49
|
style: style,
|
|
39
|
-
children: /*#__PURE__*/_jsx(BracketsClose, {
|
|
40
|
-
isBrackets: isArray || isMySet
|
|
50
|
+
children: /*#__PURE__*/_jsx(BracketsClose, _extends({
|
|
51
|
+
isBrackets: isArray || isMySet
|
|
52
|
+
}, compProps, {
|
|
41
53
|
isVisiable: true
|
|
42
|
-
})
|
|
54
|
+
}))
|
|
43
55
|
});
|
|
44
56
|
};
|
|
45
57
|
NestedClose.displayName = 'JVR.NestedClose';
|
package/esm/comps/NestedOpen.js
CHANGED
|
@@ -27,18 +27,17 @@ export var NestedOpen = props => {
|
|
|
27
27
|
collapsed,
|
|
28
28
|
shouldExpandNodeInitially
|
|
29
29
|
} = useStore();
|
|
30
|
-
var isArray = Array.isArray(value);
|
|
31
|
-
var isMySet = value instanceof Set;
|
|
32
30
|
var defaultExpanded = typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
|
|
33
|
-
var isObject = typeof value === 'object';
|
|
34
31
|
var isExpanded = (_expands$expandKey = expands[expandKey]) != null ? _expands$expandKey : defaultExpanded;
|
|
35
|
-
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(
|
|
32
|
+
var shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(isExpanded, {
|
|
36
33
|
value,
|
|
37
34
|
keys,
|
|
38
|
-
level
|
|
35
|
+
level,
|
|
36
|
+
keyName,
|
|
37
|
+
parentValue
|
|
39
38
|
});
|
|
40
|
-
if (expands[expandKey] === undefined && shouldExpandNodeInitially
|
|
41
|
-
isExpanded =
|
|
39
|
+
if (expands[expandKey] === undefined && shouldExpandNodeInitially) {
|
|
40
|
+
isExpanded = !!shouldExpand;
|
|
42
41
|
}
|
|
43
42
|
var click = () => {
|
|
44
43
|
var opt = {
|
|
@@ -61,6 +60,9 @@ export var NestedOpen = props => {
|
|
|
61
60
|
transition: 'all 0.3s'
|
|
62
61
|
};
|
|
63
62
|
var len = Object.keys(value).length;
|
|
63
|
+
var isObject = typeof value === 'object';
|
|
64
|
+
var isArray = Array.isArray(value);
|
|
65
|
+
var isMySet = value instanceof Set;
|
|
64
66
|
var showArrow = len !== 0 && (isArray || isMySet || isObject);
|
|
65
67
|
var reset = {
|
|
66
68
|
style
|
package/esm/index.d.ts
CHANGED
|
@@ -31,6 +31,13 @@ export * from './store/ShowTools';
|
|
|
31
31
|
export * from './store/Symbols';
|
|
32
32
|
export * from './store/Types';
|
|
33
33
|
export * from './symbol/';
|
|
34
|
+
export type ShouldExpandNodeInitially<T extends object> = (isExpanded: boolean, props: {
|
|
35
|
+
keyName?: string | number;
|
|
36
|
+
value?: T;
|
|
37
|
+
parentValue?: T;
|
|
38
|
+
keys: (number | string)[];
|
|
39
|
+
level: number;
|
|
40
|
+
}) => boolean;
|
|
34
41
|
export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
35
42
|
/** This property contains your input JSON */
|
|
36
43
|
value?: T;
|
|
@@ -49,11 +56,7 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
49
56
|
/** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. @default false */
|
|
50
57
|
collapsed?: boolean | number;
|
|
51
58
|
/** Determine whether the node should be expanded on the first render, or you can use collapsed to control the level of expansion (by default, the root is expanded). */
|
|
52
|
-
shouldExpandNodeInitially?:
|
|
53
|
-
value?: T;
|
|
54
|
-
keys: (number | string)[];
|
|
55
|
-
level: number;
|
|
56
|
-
}) => boolean;
|
|
59
|
+
shouldExpandNodeInitially?: ShouldExpandNodeInitially<T>;
|
|
57
60
|
/** Whether to highlight updates. @default true */
|
|
58
61
|
highlightUpdates?: boolean;
|
|
59
62
|
/** Shorten long JSON strings, Set to `0` to disable this feature @default 30 */
|
package/esm/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { PropsWithChildren } from 'react';
|
|
2
|
-
import { JsonViewProps } from './';
|
|
1
|
+
import React, { type PropsWithChildren } from 'react';
|
|
2
|
+
import { type JsonViewProps } from './';
|
|
3
3
|
import { type InitialTypesState, type TagType } from './store/Types';
|
|
4
4
|
export type BlockTagType = keyof JSX.IntrinsicElements;
|
|
5
5
|
export interface InitialState<T extends object> {
|
package/esm/symbol/index.d.ts
CHANGED
|
@@ -26,12 +26,12 @@ export declare const BracketsOpen: {
|
|
|
26
26
|
} & SymbolsElementResult<K>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
|
|
27
27
|
displayName: string;
|
|
28
28
|
};
|
|
29
|
-
type
|
|
29
|
+
type BracketsProps = {
|
|
30
30
|
isBrackets?: boolean;
|
|
31
31
|
isVisiable?: boolean;
|
|
32
32
|
};
|
|
33
33
|
export declare const BracketsClose: {
|
|
34
|
-
<K extends object>(props:
|
|
34
|
+
<K extends object>(props: BracketsProps & SymbolsElementResult<K>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
|
35
35
|
displayName: string;
|
|
36
36
|
};
|
|
37
37
|
export {};
|
package/esm/theme/basic.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const basicTheme: CSS.Properties<string | number>;
|
package/esm/theme/dark.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const darkTheme: CSS.Properties<string | number>;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const githubDarkTheme: CSS.Properties<string | number>;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const githubLightTheme: CSS.Properties<string | number>;
|
package/esm/theme/gruvbox.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const gruvboxTheme: CSS.Properties<string | number>;
|
package/esm/theme/light.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const lightTheme: CSS.Properties<string | number>;
|
package/esm/theme/monokai.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const monokaiTheme: CSS.Properties<string | number>;
|
package/esm/theme/nord.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const nordTheme: CSS.Properties<string | number>;
|
package/esm/theme/vscode.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
export declare const vscodeTheme: CSS.Properties<string | number>;
|
package/esm/types/index.d.ts
CHANGED
package/githubDark.d.ts
CHANGED
package/githubLight.d.ts
CHANGED
package/gruvbox.d.ts
CHANGED
package/light.d.ts
CHANGED
package/monokai.d.ts
CHANGED
package/nord.d.ts
CHANGED
package/package.json
CHANGED
package/vscode.d.ts
CHANGED