1
1
import { InputBase } from '@mui/material'
2
- import React , { useCallback } from 'react'
2
+ import type { ChangeEventHandler , ComponentType , FC } from 'react'
3
+ import { memo , useCallback } from 'react'
3
4
4
5
import { useJsonViewerStore } from '../../stores/JsonViewerStore'
5
6
import type { Colorspace } from '../../theme/base16'
@@ -9,7 +10,7 @@ import { DataBox } from '../mui/DataBox'
9
10
10
11
export function createEasyType < Value > (
11
12
type : string ,
12
- renderValue : React . ComponentType < Pick < DataItemProps < Value > , 'value' > > ,
13
+ renderValue : ComponentType < Pick < DataItemProps < Value > , 'value' > > ,
13
14
config : {
14
15
colorKey : keyof Colorspace
15
16
fromString ?: ( value : string ) => Value
@@ -18,8 +19,8 @@ export function createEasyType<Value> (
18
19
) : Omit < DataType < Value > , 'is' > {
19
20
const { fromString, colorKey, displayTypeLabel = true } = config
20
21
21
- const Render = React . memo ( renderValue )
22
- const EasyType : React . FC < DataItemProps < Value > > = ( props ) => {
22
+ const Render = memo ( renderValue )
23
+ const EasyType : FC < DataItemProps < Value > > = ( props ) => {
23
24
const storeDisplayDataTypes = useJsonViewerStore ( store => store . displayDataTypes )
24
25
const color = useJsonViewerStore ( store => store . colorspace [ colorKey ] )
25
26
const onSelect = useJsonViewerStore ( store => store . onSelect )
@@ -41,13 +42,13 @@ export function createEasyType<Value> (
41
42
}
42
43
}
43
44
44
- const EasyTypeEditor : React . FC < EditorProps < Value > > = ( { value, setValue } ) => {
45
+ const EasyTypeEditor : FC < EditorProps < Value > > = ( { value, setValue } ) => {
45
46
const color = useJsonViewerStore ( store => store . colorspace [ colorKey ] )
46
47
return (
47
48
< InputBase
48
49
value = { value }
49
50
onChange = {
50
- useCallback < React . ChangeEventHandler < HTMLTextAreaElement | HTMLInputElement > > (
51
+ useCallback < ChangeEventHandler < HTMLTextAreaElement | HTMLInputElement > > (
51
52
( event ) => {
52
53
const value = fromString ( event . target . value )
53
54
setValue ( value )
0 commit comments