@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
package/README.md
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
react-json-view
|
|
2
|
+
===
|
|
3
|
+
|
|
4
|
+
[](https://github.com/uiwjs/react-json-view/actions/workflows/ci.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/@uiw/react-json-view)
|
|
6
|
+
|
|
7
|
+
A React component for displaying and editing javascript arrays and JSON objects.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
📚 Use Typescript to write, better code hints.
|
|
12
|
+
🎨 Support theme customization
|
|
13
|
+
🌒 Support dark/light mode
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @uiw/react-json-view
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import JsonView from '@uiw/react-json-view';
|
|
23
|
+
|
|
24
|
+
const avatar = 'https://i.imgur.com/MK3eW3As.jpg';
|
|
25
|
+
const longArray = new Array(1000).fill(1);
|
|
26
|
+
const example = {
|
|
27
|
+
avatar,
|
|
28
|
+
string: 'Lorem ipsum dolor sit amet',
|
|
29
|
+
integer: 42,
|
|
30
|
+
float: 114.514,
|
|
31
|
+
bigint: 10086n,
|
|
32
|
+
null: null,
|
|
33
|
+
undefined,
|
|
34
|
+
timer: 0,
|
|
35
|
+
date: new Date('Tue Sep 13 2022 14:07:44 GMT-0500 (Central Daylight Time)'),
|
|
36
|
+
array: [19, 100.86, 'test', NaN, Infinity],
|
|
37
|
+
nestedArray: [
|
|
38
|
+
[1, 2],
|
|
39
|
+
[3, 4],
|
|
40
|
+
],
|
|
41
|
+
object: {
|
|
42
|
+
'first-child': true,
|
|
43
|
+
'second-child': false,
|
|
44
|
+
'last-child': null,
|
|
45
|
+
},
|
|
46
|
+
longArray,
|
|
47
|
+
string_number: '1234',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
<JsonView value={example} />
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Theme
|
|
54
|
+
|
|
55
|
+
By default, the `lightTheme` light theme is used, and a `darkTheme` dark theme configuration is built in
|
|
56
|
+
|
|
57
|
+
```tsx mdx:preview
|
|
58
|
+
import React from 'react';
|
|
59
|
+
import JsonView from '@uiw/react-json-view';
|
|
60
|
+
import { lightTheme } from '@uiw/react-json-view/light';
|
|
61
|
+
import { darkTheme } from '@uiw/react-json-view/dark';
|
|
62
|
+
|
|
63
|
+
const object = {
|
|
64
|
+
string: 'Lorem ipsum dolor sit amet',
|
|
65
|
+
integer: 42,
|
|
66
|
+
float: 114.514,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default function Demo() {
|
|
70
|
+
return (
|
|
71
|
+
<React.Fragment>
|
|
72
|
+
<JsonView value={object} style={darkTheme} />
|
|
73
|
+
<JsonView value={object} style={lightTheme} />
|
|
74
|
+
</React.Fragment>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Example of custom `vscode` theme styles:
|
|
80
|
+
|
|
81
|
+
```tsx mdx:preview
|
|
82
|
+
import React from 'react';
|
|
83
|
+
import JsonView from '@uiw/react-json-view';
|
|
84
|
+
|
|
85
|
+
const object = {
|
|
86
|
+
string: 'Lorem ipsum dolor sit amet',
|
|
87
|
+
integer: 42,
|
|
88
|
+
float: 114.514,
|
|
89
|
+
object: {
|
|
90
|
+
'first-child': true,
|
|
91
|
+
'second-child': false,
|
|
92
|
+
'last-child': null,
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
const customTheme = {
|
|
96
|
+
'--w-rjv-font-family': 'monospace',
|
|
97
|
+
'--w-rjv-color': '#9cdcfe',
|
|
98
|
+
'--w-rjv-background-color': '#1e1e1e',
|
|
99
|
+
'--w-rjv-border-left': '1px solid #323232',
|
|
100
|
+
'--w-rjv-arrow-color': 'var(--w-rjv-color)',
|
|
101
|
+
'--w-rjv-info-color': '#656565',
|
|
102
|
+
|
|
103
|
+
'--w-rjv-curlybraces-color': '#d4d4d4',
|
|
104
|
+
'--w-rjv-brackets-color': '#d4d4d4',
|
|
105
|
+
|
|
106
|
+
'--w-rjv-type-string-color': '#ce9178',
|
|
107
|
+
'--w-rjv-type-int-color': '#268bd2',
|
|
108
|
+
'--w-rjv-type-float-color': '#859900',
|
|
109
|
+
'--w-rjv-type-bigint-color': '#268bd2',
|
|
110
|
+
'--w-rjv-type-boolean-color': '#559bd4',
|
|
111
|
+
'--w-rjv-type-date-color': '#586e75',
|
|
112
|
+
'--w-rjv-type-null-color': '#d33682',
|
|
113
|
+
'--w-rjv-type-nan-color': '#859900',
|
|
114
|
+
'--w-rjv-type-undefined-color': '#586e75',
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default function Demo() {
|
|
118
|
+
return (
|
|
119
|
+
<JsonView value={object} keyName="root" style={customTheme} />
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Render
|
|
125
|
+
|
|
126
|
+
```tsx mdx:preview
|
|
127
|
+
import React from 'react';
|
|
128
|
+
import JsonView from '@uiw/react-json-view';
|
|
129
|
+
|
|
130
|
+
const object = {
|
|
131
|
+
string: 'Lorem ipsum dolor sit amet',
|
|
132
|
+
integer: 42,
|
|
133
|
+
float: 114.514,
|
|
134
|
+
object: {
|
|
135
|
+
'first-child': true,
|
|
136
|
+
'second-child': false,
|
|
137
|
+
'last-child': null,
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
export default function Demo() {
|
|
141
|
+
return (
|
|
142
|
+
<JsonView
|
|
143
|
+
value={object}
|
|
144
|
+
keyName="root"
|
|
145
|
+
displayObjectSize={false}
|
|
146
|
+
displayDataTypes={false}
|
|
147
|
+
style={{
|
|
148
|
+
'--w-rjv-background-color': '#ffffff',
|
|
149
|
+
'--w-rjv-border-left': '0',
|
|
150
|
+
}}
|
|
151
|
+
components={{
|
|
152
|
+
braces: () => <span />,
|
|
153
|
+
ellipsis: () => <React.Fragment />,
|
|
154
|
+
objectKey: ({ value, ...props}) => {
|
|
155
|
+
if (props.children === '"integer"' && value > 40) {
|
|
156
|
+
return <del {...props} />
|
|
157
|
+
}
|
|
158
|
+
return <span {...props} />
|
|
159
|
+
}
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Modify Icon Style
|
|
167
|
+
|
|
168
|
+
Use built-in default icons.
|
|
169
|
+
|
|
170
|
+
```tsx mdx:preview
|
|
171
|
+
import React from 'react';
|
|
172
|
+
import JsonView from '@uiw/react-json-view';
|
|
173
|
+
import { TriangleArrow } from '@uiw/react-json-view/triangle-arrow';
|
|
174
|
+
import { TriangleSolidArrow } from '@uiw/react-json-view/triangle-solid-arrow';
|
|
175
|
+
|
|
176
|
+
const object = {
|
|
177
|
+
string: 'Lorem ipsum dolor sit amet',
|
|
178
|
+
integer: 42,
|
|
179
|
+
float: 114.514,
|
|
180
|
+
object: {
|
|
181
|
+
'first-child': true,
|
|
182
|
+
'second-child': false,
|
|
183
|
+
'last-child': null,
|
|
184
|
+
},
|
|
185
|
+
nestedArray: [
|
|
186
|
+
[1, 2],
|
|
187
|
+
[3, 4],
|
|
188
|
+
],
|
|
189
|
+
}
|
|
190
|
+
export default function Demo() {
|
|
191
|
+
return (
|
|
192
|
+
<JsonView
|
|
193
|
+
value={object}
|
|
194
|
+
keyName="root"
|
|
195
|
+
style={{
|
|
196
|
+
'--w-rjv-background-color': '#ffffff',
|
|
197
|
+
'--w-rjv-border-left': '1px dashed #ebebeb',
|
|
198
|
+
}}
|
|
199
|
+
components={{
|
|
200
|
+
arrow: <TriangleSolidArrow />
|
|
201
|
+
}}
|
|
202
|
+
/>
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Display of custom **svg** `icon` components
|
|
208
|
+
|
|
209
|
+
```tsx mdx:preview
|
|
210
|
+
import React from 'react';
|
|
211
|
+
import JsonView from '@uiw/react-json-view';
|
|
212
|
+
|
|
213
|
+
const object = {
|
|
214
|
+
string: 'Lorem ipsum dolor sit amet',
|
|
215
|
+
integer: 42,
|
|
216
|
+
float: 114.514,
|
|
217
|
+
object: {
|
|
218
|
+
'first-child': true,
|
|
219
|
+
'second-child': false,
|
|
220
|
+
'last-child': null,
|
|
221
|
+
},
|
|
222
|
+
nestedArray: [
|
|
223
|
+
[1, 2],
|
|
224
|
+
[3, 4],
|
|
225
|
+
],
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const Arrow = (props) => {
|
|
229
|
+
const { style, 'data-expand': expand, ...reset } = props;
|
|
230
|
+
const defaultStyle = {
|
|
231
|
+
cursor: 'pointer',
|
|
232
|
+
height: '1em',
|
|
233
|
+
width: '1em',
|
|
234
|
+
};
|
|
235
|
+
if (!expand) {
|
|
236
|
+
return (
|
|
237
|
+
<svg
|
|
238
|
+
viewBox="0 0 24 24"
|
|
239
|
+
fill="var(--w-rjv-arrow-color, currentColor)"
|
|
240
|
+
style={defaultStyle}
|
|
241
|
+
{...reset}
|
|
242
|
+
>
|
|
243
|
+
<path d="M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M13,7H11V11H7V13H11V17H13V13H17V11H13V7Z" />
|
|
244
|
+
</svg>
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
return (
|
|
248
|
+
<svg
|
|
249
|
+
viewBox="0 0 24 24"
|
|
250
|
+
fill="var(--w-rjv-arrow-color, currentColor)"
|
|
251
|
+
style={defaultStyle}
|
|
252
|
+
{...reset}
|
|
253
|
+
>
|
|
254
|
+
<path d="M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M7,13H17V11H7" />
|
|
255
|
+
</svg>
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export default function Demo() {
|
|
260
|
+
return (
|
|
261
|
+
<JsonView
|
|
262
|
+
value={object}
|
|
263
|
+
keyName="root"
|
|
264
|
+
style={{
|
|
265
|
+
'--w-rjv-background-color': '#ffffff',
|
|
266
|
+
'--w-rjv-border-left': '1px dashed #ebebeb',
|
|
267
|
+
}}
|
|
268
|
+
components={{
|
|
269
|
+
arrow: <Arrow />
|
|
270
|
+
}}
|
|
271
|
+
/>
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Props
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
import React from 'react';
|
|
280
|
+
import { MetaProps, SemicolonProps, EllipsisProps, ValueViewProps } from '@uiw/react-json-view';
|
|
281
|
+
export interface JsonViewProps<T> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
282
|
+
/** This property contains your input JSON */
|
|
283
|
+
value?: T;
|
|
284
|
+
/** Set the indent-width for nested objects @default `15`*/
|
|
285
|
+
indentWidth?: number;
|
|
286
|
+
/** When set to `true`, data type labels prefix values @default `true` */
|
|
287
|
+
displayDataTypes?: boolean;
|
|
288
|
+
/** When set to `true`, `objects` and `arrays` are labeled with size @default `true` */
|
|
289
|
+
displayObjectSize?: boolean;
|
|
290
|
+
/** Define the root node name. @default `undefined` */
|
|
291
|
+
keyName?: string | number;
|
|
292
|
+
components?: {
|
|
293
|
+
braces?: MetaProps['render'];
|
|
294
|
+
ellipsis?: EllipsisProps['render'];
|
|
295
|
+
arrow?: JSX.Element;
|
|
296
|
+
objectKey?: SemicolonProps['render'];
|
|
297
|
+
value?: ValueViewProps<T>['renderValue'];
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
declare const JsonView: React.ForwardRefExoticComponent<Omit<JsonViewProps<object>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
301
|
+
export default JsonView;
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Development
|
|
305
|
+
|
|
306
|
+
Runs the project in development mode.
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
# Step 1, run first, listen to the component compile and output the .js file
|
|
310
|
+
# listen for compilation output type .d.ts file
|
|
311
|
+
npm run watch
|
|
312
|
+
# Step 2, development mode, listen to compile preview website instance
|
|
313
|
+
npm run start
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Builds the app for production to the build folder.
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
npm run build
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
The build is minified and the filenames include the hashes.
|
|
323
|
+
Your app is ready to be deployed!
|
|
324
|
+
|
|
325
|
+
## Contributors
|
|
326
|
+
|
|
327
|
+
As always, thanks to our amazing contributors!
|
|
328
|
+
|
|
329
|
+
<a href="https://github.com/uiwjs/react-json-view/graphs/contributors">
|
|
330
|
+
<img src="https://uiwjs.github.io/react-json-view/CONTRIBUTORS.svg" />
|
|
331
|
+
</a>
|
|
332
|
+
|
|
333
|
+
Made with [action-contributors](https://github.com/jaywcjlove/github-action-contributors).
|
|
334
|
+
|
|
335
|
+
## License
|
|
336
|
+
|
|
337
|
+
Licensed under the MIT License.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.TriangleArrow = TriangleArrow;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
var _excluded = ["style"];
|
|
13
|
+
function TriangleArrow(props) {
|
|
14
|
+
var style = props.style,
|
|
15
|
+
reset = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
16
|
+
var defaultStyle = (0, _objectSpread2["default"])({
|
|
17
|
+
cursor: 'pointer',
|
|
18
|
+
height: '1em',
|
|
19
|
+
width: '1em'
|
|
20
|
+
}, style);
|
|
21
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
22
|
+
viewBox: "0 0 24 24",
|
|
23
|
+
fill: "var(--w-rjv-arrow-color, currentColor)",
|
|
24
|
+
style: defaultStyle
|
|
25
|
+
}, reset), {}, {
|
|
26
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
27
|
+
d: "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"
|
|
28
|
+
})
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.TriangleSolidArrow = TriangleSolidArrow;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
var _excluded = ["style"];
|
|
13
|
+
function TriangleSolidArrow(props) {
|
|
14
|
+
var style = props.style,
|
|
15
|
+
reset = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
16
|
+
var defaultStyle = (0, _objectSpread2["default"])({
|
|
17
|
+
cursor: 'pointer',
|
|
18
|
+
height: '1em',
|
|
19
|
+
width: '1em'
|
|
20
|
+
}, style);
|
|
21
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
22
|
+
viewBox: "0 0 15 15",
|
|
23
|
+
fill: "var(--w-rjv-arrow-color, currentColor)",
|
|
24
|
+
style: defaultStyle
|
|
25
|
+
}, reset), {}, {
|
|
26
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
27
|
+
d: "M0 5l6 6 6-6z"
|
|
28
|
+
})
|
|
29
|
+
}));
|
|
30
|
+
}
|
package/cjs/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/cjs/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
var _exportNames = {};
|
|
9
|
+
exports["default"] = void 0;
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _node = require("./node");
|
|
14
|
+
Object.keys(_node).forEach(function (key) {
|
|
15
|
+
if (key === "default" || key === "__esModule") return;
|
|
16
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
17
|
+
if (key in exports && exports[key] === _node[key]) return;
|
|
18
|
+
Object.defineProperty(exports, key, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _node[key];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
+
var _value = require("./value");
|
|
27
|
+
Object.keys(_value).forEach(function (key) {
|
|
28
|
+
if (key === "default" || key === "__esModule") return;
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
30
|
+
if (key in exports && exports[key] === _value[key]) return;
|
|
31
|
+
Object.defineProperty(exports, key, {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _value[key];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
var _excluded = ["value", "style", "className"];
|
|
39
|
+
var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
40
|
+
var value = props.value,
|
|
41
|
+
style = props.style,
|
|
42
|
+
className = props.className,
|
|
43
|
+
reset = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
44
|
+
var defaultStyle = (0, _objectSpread2["default"])({
|
|
45
|
+
lineHeight: 1.4,
|
|
46
|
+
fontFamily: 'monospace',
|
|
47
|
+
color: 'var(--w-rjv-color, #002b36)',
|
|
48
|
+
backgroundColor: 'var(--w-rjv-background-color, #00000000)'
|
|
49
|
+
}, style);
|
|
50
|
+
var cls = "w-json-view-container w-rjv ".concat(className || '');
|
|
51
|
+
var keyid = (0, _react.useId)();
|
|
52
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_node.RooNode, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
53
|
+
className: cls,
|
|
54
|
+
value: value
|
|
55
|
+
}, reset), {}, {
|
|
56
|
+
ref: ref,
|
|
57
|
+
keyid: keyid,
|
|
58
|
+
style: defaultStyle
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
var _default = JsonView;
|
|
62
|
+
exports["default"] = _default;
|
package/cjs/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;
|