@uiw/react-json-view 1.8.4 → 1.9.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.
Files changed (46) hide show
  1. package/README.md +11 -6
  2. package/cjs/arrow/TriangleArrow.d.ts +3 -0
  3. package/cjs/arrow/TriangleArrow.js +2 -1
  4. package/cjs/arrow/TriangleSolidArrow.d.ts +3 -0
  5. package/cjs/arrow/TriangleSolidArrow.js +2 -1
  6. package/cjs/comps/ellipsis.js +2 -1
  7. package/cjs/comps/meta.d.ts +3 -0
  8. package/cjs/comps/meta.js +2 -1
  9. package/cjs/copied.d.ts +3 -0
  10. package/cjs/copied.js +2 -1
  11. package/cjs/editor/countInfoExtra.d.ts +3 -0
  12. package/cjs/editor/countInfoExtra.js +11 -15
  13. package/cjs/editor/index.d.ts +1 -1
  14. package/cjs/editor/index.js +1 -0
  15. package/cjs/editor/objectKey.js +10 -11
  16. package/cjs/editor/value.d.ts +3 -0
  17. package/cjs/editor/value.js +12 -17
  18. package/cjs/index.d.ts +3 -0
  19. package/cjs/index.js +13 -0
  20. package/cjs/node.js +7 -2
  21. package/cjs/semicolon.js +2 -1
  22. package/cjs/value.d.ts +4 -0
  23. package/cjs/value.js +85 -28
  24. package/esm/arrow/TriangleArrow.d.ts +3 -0
  25. package/esm/arrow/TriangleArrow.js +2 -1
  26. package/esm/arrow/TriangleSolidArrow.d.ts +3 -0
  27. package/esm/arrow/TriangleSolidArrow.js +2 -1
  28. package/esm/comps/ellipsis.js +2 -1
  29. package/esm/comps/meta.d.ts +3 -0
  30. package/esm/comps/meta.js +2 -1
  31. package/esm/copied.d.ts +3 -0
  32. package/esm/copied.js +2 -1
  33. package/esm/editor/countInfoExtra.d.ts +3 -0
  34. package/esm/editor/countInfoExtra.js +11 -15
  35. package/esm/editor/index.d.ts +1 -1
  36. package/esm/editor/index.js +1 -0
  37. package/esm/editor/objectKey.js +10 -11
  38. package/esm/editor/value.d.ts +3 -0
  39. package/esm/editor/value.js +12 -17
  40. package/esm/index.d.ts +3 -0
  41. package/esm/index.js +2 -0
  42. package/esm/node.js +6 -2
  43. package/esm/semicolon.js +2 -1
  44. package/esm/value.d.ts +4 -0
  45. package/esm/value.js +78 -20
  46. package/package.json +1 -1
package/README.md CHANGED
@@ -452,8 +452,9 @@ export default function Demo() {
452
452
  ## Editor JSON
453
453
 
454
454
  ```tsx mdx:preview
455
- import React from 'react';
455
+ import React, { useRef } from 'react';
456
456
  import JsonViewEditor from '@uiw/react-json-view/editor';
457
+ import { type SemicolonProps, useHighlight } from '@uiw/react-json-view';
457
458
 
458
459
  const object = {
459
460
  string: 'Lorem ipsum dolor sit amet',
@@ -472,12 +473,14 @@ const object = {
472
473
  nestedArray: [ [1, 2], [3, 4], { a: 1} ],
473
474
  }
474
475
 
475
- const ObjectKey = ({ value, keyName, parentName, parentValue, ...reset }) => {
476
+ const ObjectKey: SemicolonProps['render'] = ({ value, keyName, parentName, ...props }) => {
477
+ const $edit = useRef<HTMLSpanElement & HTMLModElement>(null);
478
+ useHighlight({ value, highlightUpdates: true, highlightContainer: $edit });
476
479
  if (keyName === 'integer' && typeof value === 'number' && value > 40) {
477
- return <del {...reset} />
480
+ return <del {...props} ref={$edit} />;
478
481
  }
479
- return <span {...reset} />
480
- };
482
+ return <span {...props} ref={$edit} />;
483
+ }
481
484
 
482
485
  export default function Demo() {
483
486
  return (
@@ -663,6 +666,8 @@ export interface JsonViewProps<T> extends React.DetailedHTMLProps<React.HTMLAttr
663
666
  displayDataTypes?: boolean;
664
667
  /** When set to `true`, `objects` and `arrays` are labeled with size @default true */
665
668
  displayObjectSize?: boolean;
669
+ /** Shorten long JSON strings, Set to `0` to disable this feature @default 20 */
670
+ shortenTextAfterLength?: number;
666
671
  /** Define the root node name. @default undefined */
667
672
  keyName?: string | number;
668
673
  /** The user can copy objects and arrays to clipboard by clicking on the clipboard icon. @default true */
@@ -721,7 +726,7 @@ export interface CountInfoProps {
721
726
  ```ts
722
727
  import { JsonViewProps } from '@uiw/react-json-view';
723
728
  import type { CountInfoExtraProps } from '@uiw/react-json-view/cjs/editor/countInfoExtra';
724
- export interface JsonViewEditorProps<T extends object> extends JsonViewProps<T> {
729
+ export interface JsonViewEditorProps<T extends object> extends Omit<JsonViewProps<T>, 'shortenTextAfterLength'> {
725
730
  /**
726
731
  * When a callback function is passed in, edit functionality is enabled. The callback is invoked before edits are completed.
727
732
  * @returns {boolean} Returning false from onEdit will prevent the change from being made.
@@ -2,3 +2,6 @@ import React from 'react';
2
2
  export interface TriangleArrowProps extends React.SVGProps<SVGSVGElement> {
3
3
  }
4
4
  export declare function TriangleArrow(props: TriangleArrowProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare namespace TriangleArrow {
6
+ var displayName: string;
7
+ }
@@ -27,4 +27,5 @@ function TriangleArrow(props) {
27
27
  d: "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"
28
28
  })
29
29
  }));
30
- }
30
+ }
31
+ TriangleArrow.displayName = 'JVR.TriangleArrow';
@@ -2,3 +2,6 @@ import React from 'react';
2
2
  export interface TriangleSolidArrowProps extends React.SVGProps<SVGSVGElement> {
3
3
  }
4
4
  export declare function TriangleSolidArrow(props: TriangleSolidArrowProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare namespace TriangleSolidArrow {
6
+ var displayName: string;
7
+ }
@@ -27,4 +27,5 @@ function TriangleSolidArrow(props) {
27
27
  d: "M0 5l6 6 6-6z"
28
28
  })
29
29
  }));
30
- }
30
+ }
31
+ TriangleSolidArrow.displayName = 'JVR.TriangleSolidArrow';
@@ -33,4 +33,5 @@ var Ellipsis = function Ellipsis(_ref) {
33
33
  children: "..."
34
34
  }));
35
35
  };
36
- exports.Ellipsis = Ellipsis;
36
+ exports.Ellipsis = Ellipsis;
37
+ Ellipsis.displayName = 'JVR.Ellipsis';
@@ -7,3 +7,6 @@ export interface MetaProps extends LabelProps {
7
7
  render?: (props: Pick<MetaProps, 'start' | 'level' | 'isArray' | 'className' | 'children'>) => JSX.Element;
8
8
  }
9
9
  export declare function Meta(props: MetaProps): JSX.Element;
10
+ export declare namespace Meta {
11
+ var displayName: string;
12
+ }
package/cjs/comps/meta.js CHANGED
@@ -42,4 +42,5 @@ function Meta(props) {
42
42
  }, reset), {}, {
43
43
  children: start ? mark.charAt(0) : mark.charAt(1)
44
44
  }));
45
- }
45
+ }
46
+ Meta.displayName = 'JVR.Meta';
package/cjs/copied.d.ts CHANGED
@@ -6,3 +6,6 @@ export interface CopiedProps<T = object> extends React.SVGProps<SVGSVGElement> {
6
6
  render?: (props: Omit<CopiedProps<T>, 'render'>) => JSX.Element;
7
7
  }
8
8
  export declare function Copied<T>(props: CopiedProps<T>): JSX.Element | null;
9
+ export declare namespace Copied {
10
+ var displayName: string;
11
+ }
package/cjs/copied.js CHANGED
@@ -74,4 +74,5 @@ function Copied(props) {
74
74
  d: "M27.5,33 L2.5,33 L2.5,12.5 L27.5,12.5 L27.5,20 L30,20 L30,7.5 C30,6.1 28.9,5 27.5,5 L20,5 C20,2.2 17.8,0 15,0 C12.2,0 10,2.2 10,5 L2.5,5 C1.1,5 0,6.1 0,7.5 L0,33 C0,34.4 1.1,36 2.5,36 L27.5,36 C28.9,36 30,34.4 30,33 L30,29 L27.5,29 L27.5,33 Z M7.5,7.5 L10,7.5 C10,7.5 12.5,6.4 12.5,5 C12.5,3.6 13.6,2.5 15,2.5 C16.4,2.5 17.5,3.6 17.5,5 C17.5,6.4 18.8,7.5 20,7.5 L22.5,7.5 C22.5,7.5 25,8.6 25,10 L5,10 C5,8.5 6.1,7.5 7.5,7.5 Z M5,27.5 L10,27.5 L10,25 L5,25 L5,27.5 Z M22.5,21.5 L22.5,16.5 L12.5,24 L22.5,31.5 L22.5,26.5 L32,26.5 L32,21.5 L22.5,21.5 Z M17.5,15 L5,15 L5,17.5 L17.5,17.5 L17.5,15 Z M10,20 L5,20 L5,22.5 L10,22.5 L10,20 Z"
75
75
  })
76
76
  }));
77
- }
77
+ }
78
+ Copied.displayName = 'JVR.Copied';
@@ -23,3 +23,6 @@ export interface CountInfoExtraProps<T> extends Partial<CountInfoProps> {
23
23
  }) => boolean;
24
24
  }
25
25
  export declare function CountInfoExtra<T extends object>(props: CountInfoExtraProps<T>): import("react/jsx-runtime").JSX.Element | null;
26
+ export declare namespace CountInfoExtra {
27
+ var displayName: string;
28
+ }
@@ -15,6 +15,7 @@ var _add = require("./icon/add");
15
15
  var _delete = require("./icon/delete");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
  function CountInfoExtra(props) {
18
+ var _ref, _ref2;
18
19
  var visible = props.visible,
19
20
  showTools = props.showTools,
20
21
  editable = props.editable,
@@ -27,8 +28,8 @@ function CountInfoExtra(props) {
27
28
  onAdd = props.onAdd,
28
29
  onDelete = props.onDelete;
29
30
  if (!visible || !showTools) return null;
30
- var click = /*#__PURE__*/function () {
31
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee(event) {
31
+ var click = function click(_x) {
32
+ return (_ref = _ref || (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee(event) {
32
33
  var keyOrValue, isArray, isAdd, result, maybeAdd;
33
34
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
34
35
  while (1) switch (_context.prev = _context.next) {
@@ -54,13 +55,10 @@ function CountInfoExtra(props) {
54
55
  return _context.stop();
55
56
  }
56
57
  }, _callee);
57
- }));
58
- return function click(_x) {
59
- return _ref.apply(this, arguments);
60
- };
61
- }();
62
- var deleteHandle = /*#__PURE__*/function () {
63
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2(event) {
58
+ }))).apply(this, arguments);
59
+ };
60
+ var deleteHandle = function deleteHandle(_x2) {
61
+ return (_ref2 = _ref2 || (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2(event) {
64
62
  var maybeDelete;
65
63
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
66
64
  while (1) switch (_context2.prev = _context2.next) {
@@ -90,11 +88,8 @@ function CountInfoExtra(props) {
90
88
  return _context2.stop();
91
89
  }
92
90
  }, _callee2);
93
- }));
94
- return function deleteHandle(_x2) {
95
- return _ref2.apply(this, arguments);
96
- };
97
- }();
91
+ }))).apply(this, arguments);
92
+ };
98
93
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
99
94
  children: [editable && onAdd && /*#__PURE__*/(0, _jsxRuntime.jsx)(_add.AddIcon, {
100
95
  onClick: click
@@ -102,4 +97,5 @@ function CountInfoExtra(props) {
102
97
  onClick: deleteHandle
103
98
  })]
104
99
  });
105
- }
100
+ }
101
+ CountInfoExtra.displayName = 'JVR.CountInfoExtra';
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { JsonViewProps } from '../';
3
3
  import type { CountInfoExtraProps } from './countInfoExtra';
4
- export interface JsonViewEditorProps<T extends object> extends JsonViewProps<T> {
4
+ export interface JsonViewEditorProps<T extends object> extends Omit<JsonViewProps<T>, 'shortenTextAfterLength'> {
5
5
  /**
6
6
  * When a callback function is passed in, edit functionality is enabled. The callback is invoked before edits are completed.
7
7
  * @returns {boolean} Returning false from onEdit will prevent the change from being made.
@@ -54,6 +54,7 @@ var JsonViewEditor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
54
54
  ref: ref
55
55
  }));
56
56
  });
57
+ JsonViewEditor.displayName = 'JVR.JsonViewEditor';
57
58
  var _default = JsonViewEditor;
58
59
  exports["default"] = _default;
59
60
  module.exports = exports.default;
@@ -16,6 +16,7 @@ var _value = require("../value");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
  var _excluded = ["className", "value", "keyName", "parentName", "quotes", "label", "namespace", "editableValue", "onEdit", "highlightUpdates", "render"];
18
18
  var ObjectKey = function ObjectKey(props) {
19
+ var _ref;
19
20
  var className = props.className,
20
21
  value = props.value,
21
22
  keyName = props.keyName,
@@ -55,11 +56,11 @@ var ObjectKey = function ObjectKey(props) {
55
56
  if ($edit.current) {
56
57
  var _$edit$current;
57
58
  $edit.current.contentEditable = 'true';
58
- (_$edit$current = $edit.current) === null || _$edit$current === void 0 ? void 0 : _$edit$current.focus();
59
+ (_$edit$current = $edit.current) === null || _$edit$current === void 0 || _$edit$current.focus();
59
60
  }
60
61
  };
61
- var blur = /*#__PURE__*/function () {
62
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
62
+ var blur = function blur() {
63
+ return (_ref = _ref || (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
63
64
  var _$edit$current2, result;
64
65
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
65
66
  while (1) switch (_context.prev = _context.next) {
@@ -90,7 +91,7 @@ var ObjectKey = function ObjectKey(props) {
90
91
  }
91
92
  case 6:
92
93
  $edit.current.contentEditable = 'false';
93
- (_$edit$current2 = $edit.current) === null || _$edit$current2 === void 0 ? void 0 : _$edit$current2.focus();
94
+ (_$edit$current2 = $edit.current) === null || _$edit$current2 === void 0 || _$edit$current2.focus();
94
95
  case 8:
95
96
  setEditable(false);
96
97
  case 9:
@@ -98,16 +99,13 @@ var ObjectKey = function ObjectKey(props) {
98
99
  return _context.stop();
99
100
  }
100
101
  }, _callee);
101
- }));
102
- return function blur() {
103
- return _ref.apply(this, arguments);
104
- };
105
- }();
102
+ }))).apply(this, arguments);
103
+ };
106
104
  var focus = function focus() {
107
105
  if ($edit.current) {
108
106
  var _$edit$current3;
109
107
  $edit.current.contentEditable = 'true';
110
- (_$edit$current3 = $edit.current) === null || _$edit$current3 === void 0 ? void 0 : _$edit$current3.focus();
108
+ (_$edit$current3 = $edit.current) === null || _$edit$current3 === void 0 || _$edit$current3.focus();
111
109
  }
112
110
  };
113
111
  var keyDown = function keyDown(evn) {
@@ -167,4 +165,5 @@ var ObjectKey = function ObjectKey(props) {
167
165
  ref: $edit
168
166
  }));
169
167
  };
170
- exports.ObjectKey = ObjectKey;
168
+ exports.ObjectKey = ObjectKey;
169
+ ObjectKey.displayName = 'JVR.ObjectKey';
@@ -17,3 +17,6 @@ export interface ReValueProps<T extends object> extends React.HTMLAttributes<HTM
17
17
  onDelete?: JsonViewEditorProps<T>['onDelete'];
18
18
  }
19
19
  export declare function ReValue<T extends object>(props: ReValueProps<T>): import("react/jsx-runtime").JSX.Element;
20
+ export declare namespace ReValue {
21
+ var displayName: string;
22
+ }
@@ -27,7 +27,7 @@ var Quotes = function Quotes(_ref) {
27
27
  });
28
28
  };
29
29
  function ReValue(props) {
30
- var _typeMap$typeStr;
30
+ var _ref2, _typeMap$typeStr, _ref3;
31
31
  var type = props.type,
32
32
  value = props.value,
33
33
  setValue = props.setValue,
@@ -67,7 +67,7 @@ function ReValue(props) {
67
67
  var _$edit$current;
68
68
  setEditable(true);
69
69
  $edit.current.setAttribute('contentEditable', 'true');
70
- (_$edit$current = $edit.current) === null || _$edit$current === void 0 ? void 0 : _$edit$current.focus();
70
+ (_$edit$current = $edit.current) === null || _$edit$current === void 0 || _$edit$current.focus();
71
71
  }
72
72
  };
73
73
  var keyDown = function keyDown(evn) {
@@ -81,8 +81,8 @@ function ReValue(props) {
81
81
  }
82
82
  }
83
83
  };
84
- var blur = /*#__PURE__*/function () {
85
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
84
+ var blur = function blur() {
85
+ return (_ref2 = _ref2 || (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
86
86
  var text, _typeStr, dt, result, _getValueString, oldChildStr;
87
87
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
88
88
  while (1) switch (_context.prev = _context.next) {
@@ -158,11 +158,8 @@ function ReValue(props) {
158
158
  return _context.stop();
159
159
  }
160
160
  }, _callee);
161
- }));
162
- return function blur() {
163
- return _ref2.apply(this, arguments);
164
- };
165
- }();
161
+ }))).apply(this, arguments);
162
+ };
166
163
  var defaultStyle = {
167
164
  minWidth: 34,
168
165
  minHeight: 18,
@@ -189,8 +186,8 @@ function ReValue(props) {
189
186
  if (typeStr === 'null' || typeStr === 'undefined') {
190
187
  typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
191
188
  }
192
- var deleteHandle = /*#__PURE__*/function () {
193
- var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2(evn) {
189
+ var deleteHandle = function deleteHandle(_x) {
190
+ return (_ref3 = _ref3 || (0, _asyncToGenerator2["default"])( /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2(evn) {
194
191
  var maybeDelete;
195
192
  return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
196
193
  while (1) switch (_context2.prev = _context2.next) {
@@ -215,11 +212,8 @@ function ReValue(props) {
215
212
  return _context2.stop();
216
213
  }
217
214
  }, _callee2);
218
- }));
219
- return function deleteHandle(_x) {
220
- return _ref3.apply(this, arguments);
221
- };
222
- }();
215
+ }))).apply(this, arguments);
216
+ };
223
217
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
224
218
  children: [displayDataTypes && typeView, /*#__PURE__*/(0, _jsxRuntime.jsx)(Quotes, {
225
219
  style: style,
@@ -239,4 +233,5 @@ function ReValue(props) {
239
233
  onClick: deleteHandle
240
234
  })]
241
235
  });
242
- }
236
+ }
237
+ ReValue.displayName = 'JVR.ReValue';
package/cjs/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import type { MetaProps } from './comps/meta';
7
7
  import type { CountInfoExtraProps } from './editor/countInfoExtra';
8
8
  export * from './node';
9
9
  export * from './value';
10
+ export * from './semicolon';
10
11
  export interface CountInfoProps {
11
12
  count: number;
12
13
  level: number;
@@ -32,6 +33,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
32
33
  displayDataTypes?: boolean;
33
34
  /** When set to `true`, `objects` and `arrays` are labeled with size @default true */
34
35
  displayObjectSize?: boolean;
36
+ /** Shorten long JSON strings, Set to `0` to disable this feature @default 20 */
37
+ shortenTextAfterLength?: number;
35
38
  /** Define the root node name. @default undefined */
36
39
  keyName?: string | number;
37
40
  /** The user can copy objects and arrays to clipboard by clicking on the clipboard icon. @default true */
package/cjs/index.js CHANGED
@@ -35,6 +35,18 @@ Object.keys(_value).forEach(function (key) {
35
35
  }
36
36
  });
37
37
  });
38
+ var _semicolon = require("./semicolon");
39
+ Object.keys(_semicolon).forEach(function (key) {
40
+ if (key === "default" || key === "__esModule") return;
41
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
42
+ if (key in exports && exports[key] === _semicolon[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _semicolon[key];
47
+ }
48
+ });
49
+ });
38
50
  var _excluded = ["value", "style", "className"];
39
51
  var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
40
52
  var value = props.value,
@@ -58,5 +70,6 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
58
70
  style: defaultStyle
59
71
  }));
60
72
  });
73
+ JsonView.displayName = 'JVR.JsonView';
61
74
  var _default = JsonView;
62
75
  exports["default"] = _default;
package/cjs/node.js CHANGED
@@ -19,7 +19,7 @@ var _copied = require("./copied");
19
19
  var _ellipsis = require("./comps/ellipsis");
20
20
  var _meta = require("./comps/meta");
21
21
  var _jsxRuntime = require("react/jsx-runtime");
22
- var _excluded = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "collapsed", "level", "keyid", "quotes", "namespace", "onCopied", "onExpand", "parentValue", "setParentValue"];
22
+ var _excluded = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "shortenTextAfterLength", "collapsed", "level", "keyid", "quotes", "namespace", "onCopied", "onExpand", "parentValue", "setParentValue"];
23
23
  function getLength(obj) {
24
24
  try {
25
25
  return Object.keys(obj).length;
@@ -40,6 +40,7 @@ var CountInfo = function CountInfo(_ref) {
40
40
  });
41
41
  };
42
42
  exports.CountInfo = CountInfo;
43
+ CountInfo.displayName = 'JVR.CountInfo';
43
44
  var RootNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
44
45
  var _expands$keyid;
45
46
  var _props$value = props.value,
@@ -60,6 +61,8 @@ var RootNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
60
61
  objectSortKeys = _props$objectSortKeys === void 0 ? false : _props$objectSortKeys,
61
62
  _props$indentWidth = props.indentWidth,
62
63
  indentWidth = _props$indentWidth === void 0 ? 15 : _props$indentWidth,
64
+ _props$shortenTextAft = props.shortenTextAfterLength,
65
+ shortenTextAfterLength = _props$shortenTextAft === void 0 ? 20 : _props$shortenTextAft,
63
66
  collapsed = props.collapsed,
64
67
  _props$level = props.level,
65
68
  level = _props$level === void 0 ? 1 : _props$level,
@@ -113,6 +116,7 @@ var RootNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
113
116
  displayDataTypes: displayDataTypes,
114
117
  displayObjectSize: displayObjectSize,
115
118
  enableClipboard: enableClipboard,
119
+ shortenTextAfterLength: shortenTextAfterLength,
116
120
  level: level + 1,
117
121
  parentValue: value,
118
122
  indentWidth: indentWidth,
@@ -321,4 +325,5 @@ var RootNode = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
321
325
  })]
322
326
  }));
323
327
  });
324
- exports.RootNode = RootNode;
328
+ exports.RootNode = RootNode;
329
+ RootNode.displayName = 'JVR.RootNode';
package/cjs/semicolon.js CHANGED
@@ -111,4 +111,5 @@ var Semicolon = function Semicolon(_ref2) {
111
111
  children: content
112
112
  }));
113
113
  };
114
- exports.Semicolon = Semicolon;
114
+ exports.Semicolon = Semicolon;
115
+ Semicolon.displayName = 'JSR.Semicolon';
package/cjs/value.d.ts CHANGED
@@ -55,6 +55,7 @@ export interface ValueViewProps<T extends object> extends React.DetailedHTMLProp
55
55
  enableClipboard: boolean;
56
56
  indentWidth: number;
57
57
  level?: number;
58
+ shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
58
59
  namespace?: Array<string | number>;
59
60
  quotes?: JsonViewProps<T>['quotes'];
60
61
  components?: JsonViewProps<T>['components'];
@@ -67,6 +68,9 @@ export declare function getValueString<T>(value: T): {
67
68
  content: string;
68
69
  };
69
70
  export declare function ValueView<T extends object>(props: ValueViewProps<T>): import("react/jsx-runtime").JSX.Element;
71
+ export declare namespace ValueView {
72
+ var displayName: string;
73
+ }
70
74
  export interface LabelProps extends React.HTMLAttributes<HTMLSpanElement> {
71
75
  color?: string;
72
76
  fontSize?: number;
package/cjs/value.js CHANGED
@@ -17,12 +17,15 @@ var _meta = require("./comps/meta");
17
17
  var _copied = require("./copied");
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
19
  var _excluded = ["children", "style"],
20
- _excluded2 = ["value", "parentValue", "setValue", "countInfo", "data", "keyName", "indentWidth", "namespace", "renderKey", "components", "quotes", "level", "enableClipboard", "displayObjectSize", "displayDataTypes"],
21
- _excluded3 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
20
+ _excluded2 = ["children", "length", "style"],
21
+ _excluded3 = ["color", "style", "isURL", "href", "children"],
22
+ _excluded4 = ["value", "parentValue", "setValue", "countInfo", "data", "keyName", "indentWidth", "namespace", "renderKey", "components", "quotes", "level", "enableClipboard", "displayObjectSize", "displayDataTypes", "shortenTextAfterLength"],
23
+ _excluded5 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
22
24
  var Line = function Line(props) {
23
25
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _objectSpread2["default"])({}, props));
24
26
  };
25
27
  exports.Line = Line;
28
+ Line.displayName = 'JVR.Line';
26
29
  var isFloat = function isFloat(n) {
27
30
  return Number(n) === n && n % 1 !== 0 || isNaN(n);
28
31
  };
@@ -85,6 +88,7 @@ var Colon = function Colon(_ref) {
85
88
  }));
86
89
  };
87
90
  exports.Colon = Colon;
91
+ Colon.displayName = 'JVR.Colon';
88
92
  function getValueString(value) {
89
93
  var type = (0, _typeof2["default"])(value);
90
94
  var content = '';
@@ -125,6 +129,55 @@ function getValueString(value) {
125
129
  content: content
126
130
  };
127
131
  }
132
+ var RenderShortenTextValue = function RenderShortenTextValue(_ref2) {
133
+ var children = _ref2.children,
134
+ length = _ref2.length,
135
+ style = _ref2.style,
136
+ rest = (0, _objectWithoutProperties2["default"])(_ref2, _excluded2);
137
+ var childrenStr = children;
138
+ var _useState = (0, _react.useState)(length && childrenStr.length >= length),
139
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
140
+ shorten = _useState2[0],
141
+ setShorten = _useState2[1];
142
+ var click = function click() {
143
+ console.log(shorten);
144
+ if (length && childrenStr.length <= length) return setShorten(false);
145
+ setShorten(!shorten);
146
+ };
147
+ var text = shorten ? "".concat(childrenStr.slice(0, length), "...") : childrenStr;
148
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderStringValue, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, rest), {}, {
149
+ style: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, style), {}, {
150
+ cursor: 'pointer'
151
+ }),
152
+ onClick: click,
153
+ children: text
154
+ }));
155
+ };
156
+ RenderShortenTextValue.displayName = 'JVR.RenderShortenTextValue';
157
+ var RenderStringValue = function RenderStringValue(_ref3) {
158
+ var color = _ref3.color,
159
+ style = _ref3.style,
160
+ isURL = _ref3.isURL,
161
+ href = _ref3.href,
162
+ children = _ref3.children,
163
+ rest = (0, _objectWithoutProperties2["default"])(_ref3, _excluded3);
164
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
165
+ color: color,
166
+ style: style
167
+ }, rest), {}, {
168
+ className: "w-rjv-value",
169
+ children: [isURL && /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
170
+ href: href,
171
+ style: {
172
+ color: color
173
+ },
174
+ target: "_blank",
175
+ rel: "noopener noreferrer",
176
+ children: children
177
+ }), !isURL && children]
178
+ }));
179
+ };
180
+ RenderStringValue.displayName = 'JVR.RenderStringValue';
128
181
  function ValueView(props) {
129
182
  var _typeMap$type;
130
183
  var value = props.value,
@@ -143,7 +196,8 @@ function ValueView(props) {
143
196
  enableClipboard = props.enableClipboard,
144
197
  displayObjectSize = props.displayObjectSize,
145
198
  displayDataTypes = props.displayDataTypes,
146
- reset = (0, _objectWithoutProperties2["default"])(props, _excluded2);
199
+ shortenTextAfterLength = props.shortenTextAfterLength,
200
+ reset = (0, _objectWithoutProperties2["default"])(props, _excluded4);
147
201
  var color = '';
148
202
  var style = {};
149
203
  var _getValueString = getValueString(value),
@@ -166,10 +220,10 @@ function ValueView(props) {
166
220
  typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
167
221
  }
168
222
  color = ((_typeMap$type = typeMap[type]) === null || _typeMap$type === void 0 ? void 0 : _typeMap$type.color) || '';
169
- var _useState = (0, _react.useState)(false),
170
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
171
- showTools = _useState2[0],
172
- setShowTools = _useState2[1];
223
+ var _useState3 = (0, _react.useState)(false),
224
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
225
+ showTools = _useState4[0],
226
+ setShowTools = _useState4[1];
173
227
  var tools = (0, _react.useMemo)(function () {
174
228
  return enableClipboard && showTools && /*#__PURE__*/(0, _jsxRuntime.jsx)(_copied.Copied, {
175
229
  show: showTools,
@@ -209,24 +263,24 @@ function ValueView(props) {
209
263
  content: content,
210
264
  children: content
211
265
  });
212
- var valueView = reView ? reView : /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, {
266
+ var valueView = shortenTextAfterLength && type === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderShortenTextValue, {
267
+ color: color,
268
+ href: isURL ? value.href : '',
269
+ style: style,
270
+ isURL: isURL,
271
+ length: shortenTextAfterLength,
272
+ children: content
273
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderStringValue, {
213
274
  color: color,
275
+ href: isURL ? value.href : '',
214
276
  style: style,
215
- className: "w-rjv-value",
216
- children: isURL ? /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
217
- href: value.href,
218
- style: {
219
- color: color
220
- },
221
- target: "_blank",
222
- rel: "noopener noreferrer",
223
- children: content
224
- }) : content
277
+ isURL: isURL,
278
+ children: content
225
279
  });
226
280
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, eventProps), {}, {
227
281
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Label, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
228
282
  ref: null,
229
- children: [renderKey, /*#__PURE__*/(0, _jsxRuntime.jsx)(Colon, {}), typeView, valueView, tools]
283
+ children: [renderKey, /*#__PURE__*/(0, _jsxRuntime.jsx)(Colon, {}), typeView, reView ? reView : valueView, tools]
230
284
  }))
231
285
  }));
232
286
  }
@@ -247,14 +301,15 @@ function ValueView(props) {
247
301
  }))
248
302
  }));
249
303
  }
250
- var Label = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
251
- var children = _ref2.children,
252
- color = _ref2.color,
253
- fontSize = _ref2.fontSize,
254
- opacity = _ref2.opacity,
255
- paddingRight = _ref2.paddingRight,
256
- style = _ref2.style,
257
- reset = (0, _objectWithoutProperties2["default"])(_ref2, _excluded3);
304
+ ValueView.displayName = 'JVR.ValueView';
305
+ var Label = /*#__PURE__*/(0, _react.forwardRef)(function (_ref4, ref) {
306
+ var children = _ref4.children,
307
+ color = _ref4.color,
308
+ fontSize = _ref4.fontSize,
309
+ opacity = _ref4.opacity,
310
+ paddingRight = _ref4.paddingRight,
311
+ style = _ref4.style,
312
+ reset = (0, _objectWithoutProperties2["default"])(_ref4, _excluded5);
258
313
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
259
314
  style: (0, _objectSpread2["default"])({
260
315
  color: color,
@@ -268,6 +323,7 @@ var Label = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
268
323
  }));
269
324
  });
270
325
  exports.Label = Label;
326
+ Label.displayName = 'JVR.Label';
271
327
  var Type = function Type(props) {
272
328
  var _typeMap$type2, _typeMap$type3;
273
329
  var type = props.type;
@@ -285,4 +341,5 @@ var Type = function Type(props) {
285
341
  });
286
342
  }
287
343
  };
288
- exports.Type = Type;
344
+ exports.Type = Type;
345
+ Type.displayName = 'JVR.Type';
@@ -2,3 +2,6 @@ import React from 'react';
2
2
  export interface TriangleArrowProps extends React.SVGProps<SVGSVGElement> {
3
3
  }
4
4
  export declare function TriangleArrow(props: TriangleArrowProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare namespace TriangleArrow {
6
+ var displayName: string;
7
+ }
@@ -22,4 +22,5 @@ export function TriangleArrow(props) {
22
22
  d: "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"
23
23
  })
24
24
  }));
25
- }
25
+ }
26
+ TriangleArrow.displayName = 'JVR.TriangleArrow';
@@ -2,3 +2,6 @@ import React from 'react';
2
2
  export interface TriangleSolidArrowProps extends React.SVGProps<SVGSVGElement> {
3
3
  }
4
4
  export declare function TriangleSolidArrow(props: TriangleSolidArrowProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare namespace TriangleSolidArrow {
6
+ var displayName: string;
7
+ }
@@ -22,4 +22,5 @@ export function TriangleSolidArrow(props) {
22
22
  d: "M0 5l6 6 6-6z"
23
23
  })
24
24
  }));
25
- }
25
+ }
26
+ TriangleSolidArrow.displayName = 'JVR.TriangleSolidArrow';
@@ -27,4 +27,5 @@ export var Ellipsis = _ref => {
27
27
  }, props, {
28
28
  children: "..."
29
29
  }));
30
- };
30
+ };
31
+ Ellipsis.displayName = 'JVR.Ellipsis';
@@ -7,3 +7,6 @@ export interface MetaProps extends LabelProps {
7
7
  render?: (props: Pick<MetaProps, 'start' | 'level' | 'isArray' | 'className' | 'children'>) => JSX.Element;
8
8
  }
9
9
  export declare function Meta(props: MetaProps): JSX.Element;
10
+ export declare namespace Meta {
11
+ var displayName: string;
12
+ }
package/esm/comps/meta.js CHANGED
@@ -35,4 +35,5 @@ export function Meta(props) {
35
35
  }, reset, {
36
36
  children: start ? mark.charAt(0) : mark.charAt(1)
37
37
  }));
38
- }
38
+ }
39
+ Meta.displayName = 'JVR.Meta';
package/esm/copied.d.ts CHANGED
@@ -6,3 +6,6 @@ export interface CopiedProps<T = object> extends React.SVGProps<SVGSVGElement> {
6
6
  render?: (props: Omit<CopiedProps<T>, 'render'>) => JSX.Element;
7
7
  }
8
8
  export declare function Copied<T>(props: CopiedProps<T>): JSX.Element | null;
9
+ export declare namespace Copied {
10
+ var displayName: string;
11
+ }
package/esm/copied.js CHANGED
@@ -63,4 +63,5 @@ export function Copied(props) {
63
63
  d: "M27.5,33 L2.5,33 L2.5,12.5 L27.5,12.5 L27.5,20 L30,20 L30,7.5 C30,6.1 28.9,5 27.5,5 L20,5 C20,2.2 17.8,0 15,0 C12.2,0 10,2.2 10,5 L2.5,5 C1.1,5 0,6.1 0,7.5 L0,33 C0,34.4 1.1,36 2.5,36 L27.5,36 C28.9,36 30,34.4 30,33 L30,29 L27.5,29 L27.5,33 Z M7.5,7.5 L10,7.5 C10,7.5 12.5,6.4 12.5,5 C12.5,3.6 13.6,2.5 15,2.5 C16.4,2.5 17.5,3.6 17.5,5 C17.5,6.4 18.8,7.5 20,7.5 L22.5,7.5 C22.5,7.5 25,8.6 25,10 L5,10 C5,8.5 6.1,7.5 7.5,7.5 Z M5,27.5 L10,27.5 L10,25 L5,25 L5,27.5 Z M22.5,21.5 L22.5,16.5 L12.5,24 L22.5,31.5 L22.5,26.5 L32,26.5 L32,21.5 L22.5,21.5 Z M17.5,15 L5,15 L5,17.5 L17.5,17.5 L17.5,15 Z M10,20 L5,20 L5,22.5 L10,22.5 L10,20 Z"
64
64
  })
65
65
  }));
66
- }
66
+ }
67
+ Copied.displayName = 'JVR.Copied';
@@ -23,3 +23,6 @@ export interface CountInfoExtraProps<T> extends Partial<CountInfoProps> {
23
23
  }) => boolean;
24
24
  }
25
25
  export declare function CountInfoExtra<T extends object>(props: CountInfoExtraProps<T>): import("react/jsx-runtime").JSX.Element | null;
26
+ export declare namespace CountInfoExtra {
27
+ var displayName: string;
28
+ }
@@ -6,6 +6,7 @@ import { DeleteIcon } from './icon/delete';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
8
8
  export function CountInfoExtra(props) {
9
+ var _ref, _ref2;
9
10
  var {
10
11
  visible,
11
12
  showTools,
@@ -20,8 +21,8 @@ export function CountInfoExtra(props) {
20
21
  onDelete
21
22
  } = props;
22
23
  if (!visible || !showTools) return null;
23
- var click = /*#__PURE__*/function () {
24
- var _ref = _asyncToGenerator(function* (event) {
24
+ var click = function click(_x) {
25
+ return (_ref = _ref || _asyncToGenerator(function* (event) {
25
26
  event.stopPropagation();
26
27
  var keyOrValue = 'AddKeyOrValue';
27
28
  var isArray = Array.isArray(value);
@@ -35,13 +36,10 @@ export function CountInfoExtra(props) {
35
36
  setValue(result);
36
37
  }
37
38
  }
38
- });
39
- return function click(_x) {
40
- return _ref.apply(this, arguments);
41
- };
42
- }();
43
- var deleteHandle = /*#__PURE__*/function () {
44
- var _ref2 = _asyncToGenerator(function* (event) {
39
+ })).apply(this, arguments);
40
+ };
41
+ var deleteHandle = function deleteHandle(_x2) {
42
+ return (_ref2 = _ref2 || _asyncToGenerator(function* (event) {
45
43
  event.stopPropagation();
46
44
  if (onDelete && (keyName || typeof keyName === 'number') && parentValue) {
47
45
  var maybeDelete = yield onDelete(keyName, value, parentValue, {
@@ -57,11 +55,8 @@ export function CountInfoExtra(props) {
57
55
  }
58
56
  }
59
57
  }
60
- });
61
- return function deleteHandle(_x2) {
62
- return _ref2.apply(this, arguments);
63
- };
64
- }();
58
+ })).apply(this, arguments);
59
+ };
65
60
  return /*#__PURE__*/_jsxs(Fragment, {
66
61
  children: [editable && onAdd && /*#__PURE__*/_jsx(AddIcon, {
67
62
  onClick: click
@@ -69,4 +64,5 @@ export function CountInfoExtra(props) {
69
64
  onClick: deleteHandle
70
65
  })]
71
66
  });
72
- }
67
+ }
68
+ CountInfoExtra.displayName = 'JVR.CountInfoExtra';
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { JsonViewProps } from '../';
3
3
  import type { CountInfoExtraProps } from './countInfoExtra';
4
- export interface JsonViewEditorProps<T extends object> extends JsonViewProps<T> {
4
+ export interface JsonViewEditorProps<T extends object> extends Omit<JsonViewProps<T>, 'shortenTextAfterLength'> {
5
5
  /**
6
6
  * When a callback function is passed in, edit functionality is enabled. The callback is invoked before edits are completed.
7
7
  * @returns {boolean} Returning false from onEdit will prevent the change from being made.
@@ -43,4 +43,5 @@ var JsonViewEditor = /*#__PURE__*/forwardRef((props, ref) => {
43
43
  ref: ref
44
44
  }));
45
45
  });
46
+ JsonViewEditor.displayName = 'JVR.JsonViewEditor';
46
47
  export default JsonViewEditor;
@@ -7,6 +7,7 @@ import { useHighlight } from '../semicolon';
7
7
  import { Label } from '../value';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export var ObjectKey = props => {
10
+ var _ref;
10
11
  var {
11
12
  className,
12
13
  value,
@@ -39,11 +40,11 @@ export var ObjectKey = props => {
39
40
  if ($edit.current) {
40
41
  var _$edit$current;
41
42
  $edit.current.contentEditable = 'true';
42
- (_$edit$current = $edit.current) == null ? void 0 : _$edit$current.focus();
43
+ (_$edit$current = $edit.current) == null || _$edit$current.focus();
43
44
  }
44
45
  };
45
- var blur = /*#__PURE__*/function () {
46
- var _ref = _asyncToGenerator(function* () {
46
+ var blur = function blur() {
47
+ return (_ref = _ref || _asyncToGenerator(function* () {
47
48
  if ($edit.current) {
48
49
  var _$edit$current2;
49
50
  if (onEdit) {
@@ -62,19 +63,16 @@ export var ObjectKey = props => {
62
63
  }
63
64
  }
64
65
  $edit.current.contentEditable = 'false';
65
- (_$edit$current2 = $edit.current) == null ? void 0 : _$edit$current2.focus();
66
+ (_$edit$current2 = $edit.current) == null || _$edit$current2.focus();
66
67
  }
67
68
  setEditable(false);
68
- });
69
- return function blur() {
70
- return _ref.apply(this, arguments);
71
- };
72
- }();
69
+ })).apply(this, arguments);
70
+ };
73
71
  var focus = () => {
74
72
  if ($edit.current) {
75
73
  var _$edit$current3;
76
74
  $edit.current.contentEditable = 'true';
77
- (_$edit$current3 = $edit.current) == null ? void 0 : _$edit$current3.focus();
75
+ (_$edit$current3 = $edit.current) == null || _$edit$current3.focus();
78
76
  }
79
77
  };
80
78
  var keyDown = evn => {
@@ -133,4 +131,5 @@ export var ObjectKey = props => {
133
131
  }, spanProps, {
134
132
  ref: $edit
135
133
  }));
136
- };
134
+ };
135
+ ObjectKey.displayName = 'JVR.ObjectKey';
@@ -17,3 +17,6 @@ export interface ReValueProps<T extends object> extends React.HTMLAttributes<HTM
17
17
  onDelete?: JsonViewEditorProps<T>['onDelete'];
18
18
  }
19
19
  export declare function ReValue<T extends object>(props: ReValueProps<T>): import("react/jsx-runtime").JSX.Element;
20
+ export declare namespace ReValue {
21
+ var displayName: string;
22
+ }
@@ -21,7 +21,7 @@ var Quotes = _ref => {
21
21
  });
22
22
  };
23
23
  export function ReValue(props) {
24
- var _typeMap$typeStr;
24
+ var _ref2, _typeMap$typeStr, _ref3;
25
25
  var {
26
26
  type,
27
27
  value,
@@ -51,7 +51,7 @@ export function ReValue(props) {
51
51
  var _$edit$current;
52
52
  setEditable(true);
53
53
  $edit.current.setAttribute('contentEditable', 'true');
54
- (_$edit$current = $edit.current) == null ? void 0 : _$edit$current.focus();
54
+ (_$edit$current = $edit.current) == null || _$edit$current.focus();
55
55
  }
56
56
  };
57
57
  var keyDown = evn => {
@@ -65,8 +65,8 @@ export function ReValue(props) {
65
65
  }
66
66
  }
67
67
  };
68
- var blur = /*#__PURE__*/function () {
69
- var _ref2 = _asyncToGenerator(function* () {
68
+ var blur = function blur() {
69
+ return (_ref2 = _ref2 || _asyncToGenerator(function* () {
70
70
  if (!editableValue) return;
71
71
  setEditable(false);
72
72
  if ($edit.current) {
@@ -123,11 +123,8 @@ export function ReValue(props) {
123
123
  }
124
124
  }
125
125
  }
126
- });
127
- return function blur() {
128
- return _ref2.apply(this, arguments);
129
- };
130
- }();
126
+ })).apply(this, arguments);
127
+ };
131
128
  var defaultStyle = {
132
129
  minWidth: 34,
133
130
  minHeight: 18,
@@ -155,8 +152,8 @@ export function ReValue(props) {
155
152
  if (typeStr === 'null' || typeStr === 'undefined') {
156
153
  typeView = /*#__PURE__*/_jsx(Fragment, {});
157
154
  }
158
- var deleteHandle = /*#__PURE__*/function () {
159
- var _ref3 = _asyncToGenerator(function* (evn) {
155
+ var deleteHandle = function deleteHandle(_x) {
156
+ return (_ref3 = _ref3 || _asyncToGenerator(function* (evn) {
160
157
  evn.stopPropagation();
161
158
  if (data && keyName && keyName in data && setValue && onDelete) {
162
159
  var maybeDelete = yield onDelete(keyName, value, parentValue, {
@@ -167,11 +164,8 @@ export function ReValue(props) {
167
164
  setValue(_extends({}, data));
168
165
  }
169
166
  }
170
- });
171
- return function deleteHandle(_x) {
172
- return _ref3.apply(this, arguments);
173
- };
174
- }();
167
+ })).apply(this, arguments);
168
+ };
175
169
  return /*#__PURE__*/_jsxs(Fragment, {
176
170
  children: [displayDataTypes && typeView, /*#__PURE__*/_jsx(Quotes, {
177
171
  style: style,
@@ -191,4 +185,5 @@ export function ReValue(props) {
191
185
  onClick: deleteHandle
192
186
  })]
193
187
  });
194
- }
188
+ }
189
+ ReValue.displayName = 'JVR.ReValue';
package/esm/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import type { MetaProps } from './comps/meta';
7
7
  import type { CountInfoExtraProps } from './editor/countInfoExtra';
8
8
  export * from './node';
9
9
  export * from './value';
10
+ export * from './semicolon';
10
11
  export interface CountInfoProps {
11
12
  count: number;
12
13
  level: number;
@@ -32,6 +33,8 @@ export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps
32
33
  displayDataTypes?: boolean;
33
34
  /** When set to `true`, `objects` and `arrays` are labeled with size @default true */
34
35
  displayObjectSize?: boolean;
36
+ /** Shorten long JSON strings, Set to `0` to disable this feature @default 20 */
37
+ shortenTextAfterLength?: number;
35
38
  /** Define the root node name. @default undefined */
36
39
  keyName?: string | number;
37
40
  /** The user can copy objects and arrays to clipboard by clicking on the clipboard icon. @default true */
package/esm/index.js CHANGED
@@ -7,6 +7,7 @@ import { RootNode } from './node';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  export * from './node';
9
9
  export * from './value';
10
+ export * from './semicolon';
10
11
  var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
11
12
  var {
12
13
  value,
@@ -31,4 +32,5 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
31
32
  style: defaultStyle
32
33
  }));
33
34
  });
35
+ JsonView.displayName = 'JVR.JsonView';
34
36
  export default JsonView;
package/esm/node.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 = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "collapsed", "level", "keyid", "quotes", "namespace", "onCopied", "onExpand", "parentValue", "setParentValue"];
3
+ var _excluded = ["value", "keyName", "className", "displayDataTypes", "components", "displayObjectSize", "enableClipboard", "highlightUpdates", "objectSortKeys", "indentWidth", "shortenTextAfterLength", "collapsed", "level", "keyid", "quotes", "namespace", "onCopied", "onExpand", "parentValue", "setParentValue"];
4
4
  import { Fragment, useId, cloneElement, useState, useEffect, forwardRef } from 'react';
5
5
  import { ValueView, Colon, Label, Line, typeMap } from './value';
6
6
  import { TriangleArrow } from './arrow/TriangleArrow';
@@ -32,6 +32,7 @@ export var CountInfo = _ref => {
32
32
  children: [children, " items"]
33
33
  });
34
34
  };
35
+ CountInfo.displayName = 'JVR.CountInfo';
35
36
  export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
36
37
  var _expands$keyid;
37
38
  var {
@@ -45,6 +46,7 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
45
46
  highlightUpdates = true,
46
47
  objectSortKeys = false,
47
48
  indentWidth = 15,
49
+ shortenTextAfterLength = 20,
48
50
  collapsed,
49
51
  level = 1,
50
52
  keyid = 'root',
@@ -92,6 +94,7 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
92
94
  displayDataTypes,
93
95
  displayObjectSize,
94
96
  enableClipboard,
97
+ shortenTextAfterLength,
95
98
  level: level + 1,
96
99
  parentValue: value,
97
100
  indentWidth,
@@ -280,4 +283,5 @@ export var RootNode = /*#__PURE__*/forwardRef((props, ref) => {
280
283
  })
281
284
  })]
282
285
  }));
283
- });
286
+ });
287
+ RootNode.displayName = 'JVR.RootNode';
package/esm/semicolon.js CHANGED
@@ -102,4 +102,5 @@ export var Semicolon = _ref2 => {
102
102
  ref: highlightContainer,
103
103
  children: content
104
104
  }));
105
- };
105
+ };
106
+ Semicolon.displayName = 'JSR.Semicolon';
package/esm/value.d.ts CHANGED
@@ -55,6 +55,7 @@ export interface ValueViewProps<T extends object> extends React.DetailedHTMLProp
55
55
  enableClipboard: boolean;
56
56
  indentWidth: number;
57
57
  level?: number;
58
+ shortenTextAfterLength?: JsonViewProps<T>['shortenTextAfterLength'];
58
59
  namespace?: Array<string | number>;
59
60
  quotes?: JsonViewProps<T>['quotes'];
60
61
  components?: JsonViewProps<T>['components'];
@@ -67,6 +68,9 @@ export declare function getValueString<T>(value: T): {
67
68
  content: string;
68
69
  };
69
70
  export declare function ValueView<T extends object>(props: ValueViewProps<T>): import("react/jsx-runtime").JSX.Element;
71
+ export declare namespace ValueView {
72
+ var displayName: string;
73
+ }
70
74
  export interface LabelProps extends React.HTMLAttributes<HTMLSpanElement> {
71
75
  color?: string;
72
76
  fontSize?: number;
package/esm/value.js CHANGED
@@ -1,14 +1,17 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  var _excluded = ["children", "style"],
4
- _excluded2 = ["value", "parentValue", "setValue", "countInfo", "data", "keyName", "indentWidth", "namespace", "renderKey", "components", "quotes", "level", "enableClipboard", "displayObjectSize", "displayDataTypes"],
5
- _excluded3 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
4
+ _excluded2 = ["children", "length", "style"],
5
+ _excluded3 = ["color", "style", "isURL", "href", "children"],
6
+ _excluded4 = ["value", "parentValue", "setValue", "countInfo", "data", "keyName", "indentWidth", "namespace", "renderKey", "components", "quotes", "level", "enableClipboard", "displayObjectSize", "displayDataTypes", "shortenTextAfterLength"],
7
+ _excluded5 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
6
8
  import { Fragment, forwardRef, useMemo, useState } from 'react';
7
9
  import { Meta } from './comps/meta';
8
10
  import { Copied } from './copied';
9
11
  import { jsx as _jsx } from "react/jsx-runtime";
10
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
11
13
  export var Line = props => /*#__PURE__*/_jsx("div", _extends({}, props));
14
+ Line.displayName = 'JVR.Line';
12
15
  export var isFloat = n => Number(n) === n && n % 1 !== 0 || isNaN(n);
13
16
  export var typeMap = {
14
17
  string: {
@@ -67,6 +70,7 @@ export var Colon = _ref => {
67
70
  children: children
68
71
  }));
69
72
  };
73
+ Colon.displayName = 'JVR.Colon';
70
74
  export function getValueString(value) {
71
75
  var type = typeof value;
72
76
  var content = '';
@@ -107,6 +111,56 @@ export function getValueString(value) {
107
111
  content
108
112
  };
109
113
  }
114
+ var RenderShortenTextValue = _ref2 => {
115
+ var {
116
+ children,
117
+ length,
118
+ style
119
+ } = _ref2,
120
+ rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
121
+ var childrenStr = children;
122
+ var [shorten, setShorten] = useState(length && childrenStr.length >= length);
123
+ var click = () => {
124
+ console.log(shorten);
125
+ if (length && childrenStr.length <= length) return setShorten(false);
126
+ setShorten(!shorten);
127
+ };
128
+ var text = shorten ? childrenStr.slice(0, length) + "..." : childrenStr;
129
+ return /*#__PURE__*/_jsx(RenderStringValue, _extends({}, rest, {
130
+ style: _extends({}, style, {
131
+ cursor: 'pointer'
132
+ }),
133
+ onClick: click,
134
+ children: text
135
+ }));
136
+ };
137
+ RenderShortenTextValue.displayName = 'JVR.RenderShortenTextValue';
138
+ var RenderStringValue = _ref3 => {
139
+ var {
140
+ color,
141
+ style,
142
+ isURL,
143
+ href,
144
+ children
145
+ } = _ref3,
146
+ rest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
147
+ return /*#__PURE__*/_jsxs(Label, _extends({
148
+ color: color,
149
+ style: style
150
+ }, rest, {
151
+ className: "w-rjv-value",
152
+ children: [isURL && /*#__PURE__*/_jsx("a", {
153
+ href: href,
154
+ style: {
155
+ color
156
+ },
157
+ target: "_blank",
158
+ rel: "noopener noreferrer",
159
+ children: children
160
+ }), !isURL && children]
161
+ }));
162
+ };
163
+ RenderStringValue.displayName = 'JVR.RenderStringValue';
110
164
  export function ValueView(props) {
111
165
  var _typeMap$type;
112
166
  var {
@@ -122,9 +176,10 @@ export function ValueView(props) {
122
176
  components = {},
123
177
  quotes,
124
178
  enableClipboard,
125
- displayDataTypes
179
+ displayDataTypes,
180
+ shortenTextAfterLength
126
181
  } = props,
127
- reset = _objectWithoutPropertiesLoose(props, _excluded2);
182
+ reset = _objectWithoutPropertiesLoose(props, _excluded4);
128
183
  var color = '';
129
184
  var style = {};
130
185
  var {
@@ -182,24 +237,24 @@ export function ValueView(props) {
182
237
  content,
183
238
  children: content
184
239
  });
185
- var valueView = reView ? reView : /*#__PURE__*/_jsx(Label, {
240
+ var valueView = shortenTextAfterLength && type === 'string' ? /*#__PURE__*/_jsx(RenderShortenTextValue, {
186
241
  color: color,
242
+ href: isURL ? value.href : '',
187
243
  style: style,
188
- className: "w-rjv-value",
189
- children: isURL ? /*#__PURE__*/_jsx("a", {
190
- href: value.href,
191
- style: {
192
- color
193
- },
194
- target: "_blank",
195
- rel: "noopener noreferrer",
196
- children: content
197
- }) : content
244
+ isURL: isURL,
245
+ length: shortenTextAfterLength,
246
+ children: content
247
+ }) : /*#__PURE__*/_jsx(RenderStringValue, {
248
+ color: color,
249
+ href: isURL ? value.href : '',
250
+ style: style,
251
+ isURL: isURL,
252
+ children: content
198
253
  });
199
254
  return /*#__PURE__*/_jsx(Line, _extends({}, eventProps, {
200
255
  children: /*#__PURE__*/_jsxs(Label, _extends({}, reset, {
201
256
  ref: null,
202
- children: [renderKey, /*#__PURE__*/_jsx(Colon, {}), typeView, valueView, tools]
257
+ children: [renderKey, /*#__PURE__*/_jsx(Colon, {}), typeView, reView ? reView : valueView, tools]
203
258
  }))
204
259
  }));
205
260
  }
@@ -220,7 +275,8 @@ export function ValueView(props) {
220
275
  }))
221
276
  }));
222
277
  }
223
- export var Label = /*#__PURE__*/forwardRef((_ref2, ref) => {
278
+ ValueView.displayName = 'JVR.ValueView';
279
+ export var Label = /*#__PURE__*/forwardRef((_ref4, ref) => {
224
280
  var {
225
281
  children,
226
282
  color,
@@ -228,8 +284,8 @@ export var Label = /*#__PURE__*/forwardRef((_ref2, ref) => {
228
284
  opacity,
229
285
  paddingRight,
230
286
  style
231
- } = _ref2,
232
- reset = _objectWithoutPropertiesLoose(_ref2, _excluded3);
287
+ } = _ref4,
288
+ reset = _objectWithoutPropertiesLoose(_ref4, _excluded5);
233
289
  return /*#__PURE__*/_jsx("span", _extends({
234
290
  style: _extends({
235
291
  color,
@@ -242,6 +298,7 @@ export var Label = /*#__PURE__*/forwardRef((_ref2, ref) => {
242
298
  children: children
243
299
  }));
244
300
  });
301
+ Label.displayName = 'JVR.Label';
245
302
  export var Type = props => {
246
303
  var _typeMap$type2, _typeMap$type3;
247
304
  var {
@@ -260,4 +317,5 @@ export var Type = props => {
260
317
  children: label
261
318
  });
262
319
  }
263
- };
320
+ };
321
+ Type.displayName = 'JVR.Type';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-json-view",
3
- "version": "1.8.4",
3
+ "version": "1.9.0",
4
4
  "description": "JSON viewer for react.",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",