-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from rewbs/rendered-values-in-grid
Optionally show rendered prompts and interpolated values in grid.
- Loading branch information
Showing
7 changed files
with
197 additions
and
19 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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
import { Typography } from '@mui/material'; | ||
import { experimental_extendTheme as extendTheme } from "@mui/material/styles"; | ||
import { | ||
forwardRef, | ||
useImperativeHandle, | ||
useRef | ||
} from 'react'; | ||
import { themeFactory } from "../theme"; | ||
|
||
// This is an "editor" from ag-grid's perspective, but is actually | ||
// a read-only view of the prompt at this cell. | ||
export const PromptCellEditor = forwardRef((props: any, ref) => { | ||
const refText = useRef<HTMLDivElement | null>(null); | ||
const theme = extendTheme(themeFactory()); | ||
|
||
/* Component Editor Lifecycle methods */ | ||
useImperativeHandle(ref, () => { | ||
return { | ||
getValue() { | ||
return props.value; | ||
}, | ||
}; | ||
}); | ||
|
||
|
||
const [positivePrompt, negativePrompt] = props.value.split('--neg'); | ||
|
||
return ( | ||
<div | ||
ref={refText} | ||
className='ag-custom-component-popup prompt-details' | ||
style={{ | ||
border: '1px solid #00c', | ||
padding: '2px', | ||
background: theme.vars.palette.background.paper, | ||
overflow: 'wrap', | ||
}} | ||
> | ||
<div | ||
style = {{userSelect: 'text'}}> | ||
<Typography fontSize={'1.1em'} fontFamily={'monospace'} color={theme.vars.palette.positive.main}> {positivePrompt}</Typography> | ||
{ | ||
negativePrompt && <> | ||
<Typography fontSize={'1.1em'} fontFamily={'monospace'} color={theme.vars.palette.text.primary }>--neg</Typography> | ||
<Typography fontSize={'1.1em'} fontFamily={'monospace'} color={theme.vars.palette.negative.main} >{negativePrompt}</Typography> | ||
</> | ||
} | ||
</div> | ||
</div> | ||
); | ||
}); |
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
Oops, something went wrong.