@uiw/react-json-view 2.0.0-alpha.6 → 2.0.0-alpha.7
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/cjs/comps/Copied.js +14 -11
- package/cjs/store/Types.d.ts +27 -24
- package/cjs/store/Types.js +7 -6
- package/cjs/store.d.ts +7 -4
- package/cjs/types/index.js +1 -1
- package/esm/comps/Copied.js +14 -11
- package/esm/store/Types.d.ts +27 -24
- package/esm/store/Types.js +6 -4
- package/esm/store.d.ts +7 -4
- package/esm/types/index.js +1 -1
- package/package.json +1 -1
package/cjs/comps/Copied.js
CHANGED
|
@@ -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);
|
package/cjs/store/Types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropsWithChildren, ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
export type TagType = React.ElementType | keyof JSX.IntrinsicElements;
|
|
3
|
-
type TypesElementProps<T extends TagType> = {
|
|
3
|
+
type TypesElementProps<T extends TagType = 'span'> = {
|
|
4
4
|
as?: T;
|
|
5
5
|
render?: (props: TypesElement<T>, result: {
|
|
6
6
|
type: 'type' | 'value';
|
|
@@ -9,24 +9,24 @@ type TypesElementProps<T extends TagType> = {
|
|
|
9
9
|
'data-type'?: string;
|
|
10
10
|
};
|
|
11
11
|
export type TypesElement<T extends TagType> = TypesElementProps<T> & ComponentPropsWithoutRef<T>;
|
|
12
|
-
export type InitialTypesState = {
|
|
12
|
+
export type InitialTypesState<T extends TagType = 'span'> = {
|
|
13
13
|
displayDataTypes?: boolean;
|
|
14
|
-
Url?: TypesElement<
|
|
15
|
-
Str?: TypesElement<
|
|
16
|
-
Undefined?: TypesElement<
|
|
17
|
-
Null?: TypesElement<
|
|
18
|
-
True?: TypesElement<
|
|
19
|
-
False?: TypesElement<
|
|
20
|
-
Date?: TypesElement<
|
|
21
|
-
Float?: TypesElement<
|
|
22
|
-
Set?: TypesElement<
|
|
23
|
-
Int?: TypesElement<
|
|
24
|
-
Map?: TypesElement<
|
|
25
|
-
Nan?: TypesElement<
|
|
26
|
-
Bigint?: TypesElement<
|
|
14
|
+
Url?: TypesElement<T>;
|
|
15
|
+
Str?: TypesElement<T>;
|
|
16
|
+
Undefined?: TypesElement<T>;
|
|
17
|
+
Null?: TypesElement<T>;
|
|
18
|
+
True?: TypesElement<T>;
|
|
19
|
+
False?: TypesElement<T>;
|
|
20
|
+
Date?: TypesElement<T>;
|
|
21
|
+
Float?: TypesElement<T>;
|
|
22
|
+
Set?: TypesElement<T>;
|
|
23
|
+
Int?: TypesElement<T>;
|
|
24
|
+
Map?: TypesElement<T>;
|
|
25
|
+
Nan?: TypesElement<T>;
|
|
26
|
+
Bigint?: TypesElement<T>;
|
|
27
27
|
};
|
|
28
|
-
type Dispatch = React.Dispatch<InitialTypesState
|
|
29
|
-
export declare const useTypesStore: () => InitialTypesState
|
|
28
|
+
type Dispatch<T extends TagType> = React.Dispatch<InitialTypesState<T>>;
|
|
29
|
+
export declare const useTypesStore: () => InitialTypesState<TagType>;
|
|
30
30
|
export declare function useTypes(): [{
|
|
31
31
|
displayDataTypes?: boolean | undefined;
|
|
32
32
|
Url?: TypesElement<TagType> | undefined;
|
|
@@ -42,11 +42,14 @@ export declare function useTypes(): [{
|
|
|
42
42
|
Map?: TypesElement<TagType> | undefined;
|
|
43
43
|
Nan?: TypesElement<TagType> | undefined;
|
|
44
44
|
Bigint?: TypesElement<TagType> | undefined;
|
|
45
|
-
}, import("react").Dispatch<InitialTypesState
|
|
46
|
-
export declare function useTypesDispatch(): Dispatch
|
|
47
|
-
interface TypesProps {
|
|
48
|
-
initial: InitialTypesState
|
|
49
|
-
dispatch: Dispatch
|
|
45
|
+
}, import("react").Dispatch<InitialTypesState<TagType>>];
|
|
46
|
+
export declare function useTypesDispatch(): Dispatch<TagType>;
|
|
47
|
+
interface TypesProps<T extends TagType> {
|
|
48
|
+
initial: InitialTypesState<T>;
|
|
49
|
+
dispatch: Dispatch<TagType>;
|
|
50
|
+
}
|
|
51
|
+
export declare function Types<T extends TagType>({ initial, dispatch, children }: PropsWithChildren<TypesProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export declare namespace Types {
|
|
53
|
+
var displayName: string;
|
|
50
54
|
}
|
|
51
|
-
export declare const Types: FC<PropsWithChildren<TypesProps>>;
|
|
52
55
|
export {};
|
package/cjs/store/Types.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.Types =
|
|
7
|
+
exports.Types = Types;
|
|
8
8
|
exports.useTypes = useTypes;
|
|
9
9
|
exports.useTypesDispatch = useTypesDispatch;
|
|
10
10
|
exports.useTypesStore = void 0;
|
|
@@ -50,7 +50,8 @@ var initialState = {
|
|
|
50
50
|
},
|
|
51
51
|
Map: {
|
|
52
52
|
style: {
|
|
53
|
-
color: 'var(--w-rjv-type-map-color, #268bd2)'
|
|
53
|
+
color: 'var(--w-rjv-type-map-color, #268bd2)',
|
|
54
|
+
marginRight: 3
|
|
54
55
|
},
|
|
55
56
|
as: 'span',
|
|
56
57
|
'data-type': 'map',
|
|
@@ -86,7 +87,8 @@ var initialState = {
|
|
|
86
87
|
},
|
|
87
88
|
Set: {
|
|
88
89
|
style: {
|
|
89
|
-
color: 'var(--w-rjv-type-set-color, #268bd2)'
|
|
90
|
+
color: 'var(--w-rjv-type-set-color, #268bd2)',
|
|
91
|
+
marginRight: 3
|
|
90
92
|
},
|
|
91
93
|
as: 'span',
|
|
92
94
|
'data-type': 'set',
|
|
@@ -146,7 +148,7 @@ function useTypes() {
|
|
|
146
148
|
function useTypesDispatch() {
|
|
147
149
|
return (0, _react.useContext)(DispatchTypes);
|
|
148
150
|
}
|
|
149
|
-
|
|
151
|
+
function Types(_ref) {
|
|
150
152
|
var initial = _ref.initial,
|
|
151
153
|
dispatch = _ref.dispatch,
|
|
152
154
|
children = _ref.children;
|
|
@@ -157,6 +159,5 @@ var Types = function Types(_ref) {
|
|
|
157
159
|
children: children
|
|
158
160
|
})
|
|
159
161
|
});
|
|
160
|
-
}
|
|
161
|
-
exports.Types = Types;
|
|
162
|
+
}
|
|
162
163
|
Types.displayName = 'JVR.Types';
|
package/cjs/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { JsonViewProps } from './';
|
|
3
|
-
import { type InitialTypesState } from './store/Types';
|
|
3
|
+
import { type InitialTypesState, type TagType } from './store/Types';
|
|
4
4
|
export type BlockTagType = keyof JSX.IntrinsicElements;
|
|
5
5
|
export interface InitialState<T extends object> {
|
|
6
6
|
value?: object;
|
|
@@ -20,10 +20,13 @@ export declare const Context: React.Context<InitialState<object>>;
|
|
|
20
20
|
export declare function reducer(state: InitialState<object>, action: InitialState<object>): InitialState<object>;
|
|
21
21
|
export declare const useStore: () => InitialState<object>;
|
|
22
22
|
export declare const useDispatchStore: () => Dispatch;
|
|
23
|
-
export interface ProviderProps {
|
|
23
|
+
export interface ProviderProps<T extends TagType> {
|
|
24
24
|
initialState?: InitialState<object>;
|
|
25
|
-
initialTypes?: InitialTypesState
|
|
25
|
+
initialTypes?: InitialTypesState<T>;
|
|
26
26
|
}
|
|
27
|
-
export declare const Provider:
|
|
27
|
+
export declare const Provider: {
|
|
28
|
+
<T extends TagType>({ children, initialState: init, initialTypes, }: React.PropsWithChildren<ProviderProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
displayName: string;
|
|
30
|
+
};
|
|
28
31
|
export declare function useDispatch(): Dispatch;
|
|
29
32
|
export {};
|
package/cjs/types/index.js
CHANGED
|
@@ -417,7 +417,7 @@ var TypeDate = function TypeDate(_ref10) {
|
|
|
417
417
|
type: 'type',
|
|
418
418
|
value: children
|
|
419
419
|
});
|
|
420
|
-
var childStr = children
|
|
420
|
+
var childStr = children instanceof Date ? children.toLocaleString() : children;
|
|
421
421
|
var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, {
|
|
422
422
|
children: childStr,
|
|
423
423
|
className: 'w-rjv-value'
|
package/esm/comps/Copied.js
CHANGED
|
@@ -27,18 +27,21 @@ export var Copied = props => {
|
|
|
27
27
|
if (enableClipboard === false || !isShowTools) return null;
|
|
28
28
|
var click = event => {
|
|
29
29
|
event.stopPropagation();
|
|
30
|
-
var copyText =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
30
|
+
var copyText = '';
|
|
31
|
+
if (typeof value === 'number' && value === Infinity) {
|
|
32
|
+
copyText = 'Infinity';
|
|
33
|
+
} else if (typeof value === 'number' && isNaN(value)) {
|
|
34
|
+
copyText = 'NaN';
|
|
35
|
+
} else if (typeof value === 'bigint') {
|
|
36
|
+
copyText = value + 'n';
|
|
37
|
+
} else if (value instanceof Date) {
|
|
38
|
+
copyText = value.toLocaleString();
|
|
39
|
+
} else {
|
|
40
|
+
copyText = JSON.stringify(value, null, 2);
|
|
41
|
+
}
|
|
42
|
+
onCopied && onCopied(copyText, value);
|
|
43
|
+
setCopied(true);
|
|
39
44
|
navigator.clipboard.writeText(copyText).then(() => {
|
|
40
|
-
onCopied && onCopied(copyText, value);
|
|
41
|
-
setCopied(true);
|
|
42
45
|
var timer = setTimeout(() => {
|
|
43
46
|
setCopied(false);
|
|
44
47
|
clearTimeout(timer);
|
package/esm/store/Types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropsWithChildren, ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
export type TagType = React.ElementType | keyof JSX.IntrinsicElements;
|
|
3
|
-
type TypesElementProps<T extends TagType> = {
|
|
3
|
+
type TypesElementProps<T extends TagType = 'span'> = {
|
|
4
4
|
as?: T;
|
|
5
5
|
render?: (props: TypesElement<T>, result: {
|
|
6
6
|
type: 'type' | 'value';
|
|
@@ -9,24 +9,24 @@ type TypesElementProps<T extends TagType> = {
|
|
|
9
9
|
'data-type'?: string;
|
|
10
10
|
};
|
|
11
11
|
export type TypesElement<T extends TagType> = TypesElementProps<T> & ComponentPropsWithoutRef<T>;
|
|
12
|
-
export type InitialTypesState = {
|
|
12
|
+
export type InitialTypesState<T extends TagType = 'span'> = {
|
|
13
13
|
displayDataTypes?: boolean;
|
|
14
|
-
Url?: TypesElement<
|
|
15
|
-
Str?: TypesElement<
|
|
16
|
-
Undefined?: TypesElement<
|
|
17
|
-
Null?: TypesElement<
|
|
18
|
-
True?: TypesElement<
|
|
19
|
-
False?: TypesElement<
|
|
20
|
-
Date?: TypesElement<
|
|
21
|
-
Float?: TypesElement<
|
|
22
|
-
Set?: TypesElement<
|
|
23
|
-
Int?: TypesElement<
|
|
24
|
-
Map?: TypesElement<
|
|
25
|
-
Nan?: TypesElement<
|
|
26
|
-
Bigint?: TypesElement<
|
|
14
|
+
Url?: TypesElement<T>;
|
|
15
|
+
Str?: TypesElement<T>;
|
|
16
|
+
Undefined?: TypesElement<T>;
|
|
17
|
+
Null?: TypesElement<T>;
|
|
18
|
+
True?: TypesElement<T>;
|
|
19
|
+
False?: TypesElement<T>;
|
|
20
|
+
Date?: TypesElement<T>;
|
|
21
|
+
Float?: TypesElement<T>;
|
|
22
|
+
Set?: TypesElement<T>;
|
|
23
|
+
Int?: TypesElement<T>;
|
|
24
|
+
Map?: TypesElement<T>;
|
|
25
|
+
Nan?: TypesElement<T>;
|
|
26
|
+
Bigint?: TypesElement<T>;
|
|
27
27
|
};
|
|
28
|
-
type Dispatch = React.Dispatch<InitialTypesState
|
|
29
|
-
export declare const useTypesStore: () => InitialTypesState
|
|
28
|
+
type Dispatch<T extends TagType> = React.Dispatch<InitialTypesState<T>>;
|
|
29
|
+
export declare const useTypesStore: () => InitialTypesState<TagType>;
|
|
30
30
|
export declare function useTypes(): [{
|
|
31
31
|
displayDataTypes?: boolean | undefined;
|
|
32
32
|
Url?: TypesElement<TagType> | undefined;
|
|
@@ -42,11 +42,14 @@ export declare function useTypes(): [{
|
|
|
42
42
|
Map?: TypesElement<TagType> | undefined;
|
|
43
43
|
Nan?: TypesElement<TagType> | undefined;
|
|
44
44
|
Bigint?: TypesElement<TagType> | undefined;
|
|
45
|
-
}, import("react").Dispatch<InitialTypesState
|
|
46
|
-
export declare function useTypesDispatch(): Dispatch
|
|
47
|
-
interface TypesProps {
|
|
48
|
-
initial: InitialTypesState
|
|
49
|
-
dispatch: Dispatch
|
|
45
|
+
}, import("react").Dispatch<InitialTypesState<TagType>>];
|
|
46
|
+
export declare function useTypesDispatch(): Dispatch<TagType>;
|
|
47
|
+
interface TypesProps<T extends TagType> {
|
|
48
|
+
initial: InitialTypesState<T>;
|
|
49
|
+
dispatch: Dispatch<TagType>;
|
|
50
|
+
}
|
|
51
|
+
export declare function Types<T extends TagType>({ initial, dispatch, children }: PropsWithChildren<TypesProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export declare namespace Types {
|
|
53
|
+
var displayName: string;
|
|
50
54
|
}
|
|
51
|
-
export declare const Types: FC<PropsWithChildren<TypesProps>>;
|
|
52
55
|
export {};
|
package/esm/store/Types.js
CHANGED
|
@@ -40,7 +40,8 @@ var initialState = {
|
|
|
40
40
|
},
|
|
41
41
|
Map: {
|
|
42
42
|
style: {
|
|
43
|
-
color: 'var(--w-rjv-type-map-color, #268bd2)'
|
|
43
|
+
color: 'var(--w-rjv-type-map-color, #268bd2)',
|
|
44
|
+
marginRight: 3
|
|
44
45
|
},
|
|
45
46
|
as: 'span',
|
|
46
47
|
'data-type': 'map',
|
|
@@ -76,7 +77,8 @@ var initialState = {
|
|
|
76
77
|
},
|
|
77
78
|
Set: {
|
|
78
79
|
style: {
|
|
79
|
-
color: 'var(--w-rjv-type-set-color, #268bd2)'
|
|
80
|
+
color: 'var(--w-rjv-type-set-color, #268bd2)',
|
|
81
|
+
marginRight: 3
|
|
80
82
|
},
|
|
81
83
|
as: 'span',
|
|
82
84
|
'data-type': 'set',
|
|
@@ -133,7 +135,7 @@ export function useTypes() {
|
|
|
133
135
|
export function useTypesDispatch() {
|
|
134
136
|
return useContext(DispatchTypes);
|
|
135
137
|
}
|
|
136
|
-
export
|
|
138
|
+
export function Types(_ref) {
|
|
137
139
|
var {
|
|
138
140
|
initial,
|
|
139
141
|
dispatch,
|
|
@@ -146,5 +148,5 @@ export var Types = _ref => {
|
|
|
146
148
|
children: children
|
|
147
149
|
})
|
|
148
150
|
});
|
|
149
|
-
}
|
|
151
|
+
}
|
|
150
152
|
Types.displayName = 'JVR.Types';
|
package/esm/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { JsonViewProps } from './';
|
|
3
|
-
import { type InitialTypesState } from './store/Types';
|
|
3
|
+
import { type InitialTypesState, type TagType } from './store/Types';
|
|
4
4
|
export type BlockTagType = keyof JSX.IntrinsicElements;
|
|
5
5
|
export interface InitialState<T extends object> {
|
|
6
6
|
value?: object;
|
|
@@ -20,10 +20,13 @@ export declare const Context: React.Context<InitialState<object>>;
|
|
|
20
20
|
export declare function reducer(state: InitialState<object>, action: InitialState<object>): InitialState<object>;
|
|
21
21
|
export declare const useStore: () => InitialState<object>;
|
|
22
22
|
export declare const useDispatchStore: () => Dispatch;
|
|
23
|
-
export interface ProviderProps {
|
|
23
|
+
export interface ProviderProps<T extends TagType> {
|
|
24
24
|
initialState?: InitialState<object>;
|
|
25
|
-
initialTypes?: InitialTypesState
|
|
25
|
+
initialTypes?: InitialTypesState<T>;
|
|
26
26
|
}
|
|
27
|
-
export declare const Provider:
|
|
27
|
+
export declare const Provider: {
|
|
28
|
+
<T extends TagType>({ children, initialState: init, initialTypes, }: React.PropsWithChildren<ProviderProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
displayName: string;
|
|
30
|
+
};
|
|
28
31
|
export declare function useDispatch(): Dispatch;
|
|
29
32
|
export {};
|
package/esm/types/index.js
CHANGED
|
@@ -435,7 +435,7 @@ export var TypeDate = _ref10 => {
|
|
|
435
435
|
type: 'type',
|
|
436
436
|
value: children
|
|
437
437
|
});
|
|
438
|
-
var childStr = children
|
|
438
|
+
var childStr = children instanceof Date ? children.toLocaleString() : children;
|
|
439
439
|
var child = isRender && render(_extends({}, reset, {
|
|
440
440
|
children: childStr,
|
|
441
441
|
className: 'w-rjv-value'
|