import { CrochetValue, Environment, Environments } from "../../../vm"; import * as React from "react"; import { Tabs } from "./tabs"; import { text_unsafe, html } from "../representation"; import { IElement } from "./basic"; import { List, ListItem, Proplist, ProplistField, ProplistItem, ProplistValue, } from "./info"; import { Foldable } from "./folds"; export function Value(props: IElement & { value: CrochetValue }) { return ( {html.render_value(props.value)} ), }, { key: "plain-text", tab: "Plain Text", content: (
{text_unsafe.render_value(props.value)}
), }, ]} /> ); } export function ValueS(props: IElement & { value: CrochetValue }) { return {html.render_value(props.value)}; } export function ListV(props: IElement & { values: React.ReactNode[] }) { return ( {props.values.map((x) => ( {x} ))} ); } export function LongListV( props: IElement & { values: React.ReactNode[]; maxItems?: number } ) { const max = props.maxItems ?? 5; if (props.values.length < max) { return ; } const always = props.values.slice(0, max); const folded = props.values.slice(max); return ( {always.map((x) => ( {x} ))} {folded.map((x) => ( {x} ))} ); } export function MapV( props: IElement & { pairs: [React.ReactNode, React.ReactNode][] } ) { return ( {props.pairs.map(([k, v]) => { return ( {k} {v} ); })} ); } export function EnvV(props: IElement & { env: Environment }) { const bound = [...Environments.bound_values_up_to(null, props.env)]; return [k, ])} />; }