@@ -8,13 +8,24 @@ import type { DataItemProps, DataType, EditorProps } from '../../type'
8
8
import { DataTypeLabel } from '../DataTypeLabel'
9
9
import { DataBox } from '../mui/DataBox'
10
10
11
- type EasyTypeConfig < Value > = Pick < DataType < Value > , 'is' | 'serialize' | 'deserialize' > & {
11
+ export type EasyTypeConfig < Value > = Pick < DataType < Value > , 'is' | 'serialize' | 'deserialize' > & {
12
12
type : string
13
13
colorKey : keyof Colorspace
14
14
displayTypeLabel ?: boolean
15
- Renderer : ComponentType < Pick < DataItemProps < Value > , 'value' > >
15
+ Renderer : ComponentType < DataItemProps < Value > >
16
16
}
17
- export function createEasyType < Value > ( {
17
+ /**
18
+ * Enhanced version of `defineDataType` that creates a `DataType` with editor and a optional type label.
19
+ * It will take care of the color and all the necessary props.
20
+ *
21
+ * *All of the built-in data types are defined with this function.*
22
+ *
23
+ * @param config.type The type name.
24
+ * @param config.colorKey The color key in the colorspace. ('base00' - 'base0F')
25
+ * @param config.displayTypeLabel Whether to display the type label.
26
+ * @param config.Renderer The component to render the value.
27
+ */
28
+ export function defineEasyType < Value > ( {
18
29
is,
19
30
serialize,
20
31
deserialize,
@@ -33,7 +44,13 @@ export function createEasyType<Value> ({
33
44
< DataBox onClick = { ( ) => onSelect ?.( props . path , props . value ) } sx = { { color } } >
34
45
{ ( displayTypeLabel && storeDisplayDataTypes ) && < DataTypeLabel dataType = { type } /> }
35
46
< DataBox className = { `${ type } -value` } >
36
- < Render value = { props . value } />
47
+ < Render
48
+ path = { props . path }
49
+ inspect = { props . inspect }
50
+ setInspect = { props . setInspect }
51
+ value = { props . value }
52
+ prevValue = { props . prevValue }
53
+ />
37
54
</ DataBox >
38
55
</ DataBox >
39
56
)
0 commit comments