@oursprivacy/react-json-view 1.27.2 → 1.27.4

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/index.d.ts CHANGED
@@ -1,320 +1,338 @@
1
- import * as React from 'react'
1
+ import type * as React from "react";
2
+
3
+ /**
4
+ * TypeScript definitions for react-json-view
5
+ *
6
+ * This type definition file provides comprehensive TypeScript support for the react-json-view library.
7
+ * It includes all props, interfaces, and type definitions needed for type-safe usage of the ReactJsonView component.
8
+ *
9
+ * This file is internally maintained and can be modified as needed to match the library's implementation.
10
+ * If you need to make changes or download the latest version, please visit the GitHub repository:
11
+ *
12
+ * @see {@link https://github.com/with-ours/react-json-view | GitHub Repository}
13
+ *
14
+ * The repository contains the full source code, including this type definition file, making it easy
15
+ * to download, edit, and customize the types to suit your specific needs.
16
+ */
2
17
 
3
18
  export interface ReactJsonViewProps {
4
- /**
5
- * This property contains your input JSON.
6
- *
7
- * Required.
8
- */
9
- src: object
10
- /**
11
- * Contains the name of your root node. Use null or false for no name.
12
- *
13
- * Default: "root"
14
- */
15
- name?: React.JSX.Element | string | null | false
16
- /**
17
- * RJV supports base-16 themes. Check out the list of supported themes in the demo.
18
- * A custom "rjv-default" theme applies by default.
19
- *
20
- * Default: "rjv-default"
21
- */
22
- theme?: ThemeKeys | ThemeObject
23
- /**
24
- * Style attributes for react-json-view container.
25
- * Explicit style attributes will override attributes provided by a theme.
26
- *
27
- * Default: "rjv-default"
28
- */
29
- style?: React.CSSProperties
30
- /**
31
- * Style of expand/collapse icons. Accepted values are "circle", triangle" or "square".
32
- *
33
- * Default: {}
34
- */
35
- iconStyle?: 'circle' | 'triangle' | 'square'
36
- /**
37
- * Set the indent-width for nested objects.
38
- *
39
- * Default: 4
40
- */
41
- indentWidth?: number
42
- /**
43
- * When set to true, all nodes will be collapsed by default.
44
- * Use an integer value to collapse at a particular depth.
45
- *
46
- * Default: false
47
- */
48
- collapsed?: boolean | number
49
- /**
50
- * When an integer value is assigned, strings will be cut off at that length.
51
- * Collapsed strings are followed by an ellipsis.
52
- * String content can be expanded and collapsed by clicking on the string value.
53
- *
54
- * Default: false
55
- */
56
- collapseStringsAfterLength?: number | false
57
- /**
58
- * Callback function to provide control over what objects and arrays should be collapsed by default.
59
- * An object is passed to the callback containing name, src, type ("array" or "object") and namespace.
60
- *
61
- * Default: false
62
- */
63
- shouldCollapse?: false | ((field: CollapsedFieldProps) => boolean)
64
- /**
65
- * When an integer value is assigned, arrays will be displayed in groups by count of the value.
66
- * Groups are displayed with brakcet notation and can be expanded and collapsed by clickong on the brackets.
67
- *
68
- * Default: 100
69
- */
70
- groupArraysAfterLength?: number
71
- /**
72
- * When prop is not false, the user can copy objects and arrays to clipboard by clicking on the clipboard icon.
73
- * Copy callbacks are supported.
74
- *
75
- * Default: true
76
- */
77
- enableClipboard?: boolean | ((copy: OnCopyProps) => void)
78
- /**
79
- * When set to true, objects and arrays are labeled with size.
80
- *
81
- * Default: true
82
- */
83
- displayObjectSize?: boolean
84
- /**
85
- * When set to true, data type labels prefix values.
86
- *
87
- * Default: true
88
- */
89
- displayDataTypes?: boolean
90
- /**
91
- * When set to true, the index of the elements prefix values
92
- *
93
- * Default: true
94
- */
95
- displayArrayKey?: boolean
96
- /**
97
- * set to false to remove quotes from keys (eg. "name": vs. name:)
98
- *
99
- * Default: true
100
- */
101
- quotesOnKeys?: boolean
102
- /**
103
- * When a callback function is passed in, edit functionality is enabled.
104
- * The callback is invoked before edits are completed. Returning false
105
- * from onEdit will prevent the change from being made. see: onEdit docs.
106
- *
107
- * Default: false
108
- */
109
- onEdit?: ((edit: InteractionProps) => false | any) | false
110
- /**
111
- * When a callback function is passed in, add functionality is enabled.
112
- * The callback is invoked before additions are completed.
113
- * Returning false from onAdd will prevent the change from being made. see: onAdd docs
114
- *
115
- * Default: false
116
- */
117
- onAdd?: ((add: InteractionProps) => false | any) | false
118
- /**
119
- * When a callback function is passed in, delete functionality is enabled.
120
- * The callback is invoked before deletions are completed.
121
- * Returning false from onDelete will prevent the change from being made. see: onDelete docs
122
- *
123
- * Default: false
124
- */
125
- onDelete?: ((del: InteractionProps) => false | any) | false
126
- /**
127
- * When a function is passed in, clicking a value triggers the onSelect method to be called.
128
- *
129
- * Default: false
130
- */
131
- onSelect?: ((select: OnSelectProps) => void) | false
132
- /**
133
- * Custom message for validation failures to onEdit, onAdd, or onDelete callbacks.
134
- *
135
- * Default: "Validation Error"
136
- */
137
- validationMessage?: string
138
- /**
139
- * Set to true to sort object keys.
140
- *
141
- * Default: false
142
- */
143
- sortKeys?: boolean
144
- /**
145
- * Set to a value to be used as defaultValue when adding new key to json
146
- *
147
- * Default: null
148
- */
149
- defaultValue?: TypeDefaultValue | TypeDefaultValue[] | null
150
- /**
151
- * Whether to select the textarea contents on edit
152
- *
153
- * Default: false
154
- */
155
- selectOnFocus?: boolean
156
- /**
157
- * The key modifier to be combined with a click on JSON values to edit them
158
- *
159
- * Default: (e) => e.metaKey || e.ctrlKey
160
- */
161
- keyModifier?: (event: Event, type: 'edit' | 'submit') => boolean
162
- /**
163
- * Set to true to escape strings sequences such as \n, \t, \r, \f
164
- *
165
- * Default: true
166
- */
167
- escapeStrings?: boolean
168
- /**
169
- * An object mapping key names to decorator functions. Each decorator function
170
- * receives the key content as children and returns a React element that wraps it.
171
- * Allows custom rendering of specific object keys.
172
- *
173
- * Default: undefined
174
- */
175
- keyDecorators?: Record<string, (children: React.ReactNode) => React.ReactNode>
19
+ /**
20
+ * This property contains your input JSON.
21
+ *
22
+ * Required.
23
+ */
24
+ src: object;
25
+ /**
26
+ * Contains the name of your root node. Use null or false for no name.
27
+ *
28
+ * Default: "root"
29
+ */
30
+ name?: React.JSX.Element | string | null | false;
31
+ /**
32
+ * RJV supports base-16 themes. Check out the list of supported themes in the demo.
33
+ * A custom "rjv-default" theme applies by default.
34
+ *
35
+ * Default: "rjv-default"
36
+ */
37
+ theme?: ThemeKeys | ThemeObject;
38
+ /**
39
+ * Style attributes for react-json-view container.
40
+ * Explicit style attributes will override attributes provided by a theme.
41
+ *
42
+ * Default: "rjv-default"
43
+ */
44
+ style?: React.CSSProperties;
45
+ /**
46
+ * Style of expand/collapse icons. Accepted values are "circle", triangle" or "square".
47
+ *
48
+ * Default: {}
49
+ */
50
+ iconStyle?: "circle" | "triangle" | "square";
51
+ /**
52
+ * Set the indent-width for nested objects.
53
+ *
54
+ * Default: 4
55
+ */
56
+ indentWidth?: number;
57
+ /**
58
+ * When set to true, all nodes will be collapsed by default.
59
+ * Use an integer value to collapse at a particular depth.
60
+ *
61
+ * Default: false
62
+ */
63
+ collapsed?: boolean | number;
64
+ /**
65
+ * When an integer value is assigned, strings will be cut off at that length.
66
+ * Collapsed strings are followed by an ellipsis.
67
+ * String content can be expanded and collapsed by clicking on the string value.
68
+ *
69
+ * Default: false
70
+ */
71
+ collapseStringsAfterLength?: number | false;
72
+ /**
73
+ * Callback function to provide control over what objects and arrays should be collapsed by default.
74
+ * An object is passed to the callback containing name, src, type ("array" or "object") and namespace.
75
+ *
76
+ * Default: false
77
+ */
78
+ shouldCollapse?: false | ((field: CollapsedFieldProps) => boolean);
79
+ /**
80
+ * When an integer value is assigned, arrays will be displayed in groups by count of the value.
81
+ * Groups are displayed with brakcet notation and can be expanded and collapsed by clickong on the brackets.
82
+ *
83
+ * Default: 100
84
+ */
85
+ groupArraysAfterLength?: number;
86
+ /**
87
+ * When prop is not false, the user can copy objects and arrays to clipboard by clicking on the clipboard icon.
88
+ * Copy callbacks are supported.
89
+ *
90
+ * Default: true
91
+ */
92
+ enableClipboard?: boolean | ((copy: OnCopyProps) => void);
93
+ /**
94
+ * When set to true, objects and arrays are labeled with size.
95
+ *
96
+ * Default: true
97
+ */
98
+ displayObjectSize?: boolean;
99
+ /**
100
+ * When set to true, data type labels prefix values.
101
+ *
102
+ * Default: true
103
+ */
104
+ displayDataTypes?: boolean;
105
+ /**
106
+ * When set to true, the index of the elements prefix values
107
+ *
108
+ * Default: true
109
+ */
110
+ displayArrayKey?: boolean;
111
+ /**
112
+ * set to false to remove quotes from keys (eg. "name": vs. name:)
113
+ *
114
+ * Default: true
115
+ */
116
+ quotesOnKeys?: boolean;
117
+ /**
118
+ * When a callback function is passed in, edit functionality is enabled.
119
+ * The callback is invoked before edits are completed. Returning false
120
+ * from onEdit will prevent the change from being made. see: onEdit docs.
121
+ *
122
+ * Default: false
123
+ */
124
+ onEdit?: ((edit: InteractionProps) => false | any) | false;
125
+ /**
126
+ * When a callback function is passed in, add functionality is enabled.
127
+ * The callback is invoked before additions are completed.
128
+ * Returning false from onAdd will prevent the change from being made. see: onAdd docs
129
+ *
130
+ * Default: false
131
+ */
132
+ onAdd?: ((add: InteractionProps) => false | any) | false;
133
+ /**
134
+ * When a callback function is passed in, delete functionality is enabled.
135
+ * The callback is invoked before deletions are completed.
136
+ * Returning false from onDelete will prevent the change from being made. see: onDelete docs
137
+ *
138
+ * Default: false
139
+ */
140
+ onDelete?: ((del: InteractionProps) => false | any) | false;
141
+ /**
142
+ * When a function is passed in, clicking a value triggers the onSelect method to be called.
143
+ *
144
+ * Default: false
145
+ */
146
+ onSelect?: ((select: OnSelectProps) => void) | false;
147
+ /**
148
+ * Custom message for validation failures to onEdit, onAdd, or onDelete callbacks.
149
+ *
150
+ * Default: "Validation Error"
151
+ */
152
+ validationMessage?: string;
153
+ /**
154
+ * Set to true to sort object keys.
155
+ *
156
+ * Default: false
157
+ */
158
+ sortKeys?: boolean;
159
+ /**
160
+ * Set to a value to be used as defaultValue when adding new key to json
161
+ *
162
+ * Default: null
163
+ */
164
+ defaultValue?: TypeDefaultValue | TypeDefaultValue[] | null;
165
+ /**
166
+ * Whether to select the textarea contents on edit
167
+ *
168
+ * Default: false
169
+ */
170
+ selectOnFocus?: boolean;
171
+ /**
172
+ * The key modifier to be combined with a click on JSON values to edit them
173
+ *
174
+ * Default: (e) => e.metaKey || e.ctrlKey
175
+ */
176
+ keyModifier?: (event: Event, type: "edit" | "submit") => boolean;
177
+ /**
178
+ * Set to true to escape strings sequences such as \n, \t, \r, \f
179
+ *
180
+ * Default: true
181
+ */
182
+ escapeStrings?: boolean;
183
+ /**
184
+ * An object mapping key names to decorator functions. Each decorator function
185
+ * receives the key content as children and returns a React element that wraps it.
186
+ * Allows custom rendering of specific object keys.
187
+ *
188
+ * Default: undefined
189
+ */
190
+ keyDecorators?: Record<
191
+ string,
192
+ (children: React.ReactNode) => React.ReactNode
193
+ >;
176
194
  }
177
195
 
178
196
  export interface OnCopyProps {
179
- /**
180
- * The JSON tree source object
181
- */
182
- src: object
183
- /**
184
- * List of keys.
185
- */
186
- namespace: Array<string | null>
187
- /**
188
- * The last key in the namespace array.
189
- */
190
- name: string | null
197
+ /**
198
+ * The JSON tree source object
199
+ */
200
+ src: object;
201
+ /**
202
+ * List of keys.
203
+ */
204
+ namespace: Array<string | null>;
205
+ /**
206
+ * The last key in the namespace array.
207
+ */
208
+ name: string | null;
191
209
  }
192
210
 
193
211
  export interface CollapsedFieldProps {
194
- /**
195
- * The name of the entry.
196
- */
197
- name: string | null
198
- /**
199
- * The corresponding JSON subtree.
200
- */
201
- src: object
202
- /**
203
- * The type of src. Can only be "array" or "object".
204
- */
205
- type: 'array' | 'object'
206
- /**
207
- * The scopes above the current entry.
208
- */
209
- namespace: Array<string | null>
212
+ /**
213
+ * The name of the entry.
214
+ */
215
+ name: string | null;
216
+ /**
217
+ * The corresponding JSON subtree.
218
+ */
219
+ src: object;
220
+ /**
221
+ * The type of src. Can only be "array" or "object".
222
+ */
223
+ type: "array" | "object";
224
+ /**
225
+ * The scopes above the current entry.
226
+ */
227
+ namespace: Array<string | null>;
210
228
  }
211
229
 
212
230
  export interface InteractionProps {
213
- /**
214
- * The updated subtree of the JSON tree.
215
- */
216
- updated_src: object
217
- /**
218
- * The existing subtree of the JSON tree.
219
- */
220
- existing_src: object
221
- /**
222
- * The key of the entry that is interacted with.
223
- */
224
- name: string | null
225
- /**
226
- * List of keys.
227
- */
228
- namespace: Array<string | null>
229
- /**
230
- * The original value of the entry that is interacted with.
231
- */
232
- existing_value: object | string | number | boolean | null
233
- /**
234
- * The updated value of the entry that is interacted with.
235
- */
236
- new_value?: object | string | number | boolean | null
231
+ /**
232
+ * The updated subtree of the JSON tree.
233
+ */
234
+ updated_src: object;
235
+ /**
236
+ * The existing subtree of the JSON tree.
237
+ */
238
+ existing_src: object;
239
+ /**
240
+ * The key of the entry that is interacted with.
241
+ */
242
+ name: string | null;
243
+ /**
244
+ * List of keys.
245
+ */
246
+ namespace: Array<string | null>;
247
+ /**
248
+ * The original value of the entry that is interacted with.
249
+ */
250
+ existing_value: object | string | number | boolean | null;
251
+ /**
252
+ * The updated value of the entry that is interacted with.
253
+ */
254
+ new_value?: object | string | number | boolean | null;
237
255
  }
238
256
 
239
257
  export interface OnSelectProps {
240
- /**
241
- * The name of the currently selected entry.
242
- */
243
- name: string | null
244
- /**
245
- * The value of the currently selected entry.
246
- */
247
- value: object | string | number | boolean | null
248
- /**
249
- * The type of the value. For "number" type, it will be replaced with the more
250
- * accurate types: "float", "integer", or "nan".
251
- */
252
- type: string
253
- /**
254
- * List of keys representing the scopes above the selected entry.
255
- */
256
- namespace: Array<string | null>
258
+ /**
259
+ * The name of the currently selected entry.
260
+ */
261
+ name: string | null;
262
+ /**
263
+ * The value of the currently selected entry.
264
+ */
265
+ value: object | string | number | boolean | null;
266
+ /**
267
+ * The type of the value. For "number" type, it will be replaced with the more
268
+ * accurate types: "float", "integer", or "nan".
269
+ */
270
+ type: string;
271
+ /**
272
+ * List of keys representing the scopes above the selected entry.
273
+ */
274
+ namespace: Array<string | null>;
257
275
  }
258
276
 
259
- export type TypeDefaultValue = string | number | boolean | object
277
+ export type TypeDefaultValue = string | number | boolean | object;
260
278
 
261
279
  export interface ThemeObject {
262
- base00: string
263
- base01: string
264
- base02: string
265
- base03: string
266
- base04: string
267
- base05: string
268
- base06: string
269
- base07: string
270
- base08: string
271
- base09: string
272
- base0A: string
273
- base0B: string
274
- base0C: string
275
- base0D: string
276
- base0E: string
277
- base0F: string
280
+ base00: string;
281
+ base01: string;
282
+ base02: string;
283
+ base03: string;
284
+ base04: string;
285
+ base05: string;
286
+ base06: string;
287
+ base07: string;
288
+ base08: string;
289
+ base09: string;
290
+ base0A: string;
291
+ base0B: string;
292
+ base0C: string;
293
+ base0D: string;
294
+ base0E: string;
295
+ base0F: string;
278
296
  }
279
297
 
280
298
  export type ThemeKeys =
281
- | 'apathy'
282
- | 'apathy:inverted'
283
- | 'ashes'
284
- | 'bespin'
285
- | 'brewer'
286
- | 'bright:inverted'
287
- | 'bright'
288
- | 'chalk'
289
- | 'codeschool'
290
- | 'colors'
291
- | 'eighties'
292
- | 'embers'
293
- | 'flat'
294
- | 'google'
295
- | 'grayscale'
296
- | 'grayscale:inverted'
297
- | 'greenscreen'
298
- | 'harmonic'
299
- | 'hopscotch'
300
- | 'isotope'
301
- | 'marrakesh'
302
- | 'mocha'
303
- | 'monokai'
304
- | 'ocean'
305
- | 'paraiso'
306
- | 'pop'
307
- | 'railscasts'
308
- | 'rjv-default'
309
- | 'shapeshifter'
310
- | 'shapeshifter:inverted'
311
- | 'solarized'
312
- | 'summerfruit'
313
- | 'summerfruit:inverted'
314
- | 'threezerotwofour'
315
- | 'tomorrow'
316
- | 'tube'
317
- | 'twilight'
299
+ | "apathy"
300
+ | "apathy:inverted"
301
+ | "ashes"
302
+ | "bespin"
303
+ | "brewer"
304
+ | "bright:inverted"
305
+ | "bright"
306
+ | "chalk"
307
+ | "codeschool"
308
+ | "colors"
309
+ | "eighties"
310
+ | "embers"
311
+ | "flat"
312
+ | "google"
313
+ | "grayscale"
314
+ | "grayscale:inverted"
315
+ | "greenscreen"
316
+ | "harmonic"
317
+ | "hopscotch"
318
+ | "isotope"
319
+ | "marrakesh"
320
+ | "mocha"
321
+ | "monokai"
322
+ | "ocean"
323
+ | "paraiso"
324
+ | "pop"
325
+ | "railscasts"
326
+ | "rjv-default"
327
+ | "shapeshifter"
328
+ | "shapeshifter:inverted"
329
+ | "solarized"
330
+ | "summerfruit"
331
+ | "summerfruit:inverted"
332
+ | "threezerotwofour"
333
+ | "tomorrow"
334
+ | "tube"
335
+ | "twilight";
318
336
 
319
- declare const ReactJson: React.ComponentType<ReactJsonViewProps>
320
- export default ReactJson
337
+ declare const ReactJson: React.ComponentType<ReactJsonViewProps>;
338
+ export default ReactJson;