Skip to content

🎥 Make videos programmatically with React

simplify switch

Jonny Burger61f469f9c60d
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx
index 91c2160831..207d5b3177 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx
@@ -63,6 +63,25 @@ export const ZodSwitch: React.FC<{
}
const zodTypes = useZodTypesIfPossible();
+
+ if (typeName === z.ZodFirstPartyTypeKind.ZodObject) {
+ return (
+ <ZodObjectEditor
+ setValue={setValue as UpdaterFunction<Record<string, unknown>>}
+ value={value as Record<string, unknown>}
+ defaultValue={defaultValue as Record<string, unknown>}
+ jsonPath={jsonPath}
+ schema={schema}
+ onSave={onSave as UpdaterFunction<Record<string, unknown>>}
+ showSaveButton={showSaveButton}
+ onRemove={onRemove}
+ saving={saving}
+ saveDisabledByParent={saveDisabledByParent}
+ mayPad={mayPad}
+ />
+ );
+ }
+
if (typeName === z.ZodFirstPartyTypeKind.ZodString) {
if ((value as string).startsWith(window.remotion_staticBase)) {
return (
@@ -87,27 +106,9 @@ export const ZodSwitch: React.FC<{
value={value as string}
setValue={setValue as UpdaterFunction<string>}
jsonPath={jsonPath}
- defaultValue={defaultValue as string}
- mayPad={mayPad}
schema={schema}
onSave={onSave as UpdaterFunction<string>}
- showSaveButton={showSaveButton}
- onRemove={onRemove}
- saveDisabledByParent={saveDisabledByParent}
- saving={saving}
- />
- );
- }
-
- if (typeName === z.ZodFirstPartyTypeKind.ZodObject) {
- return (
- <ZodObjectEditor
- setValue={setValue as UpdaterFunction<Record<string, unknown>>}
- value={value as Record<string, unknown>}
- defaultValue={defaultValue as Record<string, unknown>}
- jsonPath={jsonPath}
- schema={schema}
- onSave={onSave as UpdaterFunction<Record<string, unknown>>}
+ defaultValue={defaultValue as string}
showSaveButton={showSaveButton}
onRemove={onRemove}
saving={saving}
@@ -117,24 +118,6 @@ export const ZodSwitch: React.FC<{
);
}
- if (typeName === z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion) {
- return (
- <ZodDiscriminatedUnionEditor
- defaultValue={defaultValue as Record<string, unknown>}
- mayPad={mayPad}
- schema={schema}
- setValue={setValue as UpdaterFunction<Record<string, unknown>>}
- value={value as Record<string, unknown>}
- jsonPath={jsonPath}
- onRemove={onRemove}
- onSave={onSave as UpdaterFunction<unknown>}
- saving={saving}
- saveDisabledByParent={saveDisabledByParent}
- showSaveButton={showSaveButton}
- />
- );
- }
-
if (typeName === z.ZodFirstPartyTypeKind.ZodDate) {
return (
<ZodDateEditor
@@ -394,6 +377,24 @@ export const ZodSwitch: React.FC<{
);
}
+ if (typeName === z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion) {
+ return (
+ <ZodDiscriminatedUnionEditor
+ defaultValue={defaultValue as Record<string, unknown>}
+ mayPad={mayPad}
+ schema={schema}
+ setValue={setValue as UpdaterFunction<Record<string, unknown>>}
+ value={value as Record<string, unknown>}
+ jsonPath={jsonPath}
+ onRemove={onRemove}
+ onSave={onSave as UpdaterFunction<unknown>}
+ saving={saving}
+ saveDisabledByParent={saveDisabledByParent}
+ showSaveButton={showSaveButton}
+ />
+ );
+ }
+
return (
<ZonNonEditableValue
jsonPath={jsonPath}