@uiw/react-json-view 2.0.0-alpha.3 → 2.0.0-alpha.31
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 +230 -38
- package/basic.d.ts +3 -0
- package/cjs/Container.d.ts +2 -0
- package/cjs/Container.js +13 -6
- package/cjs/arrow/TriangleArrow.js +1 -1
- package/cjs/comps/Copied.d.ts +2 -4
- package/cjs/comps/Copied.js +50 -17
- package/cjs/comps/KeyValues.d.ts +2 -4
- package/cjs/comps/KeyValues.js +62 -27
- package/cjs/comps/NestedClose.d.ts +1 -0
- package/cjs/comps/NestedClose.js +15 -5
- package/cjs/comps/NestedOpen.d.ts +2 -3
- package/cjs/comps/NestedOpen.js +34 -14
- package/cjs/comps/Value.d.ts +1 -2
- package/cjs/comps/Value.js +4 -8
- package/cjs/comps/useIdCompat.d.ts +1 -0
- package/cjs/comps/useIdCompat.js +14 -0
- package/cjs/editor/KeyName.d.ts +2 -0
- package/cjs/editor/KeyName.js +82 -0
- package/cjs/editor/index.d.ts +18 -0
- package/cjs/editor/index.js +44 -0
- package/cjs/editor/store.d.ts +27 -0
- package/cjs/editor/store.js +23 -0
- package/cjs/index.d.ts +12 -3
- package/cjs/index.js +11 -4
- package/cjs/section/Copied.d.ts +1 -1
- package/cjs/section/Copied.js +1 -2
- package/cjs/section/CountInfo.d.ts +1 -2
- package/cjs/section/CountInfo.js +3 -5
- package/cjs/section/CountInfoExtra.d.ts +1 -2
- package/cjs/section/CountInfoExtra.js +2 -4
- package/cjs/section/Ellipsis.d.ts +0 -1
- package/cjs/section/Ellipsis.js +4 -5
- package/cjs/section/KeyName.d.ts +7 -6
- package/cjs/section/KeyName.js +8 -6
- package/cjs/section/Row.d.ts +13 -0
- package/cjs/section/Row.js +51 -0
- package/cjs/store/Expands.js +2 -4
- package/cjs/store/Section.d.ts +12 -6
- package/cjs/store/Section.js +6 -4
- package/cjs/store/ShowTools.js +2 -4
- package/cjs/store/Symbols.d.ts +10 -3
- package/cjs/store/Symbols.js +2 -4
- package/cjs/store/Types.d.ts +29 -25
- package/cjs/store/Types.js +8 -8
- package/cjs/store.d.ts +9 -4
- package/cjs/store.js +5 -10
- package/cjs/symbol/Arrow.d.ts +1 -1
- package/cjs/symbol/Arrow.js +1 -2
- package/cjs/symbol/BraceLeft.d.ts +1 -1
- package/cjs/symbol/BraceLeft.js +1 -2
- package/cjs/symbol/BraceRight.d.ts +1 -1
- package/cjs/symbol/BraceRight.js +1 -2
- package/cjs/symbol/BracketsLeft.d.ts +1 -1
- package/cjs/symbol/BracketsLeft.js +1 -2
- package/cjs/symbol/BracketsRight.d.ts +1 -1
- package/cjs/symbol/BracketsRight.js +1 -2
- package/cjs/symbol/Colon.d.ts +1 -1
- package/cjs/symbol/Colon.js +1 -2
- package/cjs/symbol/Quote.d.ts +1 -1
- package/cjs/symbol/Quote.js +1 -2
- package/cjs/symbol/ValueQuote.d.ts +1 -1
- package/cjs/symbol/ValueQuote.js +1 -2
- package/cjs/symbol/index.d.ts +11 -16
- package/cjs/symbol/index.js +75 -30
- package/cjs/theme/basic.d.ts +1 -2
- package/cjs/theme/basic.js +4 -3
- package/cjs/theme/dark.d.ts +1 -2
- package/cjs/theme/dark.js +2 -3
- package/cjs/theme/github.dark.d.ts +1 -2
- package/cjs/theme/github.dark.js +2 -3
- package/cjs/theme/github.light.d.ts +1 -2
- package/cjs/theme/github.light.js +2 -3
- package/cjs/theme/gruvbox.d.ts +1 -2
- package/cjs/theme/gruvbox.js +2 -3
- package/cjs/theme/light.d.ts +1 -2
- package/cjs/theme/light.js +2 -3
- package/cjs/theme/monokai.d.ts +1 -2
- package/cjs/theme/monokai.js +2 -3
- package/cjs/theme/nord.d.ts +1 -2
- package/cjs/theme/nord.js +2 -3
- package/cjs/theme/vscode.d.ts +1 -2
- package/cjs/theme/vscode.js +2 -3
- package/cjs/types/Bigint.d.ts +1 -1
- package/cjs/types/Bigint.js +1 -2
- package/cjs/types/Date.d.ts +1 -1
- package/cjs/types/Date.js +1 -2
- package/cjs/types/False.d.ts +1 -1
- package/cjs/types/False.js +1 -2
- package/cjs/types/Float.d.ts +1 -1
- package/cjs/types/Float.js +1 -2
- package/cjs/types/Int.d.ts +1 -1
- package/cjs/types/Int.js +1 -2
- package/cjs/types/Map.d.ts +1 -1
- package/cjs/types/Map.js +1 -2
- package/cjs/types/Nan.d.ts +1 -1
- package/cjs/types/Nan.js +1 -2
- package/cjs/types/Null.d.ts +1 -1
- package/cjs/types/Null.js +1 -2
- package/cjs/types/Set.d.ts +1 -1
- package/cjs/types/Set.js +1 -2
- package/cjs/types/String.d.ts +1 -1
- package/cjs/types/String.js +1 -2
- package/cjs/types/True.d.ts +1 -1
- package/cjs/types/True.js +1 -2
- package/cjs/types/Undefined.d.ts +1 -1
- package/cjs/types/Undefined.js +1 -2
- package/cjs/types/Url.d.ts +1 -1
- package/cjs/types/Url.js +1 -2
- package/cjs/types/index.d.ts +3 -1
- package/cjs/types/index.js +102 -127
- package/cjs/utils/useHighlight.d.ts +0 -1
- package/cjs/utils/useRender.d.ts +1 -1
- package/editor.d.ts +22 -20
- package/esm/Container.d.ts +2 -0
- package/esm/Container.js +15 -7
- package/esm/arrow/TriangleArrow.js +1 -1
- package/esm/comps/Copied.d.ts +2 -4
- package/esm/comps/Copied.js +48 -16
- package/esm/comps/KeyValues.d.ts +2 -4
- package/esm/comps/KeyValues.js +53 -21
- package/esm/comps/NestedClose.d.ts +1 -0
- package/esm/comps/NestedClose.js +13 -3
- package/esm/comps/NestedOpen.d.ts +2 -3
- package/esm/comps/NestedOpen.js +33 -14
- package/esm/comps/Value.d.ts +1 -2
- package/esm/comps/Value.js +2 -4
- package/esm/comps/useIdCompat.d.ts +1 -0
- package/esm/comps/useIdCompat.js +8 -0
- package/esm/editor/KeyName.d.ts +2 -0
- package/esm/editor/KeyName.js +77 -0
- package/esm/editor/index.d.ts +18 -0
- package/esm/editor/index.js +33 -0
- package/esm/editor/store.d.ts +27 -0
- package/esm/editor/store.js +13 -0
- package/esm/index.d.ts +12 -3
- package/esm/index.js +12 -5
- package/esm/section/Copied.d.ts +1 -1
- package/esm/section/CountInfo.d.ts +1 -2
- package/esm/section/CountInfo.js +1 -1
- package/esm/section/CountInfoExtra.d.ts +1 -2
- package/esm/section/Ellipsis.d.ts +0 -1
- package/esm/section/Ellipsis.js +1 -1
- package/esm/section/KeyName.d.ts +7 -6
- package/esm/section/KeyName.js +6 -2
- package/esm/section/Row.d.ts +13 -0
- package/esm/section/Row.js +47 -0
- package/esm/store/Section.d.ts +12 -6
- package/esm/store/Section.js +4 -0
- package/esm/store/Symbols.d.ts +10 -3
- package/esm/store/Types.d.ts +29 -25
- package/esm/store/Types.js +6 -4
- package/esm/store.d.ts +9 -4
- package/esm/symbol/Arrow.d.ts +1 -1
- package/esm/symbol/BraceLeft.d.ts +1 -1
- package/esm/symbol/BraceRight.d.ts +1 -1
- package/esm/symbol/BracketsLeft.d.ts +1 -1
- package/esm/symbol/BracketsRight.d.ts +1 -1
- package/esm/symbol/Colon.d.ts +1 -1
- package/esm/symbol/Quote.d.ts +1 -1
- package/esm/symbol/ValueQuote.d.ts +1 -1
- package/esm/symbol/index.d.ts +11 -16
- package/esm/symbol/index.js +76 -23
- package/esm/theme/basic.d.ts +1 -2
- package/esm/theme/basic.js +2 -0
- package/esm/theme/dark.d.ts +1 -2
- package/esm/theme/github.dark.d.ts +1 -2
- package/esm/theme/github.light.d.ts +1 -2
- package/esm/theme/gruvbox.d.ts +1 -2
- package/esm/theme/light.d.ts +1 -2
- package/esm/theme/monokai.d.ts +1 -2
- package/esm/theme/nord.d.ts +1 -2
- package/esm/theme/vscode.d.ts +1 -2
- package/esm/types/Bigint.d.ts +1 -1
- package/esm/types/Date.d.ts +1 -1
- package/esm/types/False.d.ts +1 -1
- package/esm/types/Float.d.ts +1 -1
- package/esm/types/Int.d.ts +1 -1
- package/esm/types/Map.d.ts +1 -1
- package/esm/types/Nan.d.ts +1 -1
- package/esm/types/Null.d.ts +1 -1
- package/esm/types/Set.d.ts +1 -1
- package/esm/types/String.d.ts +1 -1
- package/esm/types/True.d.ts +1 -1
- package/esm/types/Undefined.d.ts +1 -1
- package/esm/types/Url.d.ts +1 -1
- package/esm/types/index.d.ts +3 -1
- package/esm/types/index.js +87 -103
- package/esm/utils/useHighlight.d.ts +0 -1
- package/esm/utils/useRender.d.ts +1 -1
- package/githubDark.d.ts +3 -0
- package/githubLight.d.ts +3 -0
- package/gruvbox.d.ts +3 -0
- package/monokai.d.ts +3 -0
- package/nord.d.ts +3 -0
- package/package.json +11 -5
- package/vscode.d.ts +3 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["children", "onEdit", "editable"];
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import JsonView from '../';
|
|
6
|
+
import { KeyNameRender } from './KeyName';
|
|
7
|
+
import { Context, Dispatch, useStoreReducer } from './store';
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
var JsonViewEditor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
10
|
+
var {
|
|
11
|
+
children,
|
|
12
|
+
onEdit,
|
|
13
|
+
editable = true
|
|
14
|
+
} = props,
|
|
15
|
+
reset = _objectWithoutPropertiesLoose(props, _excluded);
|
|
16
|
+
var [state, dispatch] = useStoreReducer({
|
|
17
|
+
onEdit
|
|
18
|
+
});
|
|
19
|
+
return /*#__PURE__*/_jsx(Context.Provider, {
|
|
20
|
+
value: state,
|
|
21
|
+
children: /*#__PURE__*/_jsx(Dispatch.Provider, {
|
|
22
|
+
value: dispatch,
|
|
23
|
+
children: /*#__PURE__*/_jsxs(JsonView, _extends({}, reset, {
|
|
24
|
+
shortenTextAfterLength: 0,
|
|
25
|
+
ref: ref,
|
|
26
|
+
children: [editable && /*#__PURE__*/_jsx(JsonView.KeyName, {
|
|
27
|
+
render: KeyNameRender
|
|
28
|
+
}), children]
|
|
29
|
+
}))
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
export default JsonViewEditor;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type InitialState = {
|
|
2
|
+
/**
|
|
3
|
+
* When a callback function is passed in, edit functionality is enabled. The callback is invoked before edits are completed.
|
|
4
|
+
* @returns {boolean} Returning false from onEdit will prevent the change from being made.
|
|
5
|
+
*/
|
|
6
|
+
onEdit?: (option: {
|
|
7
|
+
value: unknown;
|
|
8
|
+
oldValue: unknown;
|
|
9
|
+
keyName?: string | number;
|
|
10
|
+
parentName?: string | number;
|
|
11
|
+
type?: 'value' | 'key';
|
|
12
|
+
}) => boolean;
|
|
13
|
+
};
|
|
14
|
+
type Dispatch = React.Dispatch<InitialState>;
|
|
15
|
+
export declare const Context: import("react").Context<InitialState>;
|
|
16
|
+
export declare const Dispatch: import("react").Context<Dispatch>;
|
|
17
|
+
export declare const useStore: () => InitialState;
|
|
18
|
+
export declare function useStoreReducer(initialState: InitialState): [{
|
|
19
|
+
onEdit?: (option: {
|
|
20
|
+
value: unknown;
|
|
21
|
+
oldValue: unknown;
|
|
22
|
+
keyName?: string | number;
|
|
23
|
+
parentName?: string | number;
|
|
24
|
+
type?: "value" | "key";
|
|
25
|
+
}) => boolean;
|
|
26
|
+
}, import("react").Dispatch<InitialState>];
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import { createContext, useContext, useReducer } from 'react';
|
|
3
|
+
var initialState = {};
|
|
4
|
+
export var Context = /*#__PURE__*/createContext(initialState);
|
|
5
|
+
var reducer = (state, action) => _extends({}, state, action);
|
|
6
|
+
export var Dispatch = /*#__PURE__*/createContext(() => {});
|
|
7
|
+
Dispatch.displayName = 'JVR.Editor.Dispatch';
|
|
8
|
+
export var useStore = () => {
|
|
9
|
+
return useContext(Context);
|
|
10
|
+
};
|
|
11
|
+
export function useStoreReducer(initialState) {
|
|
12
|
+
return useReducer(reducer, initialState);
|
|
13
|
+
}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { BraceLeft } from './symbol/BraceLeft';
|
|
3
2
|
import { BraceRight } from './symbol/BraceRight';
|
|
4
3
|
import { BracketsLeft } from './symbol/BracketsLeft';
|
|
@@ -25,6 +24,7 @@ import { CountInfo } from './section/CountInfo';
|
|
|
25
24
|
import { CountInfoExtra } from './section/CountInfoExtra';
|
|
26
25
|
import { Ellipsis } from './section/Ellipsis';
|
|
27
26
|
import { KeyName } from './section/KeyName';
|
|
27
|
+
import { Row } from './section/Row';
|
|
28
28
|
export * from './store';
|
|
29
29
|
export * from './store/Expands';
|
|
30
30
|
export * from './store/ShowTools';
|
|
@@ -37,7 +37,7 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
37
37
|
/** Define the root node name. @default undefined */
|
|
38
38
|
keyName?: string | number;
|
|
39
39
|
/** Whether sort keys through `String.prototype.localeCompare()` @default false */
|
|
40
|
-
objectSortKeys?: boolean | ((
|
|
40
|
+
objectSortKeys?: boolean | ((keyA: string, keyB: string, valueA: T, valueB: T) => number);
|
|
41
41
|
/** Set the indent-width for nested objects @default 15 */
|
|
42
42
|
indentWidth?: number;
|
|
43
43
|
/** When set to `true`, `objects` and `arrays` are labeled with size @default true */
|
|
@@ -48,10 +48,18 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
|
|
|
48
48
|
enableClipboard?: boolean;
|
|
49
49
|
/** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. @default false */
|
|
50
50
|
collapsed?: boolean | number;
|
|
51
|
+
/** 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?: (isExpanded: boolean, props: {
|
|
53
|
+
value?: T;
|
|
54
|
+
keys: (number | string)[];
|
|
55
|
+
level: number;
|
|
56
|
+
}) => boolean;
|
|
51
57
|
/** Whether to highlight updates. @default true */
|
|
52
58
|
highlightUpdates?: boolean;
|
|
53
|
-
/** Shorten long JSON strings, Set to `0` to disable this feature @default
|
|
59
|
+
/** Shorten long JSON strings, Set to `0` to disable this feature @default 30 */
|
|
54
60
|
shortenTextAfterLength?: number;
|
|
61
|
+
/** When the text exceeds the length, `...` will be displayed. Currently, this `...` can be customized. @default "..." */
|
|
62
|
+
stringEllipsis?: number;
|
|
55
63
|
/** Callback function for when a treeNode is expanded or collapsed */
|
|
56
64
|
onExpand?: (props: {
|
|
57
65
|
expand: boolean;
|
|
@@ -89,6 +97,7 @@ type JsonViewComponent = React.FC<React.PropsWithRef<JsonViewProps<object>>> & {
|
|
|
89
97
|
CountInfo: typeof CountInfo;
|
|
90
98
|
CountInfoExtra: typeof CountInfoExtra;
|
|
91
99
|
KeyName: typeof KeyName;
|
|
100
|
+
Row: typeof Row;
|
|
92
101
|
};
|
|
93
102
|
declare const JsonView: JsonViewComponent;
|
|
94
103
|
export default JsonView;
|
package/esm/index.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 = ["className", "style", "value", "children", "collapsed", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand"];
|
|
3
|
+
var _excluded = ["className", "style", "value", "children", "collapsed", "shouldExpandNodeInitially", "indentWidth", "displayObjectSize", "shortenTextAfterLength", "stringEllipsis", "highlightUpdates", "enableClipboard", "displayDataTypes", "objectSortKeys", "onExpand", "onCopied"];
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { Provider } from './store';
|
|
6
6
|
import { Container } from './Container';
|
|
@@ -30,8 +30,8 @@ import { CountInfo } from './section/CountInfo';
|
|
|
30
30
|
import { CountInfoExtra } from './section/CountInfoExtra';
|
|
31
31
|
import { Ellipsis } from './section/Ellipsis';
|
|
32
32
|
import { KeyName } from './section/KeyName';
|
|
33
|
-
import {
|
|
34
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
|
+
import { Row } from './section/Row';
|
|
34
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
35
|
export * from './store';
|
|
36
36
|
export * from './store/Expands';
|
|
37
37
|
export * from './store/ShowTools';
|
|
@@ -45,14 +45,17 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
45
45
|
value,
|
|
46
46
|
children,
|
|
47
47
|
collapsed,
|
|
48
|
+
shouldExpandNodeInitially,
|
|
48
49
|
indentWidth = 15,
|
|
49
50
|
displayObjectSize = true,
|
|
50
|
-
shortenTextAfterLength =
|
|
51
|
+
shortenTextAfterLength = 30,
|
|
52
|
+
stringEllipsis,
|
|
51
53
|
highlightUpdates = true,
|
|
52
54
|
enableClipboard = true,
|
|
53
55
|
displayDataTypes = true,
|
|
54
56
|
objectSortKeys = false,
|
|
55
|
-
onExpand
|
|
57
|
+
onExpand,
|
|
58
|
+
onCopied
|
|
56
59
|
} = props,
|
|
57
60
|
elmProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
58
61
|
var defaultStyle = _extends({
|
|
@@ -68,11 +71,14 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
68
71
|
value,
|
|
69
72
|
objectSortKeys,
|
|
70
73
|
indentWidth,
|
|
74
|
+
shouldExpandNodeInitially,
|
|
71
75
|
displayObjectSize,
|
|
72
76
|
collapsed,
|
|
73
77
|
enableClipboard,
|
|
74
78
|
shortenTextAfterLength,
|
|
79
|
+
stringEllipsis,
|
|
75
80
|
highlightUpdates,
|
|
81
|
+
onCopied,
|
|
76
82
|
onExpand
|
|
77
83
|
},
|
|
78
84
|
initialTypes: {
|
|
@@ -113,5 +119,6 @@ JsonView.Copied = Copied;
|
|
|
113
119
|
JsonView.CountInfo = CountInfo;
|
|
114
120
|
JsonView.CountInfoExtra = CountInfoExtra;
|
|
115
121
|
JsonView.KeyName = KeyName;
|
|
122
|
+
JsonView.Row = Row;
|
|
116
123
|
JsonView.displayName = 'JVR.JsonView';
|
|
117
124
|
export default JsonView;
|
package/esm/section/Copied.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TagType } from '../store/Types';
|
|
2
2
|
import { type SectionElement } from '../store/Section';
|
|
3
3
|
export declare const Copied: {
|
|
4
|
-
(props: SectionElement<
|
|
4
|
+
<K extends TagType = "svg">(props: SectionElement<K>): null;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { type TagType } from '../store/Types';
|
|
3
2
|
import { type SectionElement, type SectionElementProps } from '../store/Section';
|
|
4
3
|
export declare const CountInfo: {
|
|
@@ -10,6 +9,6 @@ export interface CountInfoCompProps<T extends object> {
|
|
|
10
9
|
keyName: string | number;
|
|
11
10
|
}
|
|
12
11
|
export declare const CountInfoComp: {
|
|
13
|
-
<T extends object>(props: SectionElementProps<
|
|
12
|
+
<K extends TagType, T extends object>(props: SectionElementProps<K> & CountInfoCompProps<T> & React.HTMLAttributes<HTMLElement>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
|
14
13
|
displayName: string;
|
|
15
14
|
};
|
package/esm/section/CountInfo.js
CHANGED
|
@@ -36,7 +36,7 @@ export var CountInfoComp = props => {
|
|
|
36
36
|
reset.style = _extends({}, reset.style, props.style);
|
|
37
37
|
var len = Object.keys(value).length;
|
|
38
38
|
if (!reset.children) {
|
|
39
|
-
reset.children = len + "
|
|
39
|
+
reset.children = len + " item" + (len === 1 ? '' : 's');
|
|
40
40
|
}
|
|
41
41
|
var elmProps = _extends({}, reset, other);
|
|
42
42
|
var isRender = render && typeof render === 'function';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { type TagType } from '../store/Types';
|
|
3
2
|
import { type SectionElement, type SectionElementProps } from '../store/Section';
|
|
4
3
|
export declare const CountInfoExtra: {
|
|
@@ -10,6 +9,6 @@ export interface CountInfoExtraCompsProps<T extends object> {
|
|
|
10
9
|
keyName: string | number;
|
|
11
10
|
}
|
|
12
11
|
export declare const CountInfoExtraComps: {
|
|
13
|
-
<T extends object>(props: SectionElementProps<
|
|
12
|
+
<T extends object, K extends TagType>(props: SectionElementProps<K> & CountInfoExtraCompsProps<T>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
|
14
13
|
displayName: string;
|
|
15
14
|
};
|
package/esm/section/Ellipsis.js
CHANGED
|
@@ -34,7 +34,7 @@ export var EllipsisComp = _ref => {
|
|
|
34
34
|
keyName
|
|
35
35
|
});
|
|
36
36
|
if (child) return child;
|
|
37
|
-
if (!isExpanded) return null;
|
|
37
|
+
if (!isExpanded || typeof value === 'object' && Object.keys(value).length == 0) return null;
|
|
38
38
|
return /*#__PURE__*/_jsx(Elm, _extends({}, reset));
|
|
39
39
|
};
|
|
40
40
|
EllipsisComp.displayName = 'JVR.EllipsisComp';
|
package/esm/section/KeyName.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PropsWithChildren } from 'react';
|
|
2
2
|
import { type TagType } from '../store/Types';
|
|
3
3
|
import { type SectionElement } from '../store/Section';
|
|
4
|
+
import { type SectionElementResult } from '../store/Section';
|
|
4
5
|
export declare const KeyName: {
|
|
5
6
|
<K extends TagType>(props: SectionElement<K>): null;
|
|
6
7
|
displayName: string;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
export interface KeyNameCompProps<T extends object> extends React.HTMLAttributes<HTMLSpanElement>, SectionElementResult<T> {
|
|
10
|
+
}
|
|
11
|
+
export declare const KeyNameComp: {
|
|
12
|
+
<T extends object>(props: PropsWithChildren<KeyNameCompProps<T>>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
displayName: string;
|
|
11
14
|
};
|
|
12
|
-
export declare const KeyNameComp: FC<PropsWithChildren<KeyNameCompProps>>;
|
|
13
|
-
export {};
|
package/esm/section/KeyName.js
CHANGED
|
@@ -16,7 +16,9 @@ export var KeyNameComp = props => {
|
|
|
16
16
|
var {
|
|
17
17
|
children,
|
|
18
18
|
value,
|
|
19
|
-
|
|
19
|
+
parentValue,
|
|
20
|
+
keyName,
|
|
21
|
+
keys
|
|
20
22
|
} = props;
|
|
21
23
|
var isNumber = typeof children === 'number';
|
|
22
24
|
var style = {
|
|
@@ -36,7 +38,9 @@ export var KeyNameComp = props => {
|
|
|
36
38
|
children
|
|
37
39
|
}), {
|
|
38
40
|
value,
|
|
39
|
-
|
|
41
|
+
parentValue,
|
|
42
|
+
keyName,
|
|
43
|
+
keys: keys || (keyName ? [keyName] : [])
|
|
40
44
|
});
|
|
41
45
|
if (child) return child;
|
|
42
46
|
return /*#__PURE__*/_jsx(Elm, _extends({}, reset, {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type TagType } from '../store/Types';
|
|
2
|
+
import { type SectionElement } from '../store/Section';
|
|
3
|
+
import { type SectionElementResult } from '../store/Section';
|
|
4
|
+
export declare const Row: {
|
|
5
|
+
<K extends TagType>(props: SectionElement<K>): null;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
8
|
+
export interface RowCompProps<T extends object> extends React.HTMLAttributes<HTMLDivElement>, SectionElementResult<T> {
|
|
9
|
+
}
|
|
10
|
+
export declare const RowComp: {
|
|
11
|
+
<T extends object>(props: React.PropsWithChildren<RowCompProps<T>>): string | number | true | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["children", "value", "parentValue", "keyName", "keys"],
|
|
4
|
+
_excluded2 = ["as", "render", "children"];
|
|
5
|
+
import { useSectionStore } from '../store/Section';
|
|
6
|
+
import { useSectionRender } from '../utils/useRender';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export var Row = props => {
|
|
9
|
+
var {
|
|
10
|
+
Row: Comp = {}
|
|
11
|
+
} = useSectionStore();
|
|
12
|
+
useSectionRender(Comp, props, 'Row');
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
Row.displayName = 'JVR.Row';
|
|
16
|
+
export var RowComp = props => {
|
|
17
|
+
var {
|
|
18
|
+
children,
|
|
19
|
+
value,
|
|
20
|
+
parentValue,
|
|
21
|
+
keyName,
|
|
22
|
+
keys
|
|
23
|
+
} = props,
|
|
24
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
25
|
+
var {
|
|
26
|
+
Row: Comp = {}
|
|
27
|
+
} = useSectionStore();
|
|
28
|
+
var {
|
|
29
|
+
as,
|
|
30
|
+
render
|
|
31
|
+
} = Comp,
|
|
32
|
+
reset = _objectWithoutPropertiesLoose(Comp, _excluded2);
|
|
33
|
+
var Elm = as || 'div';
|
|
34
|
+
var child = render && typeof render === 'function' && render(_extends({}, other, reset, {
|
|
35
|
+
children
|
|
36
|
+
}), {
|
|
37
|
+
value,
|
|
38
|
+
keyName,
|
|
39
|
+
parentValue,
|
|
40
|
+
keys
|
|
41
|
+
});
|
|
42
|
+
if (child) return child;
|
|
43
|
+
return /*#__PURE__*/_jsx(Elm, _extends({}, other, reset, {
|
|
44
|
+
children: children
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
RowComp.displayName = 'JVR.RowComp';
|
package/esm/store/Section.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import React, { FC, PropsWithChildren, ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
import { type TagType } from './Types';
|
|
3
|
-
export
|
|
3
|
+
export interface SectionElementResult<T extends object, K = string | number> {
|
|
4
|
+
value?: T;
|
|
5
|
+
parentValue?: T;
|
|
6
|
+
keyName?: K;
|
|
7
|
+
/** Index of the parent `keyName` */
|
|
8
|
+
keys?: K[];
|
|
9
|
+
}
|
|
10
|
+
export type SectionElementProps<T extends TagType = 'span'> = {
|
|
4
11
|
as?: T;
|
|
5
|
-
render?: (props: SectionElement<T>, result:
|
|
6
|
-
value: unknown;
|
|
7
|
-
keyName: string | number;
|
|
8
|
-
}) => React.ReactNode;
|
|
12
|
+
render?: (props: SectionElement<T>, result: SectionElementResult<object>) => React.ReactNode;
|
|
9
13
|
};
|
|
10
|
-
export type SectionElement<T extends TagType> = SectionElementProps<T> & ComponentPropsWithoutRef<T>;
|
|
14
|
+
export type SectionElement<T extends TagType = 'span'> = SectionElementProps<T> & ComponentPropsWithoutRef<T>;
|
|
11
15
|
type InitialState<T extends TagType> = {
|
|
12
16
|
Copied?: SectionElement<T>;
|
|
13
17
|
CountInfo?: SectionElement<T>;
|
|
14
18
|
CountInfoExtra?: SectionElement<T>;
|
|
15
19
|
Ellipsis?: SectionElement<T>;
|
|
20
|
+
Row?: SectionElement<T>;
|
|
16
21
|
KeyName?: SectionElement<T>;
|
|
17
22
|
};
|
|
18
23
|
type Dispatch = React.Dispatch<InitialState<TagType>>;
|
|
@@ -22,6 +27,7 @@ export declare function useSection(): [{
|
|
|
22
27
|
CountInfo?: SectionElement<TagType> | undefined;
|
|
23
28
|
CountInfoExtra?: SectionElement<TagType> | undefined;
|
|
24
29
|
Ellipsis?: SectionElement<TagType> | undefined;
|
|
30
|
+
Row?: SectionElement<TagType> | undefined;
|
|
25
31
|
KeyName?: SectionElement<TagType> | undefined;
|
|
26
32
|
}, React.Dispatch<InitialState<TagType>>];
|
|
27
33
|
export declare function useSectionDispatch(): Dispatch;
|
package/esm/store/Section.js
CHANGED
package/esm/store/Symbols.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { FC, PropsWithChildren, ElementType, ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
import { type TagType } from './Types';
|
|
3
|
-
|
|
3
|
+
export interface SymbolsElementResult<T extends object, K = string | number> {
|
|
4
|
+
value?: T;
|
|
5
|
+
parentValue?: T;
|
|
6
|
+
keyName?: K;
|
|
7
|
+
/** Index of the parent `keyName` */
|
|
8
|
+
keys?: K[];
|
|
9
|
+
}
|
|
10
|
+
type SymbolsElementProps<T extends TagType = 'span'> = {
|
|
4
11
|
as?: T;
|
|
5
|
-
render?: (props: SymbolsElement<T>) => React.ReactNode;
|
|
12
|
+
render?: (props: SymbolsElement<T>, result: SymbolsElementResult<object>) => React.ReactNode;
|
|
6
13
|
'data-type'?: string;
|
|
7
14
|
};
|
|
8
|
-
export type SymbolsElement<T extends TagType> = SymbolsElementProps<T> & ComponentPropsWithoutRef<T>;
|
|
15
|
+
export type SymbolsElement<T extends TagType = 'span'> = SymbolsElementProps<T> & ComponentPropsWithoutRef<T>;
|
|
9
16
|
type InitialState<T extends ElementType = 'span'> = {
|
|
10
17
|
Arrow?: SymbolsElement<T>;
|
|
11
18
|
Colon?: SymbolsElement<T>;
|
package/esm/store/Types.d.ts
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropsWithChildren, ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
export type TagType = React.ElementType | keyof JSX.IntrinsicElements;
|
|
3
|
-
type TypesElementProps<T extends TagType> = {
|
|
3
|
+
type TypesElementProps<T extends TagType = 'span'> = {
|
|
4
4
|
as?: T;
|
|
5
5
|
render?: (props: TypesElement<T>, result: {
|
|
6
6
|
type: 'type' | 'value';
|
|
7
7
|
value?: unknown;
|
|
8
|
+
keyName: string | number;
|
|
8
9
|
}) => React.ReactNode;
|
|
9
10
|
'data-type'?: string;
|
|
10
11
|
};
|
|
11
12
|
export type TypesElement<T extends TagType> = TypesElementProps<T> & ComponentPropsWithoutRef<T>;
|
|
12
|
-
export type InitialTypesState = {
|
|
13
|
+
export type InitialTypesState<T extends TagType = 'span'> = {
|
|
13
14
|
displayDataTypes?: boolean;
|
|
14
|
-
Url?: TypesElement<
|
|
15
|
-
Str?: TypesElement<
|
|
16
|
-
Undefined?: TypesElement<
|
|
17
|
-
Null?: TypesElement<
|
|
18
|
-
True?: TypesElement<
|
|
19
|
-
False?: TypesElement<
|
|
20
|
-
Date?: TypesElement<
|
|
21
|
-
Float?: TypesElement<
|
|
22
|
-
Set?: TypesElement<
|
|
23
|
-
Int?: TypesElement<
|
|
24
|
-
Map?: TypesElement<
|
|
25
|
-
Nan?: TypesElement<
|
|
26
|
-
Bigint?: TypesElement<
|
|
15
|
+
Url?: TypesElement<T>;
|
|
16
|
+
Str?: TypesElement<T>;
|
|
17
|
+
Undefined?: TypesElement<T>;
|
|
18
|
+
Null?: TypesElement<T>;
|
|
19
|
+
True?: TypesElement<T>;
|
|
20
|
+
False?: TypesElement<T>;
|
|
21
|
+
Date?: TypesElement<T>;
|
|
22
|
+
Float?: TypesElement<T>;
|
|
23
|
+
Set?: TypesElement<T>;
|
|
24
|
+
Int?: TypesElement<T>;
|
|
25
|
+
Map?: TypesElement<T>;
|
|
26
|
+
Nan?: TypesElement<T>;
|
|
27
|
+
Bigint?: TypesElement<T>;
|
|
27
28
|
};
|
|
28
|
-
type Dispatch = React.Dispatch<InitialTypesState
|
|
29
|
-
export declare const useTypesStore: () => InitialTypesState
|
|
29
|
+
type Dispatch<T extends TagType> = React.Dispatch<InitialTypesState<T>>;
|
|
30
|
+
export declare const useTypesStore: () => InitialTypesState<TagType>;
|
|
30
31
|
export declare function useTypes(): [{
|
|
31
|
-
displayDataTypes?: boolean
|
|
32
|
+
displayDataTypes?: boolean;
|
|
32
33
|
Url?: TypesElement<TagType> | undefined;
|
|
33
34
|
Str?: TypesElement<TagType> | undefined;
|
|
34
35
|
Undefined?: TypesElement<TagType> | undefined;
|
|
@@ -42,11 +43,14 @@ export declare function useTypes(): [{
|
|
|
42
43
|
Map?: TypesElement<TagType> | undefined;
|
|
43
44
|
Nan?: TypesElement<TagType> | undefined;
|
|
44
45
|
Bigint?: TypesElement<TagType> | undefined;
|
|
45
|
-
}, import("react").Dispatch<InitialTypesState
|
|
46
|
-
export declare function useTypesDispatch(): Dispatch
|
|
47
|
-
interface TypesProps {
|
|
48
|
-
initial: InitialTypesState
|
|
49
|
-
dispatch: Dispatch
|
|
46
|
+
}, import("react").Dispatch<InitialTypesState<TagType>>];
|
|
47
|
+
export declare function useTypesDispatch(): Dispatch<TagType>;
|
|
48
|
+
interface TypesProps<T extends TagType> {
|
|
49
|
+
initial: InitialTypesState<T>;
|
|
50
|
+
dispatch: Dispatch<TagType>;
|
|
51
|
+
}
|
|
52
|
+
export declare function Types<T extends TagType>({ initial, dispatch, children }: PropsWithChildren<TypesProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export declare namespace Types {
|
|
54
|
+
var displayName: string;
|
|
50
55
|
}
|
|
51
|
-
export declare const Types: FC<PropsWithChildren<TypesProps>>;
|
|
52
56
|
export {};
|
package/esm/store/Types.js
CHANGED
|
@@ -40,7 +40,8 @@ var initialState = {
|
|
|
40
40
|
},
|
|
41
41
|
Map: {
|
|
42
42
|
style: {
|
|
43
|
-
color: 'var(--w-rjv-type-map-color, #268bd2)'
|
|
43
|
+
color: 'var(--w-rjv-type-map-color, #268bd2)',
|
|
44
|
+
marginRight: 3
|
|
44
45
|
},
|
|
45
46
|
as: 'span',
|
|
46
47
|
'data-type': 'map',
|
|
@@ -76,7 +77,8 @@ var initialState = {
|
|
|
76
77
|
},
|
|
77
78
|
Set: {
|
|
78
79
|
style: {
|
|
79
|
-
color: 'var(--w-rjv-type-set-color, #268bd2)'
|
|
80
|
+
color: 'var(--w-rjv-type-set-color, #268bd2)',
|
|
81
|
+
marginRight: 3
|
|
80
82
|
},
|
|
81
83
|
as: 'span',
|
|
82
84
|
'data-type': 'set',
|
|
@@ -133,7 +135,7 @@ export function useTypes() {
|
|
|
133
135
|
export function useTypesDispatch() {
|
|
134
136
|
return useContext(DispatchTypes);
|
|
135
137
|
}
|
|
136
|
-
export
|
|
138
|
+
export function Types(_ref) {
|
|
137
139
|
var {
|
|
138
140
|
initial,
|
|
139
141
|
dispatch,
|
|
@@ -146,5 +148,5 @@ export var Types = _ref => {
|
|
|
146
148
|
children: children
|
|
147
149
|
})
|
|
148
150
|
});
|
|
149
|
-
}
|
|
151
|
+
}
|
|
150
152
|
Types.displayName = 'JVR.Types';
|
package/esm/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { JsonViewProps } from './';
|
|
3
|
-
import { type InitialTypesState } from './store/Types';
|
|
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> {
|
|
6
6
|
value?: object;
|
|
@@ -9,9 +9,11 @@ export interface InitialState<T extends object> {
|
|
|
9
9
|
objectSortKeys?: JsonViewProps<T>['objectSortKeys'];
|
|
10
10
|
displayObjectSize?: JsonViewProps<T>['displayObjectSize'];
|
|
11
11
|
shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
|
|
12
|
+
stringEllipsis?: JsonViewProps<T>['stringEllipsis'];
|
|
12
13
|
enableClipboard?: JsonViewProps<T>['enableClipboard'];
|
|
13
14
|
highlightUpdates?: JsonViewProps<T>['highlightUpdates'];
|
|
14
15
|
collapsed?: JsonViewProps<T>['collapsed'];
|
|
16
|
+
shouldExpandNodeInitially?: JsonViewProps<T>['shouldExpandNodeInitially'];
|
|
15
17
|
indentWidth?: number;
|
|
16
18
|
}
|
|
17
19
|
export declare const initialState: InitialState<object>;
|
|
@@ -20,10 +22,13 @@ export declare const Context: React.Context<InitialState<object>>;
|
|
|
20
22
|
export declare function reducer(state: InitialState<object>, action: InitialState<object>): InitialState<object>;
|
|
21
23
|
export declare const useStore: () => InitialState<object>;
|
|
22
24
|
export declare const useDispatchStore: () => Dispatch;
|
|
23
|
-
export interface ProviderProps {
|
|
25
|
+
export interface ProviderProps<T extends TagType> {
|
|
24
26
|
initialState?: InitialState<object>;
|
|
25
|
-
initialTypes?: InitialTypesState
|
|
27
|
+
initialTypes?: InitialTypesState<T>;
|
|
26
28
|
}
|
|
27
|
-
export declare const Provider:
|
|
29
|
+
export declare const Provider: {
|
|
30
|
+
<T extends TagType>({ children, initialState: init, initialTypes, }: PropsWithChildren<ProviderProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
displayName: string;
|
|
32
|
+
};
|
|
28
33
|
export declare function useDispatch(): Dispatch;
|
|
29
34
|
export {};
|
package/esm/symbol/Arrow.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SymbolsElement } from '../store/Symbols';
|
|
2
2
|
import { type TagType } from '../store/Types';
|
|
3
3
|
export declare const Arrow: {
|
|
4
|
-
(props: SymbolsElement<
|
|
4
|
+
<K extends TagType = "span">(props: SymbolsElement<K>): null;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SymbolsElement } from '../store/Symbols';
|
|
2
2
|
import { type TagType } from '../store/Types';
|
|
3
3
|
export declare const BraceLeft: {
|
|
4
|
-
(props: SymbolsElement<
|
|
4
|
+
<K extends TagType = "span">(props: SymbolsElement<K>): null;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SymbolsElement } from '../store/Symbols';
|
|
2
2
|
import { type TagType } from '../store/Types';
|
|
3
3
|
export declare const BraceRight: {
|
|
4
|
-
(props: SymbolsElement<
|
|
4
|
+
<K extends TagType = "span">(props: SymbolsElement<K>): null;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SymbolsElement } from '../store/Symbols';
|
|
2
2
|
import { type TagType } from '../store/Types';
|
|
3
3
|
export declare const BracketsLeft: {
|
|
4
|
-
(props: SymbolsElement<
|
|
4
|
+
<K extends TagType = "span">(props: SymbolsElement<K>): null;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SymbolsElement } from '../store/Symbols';
|
|
2
2
|
import { type TagType } from '../store/Types';
|
|
3
3
|
export declare const BracketsRight: {
|
|
4
|
-
(props: SymbolsElement<
|
|
4
|
+
<K extends TagType = "span">(props: SymbolsElement<K>): null;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
package/esm/symbol/Colon.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SymbolsElement } from '../store/Symbols';
|
|
2
2
|
import { type TagType } from '../store/Types';
|
|
3
3
|
export declare const Colon: {
|
|
4
|
-
(props: SymbolsElement<
|
|
4
|
+
<K extends TagType = "span">(props: SymbolsElement<K>): null;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
package/esm/symbol/Quote.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SymbolsElement } from '../store/Symbols';
|
|
2
2
|
import { type TagType } from '../store/Types';
|
|
3
3
|
export declare const Quote: {
|
|
4
|
-
(props: SymbolsElement<
|
|
4
|
+
<K extends TagType = "span">(props: SymbolsElement<K>): null;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|