@uiw/react-json-view 1.4.0 → 1.5.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 (55) hide show
  1. package/README.md +150 -13
  2. package/cjs/comps/ellipsis.d.ts +5 -0
  3. package/cjs/comps/ellipsis.js +32 -0
  4. package/cjs/comps/meta.d.ts +8 -0
  5. package/cjs/comps/meta.js +38 -0
  6. package/cjs/copied.js +5 -4
  7. package/cjs/editor/icon/edit.d.ts +4 -0
  8. package/cjs/editor/icon/edit.js +30 -0
  9. package/cjs/editor/index.d.ts +16 -0
  10. package/cjs/editor/index.js +48 -0
  11. package/cjs/editor/objectKey.d.ts +11 -0
  12. package/cjs/editor/objectKey.js +138 -0
  13. package/cjs/editor/value.d.ts +14 -0
  14. package/cjs/editor/value.js +165 -0
  15. package/cjs/index.d.ts +2 -1
  16. package/cjs/node.d.ts +0 -10
  17. package/cjs/node.js +45 -90
  18. package/cjs/semicolon.d.ts +11 -2
  19. package/cjs/semicolon.js +44 -25
  20. package/cjs/theme/dark.d.ts +2 -0
  21. package/cjs/theme/dark.js +2 -0
  22. package/cjs/theme/light.d.ts +2 -0
  23. package/cjs/theme/light.js +2 -0
  24. package/cjs/tools.d.ts +10 -0
  25. package/cjs/tools.js +24 -0
  26. package/cjs/value.d.ts +19 -4
  27. package/cjs/value.js +67 -28
  28. package/editor.d.ts +16 -0
  29. package/esm/comps/ellipsis.d.ts +5 -0
  30. package/esm/comps/ellipsis.js +26 -0
  31. package/esm/comps/meta.d.ts +8 -0
  32. package/esm/comps/meta.js +31 -0
  33. package/esm/copied.js +5 -4
  34. package/esm/editor/icon/edit.d.ts +4 -0
  35. package/esm/editor/icon/edit.js +24 -0
  36. package/esm/editor/index.d.ts +16 -0
  37. package/esm/editor/index.js +37 -0
  38. package/esm/editor/objectKey.d.ts +11 -0
  39. package/esm/editor/objectKey.js +122 -0
  40. package/esm/editor/value.d.ts +14 -0
  41. package/esm/editor/value.js +150 -0
  42. package/esm/index.d.ts +2 -1
  43. package/esm/node.d.ts +0 -10
  44. package/esm/node.js +35 -80
  45. package/esm/semicolon.d.ts +11 -2
  46. package/esm/semicolon.js +44 -25
  47. package/esm/theme/dark.d.ts +2 -0
  48. package/esm/theme/dark.js +2 -0
  49. package/esm/theme/light.d.ts +2 -0
  50. package/esm/theme/light.js +2 -0
  51. package/esm/tools.d.ts +10 -0
  52. package/esm/tools.js +20 -0
  53. package/esm/value.d.ts +19 -4
  54. package/esm/value.js +67 -28
  55. package/package.json +7 -1
package/esm/value.js CHANGED
@@ -1,15 +1,16 @@
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", "keyName", "indentWidth", "renderKey", "renderValue", "renderBraces", "enableClipboard", "displayObjectSize", "displayDataTypes"],
4
+ _excluded2 = ["value", "keyName", "indentWidth", "renderKey", "quotes", "renderValue", "renderBraces", "enableClipboard", "displayObjectSize", "displayDataTypes"],
5
5
  _excluded3 = ["children", "color", "fontSize", "opacity", "paddingRight", "style"];
6
6
  import { Fragment, forwardRef, useState } from 'react';
7
- import { Meta, CountInfo } from './node';
7
+ import { CountInfo } from './node';
8
+ import { Meta } from './comps/meta';
8
9
  import { Copied } from './copied';
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
11
  import { jsxs as _jsxs } from "react/jsx-runtime";
11
12
  export var Line = props => /*#__PURE__*/_jsx("div", _extends({}, props));
12
- var isFloat = n => Number(n) === n && n % 1 !== 0 || isNaN(n);
13
+ export var isFloat = n => Number(n) === n && n % 1 !== 0 || isNaN(n);
13
14
  export var typeMap = {
14
15
  string: {
15
16
  color: 'var(--w-rjv-type-string-color, #cb4b16)',
@@ -35,6 +36,10 @@ export var typeMap = {
35
36
  color: 'var(--w-rjv-type-date-color, #586e75)',
36
37
  label: 'date'
37
38
  },
39
+ url: {
40
+ color: 'var(--w-rjv-type-url-color, #0969da)',
41
+ label: 'URL'
42
+ },
38
43
  null: {
39
44
  color: 'var(--w-rjv-type-null-color, #d33682)',
40
45
  label: 'null'
@@ -63,23 +68,9 @@ export var Colon = _ref => {
63
68
  children: children
64
69
  }));
65
70
  };
66
- export function ValueView(props) {
67
- var _typeMap$type;
68
- var {
69
- value,
70
- indentWidth,
71
- renderKey,
72
- renderValue,
73
- renderBraces,
74
- enableClipboard,
75
- displayObjectSize,
76
- displayDataTypes
77
- } = props,
78
- reset = _objectWithoutPropertiesLoose(props, _excluded2);
71
+ export function getValueString(value) {
79
72
  var type = typeof value;
80
73
  var content = '';
81
- var color = '';
82
- var style = {};
83
74
  if (typeof value === 'number') {
84
75
  type = isFloat(value) ? 'float' : 'number';
85
76
  content = value.toString();
@@ -92,29 +83,65 @@ export function ValueView(props) {
92
83
  type = 'date';
93
84
  content = value.toString();
94
85
  }
95
- var typeView = /*#__PURE__*/_jsx(Type, {
96
- type: type
97
- });
98
86
  if (value === null) {
99
87
  type = 'null';
100
88
  content = ("" + value).toLocaleUpperCase();
101
- typeView = /*#__PURE__*/_jsx(Fragment, {});
102
- style = {
103
- fontWeight: 'bold'
104
- };
105
89
  }
106
90
  if (value === undefined) {
107
91
  type = 'undefined';
108
92
  content = String(value);
109
- typeView = /*#__PURE__*/_jsx(Fragment, {});
110
93
  }
111
94
  if (typeof value === 'bigint') {
112
95
  type = 'bigint';
113
96
  content = value + "n";
114
97
  }
98
+ var isURL = value instanceof URL;
99
+ if (isURL) {
100
+ type = 'url';
101
+ content = "\"" + value.href + "\"";
102
+ }
115
103
  if (typeof value === 'string') {
116
104
  content = "\"" + value + "\"";
117
105
  }
106
+ return {
107
+ type,
108
+ content
109
+ };
110
+ }
111
+ export function ValueView(props) {
112
+ var _typeMap$type;
113
+ var {
114
+ value,
115
+ keyName,
116
+ indentWidth,
117
+ renderKey,
118
+ quotes,
119
+ renderValue,
120
+ renderBraces,
121
+ enableClipboard,
122
+ displayObjectSize,
123
+ displayDataTypes
124
+ } = props,
125
+ reset = _objectWithoutPropertiesLoose(props, _excluded2);
126
+ var color = '';
127
+ var style = {};
128
+ var {
129
+ type,
130
+ content
131
+ } = getValueString(value);
132
+ var typeView = /*#__PURE__*/_jsx(Type, {
133
+ type: type
134
+ });
135
+ if (value === null) {
136
+ typeView = /*#__PURE__*/_jsx(Fragment, {});
137
+ style = {
138
+ fontWeight: 'bold'
139
+ };
140
+ }
141
+ if (value === undefined) {
142
+ typeView = /*#__PURE__*/_jsx(Fragment, {});
143
+ }
144
+ var isURL = value instanceof URL;
118
145
  if (!displayDataTypes) {
119
146
  typeView = /*#__PURE__*/_jsx(Fragment, {});
120
147
  }
@@ -141,14 +168,26 @@ export function ValueView(props) {
141
168
  color
142
169
  }, style),
143
170
  type,
171
+ value,
172
+ quotes,
173
+ keyName,
174
+ visible: showTools,
144
175
  content,
145
- children: value
176
+ children: content
146
177
  });
147
178
  var valueView = reView ? reView : /*#__PURE__*/_jsx(Label, {
148
179
  color: color,
149
180
  style: style,
150
181
  className: "w-rjv-value",
151
- children: content
182
+ children: isURL ? /*#__PURE__*/_jsx("a", {
183
+ href: value.href,
184
+ style: {
185
+ color
186
+ },
187
+ target: "_blank",
188
+ rel: "noopener noreferrer",
189
+ children: content
190
+ }) : content
152
191
  });
153
192
  return /*#__PURE__*/_jsx(Line, _extends({}, eventProps, {
154
193
  children: /*#__PURE__*/_jsxs(Label, _extends({}, reset, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-json-view",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "JSON viewer for react.",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -12,6 +12,11 @@
12
12
  "types": "./cjs/index.d.ts",
13
13
  "require": "./cjs/index.js"
14
14
  },
15
+ "./editor": {
16
+ "import": "./esm/editor/index.js",
17
+ "types": "./cjs/editor/index.d.ts",
18
+ "require": "./cjs/editor/index.js"
19
+ },
15
20
  "./light": {
16
21
  "import": "./esm/theme/light.js",
17
22
  "types": "./cjs/theme/light.d.ts",
@@ -45,6 +50,7 @@
45
50
  "react-dom": ">=18.0.0"
46
51
  },
47
52
  "files": [
53
+ "editor.d.ts",
48
54
  "dark.d.ts",
49
55
  "light.d.ts",
50
56
  "triangle-arrow.d.ts",