UNPKG

@remotion/studio

Version:

APIs for interacting with the Remotion Studio

29 lines (28 loc) 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ZodBooleanEditor = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const Checkbox_1 = require("../../Checkbox"); const Fieldset_1 = require("./Fieldset"); const SchemaLabel_1 = require("./SchemaLabel"); const local_state_1 = require("./local-state"); const fullWidth = { width: '100%', }; const ZodBooleanEditor = ({ schema, jsonPath, value, setValue, onSave, defaultValue, onRemove, showSaveButton, saving, saveDisabledByParent, mayPad, }) => { const { localValue, onChange, reset } = (0, local_state_1.useLocalState)({ schema, setValue, unsavedValue: value, savedValue: defaultValue, }); const onToggle = (0, react_1.useCallback)((e) => { onChange(() => e.target.checked, false, false); }, [onChange]); const save = (0, react_1.useCallback)(() => { onSave(() => value, false, false); }, [onSave, value]); return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { handleClick: null, isDefaultValue: localValue.value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: true, saveDisabledByParent: saveDisabledByParent, suffix: null }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { name: jsonPath.join('.'), checked: localValue.value, onChange: onToggle, disabled: false }) })] })); }; exports.ZodBooleanEditor = ZodBooleanEditor;