@uiw/react-json-view 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -249,7 +249,7 @@ export default function Demo() {
249
249
  displayDataTypes={false}
250
250
  style={{
251
251
  '--w-rjv-background-color': '#ffffff',
252
- '--w-rjv-border-left': '0',
252
+ '--w-rjv-border-left-width': '0',
253
253
  }}
254
254
  components={{
255
255
  braces: () => <span />,
@@ -266,6 +266,45 @@ export default function Demo() {
266
266
  }
267
267
  ```
268
268
 
269
+ **Preview Picture**
270
+
271
+ ```tsx mdx:preview
272
+ import React from 'react';
273
+ import JsonView from '@uiw/react-json-view';
274
+
275
+ const object = {
276
+ avatar: 'https://i.imgur.com/MK3eW3As.jpg',
277
+ string: 'Lorem ipsum dolor sit amet',
278
+ integer: 42,
279
+ }
280
+
281
+ function value({ type, children, ...props }) {
282
+ if (type === 'string' && /\.(jpg)$/.test(children)) {
283
+ return (
284
+ <span {...props}>
285
+ <img src={children} height="36" />
286
+ </span>
287
+ );
288
+ }
289
+ }
290
+
291
+ export default function Demo() {
292
+ return (
293
+ <JsonView
294
+ value={object}
295
+ keyName="root"
296
+ // quotes=""
297
+ displayObjectSize={false}
298
+ displayDataTypes={false}
299
+ style={{
300
+ '--w-rjv-background-color': '#ffffff',
301
+ }}
302
+ components={{ value }}
303
+ />
304
+ )
305
+ }
306
+ ```
307
+
269
308
  ## Modify Icon Style
270
309
 
271
310
  Use built-in default icons.
@@ -329,34 +368,25 @@ const object = {
329
368
  }
330
369
 
331
370
  const Arrow = (props) => {
332
- const { style, 'data-expand': expand, ...reset } = props;
333
- const defaultStyle = {
334
- cursor: 'pointer',
335
- height: '1em',
336
- width: '1em',
337
- };
371
+ const { style, 'data-expand': expand, ...reset } = props;
372
+ const svgProps = {
373
+ style: { cursor: 'pointer', height: '1em', width: '1em' },
374
+ viewBox: '0 0 24 24',
375
+ fill: 'var(--w-rjv-arrow-color, currentColor)',
376
+ ...reset
377
+ }
338
378
  if (!expand) {
339
379
  return (
340
- <svg
341
- viewBox="0 0 24 24"
342
- fill="var(--w-rjv-arrow-color, currentColor)"
343
- style={defaultStyle}
344
- {...reset}
345
- >
380
+ <svg {...svgProps}>
346
381
  <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" />
347
382
  </svg>
348
- )
383
+ );
349
384
  }
350
385
  return (
351
- <svg
352
- viewBox="0 0 24 24"
353
- fill="var(--w-rjv-arrow-color, currentColor)"
354
- style={defaultStyle}
355
- {...reset}
356
- >
386
+ <svg {...svgProps}>
357
387
  <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" />
358
388
  </svg>
359
- )
389
+ );
360
390
  }
361
391
 
362
392
  export default function Demo() {
@@ -396,6 +426,8 @@ export interface JsonViewProps<T> extends React.DetailedHTMLProps<React.HTMLAttr
396
426
  enableClipboard?: boolean;
397
427
  /** Display for quotes in object-key @default " */
398
428
  quotes?: "'" | '"' | '';
429
+ /** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. @default false */
430
+ collapsed?: boolean | number;
399
431
  /** Callback function for when a treeNode is expanded or collapsed */
400
432
  onExpand?: (props: {
401
433
  expand: boolean;
@@ -431,6 +463,7 @@ Here is the size benchmark (using [bundlephobia.com](https://bundlephobia.com))
431
463
  | react-json-tree-viewer | [![](https://img.shields.io/bundlephobia/min/react-json-tree-viewer?color=red&label=)](https://bundlephobia.com/result?p=react-json-tree-viewer) | [![](https://img.shields.io/bundlephobia/minzip/react-json-tree-viewer?color=red&label=)](https://bundlephobia.com/result?p=react-json-tree-viewer) | [![](https://badgen.net/bundlephobia/dependency-count/react-json-tree-viewer?color=red&label=&t=123)](https://bundlephobia.com/result?p=react-json-tree-viewer) | [![GitHub last commit](https://img.shields.io/github/last-commit/nsisodiya/react-json-viewer?style=flat&label=last)](https://github.com/nsisodiya/react-json-viewer/commits) |
432
464
  | react-domify | [![](https://img.shields.io/bundlephobia/min/react-domify?color=red&label=)](https://bundlephobia.com/result?p=react-domify) | [![](https://img.shields.io/bundlephobia/minzip/react-domify?color=red&label=)](https://bundlephobia.com/result?p=react-domify) | [![](https://badgen.net/bundlephobia/dependency-count/react-domify?color=red&label=)](https://bundlephobia.com/result?p=react-domify) | [![GitHub last commit](https://img.shields.io/github/last-commit/JedWatson/react-domify?style=flat&label=last)](https://github.com/JedWatson/react-domify/commits) |
433
465
  | react18-json-view | [![](https://img.shields.io/bundlephobia/min/react18-json-view?color=red&label=)](https://bundlephobia.com/result?p=react18-json-view) | [![](https://img.shields.io/bundlephobia/minzip/react18-json-view?color=red&label=)](https://bundlephobia.com/result?p=react18-json-view) | [![](https://badgen.net/bundlephobia/dependency-count/react18-json-view?color=red&label=)](https://bundlephobia.com/result?p=react18-json-view) | [![GitHub last commit](https://img.shields.io/github/last-commit/YYsuni/react18-json-view?style=flat&label=last)](https://github.com/YYsuni/react18-json-view/commits) |
466
+ | @textea/json-viewer | [![](https://img.shields.io/bundlephobia/min/@textea/json-viewer?color=red&label=)](https://bundlephobia.com/result?p=@textea/json-viewer) | [![](https://img.shields.io/bundlephobia/minzip/@textea/json-viewer?color=red&label=)](https://bundlephobia.com/result?p=@textea/json-viewer) | [![](https://badgen.net/bundlephobia/dependency-count/%40textea%2Fjson-viewer?color=red&label=&t=vvv12213)](https://bundlephobia.com/result?p=@textea/json-viewer) | [![GitHub last commit](https://img.shields.io/github/last-commit/TexteaInc/json-viewer?style=flat&label=last)](https://github.com/TexteaInc/json-viewer/commits) |
434
467
 
435
468
  ## Development
436
469
 
package/cjs/copied.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  export interface CopiedProps<T = object> extends React.SVGProps<SVGSVGElement> {
3
3
  show?: boolean;
4
4
  text?: T;
5
+ onCopied?: (text: string, obj: T) => void;
5
6
  render?: (props: Omit<CopiedProps<T>, 'render'>) => JSX.Element;
6
7
  }
7
8
  export declare function Copied<T>(props: CopiedProps<T>): JSX.Element | null;
package/cjs/index.d.ts CHANGED
@@ -28,6 +28,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
28
28
  keyid: string;
29
29
  keyName?: string | number;
30
30
  }) => void;
31
+ /** Fires event when you copy */
32
+ onCopied?: CopiedProps<T>['onCopied'];
31
33
  /** Redefine interface elements to re-render. */
32
34
  components?: {
33
35
  braces?: MetaProps['render'];
package/cjs/node.js CHANGED
@@ -21,7 +21,7 @@ var _jsxRuntime = require("react/jsx-runtime");
21
21
  var _excluded = ["isArray", "start", "className", "render"],
22
22
  _excluded2 = ["style", "render"],
23
23
  _excluded3 = ["children", "render", "color", "value", "className", "show", "quotes"],
24
- _excluded4 = ["value", "keyName", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "indentWidth", "collapsed", "level", "keyid", "quotes", "onExpand"];
24
+ _excluded4 = ["value", "keyName", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "indentWidth", "collapsed", "level", "keyid", "quotes", "onCopied", "onExpand"];
25
25
  function Meta(props) {
26
26
  var _props$isArray = props.isArray,
27
27
  isArray = _props$isArray === void 0 ? false : _props$isArray,
@@ -105,7 +105,7 @@ var CountInfo = function CountInfo(_ref3) {
105
105
  fontStyle: 'italic'
106
106
  },
107
107
  color: "var(--w-rjv-info-color, #0000004d)",
108
- className: "object-size",
108
+ className: "w-rjv-object-size",
109
109
  children: children
110
110
  });
111
111
  };
@@ -132,6 +132,7 @@ function RooNode(props) {
132
132
  keyid = _props$keyid === void 0 ? 'root' : _props$keyid,
133
133
  _props$quotes = props.quotes,
134
134
  quotes = _props$quotes === void 0 ? '"' : _props$quotes,
135
+ onCopied = props.onCopied,
135
136
  onExpand = props.onExpand,
136
137
  reset = (0, _objectWithoutProperties2["default"])(props, _excluded4);
137
138
  var isArray = Array.isArray(value);
@@ -160,6 +161,7 @@ function RooNode(props) {
160
161
  displayDataTypes: displayDataTypes,
161
162
  displayObjectSize: displayObjectSize,
162
163
  enableClipboard: enableClipboard,
164
+ onCopied: onCopied,
163
165
  onExpand: onExpand,
164
166
  collapsed: collapsed,
165
167
  quotes: quotes,
@@ -173,13 +175,16 @@ function RooNode(props) {
173
175
  displayObjectSize: displayObjectSize,
174
176
  enableClipboard: enableClipboard,
175
177
  indentWidth: indentWidth,
178
+ renderBraces: components.braces,
176
179
  renderValue: components.value
177
180
  };
178
181
  var arrowView = components.arrow ? /*#__PURE__*/(0, _react.cloneElement)(components.arrow, {
179
182
  style: arrowStyle,
180
- 'data-expand': expand
183
+ 'data-expand': expand,
184
+ className: "w-rjv-arrow"
181
185
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_TriangleArrow.TriangleArrow, {
182
- style: arrowStyle
186
+ style: arrowStyle,
187
+ className: "w-rjv-arrow"
183
188
  });
184
189
  var _useState = (0, _react.useState)(false),
185
190
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
@@ -188,6 +193,7 @@ function RooNode(props) {
188
193
  var tools = enableClipboard ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_copied.Copied, {
189
194
  show: showTools,
190
195
  text: value,
196
+ onCopied: onCopied,
191
197
  render: components.copied
192
198
  }) : undefined;
193
199
  var eventProps = {};
@@ -199,7 +205,9 @@ function RooNode(props) {
199
205
  return setShowTools(false);
200
206
  };
201
207
  }
202
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), eventProps), {}, {
208
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
209
+ className: "w-rjv-inner"
210
+ }, eventProps), {}, {
203
211
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_value.Line, {
204
212
  style: {
205
213
  display: 'inline-flex',
@@ -228,8 +236,9 @@ function RooNode(props) {
228
236
  children: [nameKeys.length, " items"]
229
237
  }), tools]
230
238
  }), expand && /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Line, {
239
+ className: "w-rjv-content",
231
240
  style: {
232
- borderLeft: '1px solid var(--w-rjv-line-color, #ebebeb)',
241
+ borderLeft: 'var(--w-rjv-border-left-width, 1px) solid var(--w-rjv-line-color, #ebebeb)',
233
242
  marginLeft: 6
234
243
  },
235
244
  children: nameKeys.length > 0 && nameKeys.map(function (key, idx) {
@@ -246,6 +255,7 @@ function RooNode(props) {
246
255
  if (Array.isArray(item) && !isEmpty) {
247
256
  var label = isArray ? idx : key;
248
257
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Line, {
258
+ className: "w-rjv-wrap",
249
259
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RooNode, (0, _objectSpread2["default"])({
250
260
  value: item,
251
261
  keyid: keyid + subkeyid + label,
@@ -255,6 +265,7 @@ function RooNode(props) {
255
265
  }
256
266
  if ((0, _typeof2["default"])(item) === 'object' && item && !(item instanceof Date) && !isEmpty) {
257
267
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Line, {
268
+ className: "w-rjv-wrap",
258
269
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RooNode, (0, _objectSpread2["default"])({
259
270
  keyid: keyid + subkeyid + key,
260
271
  value: item,
@@ -266,7 +277,6 @@ function RooNode(props) {
266
277
  return;
267
278
  }
268
279
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.ValueView, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, valueViewProps), {}, {
269
- renderBraces: components.braces,
270
280
  renderKey: renderKey,
271
281
  keyName: key,
272
282
  value: item
package/cjs/value.js CHANGED
@@ -142,7 +142,12 @@ function ValueView(props) {
142
142
  show: showTools,
143
143
  text: value
144
144
  }) : undefined;
145
- var eventProps = {};
145
+ var eventProps = {
146
+ className: 'w-rjv-line',
147
+ style: {
148
+ paddingLeft: indentWidth
149
+ }
150
+ };
146
151
  if (enableClipboard) {
147
152
  eventProps.onMouseEnter = function () {
148
153
  return setShowTools(true);
@@ -152,24 +157,22 @@ function ValueView(props) {
152
157
  };
153
158
  }
154
159
  if (content && typeof content === 'string') {
155
- var valueView = renderValue ? renderValue({
160
+ var reView = renderValue && renderValue({
156
161
  className: 'w-rjv-value',
157
162
  style: (0, _objectSpread2["default"])({
158
163
  color: color
159
164
  }, style),
160
165
  type: type,
161
- children: content
162
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, {
166
+ content: content,
167
+ children: value
168
+ });
169
+ var valueView = reView ? reView : /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, {
163
170
  color: color,
164
171
  style: style,
165
172
  className: "w-rjv-value",
166
173
  children: content
167
174
  });
168
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
169
- style: {
170
- paddingLeft: indentWidth
171
- }
172
- }, eventProps), {}, {
175
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, eventProps), {}, {
173
176
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
174
177
  children: [renderKey, /*#__PURE__*/(0, _jsxRuntime.jsx)(Colon, {}), typeView, valueView, tools]
175
178
  }))
@@ -188,11 +191,7 @@ function ValueView(props) {
188
191
  children: [length, " items"]
189
192
  })]
190
193
  });
191
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
192
- style: {
193
- paddingLeft: indentWidth
194
- }
195
- }, eventProps), {}, {
194
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, eventProps), {}, {
196
195
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
197
196
  children: [renderKey, /*#__PURE__*/(0, _jsxRuntime.jsx)(Colon, {}), typeView, empty, tools]
198
197
  }))
package/esm/copied.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  export interface CopiedProps<T = object> extends React.SVGProps<SVGSVGElement> {
3
3
  show?: boolean;
4
4
  text?: T;
5
+ onCopied?: (text: string, obj: T) => void;
5
6
  render?: (props: Omit<CopiedProps<T>, 'render'>) => JSX.Element;
6
7
  }
7
8
  export declare function Copied<T>(props: CopiedProps<T>): JSX.Element | null;
package/esm/index.d.ts CHANGED
@@ -28,6 +28,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
28
28
  keyid: string;
29
29
  keyName?: string | number;
30
30
  }) => void;
31
+ /** Fires event when you copy */
32
+ onCopied?: CopiedProps<T>['onCopied'];
31
33
  /** Redefine interface elements to re-render. */
32
34
  components?: {
33
35
  braces?: MetaProps['render'];
package/esm/node.js CHANGED
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutP
3
3
  var _excluded = ["isArray", "start", "className", "render"],
4
4
  _excluded2 = ["style", "render"],
5
5
  _excluded3 = ["children", "render", "color", "value", "className", "show", "quotes"],
6
- _excluded4 = ["value", "keyName", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "indentWidth", "collapsed", "level", "keyid", "quotes", "onExpand"];
6
+ _excluded4 = ["value", "keyName", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "indentWidth", "collapsed", "level", "keyid", "quotes", "onCopied", "onExpand"];
7
7
  import { Fragment, useId, cloneElement, useState } from 'react';
8
8
  import { ValueView, Colon, Label, Line, typeMap } from './value';
9
9
  import { TriangleArrow } from './arrow/TriangleArrow';
@@ -97,7 +97,7 @@ export var CountInfo = _ref3 => {
97
97
  fontStyle: 'italic'
98
98
  },
99
99
  color: "var(--w-rjv-info-color, #0000004d)",
100
- className: "object-size",
100
+ className: "w-rjv-object-size",
101
101
  children: children
102
102
  });
103
103
  };
@@ -115,6 +115,7 @@ export function RooNode(props) {
115
115
  level = 1,
116
116
  keyid = 'root',
117
117
  quotes = '"',
118
+ onCopied,
118
119
  onExpand
119
120
  } = props,
120
121
  reset = _objectWithoutPropertiesLoose(props, _excluded4);
@@ -142,6 +143,7 @@ export function RooNode(props) {
142
143
  displayDataTypes,
143
144
  displayObjectSize,
144
145
  enableClipboard,
146
+ onCopied,
145
147
  onExpand,
146
148
  collapsed,
147
149
  quotes,
@@ -155,18 +157,22 @@ export function RooNode(props) {
155
157
  displayObjectSize,
156
158
  enableClipboard,
157
159
  indentWidth,
160
+ renderBraces: components.braces,
158
161
  renderValue: components.value
159
162
  };
160
163
  var arrowView = components.arrow ? /*#__PURE__*/cloneElement(components.arrow, {
161
164
  style: arrowStyle,
162
- 'data-expand': expand
165
+ 'data-expand': expand,
166
+ className: "w-rjv-arrow"
163
167
  }) : /*#__PURE__*/_jsx(TriangleArrow, {
164
- style: arrowStyle
168
+ style: arrowStyle,
169
+ className: "w-rjv-arrow"
165
170
  });
166
171
  var [showTools, setShowTools] = useState(false);
167
172
  var tools = enableClipboard ? /*#__PURE__*/_jsx(Copied, {
168
173
  show: showTools,
169
174
  text: value,
175
+ onCopied: onCopied,
170
176
  render: components.copied
171
177
  }) : undefined;
172
178
  var eventProps = {};
@@ -174,7 +180,9 @@ export function RooNode(props) {
174
180
  eventProps.onMouseEnter = () => setShowTools(true);
175
181
  eventProps.onMouseLeave = () => setShowTools(false);
176
182
  }
177
- return /*#__PURE__*/_jsxs("div", _extends({}, reset, eventProps, {
183
+ return /*#__PURE__*/_jsxs("div", _extends({}, reset, {
184
+ className: "w-rjv-inner"
185
+ }, eventProps, {
178
186
  children: [/*#__PURE__*/_jsxs(Line, {
179
187
  style: {
180
188
  display: 'inline-flex',
@@ -203,8 +211,9 @@ export function RooNode(props) {
203
211
  children: [nameKeys.length, " items"]
204
212
  }), tools]
205
213
  }), expand && /*#__PURE__*/_jsx(Line, {
214
+ className: "w-rjv-content",
206
215
  style: {
207
- borderLeft: '1px solid var(--w-rjv-line-color, #ebebeb)',
216
+ borderLeft: 'var(--w-rjv-border-left-width, 1px) solid var(--w-rjv-line-color, #ebebeb)',
208
217
  marginLeft: 6
209
218
  },
210
219
  children: nameKeys.length > 0 && nameKeys.map((key, idx) => {
@@ -221,6 +230,7 @@ export function RooNode(props) {
221
230
  if (Array.isArray(item) && !isEmpty) {
222
231
  var label = isArray ? idx : key;
223
232
  return /*#__PURE__*/_jsx(Line, {
233
+ className: "w-rjv-wrap",
224
234
  children: /*#__PURE__*/_jsx(RooNode, _extends({
225
235
  value: item,
226
236
  keyid: keyid + subkeyid + label,
@@ -230,6 +240,7 @@ export function RooNode(props) {
230
240
  }
231
241
  if (typeof item === 'object' && item && !(item instanceof Date) && !isEmpty) {
232
242
  return /*#__PURE__*/_jsx(Line, {
243
+ className: "w-rjv-wrap",
233
244
  children: /*#__PURE__*/_jsx(RooNode, _extends({
234
245
  keyid: keyid + subkeyid + key,
235
246
  value: item,
@@ -241,7 +252,6 @@ export function RooNode(props) {
241
252
  return;
242
253
  }
243
254
  return /*#__PURE__*/_jsx(ValueView, _extends({}, valueViewProps, {
244
- renderBraces: components.braces,
245
255
  renderKey: renderKey,
246
256
  keyName: key,
247
257
  value: item
package/esm/value.js CHANGED
@@ -124,30 +124,33 @@ export function ValueView(props) {
124
124
  show: showTools,
125
125
  text: value
126
126
  }) : undefined;
127
- var eventProps = {};
127
+ var eventProps = {
128
+ className: 'w-rjv-line',
129
+ style: {
130
+ paddingLeft: indentWidth
131
+ }
132
+ };
128
133
  if (enableClipboard) {
129
134
  eventProps.onMouseEnter = () => setShowTools(true);
130
135
  eventProps.onMouseLeave = () => setShowTools(false);
131
136
  }
132
137
  if (content && typeof content === 'string') {
133
- var valueView = renderValue ? renderValue({
138
+ var reView = renderValue && renderValue({
134
139
  className: 'w-rjv-value',
135
140
  style: _extends({
136
141
  color
137
142
  }, style),
138
143
  type,
139
- children: content
140
- }) : /*#__PURE__*/_jsx(Label, {
144
+ content,
145
+ children: value
146
+ });
147
+ var valueView = reView ? reView : /*#__PURE__*/_jsx(Label, {
141
148
  color: color,
142
149
  style: style,
143
150
  className: "w-rjv-value",
144
151
  children: content
145
152
  });
146
- return /*#__PURE__*/_jsx(Line, _extends({
147
- style: {
148
- paddingLeft: indentWidth
149
- }
150
- }, eventProps, {
153
+ return /*#__PURE__*/_jsx(Line, _extends({}, eventProps, {
151
154
  children: /*#__PURE__*/_jsxs(Label, _extends({}, reset, {
152
155
  children: [renderKey, /*#__PURE__*/_jsx(Colon, {}), typeView, valueView, tools]
153
156
  }))
@@ -166,11 +169,7 @@ export function ValueView(props) {
166
169
  children: [length, " items"]
167
170
  })]
168
171
  });
169
- return /*#__PURE__*/_jsx(Line, _extends({
170
- style: {
171
- paddingLeft: indentWidth
172
- }
173
- }, eventProps, {
172
+ return /*#__PURE__*/_jsx(Line, _extends({}, eventProps, {
174
173
  children: /*#__PURE__*/_jsxs(Label, _extends({}, reset, {
175
174
  children: [renderKey, /*#__PURE__*/_jsx(Colon, {}), typeView, empty, tools]
176
175
  }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-json-view",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "JSON viewer for react.",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",