json-edit-react 1.30.1 → 2.0.0-beta.0
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.cjs.js +1 -1
- package/build/index.d.ts +285 -210
- package/build/index.esm.js +1 -1
- package/build/style.css +500 -0
- package/package.json +5 -53
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
|
-
|
|
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,
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
31
|
+
CustomComponent?: React.FC<CustomComponentProps>;
|
|
32
|
+
CustomWrapperComponent?: React.FC<CustomWrapperProps>;
|
|
33
|
+
CustomKeyComponent?: React.FC<CustomKeyProps>;
|
|
65
34
|
name?: string;
|
|
66
|
-
|
|
35
|
+
componentProps?: Record<string, unknown>;
|
|
67
36
|
wrapperProps?: Record<string, unknown>;
|
|
68
|
-
|
|
37
|
+
showKey?: boolean;
|
|
69
38
|
defaultValue?: unknown;
|
|
70
|
-
|
|
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:
|
|
82
|
-
setData
|
|
64
|
+
interface JsonEditorProps<T = JsonData> {
|
|
65
|
+
data: T;
|
|
66
|
+
setData: (data: T) => void;
|
|
83
67
|
rootName?: string;
|
|
84
|
-
onUpdate?: UpdateFunction
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
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-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
119
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
|
169
|
-
type
|
|
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
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
type
|
|
191
|
-
type
|
|
192
|
-
type
|
|
193
|
-
type
|
|
194
|
-
type
|
|
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
|
|
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
|
|
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 = (
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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:
|
|
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
|
-
|
|
260
|
-
onDelete: InternalUpdateFunction;
|
|
294
|
+
getLatestData: () => JsonData;
|
|
261
295
|
onError?: OnErrorFunction;
|
|
262
296
|
showErrorMessages: boolean;
|
|
263
297
|
showIconTooltips: boolean;
|
|
264
|
-
|
|
265
|
-
|
|
298
|
+
showClipboardButton: boolean;
|
|
299
|
+
onCopy?: OnCopyFunction;
|
|
266
300
|
onEditEvent?: OnEditEventFunction;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
301
|
+
allowEditFilter: FilterFunction;
|
|
302
|
+
allowDeleteFilter: FilterFunction;
|
|
303
|
+
allowAddFilter: FilterFunction;
|
|
304
|
+
allowDragFilter: FilterFunction;
|
|
271
305
|
canDragOnto: boolean;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
restrictTypeSelection: boolean | TypeOptions | TypeFilterFunction;
|
|
275
|
-
stringTruncate: number;
|
|
306
|
+
allowTypeSelection: boolean | TypeOptions | TypeFilterFunction;
|
|
307
|
+
stringTruncateLength: number;
|
|
276
308
|
indent: number;
|
|
277
|
-
|
|
309
|
+
arrayIndexStart: number;
|
|
278
310
|
sort: SortFunction;
|
|
279
311
|
translate: TranslateFunction;
|
|
280
312
|
customNodeDefinitions: CustomNodeDefinition[];
|
|
281
313
|
customNodeData: CustomNodeData;
|
|
282
314
|
customButtons: CustomButtonDefinition[];
|
|
283
|
-
|
|
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<
|
|
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
|
-
|
|
295
|
-
|
|
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
|
-
|
|
354
|
+
startEditingKey: () => void;
|
|
323
355
|
handleClick?: (e: React.MouseEvent) => void;
|
|
324
356
|
styles: React.CSSProperties;
|
|
325
|
-
|
|
357
|
+
componentProps?: T;
|
|
326
358
|
getStyles: (element: ThemeableElement, nodeData: NodeData) => React.CSSProperties;
|
|
327
359
|
}
|
|
328
|
-
interface
|
|
360
|
+
interface CustomComponentProps<T = Record<string, unknown>> extends Omit<BaseNodeProps, 'onError' | 'data'> {
|
|
329
361
|
value: JsonData;
|
|
330
|
-
|
|
362
|
+
componentProps?: T;
|
|
331
363
|
parentData: CollectionData | null;
|
|
332
|
-
setValue: (value:
|
|
364
|
+
setValue: (value: JsonData) => void;
|
|
333
365
|
handleEdit: (value?: unknown) => void;
|
|
334
366
|
handleCancel: () => void;
|
|
335
|
-
|
|
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
|
-
|
|
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
|
-
|
|
349
|
-
|
|
383
|
+
component?: React.FC<CustomComponentProps<T>>;
|
|
384
|
+
keyComponent?: React.FC<CustomKeyProps<T>>;
|
|
350
385
|
name?: string;
|
|
351
|
-
|
|
352
|
-
|
|
386
|
+
componentProps?: T;
|
|
387
|
+
showKey?: boolean;
|
|
353
388
|
defaultValue?: unknown;
|
|
354
|
-
|
|
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
|
-
|
|
361
|
-
wrapperProps?:
|
|
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
|
|
376
|
-
type
|
|
377
|
-
type
|
|
378
|
-
type
|
|
379
|
-
type
|
|
380
|
-
type
|
|
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?:
|
|
384
|
-
|
|
438
|
+
fragments?: ThemeFragments;
|
|
439
|
+
icons?: ThemeIcons;
|
|
440
|
+
styles: ThemeStyles;
|
|
385
441
|
}
|
|
442
|
+
type ThemeInput = Theme | ThemeStyles | Array<Theme | ThemeStyles>;
|
|
386
443
|
|
|
387
|
-
declare
|
|
444
|
+
declare function JsonEditor<T = JsonData>(props: JsonEditorProps<T>): React$1.ReactElement;
|
|
388
445
|
|
|
389
|
-
declare
|
|
446
|
+
declare function JsonViewer<T = JsonData>(props: JsonViewerProps<T>): React$1.ReactElement | null;
|
|
390
447
|
|
|
391
|
-
|
|
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
|
-
|
|
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
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
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
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
declare const
|
|
445
|
-
declare const
|
|
446
|
-
|
|
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
|
-
|
|
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
|
-
|
|
451
|
-
export { AssignInput, AssignOptions, CollapseState, CollectionNodeProps, CompareFunction,
|
|
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 };
|