From 2023c73ca23d89c1c0093673ecfa8fc5a80c8860 Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Wed, 14 Aug 2024 01:39:24 +0800 Subject: [PATCH] feat: hide colon when key is empty --- docs/pages/apis.mdx | 2 +- src/components/DataKeyPair.tsx | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/pages/apis.mdx b/docs/pages/apis.mdx index e597beb8..536efbd0 100644 --- a/docs/pages/apis.mdx +++ b/docs/pages/apis.mdx @@ -9,7 +9,7 @@ | `style` | `CSSProperties` | - | Custom style. | | `sx` | `SxProps` | - | [The `sx` prop](https://mui.com/system/getting-started/the-sx-prop/) lets you style elements inline, using values from the theme. | | `indentWidth` | `number` | 3 | Indent width for nested objects | -| `keyRenderer` | `{when: (props) => boolean}` | - | Customize a key, if `keyRenderer.when` returns `true`. | +| `keyRenderer` | `{when: (props) => boolean}` | - | Customize the rendering of key when `keyRenderer.when` returns `true`. Render `null` in `keyRenderer` will cause the colons to be hidden. | | `valueTypes` | `ValueTypes` | - | Customize the definition of data types. See [Defining Data Types](/how-to/data-types) | | `enableAdd` | `boolean` \|
`(path, currentValue) => boolean` | `false` | Whether enable add feature. Provide a function to customize this behavior by returning a boolean based on the value and path. | | `enableDelete` | `boolean` \|
`(path, currentValue) => boolean` | `false` | Whether enable delete feature. Provide a function to customize this behavior by returning a boolean based on the value and path. | diff --git a/src/components/DataKeyPair.tsx b/src/components/DataKeyPair.tsx index 1006aa55..fef5e632 100644 --- a/src/components/DataKeyPair.tsx +++ b/src/components/DataKeyPair.tsx @@ -359,7 +359,11 @@ export const DataKeyPair: FC = (props) => { ) : null } - + { (isRoot && depth === 0 ? rootName !== false @@ -380,7 +384,13 @@ export const DataKeyPair: FC = (props) => { isRoot ? (rootName !== false && :) : nestedIndex === undefined && ( - : + : ) ) }