@uiw/react-json-view 0.0.1
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 +337 -0
- package/cjs/arrow/TriangleArrow.d.ts +4 -0
- package/cjs/arrow/TriangleArrow.js +30 -0
- package/cjs/arrow/TriangleSolidArrow.d.ts +4 -0
- package/cjs/arrow/TriangleSolidArrow.js +30 -0
- package/cjs/index.d.ts +26 -0
- package/cjs/index.js +62 -0
- package/cjs/node.d.ts +26 -0
- package/cjs/node.js +272 -0
- package/cjs/store.d.ts +5 -0
- package/cjs/store.js +55 -0
- package/cjs/theme/dark.d.ts +19 -0
- package/cjs/theme/dark.js +26 -0
- package/cjs/theme/light.d.ts +19 -0
- package/cjs/theme/light.js +26 -0
- package/cjs/value.d.ts +61 -0
- package/cjs/value.js +185 -0
- package/esm/arrow/TriangleArrow.d.ts +4 -0
- package/esm/arrow/TriangleArrow.js +25 -0
- package/esm/arrow/TriangleSolidArrow.d.ts +4 -0
- package/esm/arrow/TriangleSolidArrow.js +25 -0
- package/esm/index.d.ts +26 -0
- package/esm/index.js +34 -0
- package/esm/node.d.ts +26 -0
- package/esm/node.js +255 -0
- package/esm/store.d.ts +5 -0
- package/esm/store.js +36 -0
- package/esm/theme/dark.d.ts +19 -0
- package/esm/theme/dark.js +19 -0
- package/esm/theme/light.d.ts +19 -0
- package/esm/theme/light.js +19 -0
- package/esm/value.d.ts +61 -0
- package/esm/value.js +176 -0
- package/package.json +65 -0
- package/src/arrow/TriangleArrow.tsx +17 -0
- package/src/arrow/TriangleSolidArrow.tsx +17 -0
- package/src/index.tsx +43 -0
- package/src/node.tsx +201 -0
- package/src/store.tsx +37 -0
- package/src/theme/dark.ts +21 -0
- package/src/theme/light.ts +21 -0
- package/src/value.tsx +172 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["style"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export function TriangleArrow(props) {
|
|
7
|
+
var {
|
|
8
|
+
style
|
|
9
|
+
} = props,
|
|
10
|
+
reset = _objectWithoutPropertiesLoose(props, _excluded);
|
|
11
|
+
var defaultStyle = _extends({
|
|
12
|
+
cursor: 'pointer',
|
|
13
|
+
height: '1em',
|
|
14
|
+
width: '1em'
|
|
15
|
+
}, style);
|
|
16
|
+
return /*#__PURE__*/_jsx("svg", _extends({
|
|
17
|
+
viewBox: "0 0 24 24",
|
|
18
|
+
fill: "var(--w-rjv-arrow-color, currentColor)",
|
|
19
|
+
style: defaultStyle
|
|
20
|
+
}, reset, {
|
|
21
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
22
|
+
d: "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"
|
|
23
|
+
})
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["style"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export function TriangleSolidArrow(props) {
|
|
7
|
+
var {
|
|
8
|
+
style
|
|
9
|
+
} = props,
|
|
10
|
+
reset = _objectWithoutPropertiesLoose(props, _excluded);
|
|
11
|
+
var defaultStyle = _extends({
|
|
12
|
+
cursor: 'pointer',
|
|
13
|
+
height: '1em',
|
|
14
|
+
width: '1em'
|
|
15
|
+
}, style);
|
|
16
|
+
return /*#__PURE__*/_jsx("svg", _extends({
|
|
17
|
+
viewBox: "0 0 15 15",
|
|
18
|
+
fill: "var(--w-rjv-arrow-color, currentColor)",
|
|
19
|
+
style: defaultStyle
|
|
20
|
+
}, reset, {
|
|
21
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
22
|
+
d: "M0 5l6 6 6-6z"
|
|
23
|
+
})
|
|
24
|
+
}));
|
|
25
|
+
}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MetaProps, SemicolonProps, EllipsisProps } from './node';
|
|
3
|
+
import { ValueViewProps } from './value';
|
|
4
|
+
export * from './node';
|
|
5
|
+
export * from './value';
|
|
6
|
+
export interface JsonViewProps<T> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
7
|
+
/** This property contains your input JSON */
|
|
8
|
+
value?: T;
|
|
9
|
+
/** Set the indent-width for nested objects @default `15`*/
|
|
10
|
+
indentWidth?: number;
|
|
11
|
+
/** When set to `true`, data type labels prefix values @default `true` */
|
|
12
|
+
displayDataTypes?: boolean;
|
|
13
|
+
/** When set to `true`, `objects` and `arrays` are labeled with size @default `true` */
|
|
14
|
+
displayObjectSize?: boolean;
|
|
15
|
+
/** Define the root node name. @default `undefined` */
|
|
16
|
+
keyName?: string | number;
|
|
17
|
+
components?: {
|
|
18
|
+
braces?: MetaProps['render'];
|
|
19
|
+
ellipsis?: EllipsisProps['render'];
|
|
20
|
+
arrow?: JSX.Element;
|
|
21
|
+
objectKey?: SemicolonProps['render'];
|
|
22
|
+
value?: ValueViewProps<T>['renderValue'];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
declare const JsonView: React.ForwardRefExoticComponent<Omit<JsonViewProps<object>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
26
|
+
export default JsonView;
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["value", "style", "className"];
|
|
4
|
+
import React, { useId } from 'react';
|
|
5
|
+
import { forwardRef } from 'react';
|
|
6
|
+
import { RooNode } from './node';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export * from './node';
|
|
9
|
+
export * from './value';
|
|
10
|
+
var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
|
|
11
|
+
var {
|
|
12
|
+
value,
|
|
13
|
+
style,
|
|
14
|
+
className
|
|
15
|
+
} = props,
|
|
16
|
+
reset = _objectWithoutPropertiesLoose(props, _excluded);
|
|
17
|
+
var defaultStyle = _extends({
|
|
18
|
+
lineHeight: 1.4,
|
|
19
|
+
fontFamily: 'monospace',
|
|
20
|
+
color: 'var(--w-rjv-color, #002b36)',
|
|
21
|
+
backgroundColor: 'var(--w-rjv-background-color, #00000000)'
|
|
22
|
+
}, style);
|
|
23
|
+
var cls = "w-json-view-container w-rjv " + (className || '');
|
|
24
|
+
var keyid = useId();
|
|
25
|
+
return /*#__PURE__*/_jsx(RooNode, _extends({
|
|
26
|
+
className: cls,
|
|
27
|
+
value: value
|
|
28
|
+
}, reset, {
|
|
29
|
+
ref: ref,
|
|
30
|
+
keyid: keyid,
|
|
31
|
+
style: defaultStyle
|
|
32
|
+
}));
|
|
33
|
+
});
|
|
34
|
+
export default JsonView;
|
package/esm/node.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { LabelProps } from './value';
|
|
3
|
+
import { JsonViewProps } from './';
|
|
4
|
+
export interface MetaProps extends LabelProps {
|
|
5
|
+
isArray?: boolean;
|
|
6
|
+
start?: boolean;
|
|
7
|
+
render?: (props: Pick<MetaProps, 'start' | 'isArray' | 'className' | 'children'>) => JSX.Element;
|
|
8
|
+
}
|
|
9
|
+
export declare function Meta(props: MetaProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const Line: FC<PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>>;
|
|
11
|
+
export interface EllipsisProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
12
|
+
render?: (props: EllipsisProps) => JSX.Element;
|
|
13
|
+
}
|
|
14
|
+
export declare const Ellipsis: FC<PropsWithChildren<EllipsisProps>>;
|
|
15
|
+
export interface SemicolonProps extends LabelProps {
|
|
16
|
+
show?: boolean;
|
|
17
|
+
value?: object;
|
|
18
|
+
render?: (props: Omit<SemicolonProps, 'show'> & {}) => JSX.Element;
|
|
19
|
+
}
|
|
20
|
+
export declare const Semicolon: FC<PropsWithChildren<SemicolonProps>>;
|
|
21
|
+
export declare const CountInfo: FC<PropsWithChildren<LabelProps>>;
|
|
22
|
+
export interface RooNodeProps<T> extends JsonViewProps<T> {
|
|
23
|
+
keyName?: string | number;
|
|
24
|
+
keyid?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function RooNode<T extends object>(props: RooNodeProps<T>): import("react/jsx-runtime").JSX.Element;
|
package/esm/node.js
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["isArray", "start", "className", "render"],
|
|
4
|
+
_excluded2 = ["style", "render"],
|
|
5
|
+
_excluded3 = ["children", "render", "color", "value", "className", "show"],
|
|
6
|
+
_excluded4 = ["value", "keyName", "displayDataTypes", "components", "displayObjectSize", "indentWidth", "keyid"];
|
|
7
|
+
import { Fragment, useId, cloneElement } from 'react';
|
|
8
|
+
import { ValueView, Colon, Label, typeMap } from './value';
|
|
9
|
+
import { TriangleArrow } from './arrow/TriangleArrow';
|
|
10
|
+
import { useExpandsStatus, store } from './store';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
export function Meta(props) {
|
|
14
|
+
var {
|
|
15
|
+
isArray = false,
|
|
16
|
+
start = false,
|
|
17
|
+
className,
|
|
18
|
+
render
|
|
19
|
+
} = props,
|
|
20
|
+
reset = _objectWithoutPropertiesLoose(props, _excluded);
|
|
21
|
+
var mark = isArray ? '[]' : '{}';
|
|
22
|
+
var cls = "w-rjv-" + (isArray ? 'brackets' : 'curlybraces') + "-" + (start ? 'start' : 'end') + " " + (className || '');
|
|
23
|
+
var color = "var(--w-rjv-" + (isArray ? 'brackets' : 'curlybraces') + "-color, #236a7c)";
|
|
24
|
+
if (render) return render(_extends({
|
|
25
|
+
isArray,
|
|
26
|
+
className: cls,
|
|
27
|
+
style: {
|
|
28
|
+
color
|
|
29
|
+
},
|
|
30
|
+
children: start ? mark.charAt(0) : mark.charAt(1)
|
|
31
|
+
}, reset));
|
|
32
|
+
return /*#__PURE__*/_jsx(Label, _extends({
|
|
33
|
+
color: color,
|
|
34
|
+
className: cls
|
|
35
|
+
}, reset, {
|
|
36
|
+
children: start ? mark.charAt(0) : mark.charAt(1)
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
export var Line = props => /*#__PURE__*/_jsx("div", _extends({}, props));
|
|
40
|
+
export var Ellipsis = _ref => {
|
|
41
|
+
var {
|
|
42
|
+
style,
|
|
43
|
+
render
|
|
44
|
+
} = _ref,
|
|
45
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
46
|
+
var styl = _extends({
|
|
47
|
+
cursor: 'pointer'
|
|
48
|
+
}, style);
|
|
49
|
+
var className = "w-rjv-ellipsis " + (props.className || '');
|
|
50
|
+
if (render) return render(_extends({
|
|
51
|
+
style: styl
|
|
52
|
+
}, props, {
|
|
53
|
+
className
|
|
54
|
+
}));
|
|
55
|
+
return /*#__PURE__*/_jsx("span", _extends({
|
|
56
|
+
className: className,
|
|
57
|
+
style: styl
|
|
58
|
+
}, props, {
|
|
59
|
+
children: "..."
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
export var Semicolon = _ref2 => {
|
|
63
|
+
var {
|
|
64
|
+
children,
|
|
65
|
+
render,
|
|
66
|
+
color,
|
|
67
|
+
value,
|
|
68
|
+
className = 'w-rjv-object-key',
|
|
69
|
+
show
|
|
70
|
+
} = _ref2,
|
|
71
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded3);
|
|
72
|
+
var content = show ? "\"" + children + "\"" : children;
|
|
73
|
+
if (render) return render(_extends({
|
|
74
|
+
className
|
|
75
|
+
}, props, {
|
|
76
|
+
value,
|
|
77
|
+
style: {
|
|
78
|
+
color
|
|
79
|
+
},
|
|
80
|
+
children: content
|
|
81
|
+
}));
|
|
82
|
+
return /*#__PURE__*/_jsx(Label, _extends({
|
|
83
|
+
className: className,
|
|
84
|
+
color: color
|
|
85
|
+
}, props, {
|
|
86
|
+
children: content
|
|
87
|
+
}));
|
|
88
|
+
};
|
|
89
|
+
export var CountInfo = _ref3 => {
|
|
90
|
+
var {
|
|
91
|
+
children
|
|
92
|
+
} = _ref3;
|
|
93
|
+
return /*#__PURE__*/_jsx(Label, {
|
|
94
|
+
style: {
|
|
95
|
+
paddingLeft: 4,
|
|
96
|
+
fontStyle: 'italic'
|
|
97
|
+
},
|
|
98
|
+
color: "var(--w-rjv-info-color, #0000004d)",
|
|
99
|
+
className: "object-size",
|
|
100
|
+
children: children
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
export function RooNode(props) {
|
|
104
|
+
var _expands$keyid;
|
|
105
|
+
var {
|
|
106
|
+
value = {},
|
|
107
|
+
keyName,
|
|
108
|
+
displayDataTypes = true,
|
|
109
|
+
components = {},
|
|
110
|
+
displayObjectSize = true,
|
|
111
|
+
indentWidth = 15,
|
|
112
|
+
keyid = 'root'
|
|
113
|
+
} = props,
|
|
114
|
+
reset = _objectWithoutPropertiesLoose(props, _excluded4);
|
|
115
|
+
var isArray = Array.isArray(value);
|
|
116
|
+
var nameKeys = isArray ? Object.keys(value).map(m => Number(m)) : Object.keys(value);
|
|
117
|
+
var subkeyid = useId();
|
|
118
|
+
var expands = useExpandsStatus();
|
|
119
|
+
var expand = (_expands$keyid = expands[keyid]) != null ? _expands$keyid : true;
|
|
120
|
+
var arrowStyle = {
|
|
121
|
+
transform: "rotate(" + (expand ? '0' : '-90') + "deg)",
|
|
122
|
+
transition: 'all 0.3s'
|
|
123
|
+
};
|
|
124
|
+
var handle = () => {
|
|
125
|
+
!expand ? store.expand(keyid) : store.collapse(keyid);
|
|
126
|
+
};
|
|
127
|
+
var subNodeProps = {
|
|
128
|
+
components,
|
|
129
|
+
indentWidth,
|
|
130
|
+
displayDataTypes,
|
|
131
|
+
displayObjectSize,
|
|
132
|
+
style: {
|
|
133
|
+
paddingLeft: indentWidth
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var valueViewProps = {
|
|
137
|
+
displayDataTypes,
|
|
138
|
+
renderValue: components.value
|
|
139
|
+
};
|
|
140
|
+
var arrowView = components.arrow ? /*#__PURE__*/cloneElement(components.arrow, {
|
|
141
|
+
style: arrowStyle,
|
|
142
|
+
'data-expand': expand
|
|
143
|
+
}) : /*#__PURE__*/_jsx(TriangleArrow, {
|
|
144
|
+
style: arrowStyle
|
|
145
|
+
});
|
|
146
|
+
return /*#__PURE__*/_jsxs("div", _extends({}, reset, {
|
|
147
|
+
children: [/*#__PURE__*/_jsxs(Line, {
|
|
148
|
+
style: {
|
|
149
|
+
display: 'inline-flex',
|
|
150
|
+
alignItems: 'center'
|
|
151
|
+
},
|
|
152
|
+
onClick: handle,
|
|
153
|
+
children: [arrowView, (typeof keyName === 'string' || typeof keyName === 'number') && /*#__PURE__*/_jsxs(Fragment, {
|
|
154
|
+
children: [/*#__PURE__*/_jsx(Semicolon, {
|
|
155
|
+
value: value,
|
|
156
|
+
render: components.objectKey,
|
|
157
|
+
color: typeof keyName === 'number' ? typeMap['number'].color : '',
|
|
158
|
+
show: typeof keyName === 'string',
|
|
159
|
+
children: keyName
|
|
160
|
+
}), /*#__PURE__*/_jsx(Colon, {})]
|
|
161
|
+
}), /*#__PURE__*/_jsx(Meta, {
|
|
162
|
+
start: true,
|
|
163
|
+
isArray: isArray,
|
|
164
|
+
render: components.braces
|
|
165
|
+
}), !expand && /*#__PURE__*/_jsx(Ellipsis, {
|
|
166
|
+
render: components.ellipsis
|
|
167
|
+
}), !expand && /*#__PURE__*/_jsx(Meta, {
|
|
168
|
+
isArray: isArray,
|
|
169
|
+
render: components.braces
|
|
170
|
+
}), displayObjectSize && /*#__PURE__*/_jsxs(CountInfo, {
|
|
171
|
+
children: [nameKeys.length, " items"]
|
|
172
|
+
})]
|
|
173
|
+
}), expand && /*#__PURE__*/_jsx(Line, {
|
|
174
|
+
style: {
|
|
175
|
+
borderLeft: 'var(--w-rjv-border-left, 1px solid #ebebeb)',
|
|
176
|
+
marginLeft: 6
|
|
177
|
+
},
|
|
178
|
+
children: nameKeys.length > 0 && nameKeys.map((key, idx) => {
|
|
179
|
+
var item = value[key];
|
|
180
|
+
if (Array.isArray(item)) {
|
|
181
|
+
var label = isArray ? idx : key;
|
|
182
|
+
return /*#__PURE__*/_jsx(Line, {
|
|
183
|
+
children: /*#__PURE__*/_jsx(RooNode, _extends({
|
|
184
|
+
value: item,
|
|
185
|
+
keyid: keyid + subkeyid + label,
|
|
186
|
+
keyName: label
|
|
187
|
+
}, subNodeProps))
|
|
188
|
+
}, label + idx);
|
|
189
|
+
}
|
|
190
|
+
var renderKey = /*#__PURE__*/_jsx(Semicolon, {
|
|
191
|
+
value: item,
|
|
192
|
+
render: components.objectKey,
|
|
193
|
+
color: typeof key === 'number' ? typeMap['number'].color : '',
|
|
194
|
+
show: typeof key === 'string',
|
|
195
|
+
children: key
|
|
196
|
+
});
|
|
197
|
+
if (typeof item === 'object' && item && !(item instanceof Date)) {
|
|
198
|
+
if (Object.keys(item).length === 0) {
|
|
199
|
+
return /*#__PURE__*/_jsxs(Line, {
|
|
200
|
+
style: {
|
|
201
|
+
paddingLeft: indentWidth
|
|
202
|
+
},
|
|
203
|
+
children: [/*#__PURE__*/_jsx(ValueView, _extends({}, valueViewProps, {
|
|
204
|
+
renderKey: renderKey,
|
|
205
|
+
keyName: key,
|
|
206
|
+
value: item
|
|
207
|
+
})), /*#__PURE__*/_jsx(Meta, {
|
|
208
|
+
render: components.braces,
|
|
209
|
+
start: true,
|
|
210
|
+
isArray: isArray
|
|
211
|
+
}), /*#__PURE__*/_jsx(Meta, {
|
|
212
|
+
render: components.braces,
|
|
213
|
+
isArray: isArray
|
|
214
|
+
}), displayObjectSize && /*#__PURE__*/_jsxs(CountInfo, {
|
|
215
|
+
children: [Object.keys(item).length, " items"]
|
|
216
|
+
})]
|
|
217
|
+
}, key + idx);
|
|
218
|
+
}
|
|
219
|
+
return /*#__PURE__*/_jsx(Line, {
|
|
220
|
+
children: /*#__PURE__*/_jsx(RooNode, _extends({
|
|
221
|
+
keyid: keyid + subkeyid + key,
|
|
222
|
+
value: item,
|
|
223
|
+
keyName: key
|
|
224
|
+
}, subNodeProps))
|
|
225
|
+
}, key + idx);
|
|
226
|
+
}
|
|
227
|
+
if (typeof item === 'function') {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
return /*#__PURE__*/_jsx(Line, {
|
|
231
|
+
style: {
|
|
232
|
+
paddingLeft: indentWidth
|
|
233
|
+
},
|
|
234
|
+
children: /*#__PURE__*/_jsx(ValueView, _extends({}, valueViewProps, {
|
|
235
|
+
renderKey: renderKey,
|
|
236
|
+
keyName: key,
|
|
237
|
+
value: item
|
|
238
|
+
}))
|
|
239
|
+
}, idx);
|
|
240
|
+
})
|
|
241
|
+
}), expand && /*#__PURE__*/_jsx(Line, {
|
|
242
|
+
style: {
|
|
243
|
+
paddingLeft: 2
|
|
244
|
+
},
|
|
245
|
+
children: /*#__PURE__*/_jsx(Meta, {
|
|
246
|
+
render: components.braces,
|
|
247
|
+
isArray: isArray,
|
|
248
|
+
style: {
|
|
249
|
+
paddingLeft: 2,
|
|
250
|
+
display: 'inline-block'
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
})]
|
|
254
|
+
}));
|
|
255
|
+
}
|
package/esm/store.d.ts
ADDED
package/esm/store.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import { useSyncExternalStore } from 'react';
|
|
3
|
+
var expands = {};
|
|
4
|
+
var listeners = [];
|
|
5
|
+
export var store = {
|
|
6
|
+
collapse(id) {
|
|
7
|
+
expands = _extends({}, expands, {
|
|
8
|
+
[id]: false
|
|
9
|
+
});
|
|
10
|
+
emitChange();
|
|
11
|
+
},
|
|
12
|
+
expand(id) {
|
|
13
|
+
expands = _extends({}, expands, {
|
|
14
|
+
[id]: true
|
|
15
|
+
});
|
|
16
|
+
emitChange();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function getSnapshot() {
|
|
20
|
+
return expands;
|
|
21
|
+
}
|
|
22
|
+
function subscribe(listener) {
|
|
23
|
+
listeners = [...listeners, listener];
|
|
24
|
+
return () => {
|
|
25
|
+
listeners = listeners.filter(l => l !== listener);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function emitChange() {
|
|
29
|
+
for (var listener of listeners) {
|
|
30
|
+
listener();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function useExpandsStatus() {
|
|
34
|
+
var expands = useSyncExternalStore(subscribe, getSnapshot);
|
|
35
|
+
return expands;
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const darkTheme: {
|
|
2
|
+
'--w-rjv-font-family': string;
|
|
3
|
+
'--w-rjv-color': string;
|
|
4
|
+
'--w-rjv-background-color': string;
|
|
5
|
+
'--w-rjv-border-left': string;
|
|
6
|
+
'--w-rjv-arrow-color': string;
|
|
7
|
+
'--w-rjv-info-color': string;
|
|
8
|
+
'--w-rjv-curlybraces-color': string;
|
|
9
|
+
'--w-rjv-brackets-color': string;
|
|
10
|
+
'--w-rjv-type-string-color': string;
|
|
11
|
+
'--w-rjv-type-int-color': string;
|
|
12
|
+
'--w-rjv-type-float-color': string;
|
|
13
|
+
'--w-rjv-type-bigint-color': string;
|
|
14
|
+
'--w-rjv-type-boolean-color': string;
|
|
15
|
+
'--w-rjv-type-date-color': string;
|
|
16
|
+
'--w-rjv-type-null-color': string;
|
|
17
|
+
'--w-rjv-type-nan-color': string;
|
|
18
|
+
'--w-rjv-type-undefined-color': string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var darkTheme = {
|
|
2
|
+
'--w-rjv-font-family': 'monospace',
|
|
3
|
+
'--w-rjv-color': '#0184a6',
|
|
4
|
+
'--w-rjv-background-color': '#202020',
|
|
5
|
+
'--w-rjv-border-left': '1px solid #323232',
|
|
6
|
+
'--w-rjv-arrow-color': 'var(--w-rjv-color)',
|
|
7
|
+
'--w-rjv-info-color': '#656565',
|
|
8
|
+
'--w-rjv-curlybraces-color': '#1896b6',
|
|
9
|
+
'--w-rjv-brackets-color': '#1896b6',
|
|
10
|
+
'--w-rjv-type-string-color': '#cb4b16',
|
|
11
|
+
'--w-rjv-type-int-color': '#268bd2',
|
|
12
|
+
'--w-rjv-type-float-color': '#859900',
|
|
13
|
+
'--w-rjv-type-bigint-color': '#268bd2',
|
|
14
|
+
'--w-rjv-type-boolean-color': '#2aa198',
|
|
15
|
+
'--w-rjv-type-date-color': '#586e75',
|
|
16
|
+
'--w-rjv-type-null-color': '#d33682',
|
|
17
|
+
'--w-rjv-type-nan-color': '#859900',
|
|
18
|
+
'--w-rjv-type-undefined-color': '#586e75'
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const lightTheme: {
|
|
2
|
+
'--w-rjv-font-family': string;
|
|
3
|
+
'--w-rjv-color': string;
|
|
4
|
+
'--w-rjv-background-color': string;
|
|
5
|
+
'--w-rjv-border-left': string;
|
|
6
|
+
'--w-rjv-arrow-color': string;
|
|
7
|
+
'--w-rjv-info-color': string;
|
|
8
|
+
'--w-rjv-curlybraces-color': string;
|
|
9
|
+
'--w-rjv-brackets-color': string;
|
|
10
|
+
'--w-rjv-type-string-color': string;
|
|
11
|
+
'--w-rjv-type-int-color': string;
|
|
12
|
+
'--w-rjv-type-float-color': string;
|
|
13
|
+
'--w-rjv-type-bigint-color': string;
|
|
14
|
+
'--w-rjv-type-boolean-color': string;
|
|
15
|
+
'--w-rjv-type-date-color': string;
|
|
16
|
+
'--w-rjv-type-null-color': string;
|
|
17
|
+
'--w-rjv-type-nan-color': string;
|
|
18
|
+
'--w-rjv-type-undefined-color': string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var lightTheme = {
|
|
2
|
+
'--w-rjv-font-family': 'monospace',
|
|
3
|
+
'--w-rjv-color': '#002b36',
|
|
4
|
+
'--w-rjv-background-color': '#ffffff',
|
|
5
|
+
'--w-rjv-border-left': '1px solid #ebebeb',
|
|
6
|
+
'--w-rjv-arrow-color': 'var(--w-rjv-color)',
|
|
7
|
+
'--w-rjv-info-color': '#0000004d',
|
|
8
|
+
'--w-rjv-curlybraces-color': '#236a7c',
|
|
9
|
+
'--w-rjv-brackets-color': '#236a7c',
|
|
10
|
+
'--w-rjv-type-string-color': '#cb4b16',
|
|
11
|
+
'--w-rjv-type-int-color': '#268bd2',
|
|
12
|
+
'--w-rjv-type-float-color': '#859900',
|
|
13
|
+
'--w-rjv-type-bigint-color': '#268bd2',
|
|
14
|
+
'--w-rjv-type-boolean-color': '#2aa198',
|
|
15
|
+
'--w-rjv-type-date-color': '#586e75',
|
|
16
|
+
'--w-rjv-type-null-color': '#d33682',
|
|
17
|
+
'--w-rjv-type-nan-color': '#859900',
|
|
18
|
+
'--w-rjv-type-undefined-color': '#586e75'
|
|
19
|
+
};
|
package/esm/value.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
export declare const typeMap: {
|
|
3
|
+
string: {
|
|
4
|
+
color: string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
number: {
|
|
8
|
+
color: string;
|
|
9
|
+
label: string;
|
|
10
|
+
};
|
|
11
|
+
float: {
|
|
12
|
+
color: string;
|
|
13
|
+
label: string;
|
|
14
|
+
};
|
|
15
|
+
bigint: {
|
|
16
|
+
color: string;
|
|
17
|
+
label: string;
|
|
18
|
+
};
|
|
19
|
+
boolean: {
|
|
20
|
+
color: string;
|
|
21
|
+
label: string;
|
|
22
|
+
};
|
|
23
|
+
date: {
|
|
24
|
+
color: string;
|
|
25
|
+
label: string;
|
|
26
|
+
};
|
|
27
|
+
null: {
|
|
28
|
+
color: string;
|
|
29
|
+
label: string;
|
|
30
|
+
};
|
|
31
|
+
NaN: {
|
|
32
|
+
color: string;
|
|
33
|
+
label: string;
|
|
34
|
+
};
|
|
35
|
+
undefined: {
|
|
36
|
+
color: string;
|
|
37
|
+
label: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const Colon: FC<PropsWithChildren<React.HTMLAttributes<HTMLSpanElement>>>;
|
|
41
|
+
export interface ValueViewProps<T> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
|
|
42
|
+
keyName?: string;
|
|
43
|
+
value: T;
|
|
44
|
+
displayDataTypes: boolean;
|
|
45
|
+
renderKey?: JSX.Element;
|
|
46
|
+
renderValue?: (props: React.HTMLAttributes<HTMLSpanElement> & {
|
|
47
|
+
type: TypeProps['type'];
|
|
48
|
+
}) => JSX.Element;
|
|
49
|
+
}
|
|
50
|
+
export declare function ValueView<T>(props: ValueViewProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export interface LabelProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
52
|
+
color?: string;
|
|
53
|
+
fontSize?: number;
|
|
54
|
+
opacity?: number;
|
|
55
|
+
paddingRight?: number;
|
|
56
|
+
}
|
|
57
|
+
export declare const Label: FC<PropsWithChildren<LabelProps>>;
|
|
58
|
+
export interface TypeProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> {
|
|
59
|
+
type: keyof typeof typeMap;
|
|
60
|
+
}
|
|
61
|
+
export declare const Type: FC<PropsWithChildren<TypeProps>>;
|