@uiw/react-json-view 1.10.0 → 1.11.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 CHANGED
@@ -11,10 +11,7 @@ A React component for displaying and editing javascript arrays and JSON objects.
11
11
 
12
12
  <!--rehype:ignore:start-->
13
13
  <a href="https://uiwjs.github.io/react-json-view/" target="_blank">
14
- <img width="360" alt="react-json-view" src="https://github.com/uiwjs/react-json-view/assets/1680273/b8b8300b-2a43-4173-878b-73e50cfac19c" />
15
- </a>
16
- <a href="https://uiwjs.github.io/react-json-view/" target="_blank">
17
- <img width="360" alt="react-json-view" src="https://github.com/uiwjs/react-code-preview-layout/assets/1680273/da8e8499-6de3-4d4f-8316-8b2a3b616170" />
14
+ <img width="650" alt="react-json-view" src="https://github.com/uiwjs/react-json-view/assets/1680273/1c19bd72-f2ad-4d21-8708-cb30f3059cfd" />
18
15
  </a>
19
16
 
20
17
  <!--rehype:ignore:end-->
@@ -91,6 +88,7 @@ import { githubDarkTheme } from '@uiw/react-json-view/githubDark';
91
88
  import { vscodeTheme } from '@uiw/react-json-view/vscode';
92
89
  import { gruvboxTheme } from '@uiw/react-json-view/gruvbox';
93
90
  import { monokaiTheme } from '@uiw/react-json-view/monokai';
91
+ import { basicTheme } from '@uiw/react-json-view/basic';
94
92
 
95
93
  const object = {
96
94
  string: 'Lorem ipsum dolor sit amet',
@@ -115,6 +113,7 @@ export default function Demo() {
115
113
  <JsonView value={object} style={gruvboxTheme} />
116
114
  <JsonView value={object} style={vscodeTheme} />
117
115
  <JsonView value={object} style={monokaiTheme} />
116
+ <JsonView value={object} style={basicTheme} />
118
117
  </div>
119
118
  );
120
119
  }
@@ -151,6 +150,7 @@ const customTheme = {
151
150
  '--w-rjv-copied-success-color': '#28a745',
152
151
 
153
152
  '--w-rjv-curlybraces-color': '#d4d4d4',
153
+ '--w-rjv-colon-color': '#d4d4d4',
154
154
  '--w-rjv-brackets-color': '#d4d4d4',
155
155
 
156
156
  '--w-rjv-type-string-color': '#ce9178',
@@ -190,6 +190,7 @@ const object = {
190
190
  null: null,
191
191
  undefined,
192
192
  timer: 0,
193
+ nan: NaN,
193
194
  url: new URL('https://example.com'),
194
195
  date: new Date('Tue Sep 13 2022 14:07:44 GMT-0500 (Central Daylight Time)'),
195
196
  array: [19, 100.86, 'test', NaN, Infinity],
@@ -121,6 +121,9 @@ function ReValue(props) {
121
121
  } else if (typeof text === 'string' && /^(null)$/gi.test(text)) {
122
122
  text = null;
123
123
  _typeStr = 'null';
124
+ } else if (typeof text === 'string' && /^(NaN)$/gi.test(text)) {
125
+ text = NaN;
126
+ _typeStr = 'NaN';
124
127
  } else if (typeof text === 'string' && /^(undefined)$/gi.test(text)) {
125
128
  text = undefined;
126
129
  _typeStr = 'undefined';
@@ -183,7 +186,7 @@ function ReValue(props) {
183
186
  var typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_value.Type, {
184
187
  type: typeStr
185
188
  });
186
- if (typeStr === 'null' || typeStr === 'undefined') {
189
+ if (typeStr === 'null' || typeStr === 'undefined' || type.toLocaleLowerCase() === 'nan') {
187
190
  typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
188
191
  }
189
192
  var deleteHandle = function deleteHandle(_x) {
package/cjs/index.js CHANGED
@@ -57,7 +57,8 @@ var JsonView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
57
57
  lineHeight: 1.4,
58
58
  fontFamily: 'var(--w-rjv-font-family, Menlo, monospace)',
59
59
  color: 'var(--w-rjv-color, #002b36)',
60
- backgroundColor: 'var(--w-rjv-background-color, #00000000)'
60
+ backgroundColor: 'var(--w-rjv-background-color, #00000000)',
61
+ fontSize: 13
61
62
  }, style);
62
63
  var cls = "w-json-view-container w-rjv ".concat(className || '');
63
64
  var keyid = (0, _react.useId)();
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const basicTheme: import("react").CSSProperties;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.basicTheme = void 0;
7
+ var basicTheme = {
8
+ '--w-rjv-font-family': 'monospace',
9
+ '--w-rjv-color': '#b5bd68',
10
+ '--w-rjv-background-color': '#2E3235',
11
+ '--w-rjv-line-color': '#292d30',
12
+ '--w-rjv-arrow-color': 'var(--w-rjv-color)',
13
+ '--w-rjv-edit-color': 'var(--w-rjv-color)',
14
+ '--w-rjv-info-color': '#d8d8d84d',
15
+ '--w-rjv-update-color': '#b5bd68',
16
+ '--w-rjv-copied-color': '#b5bd68',
17
+ '--w-rjv-copied-success-color': '#28a745',
18
+ '--w-rjv-curlybraces-color': '#cc99cc',
19
+ '--w-rjv-colon-color': '#bababa',
20
+ '--w-rjv-brackets-color': '#808080',
21
+ '--w-rjv-type-string-color': '#b5bd68',
22
+ '--w-rjv-type-int-color': '#fda331',
23
+ '--w-rjv-type-float-color': '#fda331',
24
+ '--w-rjv-type-bigint-color': '#fda331',
25
+ '--w-rjv-type-boolean-color': '#fda331',
26
+ '--w-rjv-type-date-color': '#8abeb7',
27
+ '--w-rjv-type-url-color': '#5a89c0',
28
+ '--w-rjv-type-null-color': '#8abeb7',
29
+ '--w-rjv-type-nan-color': '#8abeb7',
30
+ '--w-rjv-type-undefined-color': '#8abeb7'
31
+ };
32
+ exports.basicTheme = basicTheme;
package/cjs/value.js CHANGED
@@ -218,13 +218,10 @@ function ValueView(props) {
218
218
  fontWeight: 'bold'
219
219
  };
220
220
  }
221
- if (value === undefined || type === 'NaN') {
221
+ if (value === undefined || type.toLocaleLowerCase() === 'nan' || !displayDataTypes) {
222
222
  typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
223
223
  }
224
224
  var isURL = value instanceof URL;
225
- if (!displayDataTypes) {
226
- typeView = /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
227
- }
228
225
  color = ((_typeMap$type = typeMap[type]) === null || _typeMap$type === void 0 ? void 0 : _typeMap$type.color) || '';
229
226
  var _useState3 = (0, _react.useState)(false),
230
227
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
@@ -93,6 +93,9 @@ export function ReValue(props) {
93
93
  } else if (typeof text === 'string' && /^(null)$/gi.test(text)) {
94
94
  text = null;
95
95
  _typeStr = 'null';
96
+ } else if (typeof text === 'string' && /^(NaN)$/gi.test(text)) {
97
+ text = NaN;
98
+ _typeStr = 'NaN';
96
99
  } else if (typeof text === 'string' && /^(undefined)$/gi.test(text)) {
97
100
  text = undefined;
98
101
  _typeStr = 'undefined';
@@ -149,7 +152,7 @@ export function ReValue(props) {
149
152
  var typeView = /*#__PURE__*/_jsx(Type, {
150
153
  type: typeStr
151
154
  });
152
- if (typeStr === 'null' || typeStr === 'undefined') {
155
+ if (typeStr === 'null' || typeStr === 'undefined' || type.toLocaleLowerCase() === 'nan') {
153
156
  typeView = /*#__PURE__*/_jsx(Fragment, {});
154
157
  }
155
158
  var deleteHandle = function deleteHandle(_x) {
package/esm/index.js CHANGED
@@ -19,7 +19,8 @@ var JsonView = /*#__PURE__*/forwardRef((props, ref) => {
19
19
  lineHeight: 1.4,
20
20
  fontFamily: 'var(--w-rjv-font-family, Menlo, monospace)',
21
21
  color: 'var(--w-rjv-color, #002b36)',
22
- backgroundColor: 'var(--w-rjv-background-color, #00000000)'
22
+ backgroundColor: 'var(--w-rjv-background-color, #00000000)',
23
+ fontSize: 13
23
24
  }, style);
24
25
  var cls = "w-json-view-container w-rjv " + (className || '');
25
26
  var keyid = useId();
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const basicTheme: import("react").CSSProperties;
@@ -0,0 +1,25 @@
1
+ export var basicTheme = {
2
+ '--w-rjv-font-family': 'monospace',
3
+ '--w-rjv-color': '#b5bd68',
4
+ '--w-rjv-background-color': '#2E3235',
5
+ '--w-rjv-line-color': '#292d30',
6
+ '--w-rjv-arrow-color': 'var(--w-rjv-color)',
7
+ '--w-rjv-edit-color': 'var(--w-rjv-color)',
8
+ '--w-rjv-info-color': '#d8d8d84d',
9
+ '--w-rjv-update-color': '#b5bd68',
10
+ '--w-rjv-copied-color': '#b5bd68',
11
+ '--w-rjv-copied-success-color': '#28a745',
12
+ '--w-rjv-curlybraces-color': '#cc99cc',
13
+ '--w-rjv-colon-color': '#bababa',
14
+ '--w-rjv-brackets-color': '#808080',
15
+ '--w-rjv-type-string-color': '#b5bd68',
16
+ '--w-rjv-type-int-color': '#fda331',
17
+ '--w-rjv-type-float-color': '#fda331',
18
+ '--w-rjv-type-bigint-color': '#fda331',
19
+ '--w-rjv-type-boolean-color': '#fda331',
20
+ '--w-rjv-type-date-color': '#8abeb7',
21
+ '--w-rjv-type-url-color': '#5a89c0',
22
+ '--w-rjv-type-null-color': '#8abeb7',
23
+ '--w-rjv-type-nan-color': '#8abeb7',
24
+ '--w-rjv-type-undefined-color': '#8abeb7'
25
+ };
package/esm/value.js CHANGED
@@ -201,13 +201,10 @@ export function ValueView(props) {
201
201
  fontWeight: 'bold'
202
202
  };
203
203
  }
204
- if (value === undefined || type === 'NaN') {
204
+ if (value === undefined || type.toLocaleLowerCase() === 'nan' || !displayDataTypes) {
205
205
  typeView = /*#__PURE__*/_jsx(Fragment, {});
206
206
  }
207
207
  var isURL = value instanceof URL;
208
- if (!displayDataTypes) {
209
- typeView = /*#__PURE__*/_jsx(Fragment, {});
210
- }
211
208
  color = ((_typeMap$type = typeMap[type]) == null ? void 0 : _typeMap$type.color) || '';
212
209
  var [showTools, setShowTools] = useState(false);
213
210
  var tools = useMemo(() => enableClipboard && showTools && /*#__PURE__*/_jsx(Copied, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-json-view",
3
- "version": "1.10.0",
3
+ "version": "1.11.1",
4
4
  "description": "JSON viewer for react.",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -37,6 +37,11 @@
37
37
  "types": "./cjs/theme/vscode.d.ts",
38
38
  "require": "./cjs/theme/vscode.js"
39
39
  },
40
+ "./basic": {
41
+ "import": "./esm/theme/basic.js",
42
+ "types": "./cjs/theme/basic.d.ts",
43
+ "require": "./cjs/theme/basic.js"
44
+ },
40
45
  "./monokai": {
41
46
  "import": "./esm/theme/monokai.js",
42
47
  "types": "./cjs/theme/monokai.d.ts",