json-edit-react 0.9.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.
@@ -0,0 +1,98 @@
1
+ /// <reference types="react" />
2
+ import React$1 from 'react';
3
+
4
+ declare const themes: {
5
+ default: DefaultTheme;
6
+ } & Record<string, Theme>;
7
+ declare const themeableElements: readonly ["container", "property", "bracket", "itemCount", "string", "number", "boolean", "null", "input", "inputHighlight", "error", "iconCollection", "iconEdit", "iconDelete", "iconAdd", "iconCopy", "iconOk", "iconCancel"];
8
+ type ThemeableElement = (typeof themeableElements)[number];
9
+ type ThemeValue = string | React.CSSProperties | Array<string | React.CSSProperties>;
10
+ type ThemeStyles = Record<ThemeableElement, ThemeValue>;
11
+ type Fragments = Record<string, React.CSSProperties | string>;
12
+ interface Theme {
13
+ displayName?: string;
14
+ fragments?: Fragments;
15
+ styles: Partial<ThemeStyles>;
16
+ }
17
+ interface DefaultTheme extends Theme {
18
+ displayName: 'Default';
19
+ styles: ThemeStyles;
20
+ }
21
+ type ThemeName = keyof typeof themes;
22
+ type ThemeInput = ThemeName | Theme | Partial<ThemeStyles> | [ThemeName, Theme | Partial<ThemeStyles>];
23
+
24
+ declare const localisedStrings: {
25
+ ITEM_SINGLE: string;
26
+ ITEMS_MULTIPLE: string;
27
+ KEY_NEW: string;
28
+ ERROR_KEY_EXISTS: string;
29
+ ERROR_INVALID_JSON: string;
30
+ ERROR_UPDATE: string;
31
+ ERROR_DELETE: string;
32
+ ERROR_ADD: string;
33
+ };
34
+ type LocalisedStrings = typeof localisedStrings;
35
+
36
+ interface JsonEditorProps {
37
+ data: object;
38
+ rootName?: string;
39
+ onUpdate?: UpdateFunction;
40
+ onEdit?: UpdateFunction;
41
+ onDelete?: UpdateFunction;
42
+ onAdd?: UpdateFunction;
43
+ enableClipboard?: boolean | CopyFunction;
44
+ theme?: ThemeInput;
45
+ icons?: IconReplacements;
46
+ className?: string;
47
+ indent?: number;
48
+ collapse?: boolean | number | FilterFunction;
49
+ restrictEdit?: boolean | FilterFunction;
50
+ restrictDelete?: boolean | FilterFunction;
51
+ restrictAdd?: boolean | FilterFunction;
52
+ restrictKeyEdit?: boolean | FilterFunction;
53
+ keySort?: boolean | CompareFunction;
54
+ showArrayIndices?: boolean;
55
+ defaultValue?: unknown;
56
+ minWidth?: string | number;
57
+ maxWidth?: number;
58
+ stringTruncate?: number;
59
+ translations?: Partial<LocalisedStrings>;
60
+ }
61
+ type CollectionKey = string | number;
62
+ type ErrorString = string;
63
+ interface IconReplacements {
64
+ add?: JSX.Element;
65
+ edit?: JSX.Element;
66
+ delete?: JSX.Element;
67
+ copy?: JSX.Element;
68
+ ok?: JSX.Element;
69
+ cancel?: JSX.Element;
70
+ chevron?: JSX.Element;
71
+ }
72
+ type UpdateFunction = (props: {
73
+ newData: object;
74
+ currentData: object;
75
+ newValue: unknown;
76
+ currentValue: unknown;
77
+ name: CollectionKey;
78
+ path: CollectionKey[];
79
+ }) => void | ErrorString | false;
80
+ type FilterFunction = (input: {
81
+ key: CollectionKey;
82
+ path: CollectionKey[];
83
+ level: number;
84
+ value: unknown;
85
+ size: number | null;
86
+ }) => boolean;
87
+ type CopyType = 'path' | 'value';
88
+ type CopyFunction = (input: {
89
+ key: CollectionKey;
90
+ path: CollectionKey[];
91
+ value: unknown;
92
+ type: CopyType;
93
+ }) => void;
94
+ type CompareFunction = (a: string, b: string) => number;
95
+
96
+ declare const JsonEditor: React$1.FC<JsonEditorProps>;
97
+
98
+ export { JsonEditor, Theme, ThemeName, themes };