+ {prop.type === "boolean" ? (
+
+
+ setParams({
+ ...params,
+ [key]: checked,
+ })
}
/>
-
-
- {prop.enum.map((option) => (
-
- {option}
-
- ))}
-
-
- ) : prop.type === "string" ? (
-
+ ) : prop.type === "string" && prop.enum ? (
+
- ) : prop.type === "object" || prop.type === "array" ? (
-
- (formRefs.current[key] = ref)}
- schema={{
- type: prop.type,
- properties: prop.properties,
- description: prop.description,
- items: prop.items,
+ onValueChange={(value) => {
+ if (value === "") {
+ setParams({
+ ...params,
+ [key]: undefined,
+ });
+ } else {
+ setParams({
+ ...params,
+ [key]: value,
+ });
+ }
}}
+ >
+
+
+
+
+ {prop.enum.map((option) => (
+
+ {option}
+
+ ))}
+
+
+ ) : prop.type === "string" ? (
+
- ) : prop.type === "number" ||
- prop.type === "integer" ? (
-
{
- const value = e.target.value;
- if (value === "") {
- // Field cleared - set to undefined
- setParams({
- ...params,
- [key]: undefined,
- });
- } else {
- // Field has value - try to convert to number, but store input either way
- const num = Number(value);
- if (!isNaN(num)) {
+ onChange={(e) => {
+ const value = e.target.value;
+ if (value === "") {
+ // Field cleared - set to undefined
setParams({
...params,
- [key]: num,
+ [key]: undefined,
});
} else {
- // Store invalid input as string - let server validate
+ // Field has value - keep as string
setParams({
...params,
[key]: value,
});
}
- }
- }}
- className="mt-1"
- />
- ) : (
-
-
(formRefs.current[key] = ref)}
- schema={{
- type: prop.type,
- properties: prop.properties,
- description: prop.description,
- items: prop.items,
}}
- value={params[key] as JsonValue}
- onChange={(newValue: JsonValue) => {
- setParams({
- ...params,
- [key]: newValue,
- });
- // Check validation after a short delay to allow form to update
- setTimeout(checkValidationErrors, 100);
+ className="mt-1"
+ />
+ ) : prop.type === "object" ||
+ prop.type === "array" ? (
+
+ (formRefs.current[key] = ref)}
+ schema={{
+ type: prop.type,
+ properties: prop.properties,
+ description: prop.description,
+ items: prop.items,
+ }}
+ value={
+ (params[key] as JsonValue) ??
+ generateDefaultValue(prop)
+ }
+ onChange={(newValue: JsonValue) => {
+ setParams({
+ ...params,
+ [key]: newValue,
+ });
+ // Check validation after a short delay to allow form to update
+ setTimeout(checkValidationErrors, 100);
+ }}
+ />
+
+ ) : prop.type === "number" ||
+ prop.type === "integer" ? (
+ {
+ const value = e.target.value;
+ if (value === "") {
+ // Field cleared - set to undefined
+ setParams({
+ ...params,
+ [key]: undefined,
+ });
+ } else {
+ // Field has value - try to convert to number, but store input either way
+ const num = Number(value);
+ if (!isNaN(num)) {
+ setParams({
+ ...params,
+ [key]: num,
+ });
+ } else {
+ // Store invalid input as string - let server validate
+ setParams({
+ ...params,
+ [key]: value,
+ });
+ }
+ }
}}
+ className="mt-1"
/>
-
- )}
+ ) : (
+
+ (formRefs.current[key] = ref)}
+ schema={{
+ type: prop.type,
+ properties: prop.properties,
+ description: prop.description,
+ items: prop.items,
+ }}
+ value={params[key] as JsonValue}
+ onChange={(newValue: JsonValue) => {
+ setParams({
+ ...params,
+ [key]: newValue,
+ });
+ // Check validation after a short delay to allow form to update
+ setTimeout(checkValidationErrors, 100);
+ }}
+ />
+
+ )}
+