json-edit-react 1.30.2 → 2.0.0-beta.1

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/build/index.d.ts CHANGED
@@ -1,34 +1,9 @@
1
- import React$1, { JSX } from 'react';
2
-
3
- type BasicObject = {
4
- [key: string]: BasicObject | unknown | (BasicObject | unknown)[];
5
- };
6
- type BasicArray = (BasicObject | unknown)[];
7
- type InputObject$1 = BasicObject | BasicArray | unknown;
8
- declare const extract: (inputObj: InputObject$1, properties: string | number | (string | number)[], fallback?: any) => any;
9
-
10
- type Path = (string | number)[];
11
-
12
- type BasicType = string | number | boolean | undefined | null | ((...args: unknown[]) => unknown);
13
- type Value = AssignInput | BasicType;
14
- type InputObject = {
15
- [key: string]: Value;
16
- };
17
- type InputArray = Value[];
18
- type AssignInput = InputObject | InputArray;
19
- interface AssignOptions {
20
- remove?: boolean;
21
- noError?: boolean;
22
- createNew?: boolean;
23
- insert?: boolean;
24
- insertBefore?: string | number;
25
- insertAfter?: string | number;
26
- }
27
- declare const assign: (data: AssignInput, propertyPath: string | Path, newValue: any, options?: AssignOptions) => AssignInput;
1
+ import React$1, { JSX, SVGProps } from 'react';
28
2
 
29
3
  declare const localisedStrings: {
30
4
  ITEM_SINGLE: string;
31
5
  ITEMS_MULTIPLE: string;
6
+ ITEMS_FILTERED: string;
32
7
  KEY_NEW: string;
33
8
  KEY_SELECT: string;
34
9
  NO_KEY_OPTIONS: string;
@@ -37,7 +12,8 @@ declare const localisedStrings: {
37
12
  ERROR_UPDATE: string;
38
13
  ERROR_DELETE: string;
39
14
  ERROR_ADD: string;
40
- DEFAULT_STRING: string;
15
+ ERROR_RENAME: string;
16
+ ERROR_MOVE: string;
41
17
  DEFAULT_NEW_KEY: string;
42
18
  SHOW_LESS: string;
43
19
  EMPTY_STRING: string;
@@ -45,78 +21,81 @@ declare const localisedStrings: {
45
21
  TOOLTIP_EDIT: string;
46
22
  TOOLTIP_DELETE: string;
47
23
  TOOLTIP_ADD: string;
24
+ TOOLTIP_OK: string;
25
+ TOOLTIP_CANCEL: string;
48
26
  };
49
27
  type LocalisedStrings = typeof localisedStrings;
50
- type TranslateFunction = (key: keyof LocalisedStrings, customData: NodeData, count?: number) => string;
51
-
52
- interface EditState {
53
- path?: CollectionKey[];
54
- action?: 'accept' | 'cancel';
55
- }
56
- interface ExternalTriggers {
57
- collapse?: CollapseState | CollapseState[];
58
- edit?: EditState;
59
- }
28
+ type TranslateFunction = (key: keyof LocalisedStrings, customData: NodeData, counts?: number | Record<string, string | number>) => string;
60
29
 
61
30
  interface CustomNodeData {
62
- CustomNode?: React.FC<CustomNodeProps>;
63
- CustomWrapper?: React.FC<CustomNodeProps>;
64
- CustomKey?: React.FC<CustomKeyProps>;
31
+ CustomComponent?: React.FC<CustomComponentProps>;
32
+ CustomWrapperComponent?: React.FC<CustomWrapperProps>;
33
+ CustomKeyComponent?: React.FC<CustomKeyProps>;
65
34
  name?: string;
66
- customNodeProps?: Record<string, unknown>;
35
+ componentProps?: Record<string, unknown>;
67
36
  wrapperProps?: Record<string, unknown>;
68
- hideKey?: boolean;
37
+ showKey?: boolean;
69
38
  defaultValue?: unknown;
70
- showInTypesSelector?: boolean;
39
+ showInTypeSelector?: boolean;
40
+ editOnTypeSwitch?: boolean;
71
41
  showOnEdit?: boolean;
72
42
  showOnView?: boolean;
73
43
  showEditTools?: boolean;
74
44
  showCollectionWrapper?: boolean;
75
45
  passOriginalNode?: boolean;
76
46
  renderCollectionAsValue?: boolean;
47
+ toStandardType?: (value: unknown) => ValueData;
48
+ fromStandardType?: (value: unknown, nodeData: NodeData, componentProps?: Record<string, unknown>) => unknown;
49
+ }
50
+
51
+ interface SelectProps {
52
+ options: string[];
53
+ value?: string;
54
+ defaultValue?: string;
55
+ onChange: (value: string) => void;
56
+ onKeyDown?: (e: React$1.KeyboardEvent) => void;
57
+ autoFocus?: boolean;
58
+ placeholder?: string;
59
+ name?: string;
60
+ className?: string;
77
61
  }
78
62
 
79
63
  type JsonData = Record<string, unknown> | Array<unknown> | unknown;
80
- interface JsonEditorProps {
81
- data: JsonData;
82
- setData?: (data: JsonData) => void;
64
+ interface JsonEditorProps<T = JsonData> {
65
+ data: T;
66
+ setData: (data: T) => void;
83
67
  rootName?: string;
84
- onUpdate?: UpdateFunction;
85
- onEdit?: UpdateFunction;
86
- onDelete?: UpdateFunction;
87
- onAdd?: UpdateFunction;
88
- onChange?: OnChangeFunction;
89
- onError?: OnErrorFunction;
68
+ onUpdate?: UpdateFunction<T>;
69
+ onChange?: OnChangeFunction<T>;
70
+ onError?: OnErrorFunction<T>;
90
71
  showErrorMessages?: boolean;
91
- enableClipboard?: boolean | CopyFunction;
72
+ showClipboardButton?: boolean;
92
73
  theme?: ThemeInput;
93
- icons?: IconReplacements;
94
74
  className?: string;
95
75
  id?: string;
96
76
  indent?: number;
97
- collapse?: boolean | number | FilterFunction;
77
+ collapse?: boolean | number | FilterFunction<T>;
98
78
  collapseAnimationTime?: number;
99
- showCollectionCount?: boolean | 'when-closed';
100
- restrictEdit?: boolean | FilterFunction;
101
- restrictDelete?: boolean | FilterFunction;
102
- restrictAdd?: boolean | FilterFunction;
103
- restrictTypeSelection?: boolean | TypeOptions | TypeFilterFunction;
104
- restrictDrag?: boolean | FilterFunction;
105
- viewOnly?: boolean;
79
+ showCollectionCount?: boolean | 'when-collapsed' | 'when-collapsed-or-filtered';
80
+ allowEdit?: boolean | FilterFunction<T>;
81
+ allowDelete?: boolean | FilterFunction<T>;
82
+ allowAdd?: boolean | FilterFunction<T>;
83
+ allowTypeSelection?: boolean | TypeOptions | TypeFilterFunction<T>;
84
+ allowDrag?: boolean | FilterFunction<T>;
106
85
  searchText?: string;
107
- searchFilter?: 'key' | 'value' | 'all' | SearchFilterFunction;
86
+ searchFilter?: 'key' | 'value' | 'all' | SearchFilterFunction<T>;
108
87
  searchDebounceTime?: number;
109
- keySort?: boolean | CompareFunction;
110
- showArrayIndices?: boolean;
111
- arrayIndexFromOne?: boolean;
88
+ sortKeys?: boolean | CompareFunction;
89
+ showArrayIndexes?: boolean;
90
+ arrayIndexStart?: number;
112
91
  showStringQuotes?: boolean;
113
92
  showIconTooltips?: boolean;
114
- defaultValue?: string | number | boolean | null | object | DefaultValueFunction;
115
- newKeyOptions?: string[] | NewKeyOptionsFunction;
93
+ defaultValue?: string | number | boolean | null | object | DefaultValueFunction<T>;
94
+ newKeyOptions?: string[] | NewKeyOptionsFunction<T>;
116
95
  minWidth?: string | number;
117
96
  maxWidth?: string | number;
118
- rootFontSize?: string | number;
119
- stringTruncate?: number;
97
+ baseFontSize?: string | number;
98
+ stringTruncateLength?: number;
120
99
  translations?: Partial<LocalisedStrings>;
121
100
  customNodeDefinitions?: CustomNodeDefinition<Record<string, any>, Record<string, any>>[];
122
101
  customText?: CustomTextDefinitions;
@@ -124,14 +103,33 @@ interface JsonEditorProps {
124
103
  jsonParse?: (input: string, reviver?: (key: string, value: string) => unknown) => JsonData;
125
104
  jsonStringify?: (input: JsonData, replacer?: (key: string, value: unknown) => unknown) => string;
126
105
  TextEditor?: React.FC<TextEditorProps>;
127
- errorMessageTimeout?: number;
106
+ Select?: React.ComponentType<SelectProps>;
107
+ errorDisplayTime?: number;
128
108
  keyboardControls?: KeyboardControls;
129
109
  insertAtTop?: boolean | 'array' | 'object';
130
110
  collapseClickZones?: Array<'left' | 'header' | 'property'>;
131
111
  onEditEvent?: OnEditEventFunction;
132
112
  onCollapse?: OnCollapseFunction;
133
- externalTriggers?: ExternalTriggers;
113
+ onCopy?: OnCopyFunction<T>;
114
+ editorRef?: React.Ref<JsonEditorHandle>;
115
+ }
116
+ interface StartEditOptions {
117
+ path: CollectionKey[];
118
+ overrideRestrictions?: boolean;
119
+ }
120
+ type StartEditResult = true | 'RESTRICTED' | 'PATH_NOT_FOUND';
121
+ interface JsonEditorHandle {
122
+ collapse: (state: CollapseState | CollapseState[]) => void;
123
+ startEdit: (options: StartEditOptions) => StartEditResult;
124
+ confirm: () => void;
125
+ cancel: () => void;
134
126
  }
127
+ type JsonViewerHandle = Pick<JsonEditorHandle, 'collapse'>;
128
+ type JsonViewerProps<T = JsonData> = Omit<JsonEditorProps<T>, 'setData' | 'onUpdate' | 'onChange' | 'allowEdit' | 'allowAdd' | 'allowDelete' | 'allowDrag' | 'allowTypeSelection' | 'editorRef'> & {
129
+ editorRef?: React.Ref<JsonViewerHandle>;
130
+ };
131
+ declare const valueDataTypes: readonly ["string", "number", "boolean", "null"];
132
+ declare const collectionDataTypes: readonly ["object", "array"];
135
133
  declare const standardDataTypes: readonly ["string", "number", "boolean", "null", "object", "array"];
136
134
  type DataType = (typeof standardDataTypes)[number] | 'invalid';
137
135
  type CollectionKey = string | number;
@@ -143,147 +141,182 @@ interface EnumDefinition {
143
141
  }
144
142
  type TypeOptions = Array<DataType | string | EnumDefinition>;
145
143
  type ErrorString = string;
146
- interface IconReplacements {
147
- add?: JSX.Element;
148
- edit?: JSX.Element;
149
- delete?: JSX.Element;
150
- copy?: JSX.Element;
151
- ok?: JSX.Element;
152
- cancel?: JSX.Element;
153
- chevron?: JSX.Element;
154
- }
144
+ type EditOperation = 'edit' | 'rename' | 'add' | 'delete' | 'move';
155
145
  interface TextEditorProps {
156
146
  value: string;
157
147
  onChange: (value: string) => void;
158
148
  onKeyDown: (e: React.KeyboardEvent) => void;
159
149
  }
160
- interface UpdateFunctionProps {
161
- newData: JsonData;
162
- currentData: JsonData;
150
+ type JerErrorCode = 'UPDATE_ERROR' | 'ADD_ERROR' | 'DELETE_ERROR' | 'RENAME_ERROR' | 'MOVE_ERROR' | 'KEY_EXISTS' | 'INVALID_JSON' | 'CLIPBOARD_ERROR';
151
+ interface JerError {
152
+ code: JerErrorCode;
153
+ message: string;
154
+ }
155
+ type UpdateResult<T = JsonData> = true | void | undefined | false | null | {
156
+ value?: unknown;
157
+ data?: T;
158
+ error?: string | JerError;
159
+ };
160
+ type UpdateFunctionProps<T = JsonData> = NodeData<T> & {
161
+ newData: T;
162
+ } & ({
163
+ event: 'edit';
163
164
  newValue: unknown;
164
- currentValue: unknown;
165
- name: CollectionKey;
166
- path: CollectionKey[];
165
+ } | {
166
+ event: 'add';
167
+ newValue: unknown;
168
+ } | {
169
+ event: 'delete';
170
+ } | {
171
+ event: 'rename';
172
+ newKey: string;
173
+ } | {
174
+ event: 'move';
175
+ newPath: CollectionKey[];
176
+ });
177
+ interface UpdateControl {
178
+ hold: () => () => void;
167
179
  }
168
- type UpdateFunctionReturn = ['error' | 'value', JsonData];
169
- type UpdateFunction = (props: UpdateFunctionProps) => void | ErrorString | boolean | UpdateFunctionReturn | Promise<boolean | ErrorString | void | UpdateFunctionReturn>;
170
- type OnChangeFunction = (props: {
171
- currentData: JsonData;
180
+ type UpdateFunction<T = JsonData> = (props: UpdateFunctionProps<T>, control: UpdateControl) => UpdateResult<T> | Promise<UpdateResult<T>>;
181
+ type OnChangeFunction<T = JsonData> = (props: NodeData<T> & {
172
182
  newValue: ValueData;
173
- currentValue: ValueData;
174
- name: CollectionKey;
175
- path: CollectionKey[];
176
183
  }) => ValueData;
177
- interface JerError {
178
- code: 'UPDATE_ERROR' | 'DELETE_ERROR' | 'ADD_ERROR' | 'INVALID_JSON' | 'KEY_EXISTS';
179
- message: ErrorString;
180
- }
181
- type OnErrorFunction = (props: {
182
- currentData: JsonData;
183
- errorValue: JsonData;
184
- currentValue: JsonData;
185
- name: CollectionKey;
186
- path: CollectionKey[];
184
+ type OnErrorFunction<T = JsonData> = (props: NodeData<T> & {
187
185
  error: JerError;
188
- }) => unknown;
189
- type FilterFunction = (input: NodeData) => boolean;
190
- type TypeFilterFunction = (input: NodeData) => boolean | TypeOptions;
191
- type CustomTextFunction = (input: NodeData) => string | null;
192
- type DefaultValueFunction = (input: NodeData, newKey?: string) => unknown;
193
- type SearchFilterFunction = (inputData: NodeData, searchText: string) => boolean;
194
- type NewKeyOptionsFunction = (input: NodeData) => string[] | null | void;
186
+ errorValue: JsonData;
187
+ }) => void;
188
+ type FilterFunction<T = JsonData> = (input: NodeData<T>) => boolean;
189
+ type TypeFilterFunction<T = JsonData> = (input: NodeData<T>) => boolean | TypeOptions;
190
+ type CustomTextFunction<T = JsonData> = (input: NodeData<T>) => string | null;
191
+ type DefaultValueFunction<T = JsonData> = (input: NodeData<T>, newKey?: string) => unknown;
192
+ type SearchFilterFunction<T = JsonData> = (inputData: NodeData<T>, searchText: string) => boolean;
193
+ type NewKeyOptionsFunction<T = JsonData> = (input: NodeData<T>) => string[] | null | void;
195
194
  type CopyType = 'path' | 'value';
196
- type CopyFunction = (input: {
195
+ type OnCopyFunction<T = JsonData> = (props: NodeData<T> & {
197
196
  success: boolean;
198
- errorMessage: string | null;
199
- key: CollectionKey;
200
- path: CollectionKey[];
201
- value: unknown;
202
197
  stringValue: string;
203
198
  type: CopyType;
199
+ error?: JerError;
204
200
  }) => void;
205
201
  type CompareFunction = (a: [string | number, unknown], b: [string | number, unknown]) => number;
206
202
  type SortFunction = <T>(arr: T[], nodeMap: (input: T) => [string | number, unknown]) => void;
207
- type OnEditEventFunction = (path: (CollectionKey | null)[] | null, isKey: boolean) => void;
203
+ type EditEvent<T = JsonData> = NodeData<T> & ({
204
+ event: 'startEdit';
205
+ } | {
206
+ event: 'submitEdit';
207
+ } | {
208
+ event: 'commitEdit';
209
+ } | {
210
+ event: 'cancelEdit';
211
+ } | {
212
+ event: 'startRename';
213
+ } | {
214
+ event: 'submitRename';
215
+ } | {
216
+ event: 'commitRename';
217
+ oldKey: CollectionKey;
218
+ newKey: CollectionKey;
219
+ } | {
220
+ event: 'cancelRename';
221
+ } | {
222
+ event: 'startAdd';
223
+ } | {
224
+ event: 'submitAdd';
225
+ } | {
226
+ event: 'commitAdd';
227
+ } | {
228
+ event: 'cancelAdd';
229
+ } | {
230
+ event: 'delete';
231
+ } | {
232
+ event: 'move';
233
+ } | {
234
+ event: 'updateSuccess';
235
+ operation: EditOperation;
236
+ } | {
237
+ event: 'updateError';
238
+ operation: EditOperation;
239
+ error: JerError;
240
+ });
241
+ type OnEditEventFunction<T = JsonData> = (e: EditEvent<T>) => void;
208
242
  interface CollapseState {
209
243
  path: CollectionKey[];
210
244
  collapsed: boolean;
211
245
  includeChildren: boolean;
212
246
  }
213
- type OnCollapseFunction = (input: CollapseState) => void;
214
- type InternalUpdateFunction = (value: unknown, path: CollectionKey[], options?: AssignOptions) => Promise<string | void>;
215
- type Position = 'above' | 'below';
216
- type InternalMoveFunction = (source: CollectionKey[] | null, dest: CollectionKey[], position: Position) => Promise<string | void>;
247
+ type OnCollapseFunction<T = JsonData> = (props: NodeData<T> & {
248
+ collapsed: boolean;
249
+ includeChildren: boolean;
250
+ }) => void;
217
251
  interface KeyEvent {
218
252
  key: string;
219
253
  modifier?: React.ModifierKey | React.ModifierKey[];
220
254
  }
221
255
  interface KeyboardControls {
222
- confirm?: KeyEvent | string;
223
- cancel?: KeyEvent | string;
224
- objectConfirm?: KeyEvent | string;
225
- objectLineBreak?: KeyEvent | string;
226
- stringConfirm?: KeyEvent | string;
227
- stringLineBreak?: KeyEvent | string;
228
- booleanConfirm?: KeyEvent | string;
229
- booleanToggle?: KeyEvent | string;
230
- numberConfirm?: KeyEvent | string;
231
- numberUp?: KeyEvent | string;
232
- numberDown?: KeyEvent | string;
233
- tabForward?: KeyEvent | string;
234
- tabBack?: KeyEvent | string;
235
- clipboardModifier?: React.ModifierKey | React.ModifierKey[];
236
- collapseModifier?: React.ModifierKey | React.ModifierKey[];
256
+ confirm?: KeyEvent | string | null;
257
+ cancel?: KeyEvent | string | null;
258
+ objectConfirm?: KeyEvent | string | null;
259
+ objectLineBreak?: KeyEvent | string | null;
260
+ stringConfirm?: KeyEvent | string | null;
261
+ stringLineBreak?: KeyEvent | string | null;
262
+ booleanConfirm?: KeyEvent | string | null;
263
+ booleanToggle?: KeyEvent | string | null;
264
+ numberConfirm?: KeyEvent | string | null;
265
+ numberUp?: KeyEvent | string | null;
266
+ numberDown?: KeyEvent | string | null;
267
+ tabForward?: KeyEvent | string | null;
268
+ tabBack?: KeyEvent | string | null;
269
+ clipboardModifier?: React.ModifierKey | React.ModifierKey[] | null;
270
+ collapseModifier?: React.ModifierKey | React.ModifierKey[] | null;
237
271
  }
238
272
  type KeyboardControlsFull = Omit<Required<{
239
- [Property in keyof KeyboardControls]: KeyEvent;
273
+ [Property in keyof KeyboardControls]: KeyEvent | null;
240
274
  }>, 'clipboardModifier' | 'collapseModifier'> & {
241
275
  clipboardModifier: React.ModifierKey[];
242
276
  collapseModifier: React.ModifierKey[];
243
277
  };
244
- interface NodeData {
278
+ interface NodeData<T = JsonData> {
245
279
  key: CollectionKey;
246
280
  path: CollectionKey[];
247
281
  level: number;
248
282
  index: number;
249
283
  value: JsonData;
250
284
  size: number | null;
285
+ visibleSize?: number | null;
251
286
  parentData: object | null;
252
- fullData: JsonData;
287
+ fullData: T;
253
288
  collapsed?: boolean;
254
289
  }
255
290
  interface BaseNodeProps {
256
291
  data: unknown;
257
292
  parentData: CollectionData | null;
258
293
  nodeData: NodeData;
259
- onEdit: InternalUpdateFunction;
260
- onDelete: InternalUpdateFunction;
294
+ getLatestData: () => JsonData;
261
295
  onError?: OnErrorFunction;
262
296
  showErrorMessages: boolean;
263
297
  showIconTooltips: boolean;
264
- onMove: InternalMoveFunction;
265
- enableClipboard: boolean | CopyFunction;
298
+ showClipboardButton: boolean;
299
+ onCopy?: OnCopyFunction;
266
300
  onEditEvent?: OnEditEventFunction;
267
- restrictEditFilter: FilterFunction;
268
- restrictDeleteFilter: FilterFunction;
269
- restrictAddFilter: FilterFunction;
270
- restrictDragFilter: FilterFunction;
301
+ allowEditFilter: FilterFunction;
302
+ allowDeleteFilter: FilterFunction;
303
+ allowAddFilter: FilterFunction;
304
+ allowDragFilter: FilterFunction;
271
305
  canDragOnto: boolean;
272
- searchFilter?: SearchFilterFunction;
273
- searchText?: string;
274
- restrictTypeSelection: boolean | TypeOptions | TypeFilterFunction;
275
- stringTruncate: number;
306
+ allowTypeSelection: boolean | TypeOptions | TypeFilterFunction;
307
+ stringTruncateLength: number;
276
308
  indent: number;
277
- arrayIndexFromOne: boolean;
309
+ arrayIndexStart: number;
278
310
  sort: SortFunction;
279
311
  translate: TranslateFunction;
280
312
  customNodeDefinitions: CustomNodeDefinition[];
281
313
  customNodeData: CustomNodeData;
282
314
  customButtons: CustomButtonDefinition[];
283
- errorMessageTimeout: number;
315
+ Select: React.ComponentType<SelectProps>;
316
+ errorDisplayTime: number;
284
317
  keyboardControls: KeyboardControlsFull;
285
318
  handleKeyboard: (e: React.KeyboardEvent, eventMap: Partial<Record<keyof KeyboardControlsFull, () => void>>) => void;
286
- editConfirmRef: React.RefObject<HTMLDivElement | null>;
319
+ editConfirmRef: React.RefObject<HTMLButtonElement | null>;
287
320
  jsonStringify: (data: JsonData, replacer?: (this: any, key: string, value: unknown) => string) => string;
288
321
  }
289
322
  interface CollectionNodeProps extends BaseNodeProps {
@@ -291,9 +324,8 @@ interface CollectionNodeProps extends BaseNodeProps {
291
324
  data: CollectionData;
292
325
  collapseFilter: FilterFunction;
293
326
  collapseAnimationTime: number;
294
- onAdd: InternalUpdateFunction;
295
- showArrayIndices: boolean;
296
- showCollectionCount: boolean | 'when-closed';
327
+ showArrayIndexes: boolean;
328
+ showCollectionCount: boolean | 'when-collapsed' | 'when-collapsed-or-filtered';
297
329
  showStringQuotes: boolean;
298
330
  defaultValue: unknown;
299
331
  newKeyOptions?: string[] | NewKeyOptionsFunction;
@@ -319,21 +351,22 @@ interface CustomKeyProps<T = Record<string, unknown>> {
319
351
  path: CollectionKey[];
320
352
  canEditKey: boolean;
321
353
  handleEditKey: (newKey: string) => void;
322
- setIsEditingKey: () => void;
354
+ startEditingKey: () => void;
323
355
  handleClick?: (e: React.MouseEvent) => void;
324
356
  styles: React.CSSProperties;
325
- customNodeProps?: T;
357
+ componentProps?: T;
326
358
  getStyles: (element: ThemeableElement, nodeData: NodeData) => React.CSSProperties;
327
359
  }
328
- interface CustomNodeProps<T = Record<string, unknown>> extends Omit<BaseNodeProps, 'onError'> {
360
+ interface CustomComponentProps<T = Record<string, unknown>> extends Omit<BaseNodeProps, 'onError' | 'data'> {
329
361
  value: JsonData;
330
- customNodeProps?: T;
362
+ componentProps?: T;
331
363
  parentData: CollectionData | null;
332
- setValue: (value: ValueData) => void;
364
+ setValue: (value: JsonData) => void;
333
365
  handleEdit: (value?: unknown) => void;
334
366
  handleCancel: () => void;
335
- handleKeyPress: (e: React.KeyboardEvent) => void;
367
+ onKeyDown: (e: React.KeyboardEvent) => void;
336
368
  isEditing: boolean;
369
+ isPending: boolean;
337
370
  setIsEditing: React.Dispatch<React.SetStateAction<boolean>>;
338
371
  getStyles: (element: ThemeableElement, nodeData: NodeData) => React.CSSProperties;
339
372
  children?: JSX.Element | JSX.Element[] | null;
@@ -341,27 +374,32 @@ interface CustomNodeProps<T = Record<string, unknown>> extends Omit<BaseNodeProp
341
374
  originalNodeKey?: JSX.Element;
342
375
  canEdit: boolean;
343
376
  keyboardCommon: Partial<Record<keyof KeyboardControlsFull, () => void>>;
344
- onError: (error: JerError, errorValue: JsonData | string) => void;
377
+ }
378
+ interface CustomWrapperProps<U = Record<string, unknown>> extends Omit<CustomComponentProps, 'componentProps'> {
379
+ wrapperProps?: U;
345
380
  }
346
381
  interface CustomNodeDefinition<T = Record<string, unknown>, U = Record<string, unknown>> {
347
382
  condition: FilterFunction;
348
- element?: React.FC<CustomNodeProps<T>>;
349
- customKey?: React.FC<CustomKeyProps<T>>;
383
+ component?: React.FC<CustomComponentProps<T>>;
384
+ keyComponent?: React.FC<CustomKeyProps<T>>;
350
385
  name?: string;
351
- customNodeProps?: T;
352
- hideKey?: boolean;
386
+ componentProps?: T;
387
+ showKey?: boolean;
353
388
  defaultValue?: unknown;
354
- showInTypesSelector?: boolean;
389
+ showInTypeSelector?: boolean;
355
390
  showOnEdit?: boolean;
356
391
  showOnView?: boolean;
392
+ editOnTypeSwitch?: boolean;
357
393
  showEditTools?: boolean;
358
394
  passOriginalNode?: boolean;
359
395
  showCollectionWrapper?: boolean;
360
- wrapperElement?: React.FC<CustomNodeProps<U>>;
361
- wrapperProps?: Record<string, unknown>;
396
+ wrapperComponent?: React.FC<CustomWrapperProps<U>>;
397
+ wrapperProps?: U;
362
398
  renderCollectionAsValue?: boolean;
363
399
  stringifyReplacer?: (value: unknown) => unknown;
364
400
  parseReviver?: (stringified: string) => unknown;
401
+ toStandardType?: (value: unknown) => ValueData;
402
+ fromStandardType?: (value: unknown, nodeData: NodeData, componentProps?: T) => unknown;
365
403
  }
366
404
  type CustomTextDefinitions = Partial<{
367
405
  [key in keyof LocalisedStrings]: CustomTextFunction;
@@ -372,41 +410,49 @@ interface CustomButtonDefinition {
372
410
  }>;
373
411
  onClick: (nodeData: NodeData, e: React.MouseEvent) => void;
374
412
  }
375
- type ThemeInput = Theme | Partial<ThemeStyles> | Array<Theme | Partial<ThemeStyles>>;
376
- type ThemeableElement = 'container' | 'collection' | 'collectionInner' | 'collectionElement' | 'dropZone' | 'property' | 'bracket' | 'itemCount' | 'string' | 'number' | 'boolean' | 'null' | 'input' | 'inputHighlight' | 'error' | 'iconCollection' | 'iconEdit' | 'iconDelete' | 'iconAdd' | 'iconCopy' | 'iconOk' | 'iconCancel';
377
- type ThemeFunction = (nodeData: NodeData) => React.CSSProperties | null | undefined;
378
- type ThemeValue = string | React.CSSProperties | Array<string | React.CSSProperties | ThemeFunction> | ThemeFunction;
379
- type ThemeStyles = Record<ThemeableElement, ThemeValue>;
380
- type Fragments = Record<string, React.CSSProperties | string>;
413
+ type ThemeableElement = 'container' | 'collection' | 'collectionElement' | 'headerRow' | 'valueRow' | 'dropZone' | 'property' | 'bracket' | 'itemCount' | 'string' | 'number' | 'boolean' | 'null' | 'input' | 'inputHighlight' | 'error' | 'iconCollection' | 'iconEdit' | 'iconDelete' | 'iconAdd' | 'iconCopy' | 'iconOk' | 'iconCancel';
414
+ type StyleFunction = (nodeData: NodeData) => React.CSSProperties | null | undefined;
415
+ type ThemeValueUnit = string | React.CSSProperties | StyleFunction;
416
+ type ThemeElementValue = ThemeValueUnit | ThemeValueUnit[];
417
+ type ThemeFragments = Record<string, string | React.CSSProperties>;
418
+ type ThemeStyles = Partial<Record<Exclude<ThemeableElement, 'inputHighlight'>, ThemeElementValue>> & {
419
+ inputHighlight?: string;
420
+ };
421
+ interface IconDefinition {
422
+ content: React.ReactNode;
423
+ viewBox?: string;
424
+ svgProps?: React.SVGProps<SVGSVGElement>;
425
+ scale?: number;
426
+ }
427
+ interface ThemeIcons {
428
+ add?: IconDefinition;
429
+ edit?: IconDefinition;
430
+ delete?: IconDefinition;
431
+ copy?: IconDefinition;
432
+ ok?: IconDefinition;
433
+ cancel?: IconDefinition;
434
+ collection?: IconDefinition;
435
+ }
381
436
  interface Theme {
382
437
  displayName?: string;
383
- fragments?: Fragments;
384
- styles: Partial<ThemeStyles>;
438
+ fragments?: ThemeFragments;
439
+ icons?: ThemeIcons;
440
+ styles: ThemeStyles;
385
441
  }
442
+ type ThemeInput = Theme | ThemeStyles | Array<Theme | ThemeStyles>;
386
443
 
387
- declare const JsonEditor: React$1.FC<JsonEditorProps>;
444
+ declare function JsonEditor<T = JsonData>(props: JsonEditorProps<T>): React$1.ReactElement;
388
445
 
389
- declare const defaultTheme: Theme;
446
+ declare function JsonViewer<T = JsonData>(props: JsonViewerProps<T>): React$1.ReactElement | null;
390
447
 
391
- interface IconProps {
392
- size: string;
393
- style?: React$1.CSSProperties;
394
- className?: string;
395
- }
396
- declare const IconAdd: React$1.FC<IconProps>;
397
- declare const IconEdit: React$1.FC<IconProps>;
398
- declare const IconDelete: React$1.FC<IconProps>;
399
- declare const IconCopy: React$1.FC<IconProps>;
400
- declare const IconOk: React$1.FC<IconProps>;
401
- declare const IconCancel: React$1.FC<IconProps>;
402
- declare const IconChevron: React$1.FC<IconProps>;
448
+ declare const defaultTheme: Theme;
403
449
 
404
450
  interface StringDisplayProps {
405
451
  nodeData: NodeData;
406
452
  styles: React$1.CSSProperties;
407
453
  pathString: string;
408
454
  showStringQuotes?: boolean;
409
- stringTruncate?: number;
455
+ stringTruncateLength?: number;
410
456
  canEdit: boolean;
411
457
  setIsEditing: (value: React$1.SetStateAction<boolean>) => void;
412
458
  translate: TranslateFunction;
@@ -428,24 +474,53 @@ interface StringEditProps {
428
474
  declare const StringEdit: React$1.FC<StringEditProps>;
429
475
  declare const useKeyboardListener: (isEditing: boolean, listener: (e: unknown) => void) => void;
430
476
 
431
- declare const LinkCustomComponent: React$1.FC<CustomNodeProps<{
432
- stringTruncate?: number;
433
- }> & ValueNodeProps>;
434
- declare const LinkCustomNodeDefinition: CustomNodeDefinition;
477
+ interface TextAreaProps {
478
+ className: string;
479
+ name: string;
480
+ value: string;
481
+ setValue: React$1.Dispatch<React$1.SetStateAction<string>>;
482
+ onKeyDown: (e: React$1.KeyboardEvent) => void;
483
+ styles: React$1.CSSProperties;
484
+ textAreaRef?: React$1.MutableRefObject<HTMLTextAreaElement | null>;
485
+ }
486
+ declare const AutogrowTextArea: React$1.FC<TextAreaProps>;
487
+
488
+ declare const IconSvg: ({ scale, viewBox, fill, children, ...props }: {
489
+ scale?: number;
490
+ } & Omit<SVGProps<SVGSVGElement>, "scale">) => JSX.Element;
435
491
 
436
- declare const isCollection: (value: unknown) => value is Record<string, unknown> | unknown[];
437
492
  declare const matchNode: (input: Partial<NodeData>, searchText: string) => boolean;
438
493
  declare const matchNodeKey: SearchFilterFunction;
439
- declare const toPathString: (path: Array<string | number>, key?: "key_") => string;
440
494
 
441
- declare const githubDarkTheme: Theme;
442
- declare const githubLightTheme: Theme;
443
- declare const monoDarkTheme: Theme;
444
- declare const monoLightTheme: Theme;
445
- declare const candyWrapperTheme: Theme;
446
- declare const psychedelicTheme: Theme;
495
+ declare const isCollection: (value: unknown) => value is Record<string, unknown> | unknown[];
496
+
497
+ type Path = (string | number)[];
498
+ declare const splitPropertyString: (propertyPath: string) => Path;
499
+ declare const toPathString: (path: CollectionKey[]) => string;
500
+
501
+ type BasicType = string | number | boolean | undefined | null | ((...args: unknown[]) => unknown);
502
+ type Value = AssignInput | BasicType;
503
+ type InputObject$1 = {
504
+ [key: string]: Value;
505
+ };
506
+ type InputArray = Value[];
507
+ type AssignInput = InputObject$1 | InputArray;
508
+ interface AssignOptions {
509
+ remove?: boolean;
510
+ noError?: boolean;
511
+ createNew?: boolean;
512
+ insert?: boolean;
513
+ insertBefore?: string | number;
514
+ insertAfter?: string | number;
515
+ }
516
+ declare const assign: (data: AssignInput, propertyPath: string | Path, newValue: any, options?: AssignOptions) => AssignInput;
447
517
 
448
- export { IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, JsonEditor, LinkCustomComponent, LinkCustomNodeDefinition, StringDisplay, StringEdit, assign, candyWrapperTheme, defaultTheme, extract, githubDarkTheme, githubLightTheme, isCollection, matchNode, matchNodeKey, monoDarkTheme, monoLightTheme, psychedelicTheme, standardDataTypes, toPathString, useKeyboardListener };
518
+ type BasicObject = {
519
+ [key: string]: BasicObject | unknown | (BasicObject | unknown)[];
520
+ };
521
+ type BasicArray = (BasicObject | unknown)[];
522
+ type InputObject = BasicObject | BasicArray | unknown;
523
+ declare const extract: (inputObj: InputObject, properties: string | number | (string | number)[], fallback?: any) => any;
449
524
 
450
- // Types
451
- export { AssignInput, AssignOptions, CollapseState, CollectionNodeProps, CompareFunction, CopyFunction, CustomKeyProps, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, CustomTextFunction, DataType, DefaultValueFunction, EditState, EnumDefinition, ErrorString, ExternalTriggers, FilterFunction, IconProps, IconReplacements, JerError, JsonData, JsonEditorProps, KeyboardControls, LocalisedStrings, NewKeyOptionsFunction, NodeData, OnChangeFunction, OnCollapseFunction, OnEditEventFunction, OnErrorFunction, SearchFilterFunction, TextEditorProps, Theme, ThemeInput, ThemeStyles, TranslateFunction, TypeFilterFunction, TypeOptions, UpdateFunction, UpdateFunctionProps, ValueNodeProps };
525
+ export { AutogrowTextArea, IconSvg, JsonEditor, JsonViewer, StringDisplay, StringEdit, assign, collectionDataTypes, defaultTheme, extract, isCollection, matchNode, matchNodeKey, splitPropertyString, standardDataTypes, toPathString, useKeyboardListener, valueDataTypes };
526
+ export type { AssignInput, AssignOptions, CollapseState, CollectionNodeProps, CompareFunction, CustomButtonDefinition, CustomComponentProps, CustomKeyProps, CustomNodeDefinition, CustomTextDefinitions, CustomTextFunction, CustomWrapperProps, DataType, DefaultValueFunction, EditEvent, EnumDefinition, ErrorString, FilterFunction, IconDefinition, JerError, JerErrorCode, JsonData, JsonEditorHandle, JsonEditorProps, JsonViewerHandle, JsonViewerProps, KeyboardControls, LocalisedStrings, NewKeyOptionsFunction, NodeData, OnChangeFunction, OnCollapseFunction, OnCopyFunction, OnEditEventFunction, OnErrorFunction, SearchFilterFunction, SelectProps, StartEditOptions, StartEditResult, TextEditorProps, Theme, ThemeIcons, ThemeInput, ThemeStyles, TranslateFunction, TypeFilterFunction, TypeOptions, UpdateFunction, UpdateFunctionProps, UpdateResult, ValueNodeProps };