Skip to content

Commit 2f6bfa8

Browse files
committed
v0.2.6
1 parent 7c31b0d commit 2f6bfa8

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import 'react18-json-view/src/style.css'
4949
| `dark` | `boolean` | `false` | Keep in dark mode (Don't forget to import `dark.css`) |
5050
| `theme` | `default` \| `a11y` \| `github` \| `vscode` \| `atom`\|`winter-is-coming` | `'default'` | Color theme |
5151
| `enableClipboard` | `boolean` | `true` | Whether enable clipboard feature. |
52-
| `displaySize`(canary) | `boolean` \| `integer` \| 'collapsed' \| 'expanded' | `false` | Whether display the size of `Object`, `Array`. |
52+
| `displaySize` | `boolean` \| `integer` \| 'collapsed' \| 'expanded' | `false` | Whether display the size of `Object`, `Array`. |
5353
| `collapseStringsAfterLength` | `integer` | `99` | When an integer value is assigned, strings longer than that length will be truncated and indicated by an ellipsis. To expand or collapse the string content, simply click on the string value. |
5454
| `collapseStringMode` | `'directly'` \| `'word'` \| `'address'` | `'directly'` | If the `word` is assigned, the collapsed length will be adjusted to fully display the last word.(English only) |
5555
| `collapsed` | `boolean` \| `integer` \| `function` | `false` | When set to true(false), all nodes will be (not) collapsed by default. When using an integer value, it will collapse at a specific depth. The collapsed also can be a function. |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react18-json-view",
3-
"version": "0.2.6-canary.3",
3+
"version": "0.2.6",
44
"type": "module",
55
"description": "JSON viewer for react18",
66
"main": "dist/cjs/index.cjs",

website/src/contents/display-size.tsx

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,24 @@ import JsonView from 'react18-json-view'
66
import CopySVG from '@/svgs/copy.svg'
77
import CopiedSVG from '@/svgs/copied.svg'
88

9-
type Option = '0' | '1' | '2' | '3' | 'true' | 'false' | 'collapsed' | 'expanded' | 'function'
9+
type Option = '0' | '1' | '2' | '3' | 'true' | 'false' | 'collapsed' | 'expanded'
1010
const options: Option[] = ['true', 'false', '0', '1', '2', '3', 'collapsed', 'expanded']
1111

12-
const valueMap: Record<Option, any> = {
12+
const valueMap: Record<Option, number | boolean | 'collapsed' | 'expanded'> = {
1313
'0': 0,
1414
'1': 1,
1515
'2': 2,
1616
'3': 3,
1717
true: true,
1818
false: false,
1919
collapsed: 'collapsed',
20-
expanded: 'expanded',
21-
22-
function: (params: any) => {
23-
if (params.indexOrName === 'arr') return true
24-
if (params.depth > 3) return true
25-
if (params.depth > 2 && params.size > 3) return true
26-
if (params.node && typeof params.node === 'object' && params.node.nest === 'over') return true
27-
return false
28-
}
20+
expanded: 'expanded'
2921
}
3022

31-
const funcString = `(params) => {
32-
if (params.indexOrName === 'arr') return true
33-
if (params.depth > 3) return true
34-
if (params.depth > 2 && params.size > 3) return true
35-
if (params.node && typeof params.node === 'object' && params.node.nest === 'over') return true
36-
return false
37-
}`
38-
3923
export default function DisplaySize() {
4024
const [selected, setSelected] = useState(options[0])
4125

42-
const code = `<JsonView src={json_object} displaySize={${selected === 'function' ? funcString : selected}} />`
26+
const code = `<JsonView src={json_object} displaySize={${selected}} />`
4327

4428
const [copied, setCopied] = useState(false)
4529

@@ -53,9 +37,7 @@ export default function DisplaySize() {
5337

5438
return (
5539
<>
56-
<h2 className='mt-20 text-lg font-medium'>
57-
Display Size <span className=' opacity-40'>(canary)</span>
58-
</h2>
40+
<h2 className='mt-20 text-lg font-medium'>Display Size</h2>
5941
<ul className='mt-3 flex select-none flex-wrap gap-1'>
6042
{options.map(item => (
6143
<li

0 commit comments

Comments
 (0)