-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: dropping `createDataType` and change the signature of EditorComponent to only accept string
- Loading branch information
Showing
14 changed files
with
274 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
|
||
import type { DataType } from '../../type' | ||
import { createEasyType } from './createEasyType' | ||
|
||
export const booleanType: DataType<boolean> = { | ||
export const booleanType = createEasyType<boolean>({ | ||
is: (value) => typeof value === 'boolean', | ||
...createEasyType( | ||
'bool', | ||
({ value }) => <>{value ? 'true' : 'false'}</>, | ||
{ | ||
colorKey: 'base0E', | ||
fromString: value => Boolean(value) | ||
} | ||
) | ||
} | ||
type: 'bool', | ||
colorKey: 'base0E', | ||
serialize: value => value.toString(), | ||
deserialize: value => { | ||
if (value === 'true') return true | ||
if (value === 'false') return false | ||
throw new Error('Invalid boolean value') | ||
}, | ||
Renderer: ({ value }) => <>{value ? 'true' : 'false'}</> | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
import { Box } from '@mui/material' | ||
|
||
import { useJsonViewerStore } from '../../stores/JsonViewerStore' | ||
import type { DataType } from '../../type' | ||
import { createEasyType } from './createEasyType' | ||
|
||
export const nullType: DataType<null> = { | ||
export const nullType = createEasyType<null>({ | ||
is: (value) => value === null, | ||
...createEasyType( | ||
'null', | ||
() => { | ||
const backgroundColor = useJsonViewerStore(store => store.colorspace.base02) | ||
return ( | ||
<Box | ||
sx={{ | ||
fontSize: '0.8rem', | ||
backgroundColor, | ||
fontWeight: 'bold', | ||
borderRadius: '3px', | ||
padding: '0.5px 2px' | ||
}} | ||
> | ||
NULL | ||
</Box> | ||
) | ||
}, | ||
{ | ||
colorKey: 'base08', | ||
displayTypeLabel: false | ||
} | ||
) | ||
} | ||
type: 'null', | ||
colorKey: 'base08', | ||
displayTypeLabel: false, | ||
Renderer: () => { | ||
const backgroundColor = useJsonViewerStore(store => store.colorspace.base02) | ||
return ( | ||
<Box | ||
sx={{ | ||
fontSize: '0.8rem', | ||
backgroundColor, | ||
fontWeight: 'bold', | ||
borderRadius: '3px', | ||
padding: '0.5px 2px' | ||
}} | ||
> | ||
NULL | ||
</Box> | ||
) | ||
} | ||
}) |
Oops, something went wrong.