UNPKG

@remotion/studio

Version:

APIs for interacting with the Remotion Studio

32 lines (31 loc) 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SchemaEditor = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const get_zod_if_possible_1 = require("../../get-zod-if-possible"); const is_menu_item_1 = require("../../Menu/is-menu-item"); const SchemaErrorMessages_1 = require("./SchemaErrorMessages"); const scroll_to_default_props_path_1 = require("./scroll-to-default-props-path"); const zod_schema_type_1 = require("./zod-schema-type"); const ZodDiscriminatedUnionEditor_1 = require("./ZodDiscriminatedUnionEditor"); const ZodObjectEditor_1 = require("./ZodObjectEditor"); const scrollable = { display: 'flex', flexDirection: 'column', overflowY: 'auto', }; const SchemaEditor = ({ schema, value, setValue }) => { const z = (0, get_zod_if_possible_1.useZodIfPossible)(); if (!z) { throw new Error('expected zod'); } const typeName = (0, zod_schema_type_1.getZodSchemaType)(schema); if (typeName !== 'object' && typeName !== 'discriminatedUnion') { return jsx_runtime_1.jsx(SchemaErrorMessages_1.TopLevelZodValue, { typeReceived: typeName }); } if (typeName === 'discriminatedUnion') { return (jsx_runtime_1.jsx("div", { ref: scroll_to_default_props_path_1.defaultPropsEditorScrollableAreaRef, style: scrollable, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: jsx_runtime_1.jsx(ZodDiscriminatedUnionEditor_1.ZodDiscriminatedUnionEditor, { schema: schema, setValue: setValue, value: value, mayPad: true, jsonPath: [], onRemove: null }) })); } return (jsx_runtime_1.jsx("div", { ref: scroll_to_default_props_path_1.defaultPropsEditorScrollableAreaRef, style: scrollable, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: jsx_runtime_1.jsx(ZodObjectEditor_1.ZodObjectEditor, { discriminatedUnionReplacement: null, value: value, setValue: setValue, jsonPath: [], schema: schema, onRemove: null, mayPad: true }) })); }; exports.SchemaEditor = SchemaEditor;