|
1
|
import React from "react" |
|
2
|
import { ApiRunnerParamInput, ApiRunnerParamInputProps } from "../Default" |
|
3
|
import clsx from "clsx" |
|
4
|
|
|
5
|
export const ApiRunnerParamObjectInput = ({ |
|
6
|
paramName, |
|
7
|
paramValue, |
|
8
|
objPath, |
|
9
|
...props |
|
10
|
}: ApiRunnerParamInputProps) => { |
|
11
|
if (typeof paramValue !== "object") { |
|
12
|
return ( |
|
13
|
<ApiRunnerParamInput |
|
14
|
paramName={paramName} |
|
15
|
paramValue={paramValue} |
|
16
|
objPath={objPath} |
|
17
|
{...props} |
|
18
|
/> |
|
19
|
) |
|
20
|
} |
|
21
|
|
|
22
|
return ( |
|
23
|
<fieldset |
|
24
|
className={clsx( |
|
25
|
"border border-medusa-border-strong rounded", |
|
26
|
"p-docs_0.5" |
|
27
|
)} |
|
28
|
> |
|
29
|
<legend className="px-docs_0.5"> |
|
30
|
<code>{paramName}</code> Properties |
|
31
|
</legend> |
|
32
|
{Object.entries(paramValue as Record<string, unknown>).map( |
|
33
|
([key, value], index) => ( |
|
34
|
<ApiRunnerParamInput |
|
35
|
paramName={key} |
|
36
|
paramValue={value} |
|
37
|
objPath={`${objPath.length ? `${objPath}.` : ""}${paramName}`} |
|
38
|
key={index} |
|
39
|
{...props} |
|
40
|
/> |
|
41
|
) |
|
42
|
)} |
|
43
|
</fieldset> |
|
44
|
) |
|
45
|
} |