json-edit-react 1.15.3 → 1.15.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/README.md +9 -6
- package/build/index.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,9 +10,6 @@ A [React](https://github.com/facebook/react) component for editing or viewing JS
|
|
|
10
10
|

|
|
11
11
|

|
|
12
12
|
|
|
13
|
-
> [!IMPORTANT]
|
|
14
|
-
> **Version 1.14.0** has a change which recommends you provide a `setData` prop and not use `onUpdate` for updating your data externally. See [Managing state](#managing-state).
|
|
15
|
-
|
|
16
13
|
### Features include:
|
|
17
14
|
|
|
18
15
|
- edit individual values, or whole objects as JSON text
|
|
@@ -27,6 +24,11 @@ A [React](https://github.com/facebook/react) component for editing or viewing JS
|
|
|
27
24
|
|
|
28
25
|
<img width="392" alt="screenshot" src="image/screenshot.png">
|
|
29
26
|
|
|
27
|
+
> [!IMPORTANT]
|
|
28
|
+
> **Version 1.14.0** has a change which recommends you provide a `setData` prop and not use `onUpdate` for updating your data externally. See [Managing state](#managing-state).
|
|
29
|
+
|
|
30
|
+
## Contents
|
|
31
|
+
- [Contents](#contents)
|
|
30
32
|
- [Installation](#installation)
|
|
31
33
|
- [Implementation](#implementation)
|
|
32
34
|
- [Usage](#usage)
|
|
@@ -120,8 +122,8 @@ The only *required* value is `data` (although you will need to provide a `setDat
|
|
|
120
122
|
| `restrictEdit` | `boolean\|FilterFunction` | `false` | If `true`, no editing is permitted. A function can be provided for more specificity — see [Filter functions](#filter-functions) |
|
|
121
123
|
| `restrictDelete` | `boolean\|FilterFunction` | `false` | As with `restrictEdit` but for deletion |
|
|
122
124
|
| `restrictAdd` | `boolean\|FilterFunction` | `false` | As with `restrictEdit` but for adding new properties |
|
|
123
|
-
| `restrictTypeSelection` | `boolean\|
|
|
124
|
-
| `restrictDrag` | `boolean\|
|
|
125
|
+
| `restrictTypeSelection` | `boolean\|DataType[]\|TypeFilterFunction` | `true` | For restricting the data types the user can select. Can be a list of data types (e.g. `[ 'string', 'number', 'boolean', 'array', 'object', 'null' ]`) or a boolean. A function can be provided -- it should take the same input as the above `FilterFunction`s, but output should be `boolean \| DataType[]`. |
|
|
126
|
+
| `restrictDrag` | `boolean\|FilterFunction` | `true` | Set to `false` to enable drag and drop functionality. See [Drag-n-drop](#drag-n-drop) |
|
|
125
127
|
| `searchText` | `string` | `undefined` | Data visibility will be filtered by matching against value, using the method defined below in `searchFilter` |
|
|
126
128
|
| `searchFilter` | `"key"\|"value"\|"all"\|SearchFilterFunction` | `undefined` | Define how `searchText` should be matched to filter the visible items. See [Search/Filtering](#searchfiltering) |
|
|
127
129
|
| `searchDebounceTime` | `number` | `350` | Debounce time when `searchText` changes |
|
|
@@ -665,12 +667,13 @@ A few helper functions, components and types that might be useful in your own im
|
|
|
665
667
|
- `ThemeInput`: input type for the `theme` prop
|
|
666
668
|
- `JsonEditorProps`: all input props for the Json Editor component
|
|
667
669
|
- `JsonData`: main `data` object -- any valid JSON structure
|
|
668
|
-
- [`UpdateFunction`](#update-functions), [`OnChangeFunction`](#onchange-function), [`OnErrorFunction`](#onerror-function) [`FilterFunction`](#filter-functions), [`CopyFunction`](#copy-function), [`SearchFilterFunction`](#searchfiltering), [`CompareFunction`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort), [`LocalisedString`](#localisation), [`CustomNodeDefinition`](#custom-nodes), [`CustomTextDefinitions`](#custom-text)
|
|
670
|
+
- [`UpdateFunction`](#update-functions), [`OnChangeFunction`](#onchange-function), [`OnErrorFunction`](#onerror-function) [`FilterFunction`](#filter-functions), [`CopyFunction`](#copy-function), [`SearchFilterFunction`](#searchfiltering), [`CompareFunction`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort),[`TypeFilterFunction`](#filter-functions), [`LocalisedString`](#localisation), [`CustomNodeDefinition`](#custom-nodes), [`CustomTextDefinitions`](#custom-text), [`CustomTextFunction`](#custom-text),
|
|
669
671
|
- `TranslateFunction`: function that takes a [localisation](#localisation) key and returns a translated string
|
|
670
672
|
- `IconReplacements`: input type for the `icons` prop
|
|
671
673
|
- `CollectionNodeProps`: all props passed internally to "collection" nodes (i.e. objects/arrays)
|
|
672
674
|
- `ValueNodeProps`: all props passed internally to "value" nodes (i.e. *not* objects/arrays)
|
|
673
675
|
- `CustomNodeProps`: all props passed internally to [Custom nodes](#custom-nodes); basically the same as `CollectionNodeProps` with an extra `customNodeProps` field for passing props unique to your component`
|
|
676
|
+
- `DataType`: `"string"` | `"number"` | `"boolean"` | `"null"` | `"object"` | `"array"`
|
|
674
677
|
|
|
675
678
|
## Issues, bugs, suggestions?
|
|
676
679
|
|
package/build/index.d.ts
CHANGED
|
@@ -107,6 +107,7 @@ type OnErrorFunction = (props: {
|
|
|
107
107
|
type FilterFunction = (input: NodeData) => boolean;
|
|
108
108
|
type TypeFilterFunction = (input: NodeData) => boolean | DataType[];
|
|
109
109
|
type CustomTextFunction = (input: NodeData) => string | null;
|
|
110
|
+
type DefaultValueFunction = (input: NodeData) => unknown;
|
|
110
111
|
type SearchFilterFunction = (inputData: NodeData, searchText: string) => boolean;
|
|
111
112
|
type CopyType = 'path' | 'value';
|
|
112
113
|
type CopyFunction = (input: {
|
|
@@ -247,4 +248,4 @@ declare const isCollection: (value: unknown) => value is unknown[] | Record<stri
|
|
|
247
248
|
declare const matchNode: (input: Partial<NodeData>, searchText: string) => boolean;
|
|
248
249
|
declare const matchNodeKey: SearchFilterFunction;
|
|
249
250
|
|
|
250
|
-
export { CollectionNodeProps, CompareFunction, CopyFunction, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, FilterFunction, IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, IconReplacements, JerError, JsonData, JsonEditor, JsonEditorProps, LinkCustomComponent, LinkCustomNodeDefinition, LocalisedStrings, NodeData, OnChangeFunction, OnErrorFunction, SearchFilterFunction, Theme, ThemeInput, ThemeName, TranslateFunction, UpdateFunction, ValueNodeProps, isCollection, matchNode, matchNodeKey, themes, truncate };
|
|
251
|
+
export { CollectionNodeProps, CompareFunction, CopyFunction, CustomNodeDefinition, CustomNodeProps, CustomTextDefinitions, CustomTextFunction, DataType, DefaultValueFunction, FilterFunction, IconAdd, IconCancel, IconChevron, IconCopy, IconDelete, IconEdit, IconOk, IconReplacements, JerError, JsonData, JsonEditor, JsonEditorProps, LinkCustomComponent, LinkCustomNodeDefinition, LocalisedStrings, NodeData, OnChangeFunction, OnErrorFunction, SearchFilterFunction, Theme, ThemeInput, ThemeName, TranslateFunction, TypeFilterFunction, UpdateFunction, ValueNodeProps, isCollection, matchNode, matchNodeKey, themes, truncate };
|