json-edit-react 0.9.4 → 1.0.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.d.ts CHANGED
@@ -30,6 +30,8 @@ declare const localisedStrings: {
30
30
  ERROR_UPDATE: string;
31
31
  ERROR_DELETE: string;
32
32
  ERROR_ADD: string;
33
+ DEFAULT_STRING: string;
34
+ DEFAULT_NEW_KEY: string;
33
35
  };
34
36
  type LocalisedStrings = typeof localisedStrings;
35
37
  type TranslateFunction = (key: keyof LocalisedStrings, count?: number) => string;
@@ -47,19 +49,24 @@ interface JsonEditorProps {
47
49
  className?: string;
48
50
  indent?: number;
49
51
  collapse?: boolean | number | FilterFunction;
52
+ showCollectionCount?: boolean | 'when-closed';
50
53
  restrictEdit?: boolean | FilterFunction;
51
54
  restrictDelete?: boolean | FilterFunction;
52
55
  restrictAdd?: boolean | FilterFunction;
53
- restrictKeyEdit?: boolean | FilterFunction;
56
+ restrictTypeSelection?: boolean | DataType[] | TypeFilterFunction;
54
57
  keySort?: boolean | CompareFunction;
55
58
  showArrayIndices?: boolean;
56
59
  defaultValue?: unknown;
57
60
  minWidth?: string | number;
58
- maxWidth?: number;
61
+ maxWidth?: string | number;
59
62
  stringTruncate?: number;
60
63
  translations?: Partial<LocalisedStrings>;
64
+ customNodeDefinitions?: CustomNodeDefinition[];
61
65
  }
66
+ declare const DataTypes: readonly ["string", "number", "boolean", "null", "object", "array"];
67
+ type DataType = (typeof DataTypes)[number] | 'invalid';
62
68
  type CollectionKey = string | number;
69
+ type CollectionData = object | unknown[];
63
70
  type ErrorString = string;
64
71
  interface IconReplacements {
65
72
  add?: JSX.Element;
@@ -78,22 +85,56 @@ type UpdateFunction = (props: {
78
85
  name: CollectionKey;
79
86
  path: CollectionKey[];
80
87
  }) => void | ErrorString | false;
81
- type FilterFunction = (input: {
88
+ interface FilterProps {
82
89
  key: CollectionKey;
83
90
  path: CollectionKey[];
84
91
  level: number;
85
92
  value: unknown;
86
93
  size: number | null;
87
- }) => boolean;
94
+ }
95
+ type FilterFunction = (input: FilterProps) => boolean;
96
+ type TypeFilterFunction = (input: FilterProps) => boolean | DataType[];
88
97
  type CopyType = 'path' | 'value';
89
98
  type CopyFunction = (input: {
90
99
  key: CollectionKey;
91
100
  path: CollectionKey[];
92
- value: string;
101
+ value: unknown;
102
+ stringValue: string;
93
103
  type: CopyType;
94
104
  }) => void;
95
105
  type CompareFunction = (a: string, b: string) => number;
106
+ type OnChangeFunction = (value: unknown, path: (string | number)[]) => Promise<string | void>;
107
+ interface BaseNodeProps {
108
+ data: unknown;
109
+ parentData: CollectionData | null;
110
+ path: CollectionKey[];
111
+ name: CollectionKey;
112
+ onEdit: OnChangeFunction;
113
+ onDelete: OnChangeFunction;
114
+ enableClipboard: boolean | CopyFunction;
115
+ restrictEditFilter: FilterFunction;
116
+ restrictDeleteFilter: FilterFunction;
117
+ restrictAddFilter: FilterFunction;
118
+ restrictTypeSelection: boolean | DataType[] | TypeFilterFunction;
119
+ stringTruncate: number;
120
+ indent: number;
121
+ translate: TranslateFunction;
122
+ customNodeDefinitions: CustomNodeDefinition[];
123
+ }
124
+ interface CustomNodeProps extends BaseNodeProps {
125
+ customProps?: Record<string, unknown>;
126
+ parentData: CollectionData | null;
127
+ }
128
+ interface CustomNodeDefinition {
129
+ condition: FilterFunction;
130
+ element: React$1.FC<CustomNodeProps>;
131
+ name: string;
132
+ props?: Record<string, unknown>;
133
+ hideKey?: boolean;
134
+ defaultValue: unknown;
135
+ showInTypesSelector?: boolean;
136
+ }
96
137
 
97
138
  declare const JsonEditor: React$1.FC<JsonEditorProps>;
98
139
 
99
- export { CompareFunction, CopyFunction, FilterFunction, IconReplacements, JsonEditor, JsonEditorProps, LocalisedStrings, Theme, ThemeInput, ThemeName, TranslateFunction, UpdateFunction, JsonEditor as default, themes };
140
+ export { type CompareFunction, type CopyFunction, type FilterFunction, type IconReplacements, JsonEditor, type JsonEditorProps, type LocalisedStrings, type Theme, type ThemeInput, type ThemeName, type TranslateFunction, type UpdateFunction, themes };