Skip to content

Commit b436b64

Browse files
committed
[Library] Issue #7 : Update README to add new features in
1 parent cb0ae10 commit b436b64

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

README.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ npm install --save react-editable-json-tree
2828
### Example Usage
2929
```jsx
3030
// Import
31-
import { JsonTree, ADD_DELTA_TYPE, REMOVE_DELTA_TYPE, UPDATE_DELTA_TYPE } from 'react-editable-json-tree'
31+
import {
32+
JsonTree,
33+
ADD_DELTA_TYPE,
34+
REMOVE_DELTA_TYPE,
35+
UPDATE_DELTA_TYPE,
36+
DATA_TYPES,
37+
INPUT_USAGE_TYPES,
38+
} from 'react-editable-json-tree'
3239

3340
// Data
3441
const data = {
@@ -118,7 +125,7 @@ Delta data structure :
118125
### readOnly
119126
| Key | Description | Type | Required | Default |
120127
|:--------:|:--------------------------------:|:-------:|:---------:|:---------:|
121-
| readOnly | Read only boolean for all object when a boolean is provided, read only for specific keys when function is provided | Boolean | Function | False | `(keyName, data, keyPath, deep, dataType) => false` |
128+
| readOnly | Read only boolean for all object when a boolean is provided, read only for specific keys when function is provided | Boolean / Function | False | `(keyName, data, keyPath, deep, dataType) => false` |
122129

123130
This function must return a boolean.
124131

@@ -198,19 +205,41 @@ The library will add a `onClick` props on element.
198205
### inputElement
199206
| Key | Description | Type | Required | Default |
200207
|:------------:|:-----------------------------------------:|:-----------:|:--------:|:------------:|
201-
| inputElement | Input Text Element to replace library one | Element | False | `<input />` |
208+
| inputElement | Input Text Element to replace library one | Element / Function | False | `(usage, keyPath, deep, keyName, data, dataType) => <input />` |
202209

203210
The library will add a `placeholder`, `ref`, `defaultValue` props on element.
204211
This item will be focus when possible.
205212

213+
Function parameters:
214+
215+
| Key | Description | Type | Example |
216+
|:-----------:|:-------------------------------:|:-------:|:----------------------------------------------------------------------------:|
217+
| usage | Usage of the generated input | String | All values are listed in INPUT_USAGE_TYPES |
218+
| keyPath | key path | Array | [] for data: { object: { string: 'test' } } |
219+
| deep | Deep of current node | Number | 1 for data: { object: { string: 'test' } } on 'object' node |
220+
| key | Key of current node/value | String | 'object' for data: { object: { string: 'test' } } |
221+
| value | Value of the key | Any | { string: 'test' } for data: { object: { string: 'test' } } on 'object' node |
222+
| dataType | Data type of the value | String | All values are listed in DATA_TYPES |
223+
206224
### textareaElement
207225
| Key | Description | Type | Required | Default |
208226
|:---------------:|:-----------------------------------------:|:-----------:|:--------:|:--------------:|
209-
| textareaElement | Textarea Element to replace library one | Element | False | `<textarea />` |
227+
| textareaElement | Textarea Element to replace library one | Element / Function | False | `(usage, keyPath, deep, keyName, data, dataType) => <textarea />` |
210228

211229
The library will add a `ref`, `defaultValue` props on element.
212230
This item will be focus when possible.
213231

232+
Function parameters:
233+
234+
| Key | Description | Type | Example |
235+
|:-----------:|:-------------------------------:|:-------:|:----------------------------------------------------------------------------:|
236+
| usage | Usage of the generated input | String | All values are listed in INPUT_USAGE_TYPES |
237+
| keyPath | key path | Array | [] for data: { object: { string: 'test' } } |
238+
| deep | Deep of current node | Number | 1 for data: { object: { string: 'test' } } on 'object' node |
239+
| key | Key of current node/value | String | 'object' for data: { object: { string: 'test' } } |
240+
| value | Value of the key | Any | { string: 'test' } for data: { object: { string: 'test' } } on 'object' node |
241+
| dataType | Data type of the value | String | All values are listed in DATA_TYPES |
242+
214243
### minusMenuElement
215244
| Key | Description | Type | Required | Default |
216245
|:----------------:|:-----------------------------------------:|:-----------:|:--------:|:-------------------:|
@@ -279,6 +308,21 @@ Function parameters :
279308
|:------:|:----------------------------------------------------------------:|:--------:|:---------:|:---------------------:|
280309
| logger | Object used to log 'catch' from promise (using only 'error' key) | Object | False | `{ error: () => {} }` |
281310

311+
### onSubmitValueParser
312+
| Key | Description | Type | Required | Default |
313+
|:-------------------:|:-------------------------------------------------------------------------------------------------------------:|:--------:|:---------:|:----------------------------------------------------------------------:|
314+
| onSubmitValueParser | Function called after each edit/update phase to parse raw data from inputElement or textareaElement component | Function | False | `(isEditMode, keyPath, deep, key, rawValue) => nativeParser(rawValue)` |
315+
316+
Function parameters :
317+
318+
| Key | Description | Type | Example |
319+
|:-----------:|:--------------------------------------------------------:|:-------:|:----------------------------------------------------------------------------:|
320+
| isEditMode | Is in edit mode or in add mode ? | String | 'string' for data: { object: { string: 'test' } } |
321+
| keyPath | key path | Array | ['object'] for data: { object: { string: 'test' } } |
322+
| deep | Deep of current node | Number | 1 for data: { object: { string: 'test' } } on 'object' node |
323+
| key | Key of current node/value | String | 'string' for data: { object: { string: 'test' } } |
324+
| rawValue | Raw value from inputElement or textareaElement component | String | 'string' for data: { object: { string: 'test' } } |
325+
282326
## Design
283327
The library provide CSS class on elements. All are prefixed by "rejt" to avoid conflict.
284328
To avoid being linked with a CSS file, the library will use the inline style.

0 commit comments

Comments
 (0)