@uiw/react-json-view
Advanced tools
Comparing version 2.0.0-alpha.6 to 2.0.0-alpha.7
@@ -38,14 +38,17 @@ "use strict"; | ||
event.stopPropagation(); | ||
var copyText = JSON.stringify(value, function (key, value) { | ||
if (typeof value === 'bigint') { | ||
return value.toString(); | ||
} | ||
return value; | ||
}, 2); | ||
if (typeof value === 'number' && value === Infinity) copyText = 'Infinity'; | ||
if (typeof value === 'number' && isNaN(value)) copyText = 'NaN'; | ||
if (typeof value === 'bigint') copyText = value + 'n'; | ||
var copyText = ''; | ||
if (typeof value === 'number' && value === Infinity) { | ||
copyText = 'Infinity'; | ||
} else if (typeof value === 'number' && isNaN(value)) { | ||
copyText = 'NaN'; | ||
} else if (typeof value === 'bigint') { | ||
copyText = value + 'n'; | ||
} else if (value instanceof Date) { | ||
copyText = value.toLocaleString(); | ||
} else { | ||
copyText = JSON.stringify(value, null, 2); | ||
} | ||
onCopied && onCopied(copyText, value); | ||
setCopied(true); | ||
navigator.clipboard.writeText(copyText).then(function () { | ||
onCopied && onCopied(copyText, value); | ||
setCopied(true); | ||
var timer = setTimeout(function () { | ||
@@ -52,0 +55,0 @@ setCopied(false); |
import React, { PropsWithChildren } from 'react'; | ||
import { JsonViewProps } from './'; | ||
import { type InitialTypesState } from './store/Types'; | ||
import { type InitialTypesState, type TagType } from './store/Types'; | ||
export type BlockTagType = keyof JSX.IntrinsicElements; | ||
@@ -23,8 +23,11 @@ export interface InitialState<T extends object> { | ||
export declare const useDispatchStore: () => Dispatch; | ||
export interface ProviderProps { | ||
export interface ProviderProps<T extends TagType> { | ||
initialState?: InitialState<object>; | ||
initialTypes?: InitialTypesState; | ||
initialTypes?: InitialTypesState<T>; | ||
} | ||
export declare const Provider: React.FC<PropsWithChildren<ProviderProps>>; | ||
export declare const Provider: { | ||
<T extends TagType>({ children, initialState: init, initialTypes, }: React.PropsWithChildren<ProviderProps<T>>): import("react/jsx-runtime").JSX.Element; | ||
displayName: string; | ||
}; | ||
export declare function useDispatch(): Dispatch; | ||
export {}; |
@@ -1,4 +0,4 @@ | ||
import { FC, PropsWithChildren, ComponentPropsWithoutRef } from 'react'; | ||
import { PropsWithChildren, ComponentPropsWithoutRef } from 'react'; | ||
export type TagType = React.ElementType | keyof JSX.IntrinsicElements; | ||
type TypesElementProps<T extends TagType> = { | ||
type TypesElementProps<T extends TagType = 'span'> = { | ||
as?: T; | ||
@@ -12,20 +12,20 @@ render?: (props: TypesElement<T>, result: { | ||
export type TypesElement<T extends TagType> = TypesElementProps<T> & ComponentPropsWithoutRef<T>; | ||
export type InitialTypesState = { | ||
export type InitialTypesState<T extends TagType = 'span'> = { | ||
displayDataTypes?: boolean; | ||
Url?: TypesElement<TagType>; | ||
Str?: TypesElement<TagType>; | ||
Undefined?: TypesElement<TagType>; | ||
Null?: TypesElement<TagType>; | ||
True?: TypesElement<TagType>; | ||
False?: TypesElement<TagType>; | ||
Date?: TypesElement<TagType>; | ||
Float?: TypesElement<TagType>; | ||
Set?: TypesElement<TagType>; | ||
Int?: TypesElement<TagType>; | ||
Map?: TypesElement<TagType>; | ||
Nan?: TypesElement<TagType>; | ||
Bigint?: TypesElement<TagType>; | ||
Url?: TypesElement<T>; | ||
Str?: TypesElement<T>; | ||
Undefined?: TypesElement<T>; | ||
Null?: TypesElement<T>; | ||
True?: TypesElement<T>; | ||
False?: TypesElement<T>; | ||
Date?: TypesElement<T>; | ||
Float?: TypesElement<T>; | ||
Set?: TypesElement<T>; | ||
Int?: TypesElement<T>; | ||
Map?: TypesElement<T>; | ||
Nan?: TypesElement<T>; | ||
Bigint?: TypesElement<T>; | ||
}; | ||
type Dispatch = React.Dispatch<InitialTypesState>; | ||
export declare const useTypesStore: () => InitialTypesState; | ||
type Dispatch<T extends TagType> = React.Dispatch<InitialTypesState<T>>; | ||
export declare const useTypesStore: () => InitialTypesState<TagType>; | ||
export declare function useTypes(): [{ | ||
@@ -46,9 +46,12 @@ displayDataTypes?: boolean | undefined; | ||
Bigint?: TypesElement<TagType> | undefined; | ||
}, import("react").Dispatch<InitialTypesState>]; | ||
export declare function useTypesDispatch(): Dispatch; | ||
interface TypesProps { | ||
initial: InitialTypesState; | ||
dispatch: Dispatch; | ||
}, import("react").Dispatch<InitialTypesState<TagType>>]; | ||
export declare function useTypesDispatch(): Dispatch<TagType>; | ||
interface TypesProps<T extends TagType> { | ||
initial: InitialTypesState<T>; | ||
dispatch: Dispatch<TagType>; | ||
} | ||
export declare const Types: FC<PropsWithChildren<TypesProps>>; | ||
export declare function Types<T extends TagType>({ initial, dispatch, children }: PropsWithChildren<TypesProps<T>>): import("react/jsx-runtime").JSX.Element; | ||
export declare namespace Types { | ||
var displayName: string; | ||
} | ||
export {}; |
@@ -7,3 +7,3 @@ "use strict"; | ||
}); | ||
exports.Types = void 0; | ||
exports.Types = Types; | ||
exports.useTypes = useTypes; | ||
@@ -54,3 +54,4 @@ exports.useTypesDispatch = useTypesDispatch; | ||
style: { | ||
color: 'var(--w-rjv-type-map-color, #268bd2)' | ||
color: 'var(--w-rjv-type-map-color, #268bd2)', | ||
marginRight: 3 | ||
}, | ||
@@ -91,3 +92,4 @@ as: 'span', | ||
style: { | ||
color: 'var(--w-rjv-type-set-color, #268bd2)' | ||
color: 'var(--w-rjv-type-set-color, #268bd2)', | ||
marginRight: 3 | ||
}, | ||
@@ -152,3 +154,3 @@ as: 'span', | ||
} | ||
var Types = function Types(_ref) { | ||
function Types(_ref) { | ||
var initial = _ref.initial, | ||
@@ -164,4 +166,3 @@ dispatch = _ref.dispatch, | ||
}); | ||
}; | ||
exports.Types = Types; | ||
} | ||
Types.displayName = 'JVR.Types'; |
@@ -420,3 +420,3 @@ "use strict"; | ||
}); | ||
var childStr = children === null || children === void 0 ? void 0 : children.toString(); | ||
var childStr = children instanceof Date ? children.toLocaleString() : children; | ||
var child = isRender && render((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, reset), {}, { | ||
@@ -423,0 +423,0 @@ children: childStr, |
@@ -30,14 +30,17 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
event.stopPropagation(); | ||
var copyText = JSON.stringify(value, (key, value) => { | ||
if (typeof value === 'bigint') { | ||
return value.toString(); | ||
} | ||
return value; | ||
}, 2); | ||
if (typeof value === 'number' && value === Infinity) copyText = 'Infinity'; | ||
if (typeof value === 'number' && isNaN(value)) copyText = 'NaN'; | ||
if (typeof value === 'bigint') copyText = value + 'n'; | ||
var copyText = ''; | ||
if (typeof value === 'number' && value === Infinity) { | ||
copyText = 'Infinity'; | ||
} else if (typeof value === 'number' && isNaN(value)) { | ||
copyText = 'NaN'; | ||
} else if (typeof value === 'bigint') { | ||
copyText = value + 'n'; | ||
} else if (value instanceof Date) { | ||
copyText = value.toLocaleString(); | ||
} else { | ||
copyText = JSON.stringify(value, null, 2); | ||
} | ||
onCopied && onCopied(copyText, value); | ||
setCopied(true); | ||
navigator.clipboard.writeText(copyText).then(() => { | ||
onCopied && onCopied(copyText, value); | ||
setCopied(true); | ||
var timer = setTimeout(() => { | ||
@@ -44,0 +47,0 @@ setCopied(false); |
import React, { PropsWithChildren } from 'react'; | ||
import { JsonViewProps } from './'; | ||
import { type InitialTypesState } from './store/Types'; | ||
import { type InitialTypesState, type TagType } from './store/Types'; | ||
export type BlockTagType = keyof JSX.IntrinsicElements; | ||
@@ -23,8 +23,11 @@ export interface InitialState<T extends object> { | ||
export declare const useDispatchStore: () => Dispatch; | ||
export interface ProviderProps { | ||
export interface ProviderProps<T extends TagType> { | ||
initialState?: InitialState<object>; | ||
initialTypes?: InitialTypesState; | ||
initialTypes?: InitialTypesState<T>; | ||
} | ||
export declare const Provider: React.FC<PropsWithChildren<ProviderProps>>; | ||
export declare const Provider: { | ||
<T extends TagType>({ children, initialState: init, initialTypes, }: React.PropsWithChildren<ProviderProps<T>>): import("react/jsx-runtime").JSX.Element; | ||
displayName: string; | ||
}; | ||
export declare function useDispatch(): Dispatch; | ||
export {}; |
@@ -1,4 +0,4 @@ | ||
import { FC, PropsWithChildren, ComponentPropsWithoutRef } from 'react'; | ||
import { PropsWithChildren, ComponentPropsWithoutRef } from 'react'; | ||
export type TagType = React.ElementType | keyof JSX.IntrinsicElements; | ||
type TypesElementProps<T extends TagType> = { | ||
type TypesElementProps<T extends TagType = 'span'> = { | ||
as?: T; | ||
@@ -12,20 +12,20 @@ render?: (props: TypesElement<T>, result: { | ||
export type TypesElement<T extends TagType> = TypesElementProps<T> & ComponentPropsWithoutRef<T>; | ||
export type InitialTypesState = { | ||
export type InitialTypesState<T extends TagType = 'span'> = { | ||
displayDataTypes?: boolean; | ||
Url?: TypesElement<TagType>; | ||
Str?: TypesElement<TagType>; | ||
Undefined?: TypesElement<TagType>; | ||
Null?: TypesElement<TagType>; | ||
True?: TypesElement<TagType>; | ||
False?: TypesElement<TagType>; | ||
Date?: TypesElement<TagType>; | ||
Float?: TypesElement<TagType>; | ||
Set?: TypesElement<TagType>; | ||
Int?: TypesElement<TagType>; | ||
Map?: TypesElement<TagType>; | ||
Nan?: TypesElement<TagType>; | ||
Bigint?: TypesElement<TagType>; | ||
Url?: TypesElement<T>; | ||
Str?: TypesElement<T>; | ||
Undefined?: TypesElement<T>; | ||
Null?: TypesElement<T>; | ||
True?: TypesElement<T>; | ||
False?: TypesElement<T>; | ||
Date?: TypesElement<T>; | ||
Float?: TypesElement<T>; | ||
Set?: TypesElement<T>; | ||
Int?: TypesElement<T>; | ||
Map?: TypesElement<T>; | ||
Nan?: TypesElement<T>; | ||
Bigint?: TypesElement<T>; | ||
}; | ||
type Dispatch = React.Dispatch<InitialTypesState>; | ||
export declare const useTypesStore: () => InitialTypesState; | ||
type Dispatch<T extends TagType> = React.Dispatch<InitialTypesState<T>>; | ||
export declare const useTypesStore: () => InitialTypesState<TagType>; | ||
export declare function useTypes(): [{ | ||
@@ -46,9 +46,12 @@ displayDataTypes?: boolean | undefined; | ||
Bigint?: TypesElement<TagType> | undefined; | ||
}, import("react").Dispatch<InitialTypesState>]; | ||
export declare function useTypesDispatch(): Dispatch; | ||
interface TypesProps { | ||
initial: InitialTypesState; | ||
dispatch: Dispatch; | ||
}, import("react").Dispatch<InitialTypesState<TagType>>]; | ||
export declare function useTypesDispatch(): Dispatch<TagType>; | ||
interface TypesProps<T extends TagType> { | ||
initial: InitialTypesState<T>; | ||
dispatch: Dispatch<TagType>; | ||
} | ||
export declare const Types: FC<PropsWithChildren<TypesProps>>; | ||
export declare function Types<T extends TagType>({ initial, dispatch, children }: PropsWithChildren<TypesProps<T>>): import("react/jsx-runtime").JSX.Element; | ||
export declare namespace Types { | ||
var displayName: string; | ||
} | ||
export {}; |
@@ -43,3 +43,4 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
style: { | ||
color: 'var(--w-rjv-type-map-color, #268bd2)' | ||
color: 'var(--w-rjv-type-map-color, #268bd2)', | ||
marginRight: 3 | ||
}, | ||
@@ -80,3 +81,4 @@ as: 'span', | ||
style: { | ||
color: 'var(--w-rjv-type-set-color, #268bd2)' | ||
color: 'var(--w-rjv-type-set-color, #268bd2)', | ||
marginRight: 3 | ||
}, | ||
@@ -138,3 +140,3 @@ as: 'span', | ||
} | ||
export var Types = _ref => { | ||
export function Types(_ref) { | ||
var { | ||
@@ -152,3 +154,3 @@ initial, | ||
}); | ||
}; | ||
} | ||
Types.displayName = 'JVR.Types'; |
@@ -438,3 +438,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
}); | ||
var childStr = children == null ? void 0 : children.toString(); | ||
var childStr = children instanceof Date ? children.toLocaleString() : children; | ||
var child = isRender && render(_extends({}, reset, { | ||
@@ -441,0 +441,0 @@ children: childStr, |
{ | ||
"name": "@uiw/react-json-view", | ||
"version": "2.0.0-alpha.6", | ||
"version": "2.0.0-alpha.7", | ||
"description": "JSON viewer for react.", | ||
@@ -5,0 +5,0 @@ "main": "cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
291037
6864