@@ -3,6 +3,7 @@ import { type Options as AssignOptions } from 'object-property-assigner'
33import { type LocalisedStrings , type TranslateFunction } from './localisation'
44import { type ExternalTriggers } from './hooks'
55import { CustomNodeData } from './CustomNode'
6+ import { CustomKeyData } from './CustomKey'
67
78export type JsonData = Record < string , unknown > | Array < unknown > | unknown
89
@@ -51,6 +52,8 @@ export interface JsonEditorProps {
5152 // enforcing consistency between the component and the definition that uses it
5253 // eslint-disable-next-line @typescript-eslint/no-explicit-any
5354 customNodeDefinitions ?: CustomNodeDefinition < Record < string , any > , Record < string , any > > [ ]
55+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56+ customKeyDefinitions ?: CustomKeyDefinition < Record < string , any > > [ ]
5457 customText ?: CustomTextDefinitions
5558 customButtons ?: CustomButtonDefinition [ ]
5659 jsonParse ?: ( input : string , reviver ?: ( key : string , value : string ) => unknown ) => JsonData
@@ -278,6 +281,8 @@ interface BaseNodeProps {
278281 translate : TranslateFunction
279282 customNodeDefinitions : CustomNodeDefinition [ ]
280283 customNodeData : CustomNodeData
284+ customKeyDefinitions : CustomKeyDefinition [ ]
285+ customKeyData : CustomKeyData
281286 customButtons : CustomButtonDefinition [ ]
282287 errorMessageTimeout : number
283288 keyboardControls : KeyboardControlsFull
@@ -367,6 +372,26 @@ export interface CustomNodeDefinition<T = Record<string, unknown>, U = Record<st
367372 parseReviver ?: ( stringified : string ) => unknown
368373}
369374
375+ export interface CustomKeyProps < T = Record < string , unknown > > {
376+ nodeData : NodeData
377+ name : string | number
378+ path : CollectionKey [ ]
379+ value : JsonData
380+ styles : React . CSSProperties
381+ isEditingKey : boolean
382+ canEditKey : boolean
383+ handleEditKey : ( newKey : string ) => void
384+ handleClick ?: ( e : React . MouseEvent ) => void
385+ customKeyProps ?: T
386+ }
387+
388+ export interface CustomKeyDefinition < T = Record < string , unknown > > {
389+ condition : FilterFunction
390+ element : React . FC < CustomKeyProps < T > >
391+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
392+ customKeyProps ?: T
393+ }
394+
370395export type CustomTextDefinitions = Partial < { [ key in keyof LocalisedStrings ] : CustomTextFunction } >
371396
372397export interface CustomButtonDefinition {
0 commit comments