@uiw/react-json-view 2.0.0-alpha.0 → 2.0.0-alpha.10
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 +121 -54
- package/cjs/Container.js +4 -8
- package/cjs/comps/Copied.js +15 -13
- package/cjs/comps/KeyValues.js +24 -20
- package/cjs/comps/NestedClose.js +3 -4
- package/cjs/comps/NestedOpen.js +18 -16
- package/cjs/comps/Value.js +14 -16
- package/cjs/editor/KeyName.d.ts +2 -0
- package/cjs/editor/KeyName.js +82 -0
- package/cjs/editor/index.d.ts +19 -0
- package/cjs/editor/index.js +44 -0
- package/cjs/editor/store.d.ts +28 -0
- package/cjs/editor/store.js +23 -0
- package/cjs/index.d.ts +5 -3
- package/cjs/index.js +7 -8
- package/cjs/section/Copied.d.ts +1 -1
- package/cjs/section/Copied.js +1 -2
- package/cjs/section/CountInfo.d.ts +10 -1
- package/cjs/section/CountInfo.js +42 -4
- package/cjs/section/CountInfoExtra.d.ts +10 -1
- package/cjs/section/CountInfoExtra.js +32 -4
- package/cjs/section/Ellipsis.d.ts +10 -0
- package/cjs/section/Ellipsis.js +30 -4
- package/cjs/section/KeyName.d.ts +8 -0
- package/cjs/section/KeyName.js +38 -4
- package/cjs/store/Expands.js +2 -4
- package/cjs/store/Section.d.ts +3 -2
- package/cjs/store/Section.js +2 -4
- package/cjs/store/ShowTools.js +2 -4
- package/cjs/store/Symbols.d.ts +2 -2
- package/cjs/store/Symbols.js +3 -4
- package/cjs/store/Types.d.ts +28 -24
- package/cjs/store/Types.js +8 -8
- package/cjs/store.d.ts +7 -4
- package/cjs/store.js +5 -10
- package/cjs/symbol/Arrow.d.ts +1 -1
- package/cjs/symbol/Arrow.js +1 -2
- package/cjs/symbol/BraceLeft.d.ts +1 -1
- package/cjs/symbol/BraceLeft.js +1 -2
- package/cjs/symbol/BraceRight.d.ts +1 -1
- package/cjs/symbol/BraceRight.js +1 -2
- package/cjs/symbol/BracketsLeft.d.ts +1 -1
- package/cjs/symbol/BracketsLeft.js +1 -2
- package/cjs/symbol/BracketsRight.d.ts +1 -1
- package/cjs/symbol/BracketsRight.js +1 -2
- package/cjs/symbol/Colon.d.ts +1 -1
- package/cjs/symbol/Colon.js +1 -2
- package/cjs/symbol/Quote.d.ts +1 -1
- package/cjs/symbol/Quote.js +1 -2
- package/cjs/symbol/ValueQuote.d.ts +1 -1
- package/cjs/symbol/ValueQuote.js +1 -2
- package/{esm/comps/ReRender/Symbols.d.ts → cjs/symbol/index.d.ts} +4 -6
- package/cjs/{comps/ReRender/Symbols.js → symbol/index.js} +32 -33
- package/cjs/theme/basic.js +2 -3
- package/cjs/theme/dark.js +2 -3
- package/cjs/theme/github.dark.js +2 -3
- package/cjs/theme/github.light.js +2 -3
- package/cjs/theme/gruvbox.js +2 -3
- package/cjs/theme/light.js +2 -3
- package/cjs/theme/monokai.js +2 -3
- package/cjs/theme/nord.js +2 -3
- package/cjs/theme/vscode.js +2 -3
- package/cjs/types/Bigint.d.ts +1 -1
- package/cjs/types/Bigint.js +1 -2
- package/cjs/types/Date.d.ts +1 -1
- package/cjs/types/Date.js +1 -2
- package/cjs/types/False.d.ts +1 -1
- package/cjs/types/False.js +1 -2
- package/cjs/types/Float.d.ts +1 -1
- package/cjs/types/Float.js +1 -2
- package/cjs/types/Int.d.ts +1 -1
- package/cjs/types/Int.js +1 -2
- package/cjs/types/Map.d.ts +1 -1
- package/cjs/types/Map.js +1 -2
- package/cjs/types/Nan.d.ts +1 -1
- package/cjs/types/Nan.js +1 -2
- package/cjs/types/Null.d.ts +1 -1
- package/cjs/types/Null.js +1 -2
- package/cjs/types/Set.d.ts +1 -1
- package/cjs/types/Set.js +1 -2
- package/cjs/types/String.d.ts +1 -1
- package/cjs/types/String.js +1 -2
- package/cjs/types/True.d.ts +1 -1
- package/cjs/types/True.js +1 -2
- package/cjs/types/Undefined.d.ts +1 -1
- package/cjs/types/Undefined.js +1 -2
- package/cjs/types/Url.d.ts +1 -1
- package/cjs/types/Url.js +1 -2
- package/{esm/comps/ReRender/Types.d.ts → cjs/types/index.d.ts} +8 -13
- package/cjs/{comps/ReRender/Types.js → types/index.js} +103 -121
- package/cjs/utils/useHighlight.js +0 -1
- package/cjs/utils/useRender.d.ts +1 -1
- package/editor.d.ts +22 -20
- package/esm/Container.js +4 -5
- package/esm/comps/Copied.js +14 -11
- package/esm/comps/KeyValues.js +14 -9
- package/esm/comps/NestedClose.js +1 -1
- package/esm/comps/NestedOpen.js +12 -9
- package/esm/comps/Value.js +1 -1
- package/esm/editor/KeyName.d.ts +2 -0
- package/esm/editor/KeyName.js +77 -0
- package/esm/editor/index.d.ts +19 -0
- package/esm/editor/index.js +34 -0
- package/esm/editor/store.d.ts +28 -0
- package/esm/editor/store.js +13 -0
- package/esm/index.d.ts +5 -3
- package/esm/index.js +3 -3
- package/esm/section/Copied.d.ts +1 -1
- package/esm/section/CountInfo.d.ts +10 -1
- package/esm/section/CountInfo.js +43 -1
- package/esm/section/CountInfoExtra.d.ts +10 -1
- package/esm/section/CountInfoExtra.js +32 -1
- package/esm/section/Ellipsis.d.ts +10 -0
- package/esm/section/Ellipsis.js +31 -1
- package/esm/section/KeyName.d.ts +8 -0
- package/esm/section/KeyName.js +39 -1
- package/esm/store/Section.d.ts +3 -2
- package/esm/store/Symbols.d.ts +2 -2
- package/esm/store/Symbols.js +1 -0
- package/esm/store/Types.d.ts +28 -24
- package/esm/store/Types.js +6 -4
- package/esm/store.d.ts +7 -4
- package/esm/symbol/Arrow.d.ts +1 -1
- package/esm/symbol/BraceLeft.d.ts +1 -1
- package/esm/symbol/BraceRight.d.ts +1 -1
- package/esm/symbol/BracketsLeft.d.ts +1 -1
- package/esm/symbol/BracketsRight.d.ts +1 -1
- package/esm/symbol/Colon.d.ts +1 -1
- package/esm/symbol/Quote.d.ts +1 -1
- package/esm/symbol/ValueQuote.d.ts +1 -1
- package/{cjs/comps/ReRender/Symbols.d.ts → esm/symbol/index.d.ts} +4 -6
- package/esm/{comps/ReRender/Symbols.js → symbol/index.js} +26 -24
- package/esm/types/Bigint.d.ts +1 -1
- package/esm/types/Date.d.ts +1 -1
- package/esm/types/False.d.ts +1 -1
- package/esm/types/Float.d.ts +1 -1
- package/esm/types/Int.d.ts +1 -1
- package/esm/types/Map.d.ts +1 -1
- package/esm/types/Nan.d.ts +1 -1
- package/esm/types/Null.d.ts +1 -1
- package/esm/types/Set.d.ts +1 -1
- package/esm/types/String.d.ts +1 -1
- package/esm/types/True.d.ts +1 -1
- package/esm/types/Undefined.d.ts +1 -1
- package/esm/types/Url.d.ts +1 -1
- package/{cjs/comps/ReRender/Types.d.ts → esm/types/index.d.ts} +8 -13
- package/esm/{comps/ReRender/Types.js → types/index.js} +84 -94
- package/esm/utils/useHighlight.js +0 -1
- package/esm/utils/useRender.d.ts +1 -1
- package/package.json +3 -4
- package/cjs/comps/CountInfo.d.ts +0 -19
- package/cjs/comps/CountInfo.js +0 -72
- package/cjs/comps/Ellipsis.d.ts +0 -10
- package/cjs/comps/Ellipsis.js +0 -35
- package/cjs/comps/Key.d.ts +0 -7
- package/cjs/comps/Key.js +0 -39
- package/cjs/type.d.ts +0 -50
- package/cjs/type.js +0 -57
- package/esm/comps/CountInfo.d.ts +0 -19
- package/esm/comps/CountInfo.js +0 -70
- package/esm/comps/Ellipsis.d.ts +0 -10
- package/esm/comps/Ellipsis.js +0 -31
- package/esm/comps/Key.d.ts +0 -7
- package/esm/comps/Key.js +0 -35
- package/esm/type.d.ts +0 -50
- package/esm/type.js +0 -50
package/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
react-json-view
|
|
2
2
|
===
|
|
3
3
|
|
|
4
|
+
[](https://jaywcjlove.github.io/#/sponsor)
|
|
4
5
|
[](https://github.com/uiwjs/react-json-view/actions/workflows/ci.yml)
|
|
5
6
|
[](https://www.npmjs.com/package/@uiw/react-json-view)
|
|
6
7
|
[](https://www.npmjs.com/package/@uiw/react-json-view)
|
|
7
8
|
[](https://github.com/facebook/react/releases)
|
|
8
9
|
[](https://uiwjs.github.io/react-json-view/lcov-report/)
|
|
9
10
|
|
|
10
|
-
A React component for displaying and editing javascript arrays and JSON objects.
|
|
11
|
+
A React component for displaying and editing javascript arrays and JSON objects. Preview of [**v1 documentation**](https://raw.githack.com/uiwjs/react-json-view/v1-docs/index.html) is available [here](https://raw.githack.com/uiwjs/react-json-view/v1-docs/index.html).
|
|
11
12
|
|
|
12
13
|
<!--rehype:ignore:start-->
|
|
13
14
|
<a href="https://uiwjs.github.io/react-json-view/" target="_blank">
|
|
@@ -26,11 +27,12 @@ A React component for displaying and editing javascript arrays and JSON objects.
|
|
|
26
27
|
✏️ Support editing and adding features
|
|
27
28
|
♻️ Whether to highlight updates.
|
|
28
29
|
|
|
29
|
-
The new version [**v2**](https://
|
|
30
|
+
The new version [**v2**](https://uiwjs.github.io/react-json-view/) has redesigned the API to make the code more maintainable and introduced a simpler and more flexible component customization rendering API. Each component can now have custom rendering, and the new API resembles React more closely. Preview [v2 documentation](https://uiwjs.github.io/react-json-view/) and [examples](https://uiwjs.github.io/react-json-view/).
|
|
30
31
|
|
|
31
32
|
- [x] Complete all features of displaying JSON in v1.
|
|
32
33
|
- [ ] Add editing functionality to v2.
|
|
33
|
-
- [
|
|
34
|
+
- [x] Add test cases to v2.
|
|
35
|
+
|
|
34
36
|
|
|
35
37
|
## Quick Start
|
|
36
38
|
|
|
@@ -323,13 +325,13 @@ export default function Demo() {
|
|
|
323
325
|
}}
|
|
324
326
|
>
|
|
325
327
|
<JsonView.String
|
|
326
|
-
render={({ children, ...reset }, { type }) => {
|
|
327
|
-
const isImg = /^https?.*\.(jpg|png)$/i.test(
|
|
328
|
+
render={({ children, ...reset }, { type, value, keyName }) => {
|
|
329
|
+
const isImg = /^https?.*\.(jpg|png)$/i.test(value)
|
|
328
330
|
if (type === 'type' && isImg) {
|
|
329
331
|
return <span />
|
|
330
332
|
}
|
|
331
333
|
if (type === 'value' && isImg) {
|
|
332
|
-
return <img {...reset} height="26" src={
|
|
334
|
+
return <img {...reset} height="26" src={value} />
|
|
333
335
|
}
|
|
334
336
|
}}
|
|
335
337
|
/>
|
|
@@ -414,6 +416,59 @@ export default function Demo() {
|
|
|
414
416
|
}
|
|
415
417
|
```
|
|
416
418
|
|
|
419
|
+
More in-depth customization ([#19](https://github.com/uiwjs/react-json-view/issues/19))
|
|
420
|
+
|
|
421
|
+
```tsx mdx:preview
|
|
422
|
+
import React from 'react';
|
|
423
|
+
import JsonView from '@uiw/react-json-view';
|
|
424
|
+
|
|
425
|
+
const object = {
|
|
426
|
+
_id: "ObjectId('13212hakjdhajksd')",
|
|
427
|
+
uid: "test1",
|
|
428
|
+
attival_time: new Date('Tue Sep 13 2022 14:07:44 GMT-0500 (Central Daylight Time)'),
|
|
429
|
+
__v: 0
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export default function Demo() {
|
|
433
|
+
return (
|
|
434
|
+
<JsonView
|
|
435
|
+
value={object}
|
|
436
|
+
// keyName="root"
|
|
437
|
+
displayObjectSize={false}
|
|
438
|
+
style={{
|
|
439
|
+
'--w-rjv-background-color': '#ffffff',
|
|
440
|
+
}}
|
|
441
|
+
>
|
|
442
|
+
<JsonView.Quote render={() => <span />}/>
|
|
443
|
+
<JsonView.String
|
|
444
|
+
render={({ children, ...reset }, { type, value, keyName }) => {
|
|
445
|
+
if (type === 'type') {
|
|
446
|
+
return <span />
|
|
447
|
+
}
|
|
448
|
+
if (type === 'value' && /ObjectId\(['"](.*?)['"]\)/.test(value)) {
|
|
449
|
+
return <span {...reset}>{children}</span>
|
|
450
|
+
}
|
|
451
|
+
}}
|
|
452
|
+
/>
|
|
453
|
+
<JsonView.Date
|
|
454
|
+
render={({ children, ...reset }, { type, value, keyName }) => {
|
|
455
|
+
if (type === 'type') {
|
|
456
|
+
return <span />
|
|
457
|
+
}
|
|
458
|
+
}}
|
|
459
|
+
/>
|
|
460
|
+
<JsonView.Int
|
|
461
|
+
render={({ children, ...reset }, { type, value, keyName }) => {
|
|
462
|
+
if (type === 'type') {
|
|
463
|
+
return <span />
|
|
464
|
+
}
|
|
465
|
+
}}
|
|
466
|
+
/>
|
|
467
|
+
</JsonView>
|
|
468
|
+
)
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
417
472
|
Inspector
|
|
418
473
|
|
|
419
474
|
```tsx mdx:preview
|
|
@@ -670,6 +725,49 @@ export default function Demo() {
|
|
|
670
725
|
|
|
671
726
|
## Props
|
|
672
727
|
|
|
728
|
+
Migrate from JSON View v1 to v2. The new v2 version has removed the ~~`quotes`~~ and ~~`components`~~ props.
|
|
729
|
+
|
|
730
|
+
```diff
|
|
731
|
+
export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
732
|
+
- quotes?: "'" | '"' | '';
|
|
733
|
+
- components?: {};
|
|
734
|
+
}
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
```ts
|
|
738
|
+
export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
739
|
+
/** This property contains your input JSON */
|
|
740
|
+
value?: T;
|
|
741
|
+
/** Define the root node name. @default undefined */
|
|
742
|
+
keyName?: string | number;
|
|
743
|
+
/** Whether sort keys through `String.prototype.localeCompare()` @default false */
|
|
744
|
+
objectSortKeys?: boolean | ((keyA: string, keyB: string, valueA: T, valueB: T) => number);
|
|
745
|
+
/** Set the indent-width for nested objects @default 15 */
|
|
746
|
+
indentWidth?: number;
|
|
747
|
+
/** When set to `true`, `objects` and `arrays` are labeled with size @default true */
|
|
748
|
+
displayObjectSize?: boolean;
|
|
749
|
+
/** When set to `true`, data type labels prefix values @default true */
|
|
750
|
+
displayDataTypes?: boolean;
|
|
751
|
+
/** The user can copy objects and arrays to clipboard by clicking on the clipboard icon. @default true */
|
|
752
|
+
enableClipboard?: boolean;
|
|
753
|
+
/** When set to true, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth. @default false */
|
|
754
|
+
collapsed?: boolean | number;
|
|
755
|
+
/** Whether to highlight updates. @default true */
|
|
756
|
+
highlightUpdates?: boolean;
|
|
757
|
+
/** Shorten long JSON strings, Set to `0` to disable this feature @default 30 */
|
|
758
|
+
shortenTextAfterLength?: number;
|
|
759
|
+
/** Callback function for when a treeNode is expanded or collapsed */
|
|
760
|
+
onExpand?: (props: {
|
|
761
|
+
expand: boolean;
|
|
762
|
+
value?: T;
|
|
763
|
+
keyid: string;
|
|
764
|
+
keyName?: string | number;
|
|
765
|
+
}) => void;
|
|
766
|
+
/** Fires event when you copy */
|
|
767
|
+
onCopied?: (text: string, value?: T) => void;
|
|
768
|
+
}
|
|
769
|
+
```
|
|
770
|
+
|
|
673
771
|
```ts
|
|
674
772
|
import { BraceLeft } from './symbol/BraceLeft';
|
|
675
773
|
import { BraceRight } from './symbol/BraceRight';
|
|
@@ -677,7 +775,6 @@ import { BracketsLeft } from './symbol/BracketsLeft';
|
|
|
677
775
|
import { BracketsRight } from './symbol/BracketsRight';
|
|
678
776
|
import { Arrow } from './symbol/Arrow';
|
|
679
777
|
import { Colon } from './symbol/Colon';
|
|
680
|
-
import { Ellipsis } from './symbol/Ellipsis';
|
|
681
778
|
import { Quote } from './symbol/Quote';
|
|
682
779
|
import { ValueQuote } from './symbol/ValueQuote';
|
|
683
780
|
import { Bigint } from './types/Bigint';
|
|
@@ -696,40 +793,9 @@ import { Url } from './types/Url';
|
|
|
696
793
|
import { Copied } from './section/Copied';
|
|
697
794
|
import { CountInfo } from './section/CountInfo';
|
|
698
795
|
import { CountInfoExtra } from './section/CountInfoExtra';
|
|
796
|
+
import { Ellipsis } from './section/Ellipsis';
|
|
699
797
|
import { KeyName } from './section/KeyName';
|
|
700
|
-
|
|
701
|
-
import { type CopiedOption } from "./comps/Copied";
|
|
702
|
-
import { type NestedOpenProps } from "./comps/NestedOpen";
|
|
703
|
-
export interface JsonViewProps<T extends object> extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
704
|
-
/** This property contains your input JSON */
|
|
705
|
-
value?: T;
|
|
706
|
-
/** Whether sort keys through `String.prototype.localeCompare()` @default false */
|
|
707
|
-
objectSortKeys?: boolean | ((a: string, b: string) => number);
|
|
708
|
-
/** Set the indent-width for nested objects @default 15 */
|
|
709
|
-
indentWidth?: number;
|
|
710
|
-
/** When set to `true`, `objects` and `arrays` are labeled with size @default true */
|
|
711
|
-
displayObjectSize?: boolean;
|
|
712
|
-
/** When set to `true`, data type labels prefix values @default true */
|
|
713
|
-
displayDataTypes?: boolean;
|
|
714
|
-
/** The user can copy objects and arrays to clipboard by clicking on the clipboard icon. @default true */
|
|
715
|
-
enableClipboard?: boolean;
|
|
716
|
-
/** Whether to highlight updates. @default true */
|
|
717
|
-
highlightUpdates?: boolean;
|
|
718
|
-
/** Callback function for when a treeNode is expanded or collapsed */
|
|
719
|
-
onExpand?: (props: {
|
|
720
|
-
expand: boolean;
|
|
721
|
-
value?: T;
|
|
722
|
-
keyid: string;
|
|
723
|
-
keyName?: string | number;
|
|
724
|
-
}) => void;
|
|
725
|
-
/** Fires event when you copy */
|
|
726
|
-
onCopied?: (text: string, value?: T) => void;
|
|
727
|
-
/** Redefine interface elements to re-render. */
|
|
728
|
-
components?: {
|
|
729
|
-
copied?: (props: React.SVGProps<SVGSVGElement>, opts: CopiedOption<T>) => React.ReactNode;
|
|
730
|
-
countInfoExtra?: (props: NestedOpenProps<T>) => React.ReactNode;
|
|
731
|
-
};
|
|
732
|
-
}
|
|
798
|
+
|
|
733
799
|
type JsonViewComponent = React.FC<React.PropsWithRef<JsonViewProps<object>>> & {
|
|
734
800
|
Bigint: typeof Bigint;
|
|
735
801
|
Date: typeof Date;
|
|
@@ -766,19 +832,20 @@ export default JsonView;
|
|
|
766
832
|
|
|
767
833
|
Here is the size benchmark (using [bundlephobia.com](https://bundlephobia.com)) against similar React libraries (found by [`npmjs.com/search`](https://www.npmjs.com/search?q=react%20json&ranking=popularity)):
|
|
768
834
|
|
|
769
|
-
| Library | Bundle size (gzip) | Deps | Last commit | Download | Editable |
|
|
770
|
-
| ------- | ------- | ------- | ------- | ------- | ------- |
|
|
771
|
-
|
|
|
772
|
-
| react-json-view-lite | [](https://bundlephobia.com/result?p=react-json-view-lite) [](https://bundlephobia.com/result?p=react-json-view-lite) | [](https://bundlephobia.com/result?p=react-json-view-lite) | [](https://github.com/AnyRoad/react-json-view-lite/commits) | [](https://www.npmjs.com/package/react-json-view-lite) | ❌ |
|
|
773
|
-
| react-json-pretty | [](https://bundlephobia.com/result?p=react-json-pretty) [](https://bundlephobia.com/result?p=react-json-pretty) | [](https://bundlephobia.com/result?p=react-json-pretty) | [](https://github.com/chenckang/react-json-pretty/commits) | [](https://www.npmjs.com/package/react-json-pretty) | ❌ |
|
|
774
|
-
| react-json-inspector | [](https://bundlephobia.com/result?p=react-json-inspector) [](https://bundlephobia.com/result?p=react-json-inspector) | [](https://bundlephobia.com/result?p=react-json-inspector) | [](https://github.com/Lapple/react-json-inspector/commits) | [](https://www.npmjs.com/package/react-json-inspector) | ❌ |
|
|
775
|
-
| react-json-tree | [](https://bundlephobia.com/result?p=react-json-tree) [](https://bundlephobia.com/result?p=react-json-tree) | [](https://bundlephobia.com/result?p=react-json-tree) | [](https://github.com/reduxjs/redux-devtools/commits) | [](https://www.npmjs.com/package/react-json-tree) | ❌ |
|
|
776
|
-
| ~~react-json-view~~ | [](https://bundlephobia.com/result?p=react-json-view) [](https://bundlephobia.com/result?p=react-json-view) | [](https://bundlephobia.com/result?p=react-json-view) | [](https://github.com/mac-s-g/react-json-view/commits) | [](https://www.npmjs.com/package/react-json-view) | ✅ |
|
|
777
|
-
|
|
|
778
|
-
| react-
|
|
779
|
-
|
|
|
780
|
-
|
|
|
781
|
-
|
|
|
835
|
+
| Library | Bundle size (gzip) | Deps | Last commit | Download | Editable | Demo |
|
|
836
|
+
| ------- | ------- | ------- | ------- | ------- | ------- | ------- |
|
|
837
|
+
| **[@uiw/react-json-view](https://github.com/uiwjs/react-json-view)** | [](https://bundlephobia.com/result?p=@uiw/react-json-view) [](https://bundlephobia.com/result?p=@uiw/react-json-view) | [](https://bundlephobia.com/result?p=@uiw/react-json-view) | [](https://github.com/uiwjs/react-json-view/commits) | [](https://www.npmjs.com/package/@uiw/react-json-view) | ✅ | [demo](https://uiwjs.github.io/react-json-view/) |
|
|
838
|
+
| [react-json-view-lite](https://github.com/anyroad/react-json-view-lite) | [](https://bundlephobia.com/result?p=react-json-view-lite) [](https://bundlephobia.com/result?p=react-json-view-lite) | [](https://bundlephobia.com/result?p=react-json-view-lite) | [](https://github.com/AnyRoad/react-json-view-lite/commits) | [](https://www.npmjs.com/package/react-json-view-lite) | ❌ | [demo](https://anyroad.github.io/react-json-view-lite/) |
|
|
839
|
+
| [react-json-pretty](https://github.com/chenckang/react-json-pretty) | [](https://bundlephobia.com/result?p=react-json-pretty) [](https://bundlephobia.com/result?p=react-json-pretty) | [](https://bundlephobia.com/result?p=react-json-pretty) | [](https://github.com/chenckang/react-json-pretty/commits) | [](https://www.npmjs.com/package/react-json-pretty) | ❌ | - |
|
|
840
|
+
| [~~react-json-inspector~~](https://github.com/Lapple/react-json-inspector) | [](https://bundlephobia.com/result?p=react-json-inspector) [](https://bundlephobia.com/result?p=react-json-inspector) | [](https://bundlephobia.com/result?p=react-json-inspector) | [](https://github.com/Lapple/react-json-inspector/commits) | [](https://www.npmjs.com/package/react-json-inspector) | ❌ | [demo](https://lapple.github.io/react-json-inspector/)
|
|
841
|
+
| [react-json-tree](https://github.com/reduxjs/redux-devtools/tree/main/packages/react-json-tree) | [](https://bundlephobia.com/result?p=react-json-tree) [](https://bundlephobia.com/result?p=react-json-tree) | [](https://bundlephobia.com/result?p=react-json-tree) | [](https://github.com/reduxjs/redux-devtools/commits) | [](https://www.npmjs.com/package/react-json-tree) | ❌ |
|
|
842
|
+
| ~~[react-json-view](https://github.com/mac-s-g/react-json-view)~~ | [](https://bundlephobia.com/result?p=react-json-view) [](https://bundlephobia.com/result?p=react-json-view) | [](https://bundlephobia.com/result?p=react-json-view) | [](https://github.com/mac-s-g/react-json-view/commits) | [](https://www.npmjs.com/package/react-json-view) | ✅ | [demo](https://mac-s-g.github.io/react-json-view/demo/dist/) |
|
|
843
|
+
| [react-inspector](https://github.com/storybookjs/react-inspector) | [](https://bundlephobia.com/result?p=react-inspector) [](https://bundlephobia.com/result?p=react-inspector) | [](https://bundlephobia.com/result?p=react-inspector) | [](https://github.com/storybookjs/react-inspector/commits) | [](https://www.npmjs.com/package/react-inspector) | ❌ | [demo](https://react-inspector.netlify.app/) |
|
|
844
|
+
| [react-domify](https://github.com/JedWatson/react-domify) | [](https://bundlephobia.com/result?p=react-domify) [](https://bundlephobia.com/result?p=react-domify) | [](https://bundlephobia.com/result?p=react-domify) | [](https://github.com/JedWatson/react-domify/commits) | [](https://www.npmjs.com/package/react-domify) | ❌ | [demo](https://jedwatson.github.io/react-domify/) |
|
|
845
|
+
| [react18-json-view](https://github.com/YYsuni/react18-json-view) | [](https://bundlephobia.com/result?p=react18-json-view) [](https://bundlephobia.com/result?p=react18-json-view) | [](https://bundlephobia.com/result?p=react18-json-view) | [](https://github.com/YYsuni/react18-json-view/commits) | [](https://www.npmjs.com/package/react18-json-view) | ❌ | [demo](https://jv.yysuni.com/) |
|
|
846
|
+
| [@textea/json-viewer](https://github.com/TexteaInc/json-viewer) | [](https://bundlephobia.com/result?p=@textea/json-viewer) [](https://bundlephobia.com/result?p=@textea/json-viewer) | [](https://bundlephobia.com/result?p=@textea/json-viewer) | [](https://github.com/TexteaInc/json-viewer/commits) | [](https://www.npmjs.com/package/@textea/json-viewer) | ✅ | [demo](https://stackblitz.com/edit/textea-json-viewer-v3-b4wgxq) |
|
|
847
|
+
| [react-editable-json-tree](https://github.com/oxyno-zeta/react-editable-json-tree) | [](https://bundlephobia.com/result?p=react-editable-json-tree) [](https://bundlephobia.com/result?p=react-editable-json-tree) | [](https://bundlephobia.com/result?p=react-editable-json-tree) | [](https://github.com/TexteaInc/json-viewer/commits) | [](https://www.npmjs.com/package/react-editable-json-tree) | ✅ | [demo](https://oxyno-zeta.github.io/react-editable-json-tree/) |
|
|
848
|
+
| [react-json-view](https://github.com/HuolalaTech/react-json-view) | [](https://bundlephobia.com/result?p=@huolala-tech/react-json-view) [](https://bundlephobia.com/result?p=@huolala-tech/react-json-view) | [](https://bundlephobia.com/result?p=@huolala-tech/react-json-view) | [](https://github.com/HuolalaTech/react-json-view/commits) | [](https://www.npmjs.com/package/@huolala-tech/react-json-view) | ❌ | [demo](https://huolalatech.github.io/react-json-view/) |
|
|
782
849
|
|
|
783
850
|
## Development
|
|
784
851
|
|
|
@@ -809,7 +876,7 @@ As always, thanks to our amazing contributors!
|
|
|
809
876
|
<img src="https://uiwjs.github.io/react-json-view/CONTRIBUTORS.svg" />
|
|
810
877
|
</a>
|
|
811
878
|
|
|
812
|
-
Made with [
|
|
879
|
+
Made with [contributors](https://github.com/jaywcjlove/github-action-contributors).
|
|
813
880
|
|
|
814
881
|
## License
|
|
815
882
|
|
package/cjs/Container.js
CHANGED
|
@@ -16,7 +16,7 @@ var _KeyValues = require("./comps/KeyValues");
|
|
|
16
16
|
var _ShowTools = require("./store/ShowTools");
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
18
|
var _excluded = ["className", "children", "parentValue", "keyid", "level", "value", "initialValue", "keyName"];
|
|
19
|
-
var Container = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
19
|
+
var Container = exports.Container = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
20
20
|
var _props$className = props.className,
|
|
21
21
|
className = _props$className === void 0 ? '' : _props$className,
|
|
22
22
|
children = props.children,
|
|
@@ -28,13 +28,9 @@ var Container = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
28
28
|
initialValue = props.initialValue,
|
|
29
29
|
keyName = props.keyName,
|
|
30
30
|
elmProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
31
|
-
var $ref = (0, _react.useRef)(null);
|
|
32
31
|
var dispatch = (0, _ShowTools.useShowToolsDispatch)();
|
|
33
|
-
(0, _react.useImperativeHandle)(ref, function () {
|
|
34
|
-
return $ref.current;
|
|
35
|
-
}, [$ref]);
|
|
36
32
|
var subkeyid = (0, _react.useId)();
|
|
37
|
-
var defaultClassNames =
|
|
33
|
+
var defaultClassNames = [className, 'w-rjv-inner'].filter(Boolean).join(' ');
|
|
38
34
|
var reset = {
|
|
39
35
|
onMouseEnter: function onMouseEnter() {
|
|
40
36
|
return dispatch((0, _defineProperty2["default"])({}, subkeyid, true));
|
|
@@ -44,7 +40,8 @@ var Container = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
44
40
|
}
|
|
45
41
|
};
|
|
46
42
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
47
|
-
className: defaultClassNames
|
|
43
|
+
className: defaultClassNames,
|
|
44
|
+
ref: ref
|
|
48
45
|
}, elmProps), reset), {}, {
|
|
49
46
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_NestedOpen.NestedOpen, {
|
|
50
47
|
expandKey: subkeyid,
|
|
@@ -63,5 +60,4 @@ var Container = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
63
60
|
})]
|
|
64
61
|
}));
|
|
65
62
|
});
|
|
66
|
-
exports.Container = Container;
|
|
67
63
|
Container.displayName = 'JVR.Container';
|
package/cjs/comps/Copied.js
CHANGED
|
@@ -15,7 +15,7 @@ var _Section = require("../store/Section");
|
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
var _excluded = ["keyName", "value", "expandKey"],
|
|
17
17
|
_excluded2 = ["as", "render"];
|
|
18
|
-
var Copied = function Copied(props) {
|
|
18
|
+
var Copied = exports.Copied = function Copied(props) {
|
|
19
19
|
var keyName = props.keyName,
|
|
20
20
|
value = props.value,
|
|
21
21
|
expandKey = props.expandKey,
|
|
@@ -35,18 +35,21 @@ var Copied = function Copied(props) {
|
|
|
35
35
|
if (enableClipboard === false || !isShowTools) return null;
|
|
36
36
|
var click = function click(event) {
|
|
37
37
|
event.stopPropagation();
|
|
38
|
-
var copyText =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
38
|
+
var copyText = '';
|
|
39
|
+
if (typeof value === 'number' && value === Infinity) {
|
|
40
|
+
copyText = 'Infinity';
|
|
41
|
+
} else if (typeof value === 'number' && isNaN(value)) {
|
|
42
|
+
copyText = 'NaN';
|
|
43
|
+
} else if (typeof value === 'bigint') {
|
|
44
|
+
copyText = value + 'n';
|
|
45
|
+
} else if (value instanceof Date) {
|
|
46
|
+
copyText = value.toLocaleString();
|
|
47
|
+
} else {
|
|
48
|
+
copyText = JSON.stringify(value, null, 2);
|
|
49
|
+
}
|
|
50
|
+
onCopied && onCopied(copyText, value);
|
|
51
|
+
setCopied(true);
|
|
47
52
|
navigator.clipboard.writeText(copyText).then(function () {
|
|
48
|
-
onCopied && onCopied(copyText, value);
|
|
49
|
-
setCopied(true);
|
|
50
53
|
var timer = setTimeout(function () {
|
|
51
54
|
setCopied(false);
|
|
52
55
|
clearTimeout(timer);
|
|
@@ -86,5 +89,4 @@ var Copied = function Copied(props) {
|
|
|
86
89
|
})
|
|
87
90
|
}));
|
|
88
91
|
};
|
|
89
|
-
exports.Copied = Copied;
|
|
90
92
|
Copied.displayName = 'JVR.Copied';
|
package/cjs/comps/KeyValues.js
CHANGED
|
@@ -14,12 +14,12 @@ var _store = require("../store");
|
|
|
14
14
|
var _Expands = require("../store/Expands");
|
|
15
15
|
var _ShowTools = require("../store/ShowTools");
|
|
16
16
|
var _Value = require("./Value");
|
|
17
|
-
var
|
|
17
|
+
var _KeyName = require("../section/KeyName");
|
|
18
18
|
var _Container = require("../Container");
|
|
19
|
-
var
|
|
19
|
+
var _symbol = require("../symbol");
|
|
20
20
|
var _useHighlight = require("../utils/useHighlight");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
var KeyValues = function KeyValues(props) {
|
|
22
|
+
var KeyValues = exports.KeyValues = function KeyValues(props) {
|
|
23
23
|
var _expands$expandKey;
|
|
24
24
|
var value = props.value,
|
|
25
25
|
_props$expandKey = props.expandKey,
|
|
@@ -47,11 +47,13 @@ var KeyValues = function KeyValues(props) {
|
|
|
47
47
|
b = _ref4[0];
|
|
48
48
|
return typeof a === 'string' && typeof b === 'string' ? a.localeCompare(b) : 0;
|
|
49
49
|
}) : entries.sort(function (_ref5, _ref6) {
|
|
50
|
-
var _ref7 = (0, _slicedToArray2["default"])(_ref5,
|
|
51
|
-
a = _ref7[0]
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
var _ref7 = (0, _slicedToArray2["default"])(_ref5, 2),
|
|
51
|
+
a = _ref7[0],
|
|
52
|
+
valA = _ref7[1];
|
|
53
|
+
var _ref8 = (0, _slicedToArray2["default"])(_ref6, 2),
|
|
54
|
+
b = _ref8[0],
|
|
55
|
+
valB = _ref8[1];
|
|
56
|
+
return typeof a === 'string' && typeof b === 'string' ? objectSortKeys(a, b, valA, valB) : 0;
|
|
55
57
|
});
|
|
56
58
|
}
|
|
57
59
|
var style = {
|
|
@@ -75,10 +77,10 @@ var KeyValues = function KeyValues(props) {
|
|
|
75
77
|
})
|
|
76
78
|
});
|
|
77
79
|
};
|
|
78
|
-
exports.KeyValues = KeyValues;
|
|
79
80
|
KeyValues.displayName = 'JVR.KeyValues';
|
|
80
|
-
var KayName = function KayName(props) {
|
|
81
|
+
var KayName = exports.KayName = function KayName(props) {
|
|
81
82
|
var keyName = props.keyName,
|
|
83
|
+
parentValue = props.parentValue,
|
|
82
84
|
value = props.value;
|
|
83
85
|
var _useStore2 = (0, _store.useStore)(),
|
|
84
86
|
highlightUpdates = _useStore2.highlightUpdates;
|
|
@@ -92,21 +94,23 @@ var KayName = function KayName(props) {
|
|
|
92
94
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
93
95
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
94
96
|
ref: highlightContainer,
|
|
95
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
96
|
-
isNumber: isNumber
|
|
97
|
-
|
|
97
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.Quote, {
|
|
98
|
+
isNumber: isNumber,
|
|
99
|
+
"data-placement": "left"
|
|
100
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_KeyName.KeyNameComp, {
|
|
98
101
|
keyName: keyName,
|
|
99
102
|
value: value,
|
|
103
|
+
parentValue: parentValue,
|
|
100
104
|
children: keyName
|
|
101
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
102
|
-
isNumber: isNumber
|
|
105
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.Quote, {
|
|
106
|
+
isNumber: isNumber,
|
|
107
|
+
"data-placement": "right"
|
|
103
108
|
})]
|
|
104
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
109
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.Colon, {})]
|
|
105
110
|
});
|
|
106
111
|
};
|
|
107
|
-
exports.KayName = KayName;
|
|
108
112
|
KayName.displayName = 'JVR.KayName';
|
|
109
|
-
var KeyValuesItem = function KeyValuesItem(props) {
|
|
113
|
+
var KeyValuesItem = exports.KeyValuesItem = function KeyValuesItem(props) {
|
|
110
114
|
var keyName = props.keyName,
|
|
111
115
|
value = props.value,
|
|
112
116
|
parentValue = props.parentValue,
|
|
@@ -144,7 +148,8 @@ var KeyValuesItem = function KeyValuesItem(props) {
|
|
|
144
148
|
}, reset), {}, {
|
|
145
149
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(KayName, {
|
|
146
150
|
keyName: keyName,
|
|
147
|
-
value: value
|
|
151
|
+
value: value,
|
|
152
|
+
parentValue: parentValue
|
|
148
153
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Value.Value, {
|
|
149
154
|
keyName: keyName,
|
|
150
155
|
value: value,
|
|
@@ -152,5 +157,4 @@ var KeyValuesItem = function KeyValuesItem(props) {
|
|
|
152
157
|
})]
|
|
153
158
|
}));
|
|
154
159
|
};
|
|
155
|
-
exports.KeyValuesItem = KeyValuesItem;
|
|
156
160
|
KeyValuesItem.displayName = 'JVR.KeyValuesItem';
|
package/cjs/comps/NestedClose.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.NestedClose = void 0;
|
|
7
7
|
var _store = require("../store");
|
|
8
8
|
var _Expands = require("../store/Expands");
|
|
9
|
-
var
|
|
9
|
+
var _symbol = require("../symbol");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
var NestedClose = function NestedClose(props) {
|
|
11
|
+
var NestedClose = exports.NestedClose = function NestedClose(props) {
|
|
12
12
|
var _expands$expandKey;
|
|
13
13
|
var value = props.value,
|
|
14
14
|
expandKey = props.expandKey,
|
|
@@ -28,11 +28,10 @@ var NestedClose = function NestedClose(props) {
|
|
|
28
28
|
};
|
|
29
29
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
30
30
|
style: style,
|
|
31
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
31
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.BracketsClose, {
|
|
32
32
|
isBrackets: isArray || isMySet,
|
|
33
33
|
isVisiable: true
|
|
34
34
|
})
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
exports.NestedClose = NestedClose;
|
|
38
37
|
NestedClose.displayName = 'JVR.NestedClose';
|
package/cjs/comps/NestedOpen.js
CHANGED
|
@@ -12,12 +12,13 @@ var _KeyValues = require("./KeyValues");
|
|
|
12
12
|
var _Expands = require("../store/Expands");
|
|
13
13
|
var _store = require("../store");
|
|
14
14
|
var _Copied = require("./Copied");
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
15
|
+
var _CountInfoExtra = require("../section/CountInfoExtra");
|
|
16
|
+
var _CountInfo = require("../section/CountInfo");
|
|
17
|
+
var _symbol = require("../symbol");
|
|
18
|
+
var _Ellipsis = require("../section/Ellipsis");
|
|
19
|
+
var _types = require("../types");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
var NestedOpen = function NestedOpen(props) {
|
|
21
|
+
var NestedOpen = exports.NestedOpen = function NestedOpen(props) {
|
|
21
22
|
var _expands$expandKey;
|
|
22
23
|
var keyName = props.keyName,
|
|
23
24
|
expandKey = props.expandKey,
|
|
@@ -60,28 +61,30 @@ var NestedOpen = function NestedOpen(props) {
|
|
|
60
61
|
reset.onClick = click;
|
|
61
62
|
}
|
|
62
63
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
|
|
63
|
-
children: [showArrow && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
64
|
+
children: [showArrow && /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.Arrow, {
|
|
64
65
|
style: arrowStyle,
|
|
65
66
|
expandKey: expandKey
|
|
66
67
|
}), (keyName || typeof keyName === 'number') && /*#__PURE__*/(0, _jsxRuntime.jsx)(_KeyValues.KayName, {
|
|
67
68
|
keyName: keyName
|
|
68
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_types.SetComp, {
|
|
70
|
+
value: initialValue,
|
|
71
|
+
keyName: keyName
|
|
72
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_types.MapComp, {
|
|
73
|
+
value: initialValue,
|
|
74
|
+
keyName: keyName
|
|
75
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.BracketsOpen, {
|
|
73
76
|
isBrackets: isArray || isMySet
|
|
74
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Ellipsis.
|
|
77
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Ellipsis.EllipsisComp, {
|
|
75
78
|
keyName: keyName,
|
|
76
79
|
value: value,
|
|
77
80
|
isExpanded: isExpanded
|
|
78
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
81
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_symbol.BracketsClose, {
|
|
79
82
|
isVisiable: isExpanded || !showArrow,
|
|
80
83
|
isBrackets: isArray || isMySet
|
|
81
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CountInfo.
|
|
84
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CountInfo.CountInfoComp, {
|
|
82
85
|
value: value,
|
|
83
86
|
keyName: keyName
|
|
84
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
87
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CountInfoExtra.CountInfoExtraComps, {
|
|
85
88
|
value: value,
|
|
86
89
|
keyName: keyName
|
|
87
90
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Copied.Copied, {
|
|
@@ -91,5 +94,4 @@ var NestedOpen = function NestedOpen(props) {
|
|
|
91
94
|
})]
|
|
92
95
|
}));
|
|
93
96
|
};
|
|
94
|
-
exports.NestedOpen = NestedOpen;
|
|
95
97
|
NestedOpen.displayName = 'JVR.NestedOpen';
|