{selectedIndex !== undefined && (
/**
* This form provider act as a substate of the parent form
* Consider creating an InnerFormProvider since not every feature is expected
*/
{
// current state is ignored
// the state is defined by the parent form
// elements should be present in the state object since this is expected to be an array
//@ts-ignore
// return state.elements[selectedIndex];
return {};
}}
onSubmit={(v) => {
const newValue = [...list];
newValue.splice(selectedIndex, 1, v);
onChange(newValue as any);
setSelected(undefined);
}}
onUpdate={(v) => {
const newValue = [...list];
newValue.splice(selectedIndex, 1, v);
onChange(newValue as any);
}}
>
)}
{selectedIndex !== undefined && (
{selected !== undefined && (
)}
)}
);
}
export function getValueDeeper(
object: Record,
names: string[],
): string {
if (names.length === 0) {
return object as any as string;
}
const [head, ...rest] = names;
if (!head) {
return getValueDeeper(object, rest);
}
if (object === undefined) {
return ""
}
return getValueDeeper(object[head], rest);
}