Skip to content

Commit 13d4f15

Browse files
authored
docs: add description for Props (#229)
1 parent 4a0e364 commit 13d4f15

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

docs/pages/index.mdx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ import { JsonViewerPreview } from '../components/JsonViewerPreview'
55
# @textea/json-viewer
66

77
### NPM
8+
89
```shell
910
npm install @textea/json-viewer
1011
```
12+
1113
### Yarn
14+
1215
```shell
1316
yarn add @textea/json-viewer
1417
```
18+
1519
### PNPM
20+
1621
```shell
1722
pnpm add @textea/json-viewer
1823
```
@@ -38,13 +43,46 @@ const Component = () => (<JsonViewer value={object}/>)
3843
}}
3944
/>
4045

46+
### Props
47+
48+
| Name | Type | Default | Description |
49+
| ---------------------------- | ------------------------------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
50+
| `value` | `any` | - | Your input data. Any value, `object`, `Array`, primitive type, even `Map` or `Set`. |
51+
| `rootName` | `string` or `false` | "root" | The name of the root value. |
52+
| `theme` | `"light"` <br />\| `"dark"` <br />\| `"auto"` <br />\| [Base16](https://github.com/chriskempson/base16) | `"light"` | Color theme. |
53+
| `className` | `string` | - | Custom class name. |
54+
| `style` | `CSSProperties` | - | Custom style. |
55+
| `indentWidth` | `number` | 3 | Indent width for nested objects |
56+
| `keyRenderer` | `{when: (props) => boolean}` | - | Customize a key, if `keyRenderer.when` returns `true`. |
57+
| `valueTypes` | `ValueTypes` | - | Customize value types. |
58+
| `onChange` | `(path, oldVal, newVal) => void` | - | Callback when value changed. |
59+
| `onCopy` | `(path, value) => void` | - | Callback when value copied. |
60+
| `enableClipboard` | `boolean` | `true` | Whether enable clipboard feature. |
61+
| `editable` | `boolean` \|<br />`(path, currentValue) => boolean` | `false` | Whether enable edit feature. You can pass a function to customize the result. |
62+
| `defaultInspectDepth` | `number` | 5 | Default inspect depth for nested objects.<br /><br />_\* If the number is set too large, it could result in performance issues._ |
63+
| `maxDisplayLength` | `number` | 30 | Hide items after reaching the count.<br />`Array` and `Object` will be affected.<br /><br />_\* If the number is set too large, it could result in performance issues._ |
64+
| `groupArraysAfterLength` | `number` | 100 | Group arrays after reaching the count.<br />Groups are displayed with bracket notation and can be expanded and collapsed by clicking on the brackets. |
65+
| `collapseStringsAfterLength` | `number` | 50 | Cut off the string after reaching the count. Collapsed strings are followed by an ellipsis.<br /><br />String content can be expanded and collapsed by clicking on the string value. |
66+
| `objectSortKeys` | `boolean` | `false` | Whether sort keys through `String.prototype.localeCompare()` |
67+
| `quotesOnKeys` | `boolean` | `true` | Whether add quotes on keys. |
68+
| `displayDataTypes` | `boolean` | `true` | Whether display data type labels. |
69+
| `displayObjectSize` | `boolean` | `true` | Whether display the size of array and object. |
70+
71+
#### Props mapping from `react-json-view`
72+
73+
| Name | Type | Alternative |
74+
| ----------- | --------- | ------------------------------------------------- |
75+
| `name` | `string` | See `rootName` |
76+
| `src` | `any` | See `value` |
77+
| `collapsed` | `boolean` | Set `defaultInspectDepth` to `0` to collapse all. |
78+
4179
### Type Declaration
4280

4381
see [src/type.ts](https://github.com/TexteaInc/json-viewer/blob/main/src/type.ts)
4482

4583
### Full Example
4684

47-
<Link href='/full'>
85+
<Link href="/full">
4886
<Button>
4987
View ->
5088
</Button>

0 commit comments

Comments
 (0)