feat(frontend): multiselect/artifact-gate/artifact widgets + linkage + no-limbo
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { useState } from "react";
|
||||
import type { WidgetDescriptor, UiResponse } from "../api/types";
|
||||
import { FreetextWidget } from "./FreetextWidget";
|
||||
|
||||
/**
|
||||
* LinkageHost: when an artifact-gate option has `opens` (a child descriptor),
|
||||
* this component renders the child widget and merges the parent choice with
|
||||
* the child's text into a single combined UiResponse.
|
||||
*/
|
||||
export function LinkageHost({
|
||||
parentResponse,
|
||||
childDescriptor,
|
||||
onRespond,
|
||||
}: {
|
||||
parentResponse: UiResponse;
|
||||
childDescriptor: WidgetDescriptor;
|
||||
onRespond: (r: UiResponse) => void;
|
||||
}) {
|
||||
function handleChildResponse(childResponse: UiResponse) {
|
||||
// Merge parent choice + child text into one response
|
||||
onRespond({ ...parentResponse, text: childResponse.text });
|
||||
}
|
||||
|
||||
// Currently only freetext child is supported per spec.
|
||||
// FreetextWidget is the canonical child for "opens".
|
||||
return <FreetextWidget descriptor={childDescriptor} onRespond={handleChildResponse} />;
|
||||
}
|
||||
Reference in New Issue
Block a user