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.cjs.js +1 -1081
- package/build/index.d.ts +151 -114
- package/build/index.esm.js +1 -1078
- package/package.json +2 -2
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
|
-
|
|
6
|
-
} & Record<string, Theme
|
|
7
|
-
declare const themeableElements: readonly [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
displayName?: string
|
|
33
|
+
fragments?: Fragments
|
|
34
|
+
styles: Partial<ThemeStyles>
|
|
16
35
|
}
|
|
17
36
|
interface DefaultTheme extends Theme {
|
|
18
|
-
|
|
19
|
-
|
|
37
|
+
displayName: 'Default'
|
|
38
|
+
styles: ThemeStyles
|
|
20
39
|
}
|
|
21
|
-
type ThemeName = keyof typeof themes
|
|
22
|
-
type ThemeInput =
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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 [
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
126
|
-
|
|
148
|
+
customProps?: Record<string, unknown>
|
|
149
|
+
parentData: CollectionData | null
|
|
127
150
|
}
|
|
128
151
|
interface CustomNodeDefinition {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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 {
|
|
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
|
+
}
|