Skip to content

Commit 2d9543e

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/patterns-bc6ca2550e
2 parents 185993f + c1ce6ed commit 2d9543e

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

docs/pages/apis.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| `style` | `CSSProperties` | - | Custom style. |
1010
| `sx` | `SxProps` | - | [The `sx` prop](https://mui.com/system/getting-started/the-sx-prop/) lets you style elements inline, using values from the theme. |
1111
| `indentWidth` | `number` | 3 | Indent width for nested objects |
12-
| `keyRenderer` | `{when: (props) => boolean}` | - | Customize a key, if `keyRenderer.when` returns `true`. |
12+
| `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. |
1313
| `valueTypes` | `ValueTypes` | - | Customize the definition of data types. See [Defining Data Types](/how-to/data-types) |
1414
| `enableAdd` | `boolean` \|<br />`(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. |
1515
| `enableDelete` | `boolean` \|<br />`(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. |

docs/pages/how-to/data-types.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For advanced use cases, you can provide `PreComponent` and `PostComponent` to re
3737
#### `Editor`
3838

3939
To enable editing for a data type, you need to provide `serialize` and `deserialize` functions to convert the value to and from a string representation. You can then use the `Editor` component to provide a custom editor for the stringified value. When the user edits the value, it will be parsed using `deserialize`, and the result will be passed to the `onChange` callback.
40-
40+
- `props.path` - The path to the value.
4141
- `props.value` - The value to edit.
4242
- `props.setValue` - A function that can be used to update the value.
4343
- `props.abortEditing` - A function that can be used to abort editing.

src/components/DataKeyPair.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,11 @@ export const DataKeyPair: FC<DataKeyPairProps> = (props) => {
359359
)
360360
: null
361361
}
362-
<Box ref={highlightContainer} component='span'>
362+
<Box
363+
ref={highlightContainer}
364+
className='data-key-key'
365+
component='span'
366+
>
363367
{
364368
(isRoot && depth === 0
365369
? rootName !== false
@@ -380,7 +384,13 @@ export const DataKeyPair: FC<DataKeyPairProps> = (props) => {
380384
isRoot
381385
? (rootName !== false && <DataBox sx={{ mr: 0.5 }}>:</DataBox>)
382386
: nestedIndex === undefined && (
383-
<DataBox sx={{ mr: 0.5 }}>:</DataBox>
387+
<DataBox
388+
className='data-key-colon'
389+
sx={{
390+
mr: 0.5,
391+
'.data-key-key:empty + &': { display: 'none' }
392+
}}
393+
>:</DataBox>
384394
)
385395
)
386396
}
@@ -391,6 +401,7 @@ export const DataKeyPair: FC<DataKeyPairProps> = (props) => {
391401
(editing && editable)
392402
? (Editor && (
393403
<Editor
404+
path={path}
394405
value={tempValue}
395406
setValue={setTempValue}
396407
abortEditing={abortEditing}

src/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export interface DataItemProps<ValueType = unknown> {
6363
}
6464

6565
export type EditorProps<ValueType = unknown> = {
66+
path: Path
6667
value: ValueType
6768
setValue: Dispatch<ValueType>
6869
abortEditing: () => void

0 commit comments

Comments
 (0)