import { html, type TemplateResult } from 'lit';
import type { PlaygroundControl, PlaygroundProps } from '../types.js';
import { groupControlsBySection } from '../types.js';
export function renderPropsPanel(
controls: PlaygroundControl[],
values: PlaygroundProps,
onChange: (key: string, value: string | boolean) => void,
): TemplateResult {
const sections = groupControlsBySection(controls);
return html`
${[...sections.entries()].map(
([section, sectionControls]) => html`
${sectionControls.map((control) =>
renderControlField(control, values[control.key], onChange),
)}
`,
)}
`;
}
function renderControlField(
control: PlaygroundControl,
value: string | boolean | undefined,
onChange: (key: string, value: string | boolean) => void,
): TemplateResult {
if (control.type === 'boolean') {
return html`
onChange(control.key, (event.target as HTMLInputElement).checked)}
/>
`;
}
if (control.type === 'select') {
const current = String(value ?? '');
return html`
`;
}
if (control.type === 'textarea') {
return html`
`;
}
return html`
onChange(control.key, (event.target as HTMLInputElement).value)}
/>
`;
}