Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.3 KB
Raw Blame
import { LemonLabel } from 'lib/lemon-ui/LemonLabel'
import { CodeEditorResizeable } from 'lib/monaco/CodeEditorResizable'

export type WarehouseNativeQueryEditorProps = {
    label: string
    /** Which columns the query must return. */
    hint: string
    query: string
    onChange: (query: string) => void
    'data-attr'?: string
}

export function WarehouseNativeQueryEditor({
    label,
    hint,
    query,
    onChange,
    'data-attr': dataAttr,
}: WarehouseNativeQueryEditorProps): JSX.Element {
    return (
        <div className="flex flex-col gap-1" data-attr={dataAttr}>
            <LemonLabel>{label}</LemonLabel>
            <CodeEditorResizeable
                language="sql"
                value={query}
                onChange={(value) => onChange(value ?? '')}
                minHeight="8rem"
                maxHeight="24rem"
                options={{
                    minimap: { enabled: false },
                    scrollbar: { alwaysConsumeMouseWheel: false },
                    scrollBeyondLastLine: false,
                    lineNumbers: 'off',
                    folding: false,
                    wordWrap: 'on',
                    renderLineHighlight: 'none',
                }}
            />
            <div className="text-secondary text-xs">{hint}</div>
        </div>
    )
}