This repository has been archived by the owner on Oct 31, 2024. It is now read-only.
forked from mac-s-g/react-json-view
-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.d.ts
290 lines (279 loc) · 7.03 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
import * as React from 'react';
export interface ReactJsonViewProps {
/**
* This property contains your input JSON.
*
* Required.
*/
src: object;
/**
* Contains the name of your root node. Use null or false for no name.
*
* Default: "root"
*/
name?: string | null | false;
/**
* RJV supports base-16 themes. Check out the list of supported themes in the demo.
* A custom "rjv-default" theme applies by default.
*
* Default: "rjv-default"
*/
theme?: ThemeKeys | ThemeObject;
/**
* Style attributes for react-json-view container.
* Explicit style attributes will override attributes provided by a theme.
*
* Default: "rjv-default"
*/
style?: React.CSSProperties;
/**
* Style of expand/collapse icons. Accepted values are "circle", triangle" or "square".
*
* Default: {}
*/
iconStyle?: 'circle' | 'triangle' | 'square';
/**
* Set the indent-width for nested objects.
*
* Default: 4
*/
indentWidth?: number;
/**
* When set to true, all nodes will be collapsed by default.
* Use an integer value to collapse at a particular depth.
*
* Default: false
*/
collapsed?: boolean | number;
/**
* When an integer value is assigned, strings will be cut off at that length.
* Collapsed strings are followed by an ellipsis.
* String content can be expanded and collapsed by clicking on the string value.
*
* Default: false
*/
collapseStringsAfterLength?: number | false;
/**
* Callback function to provide control over what objects and arrays should be collapsed by default.
* An object is passed to the callback containing name, src, type ("array" or "object") and namespace.
*
* Default: false
*/
shouldCollapse?: false | ((field: CollapsedFieldProps) => boolean);
/**
* When an integer value is assigned, arrays will be displayed in groups by count of the value.
* Groups are displayed with brakcet notation and can be expanded and collapsed by clickong on the brackets.
*
* Default: 100
*/
groupArraysAfterLength?: number;
/**
* When prop is not false, the user can copy objects and arrays to clipboard by clicking on the clipboard icon.
* Copy callbacks are supported.
*
* Default: true
*/
enableClipboard?: boolean | ((copy: OnCopyProps) => void);
/**
* When set to true, objects and arrays are labeled with size.
*
* Default: true
*/
displayObjectSize?: boolean;
/**
* When set to true, data type labels prefix values.
*
* Default: true
*/
displayDataTypes?: boolean;
/**
* When a callback function is passed in, edit functionality is enabled.
* The callback is invoked before edits are completed. Returning false
* from onEdit will prevent the change from being made. see: onEdit docs.
*
* Default: false
*/
onEdit?: ((edit: InteractionProps) => false | any) | false;
/**
* When a callback function is passed in, add functionality is enabled.
* The callback is invoked before additions are completed.
* Returning false from onAdd will prevent the change from being made. see: onAdd docs
*
* Default: false
*/
onAdd?: ((add: InteractionProps) => false | any) | false;
/**
* When a callback function is passed in, delete functionality is enabled.
* The callback is invoked before deletions are completed.
* Returning false from onDelete will prevent the change from being made. see: onDelete docs
*
* Default: false
*/
onDelete?: ((del: InteractionProps) => false | any) | false;
/**
* When a function is passed in, clicking a value triggers the onSelect method to be called.
*
* Default: false
*/
onSelect?: ((select: OnSelectProps) => void) | false;
/**
* Custom message for validation failures to onEdit, onAdd, or onDelete callbacks.
*
* Default: "Validation Error"
*/
validationMessage?: string;
/**
* Set to true to sort object keys.
*
* Default: false
*/
sortKeys?: boolean;
/**
* Set to a value to be used as defaultValue when adding new key to json
*
* Default: null
*/
defaultValue?: TypeDefaultValue | TypeDefaultValue[] | null;
highlightSearch?: string;
highlightSearchColor?: string;
highlightCurrentSearchColor?: string;
customCopiedIcon?: object;
customCopyIcon?: object;
customActions?: Array<object>;
}
export interface OnCopyProps {
/**
* The JSON tree source object
*/
src: object;
/**
* List of keys.
*/
namespace: Array<string | null>;
/**
* The last key in the namespace array.
*/
name: string | null;
}
export interface CollapsedFieldProps {
/**
* The name of the entry.
*/
name: string | null;
/**
* The corresponding JSON subtree.
*/
src: object;
/**
* The type of src. Can only be "array" or "object".
*/
type: 'array' | 'object';
/**
* The scopes above the current entry.
*/
namespace: Array<string | null>;
}
export interface InteractionProps {
/**
* The updated subtree of the JSON tree.
*/
updated_src: object;
/**
* The existing subtree of the JSON tree.
*/
existing_src: object;
/**
* The key of the entry that is interacted with.
*/
name: string | null;
/**
* List of keys.
*/
namespace: Array<string | null>;
/**
* The original value of the entry that is interacted with.
*/
existing_value: object | string | number | boolean | null;
/**
* The updated value of the entry that is interacted with.
*/
new_value?: object | string | number | boolean | null;
}
export interface OnSelectProps {
/**
* The name of the currently selected entry.
*/
name: string | null;
/**
* The value of the currently selected entry.
*/
value: object | string | number | boolean | null;
/**
* The type of the value. For "number" type, it will be replaced with the more
* accurate types: "float", "integer", or "nan".
*/
type: string;
/**
* List of keys representing the scopes above the selected entry.
*/
namespace: Array<string | null>;
}
export type TypeDefaultValue = string | number | boolean | object;
export interface ThemeObject {
base00: string;
base01: string;
base02: string;
base03: string;
base04: string;
base05: string;
base06: string;
base07: string;
base08: string;
base09: string;
base0A: string;
base0B: string;
base0C: string;
base0D: string;
base0E: string;
base0F: string;
}
export type ThemeKeys =
| 'apathy'
| 'apathy:inverted'
| 'ashes'
| 'bespin'
| 'brewer'
| 'bright:inverted'
| 'bright'
| 'chalk'
| 'codeschool'
| 'colors'
| 'eighties'
| 'embers'
| 'flat'
| 'google'
| 'grayscale'
| 'grayscale:inverted'
| 'greenscreen'
| 'harmonic'
| 'hopscotch'
| 'isotope'
| 'marrakesh'
| 'mocha'
| 'monokai'
| 'ocean'
| 'paraiso'
| 'pop'
| 'railscasts'
| 'rjv-default'
| 'shapeshifter'
| 'shapeshifter:inverted'
| 'solarized'
| 'summerfruit'
| 'summerfruit:inverted'
| 'threezerotwofour'
| 'tomorrow'
| 'tube'
| 'twilight';
declare const ReactJson: React.ComponentType<ReactJsonViewProps>;
export default ReactJson;