json-edit-react 1.1.0 → 1.1.1

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
@@ -1,140 +1,177 @@
1
1
  /// <reference types="react" />
2
- import React$1 from 'react';
2
+ import React$1 from 'react'
3
3
 
4
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>;
5
+ default: DefaultTheme
6
+ } & Record<string, Theme>
7
+ declare const themeableElements: readonly [
8
+ 'container',
9
+ 'property',
10
+ 'bracket',
11
+ 'itemCount',
12
+ 'string',
13
+ 'number',
14
+ 'boolean',
15
+ 'null',
16
+ 'input',
17
+ 'inputHighlight',
18
+ 'error',
19
+ 'iconCollection',
20
+ 'iconEdit',
21
+ 'iconDelete',
22
+ 'iconAdd',
23
+ 'iconCopy',
24
+ 'iconOk',
25
+ 'iconCancel'
26
+ ]
27
+ type ThemeableElement = (typeof themeableElements)[number]
28
+ type ThemeValue = string | React.CSSProperties | Array<string | React.CSSProperties>
29
+ type ThemeStyles = Record<ThemeableElement, ThemeValue>
30
+ type Fragments = Record<string, React.CSSProperties | string>
12
31
  interface Theme {
13
- displayName?: string;
14
- fragments?: Fragments;
15
- styles: Partial<ThemeStyles>;
32
+ displayName?: string
33
+ fragments?: Fragments
34
+ styles: Partial<ThemeStyles>
16
35
  }
17
36
  interface DefaultTheme extends Theme {
18
- displayName: 'Default';
19
- styles: ThemeStyles;
37
+ displayName: 'Default'
38
+ styles: ThemeStyles
20
39
  }
21
- type ThemeName = keyof typeof themes;
22
- type ThemeInput = ThemeName | Theme | Partial<ThemeStyles> | [ThemeName, Theme | Partial<ThemeStyles>];
40
+ type ThemeName = keyof typeof themes
41
+ type ThemeInput =
42
+ | ThemeName
43
+ | Theme
44
+ | Partial<ThemeStyles>
45
+ | [ThemeName, Theme | Partial<ThemeStyles>]
23
46
 
24
47
  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
- DEFAULT_STRING: string;
34
- DEFAULT_NEW_KEY: string;
35
- };
36
- type LocalisedStrings = typeof localisedStrings;
37
- type TranslateFunction = (key: keyof LocalisedStrings, count?: number) => string;
48
+ ITEM_SINGLE: string
49
+ ITEMS_MULTIPLE: string
50
+ KEY_NEW: string
51
+ ERROR_KEY_EXISTS: string
52
+ ERROR_INVALID_JSON: string
53
+ ERROR_UPDATE: string
54
+ ERROR_DELETE: string
55
+ ERROR_ADD: string
56
+ DEFAULT_STRING: string
57
+ DEFAULT_NEW_KEY: string
58
+ }
59
+ type LocalisedStrings = typeof localisedStrings
60
+ type TranslateFunction = (key: keyof LocalisedStrings, count?: number) => string
38
61
 
39
62
  interface JsonEditorProps {
40
- data: object;
41
- rootName?: string;
42
- onUpdate?: UpdateFunction;
43
- onEdit?: UpdateFunction;
44
- onDelete?: UpdateFunction;
45
- onAdd?: UpdateFunction;
46
- enableClipboard?: boolean | CopyFunction;
47
- theme?: ThemeInput;
48
- icons?: IconReplacements;
49
- className?: string;
50
- indent?: number;
51
- collapse?: boolean | number | FilterFunction;
52
- showCollectionCount?: boolean | 'when-closed';
53
- restrictEdit?: boolean | FilterFunction;
54
- restrictDelete?: boolean | FilterFunction;
55
- restrictAdd?: boolean | FilterFunction;
56
- restrictTypeSelection?: boolean | DataType[] | TypeFilterFunction;
57
- keySort?: boolean | CompareFunction;
58
- showArrayIndices?: boolean;
59
- defaultValue?: unknown;
60
- minWidth?: string | number;
61
- maxWidth?: string | number;
62
- stringTruncate?: number;
63
- translations?: Partial<LocalisedStrings>;
64
- customNodeDefinitions?: CustomNodeDefinition[];
63
+ data: object
64
+ rootName?: string
65
+ onUpdate?: UpdateFunction
66
+ onEdit?: UpdateFunction
67
+ onDelete?: UpdateFunction
68
+ onAdd?: UpdateFunction
69
+ enableClipboard?: boolean | CopyFunction
70
+ theme?: ThemeInput
71
+ icons?: IconReplacements
72
+ className?: string
73
+ indent?: number
74
+ collapse?: boolean | number | FilterFunction
75
+ showCollectionCount?: boolean | 'when-closed'
76
+ restrictEdit?: boolean | FilterFunction
77
+ restrictDelete?: boolean | FilterFunction
78
+ restrictAdd?: boolean | FilterFunction
79
+ restrictTypeSelection?: boolean | DataType[] | TypeFilterFunction
80
+ keySort?: boolean | CompareFunction
81
+ showArrayIndices?: boolean
82
+ defaultValue?: unknown
83
+ minWidth?: string | number
84
+ maxWidth?: string | number
85
+ stringTruncate?: number
86
+ translations?: Partial<LocalisedStrings>
87
+ customNodeDefinitions?: CustomNodeDefinition[]
65
88
  }
66
- declare const DataTypes: readonly ["string", "number", "boolean", "null", "object", "array"];
67
- type DataType = (typeof DataTypes)[number] | 'invalid';
68
- type CollectionKey = string | number;
69
- type CollectionData = object | unknown[];
70
- type ErrorString = string;
89
+ declare const DataTypes: readonly ['string', 'number', 'boolean', 'null', 'object', 'array']
90
+ type DataType = (typeof DataTypes)[number] | 'invalid'
91
+ type CollectionKey = string | number
92
+ type CollectionData = object | unknown[]
93
+ type ErrorString = string
71
94
  interface IconReplacements {
72
- add?: JSX.Element;
73
- edit?: JSX.Element;
74
- delete?: JSX.Element;
75
- copy?: JSX.Element;
76
- ok?: JSX.Element;
77
- cancel?: JSX.Element;
78
- chevron?: JSX.Element;
95
+ add?: JSX.Element
96
+ edit?: JSX.Element
97
+ delete?: JSX.Element
98
+ copy?: JSX.Element
99
+ ok?: JSX.Element
100
+ cancel?: JSX.Element
101
+ chevron?: JSX.Element
79
102
  }
80
103
  type UpdateFunction = (props: {
81
- newData: object;
82
- currentData: object;
83
- newValue: unknown;
84
- currentValue: unknown;
85
- name: CollectionKey;
86
- path: CollectionKey[];
87
- }) => void | ErrorString | false;
104
+ newData: object
105
+ currentData: object
106
+ newValue: unknown
107
+ currentValue: unknown
108
+ name: CollectionKey
109
+ path: CollectionKey[]
110
+ }) => void | ErrorString | false
88
111
  interface FilterProps {
89
- key: CollectionKey;
90
- path: CollectionKey[];
91
- level: number;
92
- value: unknown;
93
- size: number | null;
112
+ key: CollectionKey
113
+ path: CollectionKey[]
114
+ level: number
115
+ value: unknown
116
+ size: number | null
94
117
  }
95
- type FilterFunction = (input: FilterProps) => boolean;
96
- type TypeFilterFunction = (input: FilterProps) => boolean | DataType[];
97
- type CopyType = 'path' | 'value';
118
+ type FilterFunction = (input: FilterProps) => boolean
119
+ type TypeFilterFunction = (input: FilterProps) => boolean | DataType[]
120
+ type CopyType = 'path' | 'value'
98
121
  type CopyFunction = (input: {
99
- key: CollectionKey;
100
- path: CollectionKey[];
101
- value: unknown;
102
- stringValue: string;
103
- type: CopyType;
104
- }) => void;
105
- type CompareFunction = (a: string, b: string) => number;
106
- type OnChangeFunction = (value: unknown, path: (string | number)[]) => Promise<string | void>;
122
+ key: CollectionKey
123
+ path: CollectionKey[]
124
+ value: unknown
125
+ stringValue: string
126
+ type: CopyType
127
+ }) => void
128
+ type CompareFunction = (a: string, b: string) => number
129
+ type OnChangeFunction = (value: unknown, path: (string | number)[]) => Promise<string | void>
107
130
  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[];
131
+ data: unknown
132
+ parentData: CollectionData | null
133
+ path: CollectionKey[]
134
+ name: CollectionKey
135
+ onEdit: OnChangeFunction
136
+ onDelete: OnChangeFunction
137
+ enableClipboard: boolean | CopyFunction
138
+ restrictEditFilter: FilterFunction
139
+ restrictDeleteFilter: FilterFunction
140
+ restrictAddFilter: FilterFunction
141
+ restrictTypeSelection: boolean | DataType[] | TypeFilterFunction
142
+ stringTruncate: number
143
+ indent: number
144
+ translate: TranslateFunction
145
+ customNodeDefinitions: CustomNodeDefinition[]
123
146
  }
124
147
  interface CustomNodeProps extends BaseNodeProps {
125
- customProps?: Record<string, unknown>;
126
- parentData: CollectionData | null;
148
+ customProps?: Record<string, unknown>
149
+ parentData: CollectionData | null
127
150
  }
128
151
  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;
152
+ condition: FilterFunction
153
+ element: React$1.FC<CustomNodeProps>
154
+ name: string
155
+ props?: Record<string, unknown>
156
+ hideKey?: boolean
157
+ defaultValue: unknown
158
+ showInTypesSelector?: boolean
136
159
  }
137
160
 
138
- declare const JsonEditor: React$1.FC<JsonEditorProps>;
161
+ declare const JsonEditor: React$1.FC<JsonEditorProps>
139
162
 
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 };
163
+ export {
164
+ CompareFunction,
165
+ CopyFunction,
166
+ FilterFunction,
167
+ IconReplacements,
168
+ JsonEditor,
169
+ JsonEditorProps,
170
+ LocalisedStrings,
171
+ Theme,
172
+ ThemeInput,
173
+ ThemeName,
174
+ TranslateFunction,
175
+ UpdateFunction,
176
+ themes,
177
+ }