🎥 Make videos programmatically with React
non editable values
Jonny Burger0780a9c88bd9
diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsxnew file mode 100644index 0000000000..5d17268a39--- /dev/null+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.tsx@@ -0,0 +1,44 @@+import React, {useCallback} from 'react';+import {LIGHT_TEXT} from '../../../helpers/colors';+import {narrowOption, optionRow} from '../layout';+import {SchemaLabel} from './SchemaLabel';+import type {JSONPath} from './zod-types';++const fullWidth: React.CSSProperties = {+ width: '100%',+};++const emptyLabel: React.CSSProperties = {+ width: '100%',+ color: LIGHT_TEXT,+ fontFamily: 'sans-serif',+ fontSize: 14,+};++export const ZonNonEditableValue: React.FC<{+ jsonPath: JSONPath;+ value: unknown;+ compact: boolean;+ showSaveButton: boolean;+}> = ({jsonPath, value, compact, showSaveButton}) => {+ const save = useCallback(() => undefined, []);+ const reset = useCallback(() => undefined, []);+ return (+ <div style={compact ? narrowOption : optionRow}>+ <SchemaLabel+ isDefaultValue+ jsonPath={jsonPath}+ onReset={reset}+ onSave={save}+ showSaveButton={showSaveButton}+ compact={compact}+ onRemove={null}+ />+ <div style={fullWidth}>+ <em style={emptyLabel}>+ {value === undefined ? 'undefined' : JSON.stringify(value)}+ </em>+ </div>+ </div>+ );+};diff --git a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsxindex 5482a705bd..e9b14e1d32 100644--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodSwitch.tsx@@ -4,6 +4,7 @@ import type {JSONPath} from './zod-types';import {ZodArrayEditor} from './ZodArrayEditor';import {ZodBooleanEditor} from './ZodBooleanEditor';import {ZodEffectEditor} from './ZodEffectEditor';+import {ZonNonEditableValue} from './ZodNonEditableValue';import {ZodNumberEditor} from './ZodNumberEditor';import {ZodObjectEditor} from './ZodObjectEditor';import {ZodStringEditor} from './ZodStringEditor';@@ -106,6 +107,17 @@ export const ZodSwitch: React.FC<{);}+ if (typeName === z.ZodFirstPartyTypeKind.ZodUndefined) {+ return (+ <ZonNonEditableValue+ compact={compact}+ jsonPath={jsonPath}+ showSaveButton={showSaveButton}+ value={value}+ />+ );+ }+if (typeName === z.ZodFirstPartyTypeKind.ZodArray) {return (<ZodArrayEditordiff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsxindex 93a9bada6c..c9338267e6 100644--- a/packages/example/src/Video.tsx+++ b/packages/example/src/Video.tsx@@ -698,6 +698,7 @@ export const Index: React.FC = () => {array2: z.array(z.array(z.string())),mynum: z.number(),value: z.boolean().refine((v) => v === false || v === true),+ lol: z.undefined(),})}defaultProps={{vehicle: 'bus',