json-edit-react
Advanced tools
Comparing version 1.2.2 to 1.2.3
/// <reference types="react" /> | ||
import React$1 from 'react' | ||
import React$1 from 'react'; | ||
declare const themes: { | ||
default: DefaultTheme | ||
} & Record<string, Theme> | ||
declare const themeableElements: readonly [ | ||
'container', | ||
'property', | ||
'bracket', | ||
'itemCount', | ||
'string', | ||
'number', | ||
'boolean', | ||
'null', | ||
'input', | ||
'inputHighlight', | ||
'error', | ||
'iconCollection', | ||
'iconEdit', | ||
'iconDelete', | ||
'iconAdd', | ||
'iconCopy', | ||
'iconOk', | ||
'iconCancel' | ||
] | ||
type ThemeableElement = (typeof themeableElements)[number] | ||
type ThemeValue = string | React.CSSProperties | Array<string | React.CSSProperties> | ||
type ThemeStyles = Record<ThemeableElement, ThemeValue> | ||
type Fragments = Record<string, React.CSSProperties | string> | ||
default: DefaultTheme; | ||
} & Record<string, Theme>; | ||
declare const themeableElements: readonly ["container", "property", "bracket", "itemCount", "string", "number", "boolean", "null", "input", "inputHighlight", "error", "iconCollection", "iconEdit", "iconDelete", "iconAdd", "iconCopy", "iconOk", "iconCancel"]; | ||
type ThemeableElement = (typeof themeableElements)[number]; | ||
type ThemeValue = string | React.CSSProperties | Array<string | React.CSSProperties>; | ||
type ThemeStyles = Record<ThemeableElement, ThemeValue>; | ||
type Fragments = Record<string, React.CSSProperties | string>; | ||
interface Theme { | ||
displayName?: string | ||
fragments?: Fragments | ||
styles: Partial<ThemeStyles> | ||
displayName?: string; | ||
fragments?: Fragments; | ||
styles: Partial<ThemeStyles>; | ||
} | ||
interface DefaultTheme extends Theme { | ||
displayName: 'Default' | ||
styles: ThemeStyles | ||
displayName: 'Default'; | ||
styles: ThemeStyles; | ||
} | ||
type CompiledStyles = Record<ThemeableElement, React.CSSProperties> | ||
type ThemeName = keyof typeof themes | ||
type ThemeInput = | ||
| ThemeName | ||
| Theme | ||
| Partial<ThemeStyles> | ||
| [ThemeName, Theme | Partial<ThemeStyles>] | ||
type CompiledStyles = Record<ThemeableElement, React.CSSProperties>; | ||
type ThemeName = keyof typeof themes; | ||
type ThemeInput = ThemeName | Theme | Partial<ThemeStyles> | [ThemeName, Theme | Partial<ThemeStyles>]; | ||
declare const localisedStrings: { | ||
ITEM_SINGLE: string | ||
ITEMS_MULTIPLE: string | ||
KEY_NEW: string | ||
ERROR_KEY_EXISTS: string | ||
ERROR_INVALID_JSON: string | ||
ERROR_UPDATE: string | ||
ERROR_DELETE: string | ||
ERROR_ADD: string | ||
DEFAULT_STRING: string | ||
DEFAULT_NEW_KEY: string | ||
} | ||
type LocalisedStrings = typeof localisedStrings | ||
type TranslateFunction = (key: keyof LocalisedStrings, count?: number) => string | ||
ITEM_SINGLE: string; | ||
ITEMS_MULTIPLE: string; | ||
KEY_NEW: string; | ||
ERROR_KEY_EXISTS: string; | ||
ERROR_INVALID_JSON: string; | ||
ERROR_UPDATE: string; | ||
ERROR_DELETE: string; | ||
ERROR_ADD: string; | ||
DEFAULT_STRING: string; | ||
DEFAULT_NEW_KEY: string; | ||
}; | ||
type LocalisedStrings = typeof localisedStrings; | ||
type TranslateFunction = (key: keyof LocalisedStrings, count?: number) => string; | ||
interface JsonEditorProps { | ||
data: object | ||
rootName?: string | ||
onUpdate?: UpdateFunction | ||
onEdit?: UpdateFunction | ||
onDelete?: UpdateFunction | ||
onAdd?: UpdateFunction | ||
enableClipboard?: boolean | CopyFunction | ||
theme?: ThemeInput | ||
icons?: IconReplacements | ||
className?: string | ||
indent?: number | ||
collapse?: boolean | number | FilterFunction | ||
showCollectionCount?: boolean | 'when-closed' | ||
restrictEdit?: boolean | FilterFunction | ||
restrictDelete?: boolean | FilterFunction | ||
restrictAdd?: boolean | FilterFunction | ||
restrictTypeSelection?: boolean | DataType[] | TypeFilterFunction | ||
keySort?: boolean | CompareFunction | ||
showArrayIndices?: boolean | ||
defaultValue?: unknown | ||
minWidth?: string | number | ||
maxWidth?: string | number | ||
stringTruncate?: number | ||
translations?: Partial<LocalisedStrings> | ||
customNodeDefinitions?: CustomNodeDefinition[] | ||
data: object; | ||
rootName?: string; | ||
onUpdate?: UpdateFunction; | ||
onEdit?: UpdateFunction; | ||
onDelete?: UpdateFunction; | ||
onAdd?: UpdateFunction; | ||
enableClipboard?: boolean | CopyFunction; | ||
theme?: ThemeInput; | ||
icons?: IconReplacements; | ||
className?: string; | ||
indent?: number; | ||
collapse?: boolean | number | FilterFunction; | ||
showCollectionCount?: boolean | 'when-closed'; | ||
restrictEdit?: boolean | FilterFunction; | ||
restrictDelete?: boolean | FilterFunction; | ||
restrictAdd?: boolean | FilterFunction; | ||
restrictTypeSelection?: boolean | DataType[] | TypeFilterFunction; | ||
keySort?: boolean | CompareFunction; | ||
showArrayIndices?: boolean; | ||
defaultValue?: unknown; | ||
minWidth?: string | number; | ||
maxWidth?: string | number; | ||
stringTruncate?: number; | ||
translations?: Partial<LocalisedStrings>; | ||
customNodeDefinitions?: CustomNodeDefinition[]; | ||
} | ||
declare const DataTypes: readonly ['string', 'number', 'boolean', 'null', 'object', 'array'] | ||
type DataType = (typeof DataTypes)[number] | 'invalid' | ||
type CollectionKey = string | number | ||
type CollectionData = object | unknown[] | ||
type ErrorString = string | ||
declare const DataTypes: readonly ["string", "number", "boolean", "null", "object", "array"]; | ||
type DataType = (typeof DataTypes)[number] | 'invalid'; | ||
type CollectionKey = string | number; | ||
type CollectionData = object | unknown[]; | ||
type ErrorString = string; | ||
interface IconReplacements { | ||
add?: JSX.Element | ||
edit?: JSX.Element | ||
delete?: JSX.Element | ||
copy?: JSX.Element | ||
ok?: JSX.Element | ||
cancel?: JSX.Element | ||
chevron?: JSX.Element | ||
add?: JSX.Element; | ||
edit?: JSX.Element; | ||
delete?: JSX.Element; | ||
copy?: JSX.Element; | ||
ok?: JSX.Element; | ||
cancel?: JSX.Element; | ||
chevron?: JSX.Element; | ||
} | ||
type UpdateFunction = (props: { | ||
newData: object | ||
currentData: object | ||
newValue: unknown | ||
currentValue: unknown | ||
name: CollectionKey | ||
path: CollectionKey[] | ||
}) => void | ErrorString | false | ||
newData: object; | ||
currentData: object; | ||
newValue: unknown; | ||
currentValue: unknown; | ||
name: CollectionKey; | ||
path: CollectionKey[]; | ||
}) => void | ErrorString | false; | ||
interface FilterProps { | ||
key: CollectionKey | ||
path: CollectionKey[] | ||
level: number | ||
value: unknown | ||
size: number | null | ||
key: CollectionKey; | ||
path: CollectionKey[]; | ||
level: number; | ||
value: unknown; | ||
size: number | null; | ||
} | ||
type FilterFunction = (input: FilterProps) => boolean | ||
type TypeFilterFunction = (input: FilterProps) => boolean | DataType[] | ||
type CopyType = 'path' | 'value' | ||
type FilterFunction = (input: FilterProps) => boolean; | ||
type TypeFilterFunction = (input: FilterProps) => boolean | DataType[]; | ||
type CopyType = 'path' | 'value'; | ||
type CopyFunction = (input: { | ||
key: CollectionKey | ||
path: CollectionKey[] | ||
value: unknown | ||
stringValue: string | ||
type: CopyType | ||
}) => void | ||
type CompareFunction = (a: string, b: string) => number | ||
type OnChangeFunction = (value: unknown, path: (string | number)[]) => Promise<string | void> | ||
key: CollectionKey; | ||
path: CollectionKey[]; | ||
value: unknown; | ||
stringValue: string; | ||
type: CopyType; | ||
}) => void; | ||
type CompareFunction = (a: string, b: string) => number; | ||
type OnChangeFunction = (value: unknown, path: (string | number)[]) => Promise<string | void>; | ||
interface BaseNodeProps { | ||
data: unknown | ||
parentData: CollectionData | null | ||
path: CollectionKey[] | ||
name: CollectionKey | ||
onEdit: OnChangeFunction | ||
onDelete: OnChangeFunction | ||
enableClipboard: boolean | CopyFunction | ||
restrictEditFilter: FilterFunction | ||
restrictDeleteFilter: FilterFunction | ||
restrictAddFilter: FilterFunction | ||
restrictTypeSelection: boolean | DataType[] | TypeFilterFunction | ||
stringTruncate: number | ||
indent: number | ||
translate: TranslateFunction | ||
customNodeDefinitions: CustomNodeDefinition[] | ||
data: unknown; | ||
parentData: CollectionData | null; | ||
path: CollectionKey[]; | ||
name: CollectionKey; | ||
onEdit: OnChangeFunction; | ||
onDelete: OnChangeFunction; | ||
enableClipboard: boolean | CopyFunction; | ||
restrictEditFilter: FilterFunction; | ||
restrictDeleteFilter: FilterFunction; | ||
restrictAddFilter: FilterFunction; | ||
restrictTypeSelection: boolean | DataType[] | TypeFilterFunction; | ||
stringTruncate: number; | ||
indent: number; | ||
translate: TranslateFunction; | ||
customNodeDefinitions: CustomNodeDefinition[]; | ||
} | ||
interface CollectionNodeProps extends BaseNodeProps { | ||
data: CollectionData | ||
collapseFilter: FilterFunction | ||
onAdd: OnChangeFunction | ||
keySort: boolean | CompareFunction | ||
showArrayIndices: boolean | ||
showCollectionCount: boolean | 'when-closed' | ||
defaultValue: unknown | ||
data: CollectionData; | ||
collapseFilter: FilterFunction; | ||
onAdd: OnChangeFunction; | ||
keySort: boolean | CompareFunction; | ||
showArrayIndices: boolean; | ||
showCollectionCount: boolean | 'when-closed'; | ||
defaultValue: unknown; | ||
} | ||
type ValueData = string | number | boolean | null | ||
type ValueData = string | number | boolean | null; | ||
interface ValueNodeProps extends BaseNodeProps { | ||
data: ValueData | ||
showLabel: boolean | ||
data: ValueData; | ||
showLabel: boolean; | ||
} | ||
interface CustomNodeProps extends BaseNodeProps { | ||
value: ValueData | CollectionData | ||
customProps?: Record<string, unknown> | ||
parentData: CollectionData | null | ||
setValue: React$1.Dispatch<React$1.SetStateAction<ValueData>> | ||
handleEdit: () => void | ||
handleCancel: () => void | ||
handleKeyPress: (e: React$1.KeyboardEvent) => void | ||
isEditing: boolean | ||
setIsEditing: React$1.Dispatch<React$1.SetStateAction<boolean>> | ||
styles: CompiledStyles | ||
value: ValueData | CollectionData; | ||
customProps?: Record<string, unknown>; | ||
parentData: CollectionData | null; | ||
setValue: React$1.Dispatch<React$1.SetStateAction<ValueData>>; | ||
handleEdit: () => void; | ||
handleCancel: () => void; | ||
handleKeyPress: (e: React$1.KeyboardEvent) => void; | ||
isEditing: boolean; | ||
setIsEditing: React$1.Dispatch<React$1.SetStateAction<boolean>>; | ||
styles: CompiledStyles; | ||
} | ||
interface CustomNodeDefinition { | ||
condition: FilterFunction | ||
element: React$1.FC<CustomNodeProps> | ||
name?: string | ||
customNodeProps?: Record<string, unknown> | ||
hideKey?: boolean | ||
defaultValue?: unknown | ||
showInTypesSelector?: boolean | ||
showOnEdit?: boolean | ||
showOnView?: boolean | ||
showEditTools?: boolean | ||
condition: FilterFunction; | ||
element: React$1.FC<CustomNodeProps>; | ||
name?: string; | ||
customNodeProps?: Record<string, unknown>; | ||
hideKey?: boolean; | ||
defaultValue?: unknown; | ||
showInTypesSelector?: boolean; | ||
showOnEdit?: boolean; | ||
showOnView?: boolean; | ||
showEditTools?: boolean; | ||
} | ||
declare const JsonEditor: React$1.FC<JsonEditorProps> | ||
declare const JsonEditor: React$1.FC<JsonEditorProps>; | ||
export { | ||
CollectionNodeProps, | ||
CompareFunction, | ||
CopyFunction, | ||
CustomNodeDefinition, | ||
CustomNodeProps, | ||
FilterFunction, | ||
IconReplacements, | ||
JsonEditor, | ||
JsonEditorProps, | ||
LocalisedStrings, | ||
Theme, | ||
ThemeInput, | ||
ThemeName, | ||
TranslateFunction, | ||
UpdateFunction, | ||
ValueNodeProps, | ||
themes, | ||
} | ||
export { type CollectionNodeProps, type CompareFunction, type CopyFunction, type CustomNodeDefinition, type CustomNodeProps, type FilterFunction, type IconReplacements, JsonEditor, type JsonEditorProps, type LocalisedStrings, type Theme, type ThemeInput, type ThemeName, type TranslateFunction, type UpdateFunction, type ValueNodeProps, themes }; |
{ | ||
"name": "json-edit-react", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "React component for editing or viewing JSON/object data", | ||
@@ -40,2 +40,3 @@ "main": "build/index.cjs.js", | ||
"rollup": "^4.9.6", | ||
"rollup-plugin-bundle-size": "^1.0.3", | ||
"rollup-plugin-dts": "^6.1.0", | ||
@@ -42,0 +43,0 @@ "rollup-plugin-peer-deps-external": "^2.2.4", |
@@ -86,3 +86,3 @@ # json-edit-react | ||
| `onUpdate` | `UpdateFunction` | | A function to run whenever a value is **updated** (edit, delete *or* add) in the editor. See [Update functions](#update-functions). | | ||
| `onUpdate` | `UpdateFunction` | | A function to run whenever a value is **edited**. | | ||
| `onEdit` | `UpdateFunction` | | A function to run whenever a value is **edited**. | | ||
| `onDelete` | `UpdateFunction` | | A function to run whenever a value is **deleted**. | | ||
@@ -89,0 +89,0 @@ | `onAdd` | `UpdateFunction` | | A function to run whenever a new property is **added**. | |
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
158516
14
491