Skip to content

🎥 Make videos programmatically with React

default editor

Jonny Burgeraa9823fe0ce2
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.tsx
new file mode 100644
index 0000000000..e2f2739e40
--- /dev/null
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.tsx
@@ -0,0 +1,46 @@
+import React from 'react';
+import type {z} from 'zod';
+import type {JSONPath} from './zod-types';
+import type {UpdaterFunction} from './ZodSwitch';
+import {ZodSwitch} from './ZodSwitch';
+
+export const ZodDefaultEditor: React.FC<{
+ showSaveButton: boolean;
+ jsonPath: JSONPath;
+ compact: boolean;
+ value: unknown;
+ defaultValue: unknown;
+ schema: z.ZodTypeAny;
+ setValue: UpdaterFunction<unknown>;
+ onSave: UpdaterFunction<unknown>;
+ onRemove: null | (() => void);
+ saving: boolean;
+}> = ({
+ jsonPath,
+ compact,
+ schema,
+ setValue,
+ onSave,
+ defaultValue,
+ value,
+ showSaveButton,
+ onRemove,
+ saving,
+}) => {
+ const {innerType} = schema._def as z.ZodDefaultDef;
+
+ return (
+ <ZodSwitch
+ compact={compact}
+ defaultValue={defaultValue}
+ jsonPath={jsonPath}
+ onRemove={onRemove}
+ onSave={onSave}
+ schema={innerType}
+ setValue={setValue}
+ showSaveButton={showSaveButton}
+ value={value}
+ saving={saving}
+ />
+ );
+};
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx
index aa3fbb2ab7..27c91f19a3 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx
@@ -9,6 +9,7 @@ import {ZodArrayEditor} from './ZodArrayEditor';
import {ZodBooleanEditor} from './ZodBooleanEditor';
import {ZodColorEditor} from './ZodColorEditor';
import {ZodDateEditor} from './ZodDateEditor';
+import {ZodDefaultEditor} from './ZodDefaultEditor';
import {ZodEffectEditor} from './ZodEffectEditor';
import {ZodEnumEditor} from './ZodEnumEditor';
import {ZonNonEditableValue} from './ZodNonEditableValue';
@@ -345,6 +346,23 @@ export const ZodSwitch: React.FC<{
);
}
+ if (typeName === z.ZodFirstPartyTypeKind.ZodDefault) {
+ return (
+ <ZodDefaultEditor
+ compact={compact}
+ jsonPath={jsonPath}
+ showSaveButton={showSaveButton}
+ defaultValue={defaultValue}
+ value={value}
+ setValue={setValue}
+ onSave={onSave}
+ onRemove={onRemove}
+ schema={schema}
+ saving={saving}
+ />
+ );
+ }
+
return (
<ZonNonEditableValue
compact={compact}