Skip to content

🎥 Make videos programmatically with React

better support for non-editable values

Jonny Burgerd4abd719ee08
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx
index 5d17268a39..2620f2f6f9 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx
@@ -17,10 +17,10 @@ const emptyLabel: React.CSSProperties = {
export const ZonNonEditableValue: React.FC<{
jsonPath: JSONPath;
- value: unknown;
+ label: string;
compact: boolean;
showSaveButton: boolean;
-}> = ({jsonPath, value, compact, showSaveButton}) => {
+}> = ({jsonPath, label, compact, showSaveButton}) => {
const save = useCallback(() => undefined, []);
const reset = useCallback(() => undefined, []);
return (
@@ -35,9 +35,7 @@ export const ZonNonEditableValue: React.FC<{
onRemove={null}
/>
<div style={fullWidth}>
- <em style={emptyLabel}>
- {value === undefined ? 'undefined' : JSON.stringify(value)}
- </em>
+ <em style={emptyLabel}>{label}</em>
</div>
</div>
);
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx
index 5faba30e96..1b706ccbfb 100644
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx
@@ -33,10 +33,6 @@ export const ZodSwitch: React.FC<{
const def: z.ZodTypeDef = schema._def;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const typeName = (def as any).typeName as z.ZodFirstPartyTypeKind;
- if (typeName === z.ZodFirstPartyTypeKind.ZodAny) {
- // TODO: Better UI for this
- return <div>any</div>;
- }
if (typeName === z.ZodFirstPartyTypeKind.ZodObject) {
return (
@@ -107,16 +103,46 @@ export const ZodSwitch: React.FC<{
);
}
- if (
- typeName === z.ZodFirstPartyTypeKind.ZodUndefined ||
- typeName === z.ZodFirstPartyTypeKind.ZodNull
- ) {
+ if (typeName === z.ZodFirstPartyTypeKind.ZodUndefined) {
return (
<ZonNonEditableValue
compact={compact}
jsonPath={jsonPath}
showSaveButton={showSaveButton}
- value={value}
+ label={'undefined'}
+ />
+ );
+ }
+
+ if (typeName === z.ZodFirstPartyTypeKind.ZodNull) {
+ return (
+ <ZonNonEditableValue
+ compact={compact}
+ jsonPath={jsonPath}
+ showSaveButton={showSaveButton}
+ label={'null'}
+ />
+ );
+ }
+
+ if (typeName === z.ZodFirstPartyTypeKind.ZodAny) {
+ return (
+ <ZonNonEditableValue
+ compact={compact}
+ jsonPath={jsonPath}
+ showSaveButton={showSaveButton}
+ label={'any (not editable)'}
+ />
+ );
+ }
+
+ if (typeName === z.ZodFirstPartyTypeKind.ZodUnknown) {
+ return (
+ <ZonNonEditableValue
+ compact={compact}
+ jsonPath={jsonPath}
+ showSaveButton={showSaveButton}
+ label={'unknown (not editable)'}
/>
);
}
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index 584cac69b3..d0b685e159 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -700,6 +700,10 @@ export const Index: React.FC = () => {
value: z.boolean().refine((v) => v === false || v === true),
lol: z.undefined(),
haha: z.null(),
+ yo: z.any(),
+ un: z.unknown(),
+ num: z.coerce.string(),
+ date: z.date(),
})}
defaultProps={{
vehicle: 'bus',
@@ -711,9 +715,12 @@ export const Index: React.FC = () => {
],
array2: [['bbbbbb'], ['bbbbbb']],
mynum: 179,
- value: false,
- lol: undefined,
+ value: true,
haha: null,
+ yo: {hi: ' there'},
+ un: 'hi',
+ num: '179',
+ date: new Date('2022-01-01'),
}}
durationInFrames={150}
/>