-
Notifications
You must be signed in to change notification settings - Fork 196
/
ParamTextFormItem.tsx
38 lines (34 loc) 路 1.15 KB
/
ParamTextFormItem.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* ============================================================================
* Copyright (c) Palo Alto Networks
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* ========================================================================== */
import React from "react";
import FormTextInput from "@theme/ApiExplorer/FormTextInput";
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
import { useTypedDispatch } from "@theme/ApiItem/hooks";
export interface ParamProps {
param: Param;
}
export default function ParamTextFormItem({ param }: ParamProps) {
const dispatch = useTypedDispatch();
return (
<FormTextInput
isRequired={param.required}
paramName={param.name}
placeholder={param.description || param.name}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
dispatch(
setParam({
...param,
value:
param.in === "path" || param.in === "query"
? e.target.value.replace(/\s/g, "%20")
: e.target.value,
})
)
}
/>
);
}