🎥 Make videos programmatically with React
working for string
Patric Salvisbergb8ec3ef2494c
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsxindex 7ae6f62fe1..16e8f373d0 100644--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx@@ -62,7 +62,6 @@ export const ZodSwitch: React.FC<{}if (typeName === z.ZodFirstPartyTypeKind.ZodString) {- console.log(typeName, value);return (<ZodStringEditorvalue={value as string}@@ -229,7 +228,6 @@ export const ZodSwitch: React.FC<{}if (typeName === z.ZodFirstPartyTypeKind.ZodUnion) {- console.log(typeName, value);return (<ZodUnionEditorschema={schema}diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.tsxindex 3c82fc3f1e..97f02f1d46 100644--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.tsx+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.tsx@@ -1,10 +1,11 @@-import {useCallback, useState} from 'react';+import {useCallback, useEffect, useState} from 'react';import {z} from 'remotion';import {LIGHT_TEXT} from '../../../helpers/colors';import {Checkbox} from '../../Checkbox';import {Spacing} from '../../layout';import {SchemaLabel} from './SchemaLabel';import type {JSONPath} from './zod-types';+import {ZonNonEditableValue} from './ZodNonEditableValue';import {ZodSwitch} from './ZodSwitch';const fullWidth: React.CSSProperties = {@@ -31,7 +32,7 @@ export const ZodUnionEditor: React.FC<{value: unknown;defaultValue: unknown;schema: z.ZodTypeAny;- setValue: React.Dispatch<React.SetStateAction<any>>;+ setValue: React.Dispatch<React.SetStateAction<unknown>>;onSave: (updater: (oldNum: unknown) => unknown) => void;onRemove: null | (() => void);}> = ({@@ -46,7 +47,6 @@ export const ZodUnionEditor: React.FC<{onRemove,}) => {const {options} = schema._def;- console.log({value});const [isChecked, setIsChecked] = useState<boolean>(false);const onValueChange = useCallback(@@ -55,12 +55,17 @@ export const ZodUnionEditor: React.FC<{},[setValue]);+ useEffect(() => {+ if (value === null) {+ setIsChecked(true);+ }+ }, [value]);const onCheckBoxChange: React.ChangeEventHandler<HTMLInputElement> =useCallback((e) => {setIsChecked(!isChecked);- console.log(e.target.checked);+ // TODO: Don't assume stringconst val = e.target.checked ? null : '';onValueChange(val);},@@ -82,8 +87,6 @@ export const ZodUnionEditor: React.FC<{onSave(() => value);}, [onSave, value]);- console.log(value);-if (options[0]._def.typeName === z.ZodFirstPartyTypeKind.ZodNull ||options[1]._def.typeName === z.ZodFirstPartyTypeKind.ZodNull@@ -131,4 +134,13 @@ export const ZodUnionEditor: React.FC<{</>);}++ return (+ <ZonNonEditableValue+ jsonPath={jsonPath}+ label={'Union only supported with null'}+ compact={compact}+ showSaveButton={showSaveButton}+ />+ );};diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsxindex 4ccbbea23f..393aff9570 100644--- a/packages/example/src/Video.tsx+++ b/packages/example/src/Video.tsx@@ -683,7 +683,7 @@ export const Index: React.FC = () => {union: z.null().or(z.string()),jkl: z.string(),def: z.object({- xyz: z.null().or(z.string()),+ unionArray: z.array(z.null().or(z.string())),pef: z.string(),}),}),@@ -710,7 +710,11 @@ export const Index: React.FC = () => {defaultProps={{vehicle: 'bus',other: 'hi',- abc: {def: {xyz: 'hell', pef: 'hu'}, jkl: 'sting', union: 'hello'},+ abc: {+ def: {unionArray: ['someString', null], pef: 'hu'},+ jkl: 'sting',+ union: 'hello',+ },array: [{a: 'a', b: 'bbbbb'},{a: 'a', b: 'b'},