import { PropsWithChildren } from 'react' import { unixMicroToIsoTimestamp } from './Messages.utils' import CopyButton from '@/components/ui/CopyButton' export const RowLayout = ({ children }: PropsWithChildren<{}>) => (
{children}
) // renders a timestamp (either unix microsecond or iso timestamp) export const SelectionDetailedTimestampRow = ({ value, hideCopy = false, }: { value: string | number hideCopy?: boolean }) => ( ) export const SelectionDetailedRow = ({ label, value, valueRender, hideCopy = false, }: { label: string value: string valueRender?: React.ReactNode hideCopy?: boolean }) => { return (
{label} {valueRender ?? value} {!hideCopy && ( )}
) } /* * JSON Syntax Highlighter * * for http response codes */ export function jsonSyntaxHighlight(input: Object) { let json: string = JSON.stringify(input, null, 2) json = json.replace(/&/g, '&').replace(//g, '>') const newJson = json.replace( /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { var cls = 'number text-tomato-900' if (/^"/.test(match)) { if (/:$/.test(match)) { cls = 'key text-scale-1200' } else { cls = 'string text-brand-600' } } else if (/true|false/.test(match)) { cls = 'boolean text-blue-900' } else if (/null/.test(match)) { cls = 'null text-amber-1100' } return '' + match + '' } ) const jsonWithLineWraps = newJson.split(`\n`).map((x) => { return `${x}` }) return jsonWithLineWraps.join('\n') }