@remotion/cli 4.0.0-alpha.185 → 4.0.0-alpha.217
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ansi/ansi-split.d.ts +1 -0
- package/dist/ansi/ansi-split.js +16 -3
- package/dist/benchmark.js +3 -0
- package/dist/color-math.d.ts +2 -1
- package/dist/color-math.js +2 -3
- package/dist/composition-prompts.d.ts +3 -4
- package/dist/composition-prompts.js +0 -1
- package/dist/compositions.js +3 -0
- package/dist/config/browser.d.ts +1 -3
- package/dist/config/browser.js +2 -12
- package/dist/config/index.d.ts +11 -2
- package/dist/config/index.js +6 -1
- package/dist/config/scale.d.ts +2 -1
- package/dist/config/user-agent.d.ts +4 -0
- package/dist/config/user-agent.js +12 -0
- package/dist/download-progress.js +7 -2
- package/dist/editor/components/EditorContexts.js +2 -1
- package/dist/editor/components/Menu/MenuSubItem.d.ts +0 -1
- package/dist/editor/components/Menu/MenuSubItem.js +1 -2
- package/dist/editor/components/ModalContainer.d.ts +2 -0
- package/dist/editor/components/ModalContainer.js +12 -3
- package/dist/editor/components/Modals.js +1 -1
- package/dist/editor/components/NewComposition/InputDragger.d.ts +1 -0
- package/dist/editor/components/NewComposition/InputDragger.js +2 -2
- package/dist/editor/components/NewComposition/NewCompDuration.js +1 -1
- package/dist/editor/components/NewComposition/NewComposition.js +8 -5
- package/dist/editor/components/NewComposition/RemInput.d.ts +2 -1
- package/dist/editor/components/NewComposition/RemInput.js +3 -2
- package/dist/editor/components/NewComposition/RemInputTypeColor.d.ts +0 -1
- package/dist/editor/components/NewComposition/RemInputTypeColor.js +3 -3
- package/dist/editor/components/NewComposition/ValidationMessage.js +2 -2
- package/dist/editor/components/Notifications/ServerDisconnected.d.ts +0 -4
- package/dist/editor/components/Notifications/ServerDisconnected.js +1 -2
- package/dist/editor/components/PlaybackRateSelector.d.ts +0 -2
- package/dist/editor/components/PlaybackRateSelector.js +5 -6
- package/dist/editor/components/Preview.d.ts +0 -1
- package/dist/editor/components/Preview.js +4 -4
- package/dist/editor/components/PreviewToolbar.js +1 -1
- package/dist/editor/components/QuickSwitcher/QuickSwitcherContent.js +1 -1
- package/dist/editor/components/QuickSwitcher/algolia-search.d.ts +0 -27
- package/dist/editor/components/QuickSwitcher/algolia-search.js +2 -3
- package/dist/editor/components/RenderButton.js +9 -2
- package/dist/editor/components/RenderModal/CrfSetting.js +1 -1
- package/dist/editor/components/RenderModal/EnvInput.js +1 -1
- package/dist/editor/components/RenderModal/FrameRangeSetting.js +1 -1
- package/dist/editor/components/RenderModal/NumberOfLoopsSetting.js +1 -1
- package/dist/editor/components/RenderModal/NumberSetting.js +1 -1
- package/dist/editor/components/RenderModal/RenderModal.d.ts +1 -0
- package/dist/editor/components/RenderModal/RenderModal.js +20 -11
- package/dist/editor/components/RenderModal/RenderModalAudio.js +1 -1
- package/dist/editor/components/RenderModal/RenderModalBasic.js +1 -1
- package/dist/editor/components/RenderModal/RenderModalData.js +116 -13
- package/dist/editor/components/RenderModal/RenderModalInput.js +1 -1
- package/dist/editor/components/RenderModal/RenderModalJSONInputPropsEditor.d.ts +1 -2
- package/dist/editor/components/RenderModal/RenderModalPicture.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +9 -42
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +11 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +55 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +10 -5
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +17 -9
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +7 -3
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +7 -3
- package/dist/editor/components/RenderModal/SchemaEditor/ZodErrorMessages.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.js +10 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +1 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +6 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +10 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +11 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +6 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +30 -18
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.js +12 -8
- package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.d.ts +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.js +62 -57
- package/dist/editor/components/RenderModal/WarningIndicatorButton.d.ts +6 -0
- package/dist/editor/components/RenderModal/WarningIndicatorButton.js +49 -0
- package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +11 -0
- package/dist/editor/components/RenderModal/get-render-modal-warnings.js +26 -0
- package/dist/editor/components/RenderModal/layout.js +0 -1
- package/dist/editor/components/RenderModal/out-name-checker.d.ts +0 -1
- package/dist/editor/components/RenderModal/out-name-checker.js +3 -3
- package/dist/editor/components/RenderQueue/actions.d.ts +0 -2
- package/dist/editor/components/RenderQueue/actions.js +10 -11
- package/dist/editor/components/RenderQueue/index.js +25 -1
- package/dist/editor/components/RenderToolbarIcon.js +25 -10
- package/dist/editor/components/SegmentedControl.d.ts +0 -5
- package/dist/editor/components/SegmentedControl.js +2 -3
- package/dist/editor/components/SizeSelector.d.ts +0 -1
- package/dist/editor/components/SizeSelector.js +3 -3
- package/dist/editor/components/Splitter/SplitterElement.js +1 -0
- package/dist/editor/components/Splitter/SplitterHandle.d.ts +0 -1
- package/dist/editor/components/Splitter/SplitterHandle.js +6 -6
- package/dist/editor/components/Tabs/index.d.ts +0 -1
- package/dist/editor/components/Tabs/index.js +3 -3
- package/dist/editor/components/Tabs/vertical.d.ts +0 -5
- package/dist/editor/components/Tabs/vertical.js +3 -17
- package/dist/editor/components/TimeValue.js +3 -4
- package/dist/editor/components/Timeline/TimelineListItem.js +9 -1
- package/dist/editor/components/Timeline/imperative-state.d.ts +0 -4
- package/dist/editor/components/Timeline/imperative-state.js +13 -13
- package/dist/editor/components/Timeline/timeline-scroll-logic.d.ts +0 -1
- package/dist/editor/components/Timeline/timeline-scroll-logic.js +5 -6
- package/dist/editor/components/ZoomPersistor.d.ts +0 -1
- package/dist/editor/components/ZoomPersistor.js +2 -3
- package/dist/editor/components/get-zod-if-possible.d.ts +10 -0
- package/dist/editor/components/get-zod-if-possible.js +79 -0
- package/dist/editor/helpers/calculate-timeline.d.ts +0 -4
- package/dist/editor/helpers/colors.d.ts +0 -1
- package/dist/editor/helpers/colors.js +3 -3
- package/dist/editor/helpers/create-folder-tree.d.ts +0 -1
- package/dist/editor/helpers/create-folder-tree.js +3 -4
- package/dist/editor/helpers/get-timeline-sequence-sort-key.d.ts +2 -1
- package/dist/editor/icons/caret.d.ts +4 -2
- package/dist/editor/icons/caret.js +17 -3
- package/dist/editor/state/keybindings.d.ts +2 -1
- package/dist/editor/state/modals.d.ts +1 -0
- package/dist/editor/state/preview-size.d.ts +0 -1
- package/dist/editor/state/preview-size.js +3 -4
- package/dist/editor/state/sidebar.d.ts +1 -1
- package/dist/editor/state/timeline-ref.d.ts +2 -1
- package/dist/editor/state/z-index.d.ts +0 -5
- package/dist/editor/state/z-index.js +8 -5
- package/dist/get-cli-options.js +1 -0
- package/dist/get-config-file-name.d.ts +0 -2
- package/dist/get-config-file-name.js +7 -7
- package/dist/index.d.ts +52 -1
- package/dist/list-of-remotion-packages.js +1 -0
- package/dist/parse-command-line.d.ts +3 -1
- package/dist/parse-command-line.js +3 -0
- package/dist/preview-server/api-types.d.ts +0 -4
- package/dist/preview-server/dev-middleware/middleware.d.ts +0 -1
- package/dist/preview-server/dev-middleware/middleware.js +1 -2
- package/dist/preview-server/error-overlay/remotion-overlay/Button.d.ts +8 -5
- package/dist/preview-server/error-overlay/remotion-overlay/Button.js +5 -4
- package/dist/preview-server/hot-middleware/client.js +2 -2
- package/dist/preview-server/public-folder.d.ts +0 -5
- package/dist/preview-server/public-folder.js +3 -4
- package/dist/preview-server/render-queue/job.d.ts +1 -1
- package/dist/preview-server/render-queue/make-retry-payload.js +2 -0
- package/dist/preview-server/render-queue/queue.d.ts +1 -13
- package/dist/preview-server/render-queue/queue.js +13 -9
- package/dist/progress-bar.d.ts +1 -12
- package/dist/progress-bar.js +4 -15
- package/dist/render-flows/render.js +3 -0
- package/dist/render-flows/still.js +6 -0
- package/dist/select-composition.d.ts +2 -1
- package/dist/setup-cache.d.ts +2 -14
- package/dist/setup-cache.js +6 -5
- package/package.json +10 -8
- package/dist/editor/components/CollapsedSidebarExpander.d.ts +0 -5
- package/dist/editor/components/CollapsedSidebarExpander.js +0 -40
- package/dist/editor/components/SidebarContent.d.ts +0 -5
- package/dist/editor/components/SidebarContent.js +0 -53
- package/dist/editor/icons/save.d.ts +0 -2
- package/dist/editor/icons/save.js +0 -8
|
@@ -51,6 +51,6 @@ const RenderModalPicture = ({ renderMode, scale, setScale, pixelFormat, setPixel
|
|
|
51
51
|
}, [setCustomTargetVideoBitrateValue]);
|
|
52
52
|
return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Image Format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: false }) })] })) : null, renderMode === 'video' && videoImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'still' && stillImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Quality control" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: qualityControlOptions, needsWrapping: true }) })] })) : null, shouldDisplayCrfOption &&
|
|
53
53
|
qualityControlType === 'crf' &&
|
|
54
|
-
renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(CrfSetting_1.CrfSetting, { crf: crf, min: minCrf, max: maxCrf, setCrf: setCrf, option: client_1.BrowserSafeApis.options.crfOption })) : null, qualityControlType === 'bitrate' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Target video bitrate" }), (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Learn more about this option", children: (0, jsx_runtime_1.jsx)(OptionExplainer_1.OptionExplainer, { option: client_1.BrowserSafeApis.options.videoBitrate }) }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { style: layout_1.input, value: customTargetVideoBitrate, onChange: onTargetVideoBitrateChanged, status: "ok" }) }) })] })) : null, renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, (0, jsx_runtime_1.jsx)(ScaleSetting_1.ScaleSetting, { scale: scale, setScale: setScale }), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Pixel format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: pixelFormatOptions, selectedId: pixelFormat, title: "Pixel Format" }) })] })) : null] }));
|
|
54
|
+
renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(CrfSetting_1.CrfSetting, { crf: crf, min: minCrf, max: maxCrf, setCrf: setCrf, option: client_1.BrowserSafeApis.options.crfOption })) : null, qualityControlType === 'bitrate' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Target video bitrate" }), (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Learn more about this option", children: (0, jsx_runtime_1.jsx)(OptionExplainer_1.OptionExplainer, { option: client_1.BrowserSafeApis.options.videoBitrate }) }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { style: layout_1.input, value: customTargetVideoBitrate, onChange: onTargetVideoBitrateChanged, status: "ok", rightAlign: true }) }) })] })) : null, renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, (0, jsx_runtime_1.jsx)(ScaleSetting_1.ScaleSetting, { scale: scale, setScale: setScale }), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Pixel format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: pixelFormatOptions, selectedId: pixelFormat, title: "Pixel Format" }) })] })) : null] }));
|
|
55
55
|
};
|
|
56
56
|
exports.RenderModalPicture = RenderModalPicture;
|
|
@@ -3,68 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SchemaEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
7
|
-
const Button_1 = require("../../../../preview-server/error-overlay/remotion-overlay/Button");
|
|
8
|
-
const colors_1 = require("../../../helpers/colors");
|
|
9
|
-
const layout_1 = require("../../layout");
|
|
6
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
10
7
|
const is_menu_item_1 = require("../../Menu/is-menu-item");
|
|
11
|
-
const
|
|
12
|
-
const ZodErrorMessages_1 = require("./ZodErrorMessages");
|
|
8
|
+
const SchemaErrorMessages_1 = require("./SchemaErrorMessages");
|
|
13
9
|
const ZodObjectEditor_1 = require("./ZodObjectEditor");
|
|
14
|
-
const errorExplanation = {
|
|
15
|
-
fontSize: 14,
|
|
16
|
-
color: colors_1.LIGHT_TEXT,
|
|
17
|
-
fontFamily: 'sans-serif',
|
|
18
|
-
lineHeight: 1.5,
|
|
19
|
-
};
|
|
20
|
-
const codeSnippet = {
|
|
21
|
-
fontSize: 14,
|
|
22
|
-
color: 'var(--blue)',
|
|
23
|
-
fontFamily: 'monospace',
|
|
24
|
-
};
|
|
25
10
|
const scrollable = {
|
|
26
11
|
padding: '8px 12px',
|
|
27
12
|
display: 'flex',
|
|
28
13
|
flexDirection: 'column',
|
|
29
14
|
overflowY: 'auto',
|
|
30
15
|
};
|
|
31
|
-
const explainer = {
|
|
32
|
-
display: 'flex',
|
|
33
|
-
flex: 1,
|
|
34
|
-
flexDirection: 'column',
|
|
35
|
-
padding: '0 12px',
|
|
36
|
-
justifyContent: 'center',
|
|
37
|
-
alignItems: 'center',
|
|
38
|
-
textAlign: 'center',
|
|
39
|
-
};
|
|
40
16
|
const SchemaEditor = ({ schema, value, setValue, zodValidationResult, compact, defaultProps, onSave, showSaveButton, }) => {
|
|
17
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
18
|
+
if (!z) {
|
|
19
|
+
throw new Error('expected zod');
|
|
20
|
+
}
|
|
41
21
|
const def = schema._def;
|
|
42
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
23
|
const typeName = def.typeName;
|
|
44
24
|
const reset = (0, react_1.useCallback)(() => {
|
|
45
25
|
setValue(defaultProps);
|
|
46
26
|
}, [defaultProps, setValue]);
|
|
47
|
-
const openDocs = (0, react_1.useCallback)(() => {
|
|
48
|
-
window.open(
|
|
49
|
-
// TODO: Make sure to update this link when we release v4
|
|
50
|
-
'https://v4.remotion.dev/docs/parametrized-rendering#define-a-schema-');
|
|
51
|
-
}, []);
|
|
52
|
-
if (typeName === remotion_1.z.ZodFirstPartyTypeKind.ZodAny) {
|
|
53
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsx)(SchemaEmptyStateGraphic_1.SchemaEmptyStateGraphic, {}), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 5 }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Make the props of this composition interactively editable by adding a", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "schema" }), " prop to the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " component."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn how" })] }));
|
|
54
|
-
}
|
|
55
27
|
if (!zodValidationResult.success) {
|
|
56
|
-
if (defaultProps === undefined) {
|
|
57
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The schema can not be edited because the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop in the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " does not exist."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Fix the schema by adding a", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop to your composition."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn more" })] }));
|
|
58
|
-
}
|
|
59
28
|
const defaultPropsValid = schema.safeParse(defaultProps);
|
|
60
29
|
if (!defaultPropsValid.success) {
|
|
61
|
-
|
|
62
|
-
// TODO: Does not react to when schema is updated
|
|
63
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The schema can not be edited because the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop in the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " is not valid:"] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Fix the schema by changing the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop in your composition so it does not give a type error."] })] }));
|
|
30
|
+
return (0, jsx_runtime_1.jsx)(SchemaErrorMessages_1.InvalidDefaultProps, { zodValidationResult: zodValidationResult });
|
|
64
31
|
}
|
|
65
|
-
return ((0, jsx_runtime_1.
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(SchemaErrorMessages_1.InvalidSchema, { reset: reset, zodValidationResult: zodValidationResult }));
|
|
66
33
|
}
|
|
67
|
-
if (typeName ===
|
|
34
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodObject) {
|
|
68
35
|
return ((0, jsx_runtime_1.jsx)("div", { style: scrollable, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: (0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { value: value, setValue: setValue, jsonPath: [], schema: schema, compact: compact, defaultValue: defaultProps, onSave: onSave, showSaveButton: showSaveButton, onRemove: null }) }));
|
|
69
36
|
}
|
|
70
37
|
return null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
export declare const NoSchemaDefined: () => JSX.Element;
|
|
4
|
+
export declare const NoDefaultProps: () => JSX.Element;
|
|
5
|
+
export declare const InvalidDefaultProps: React.FC<{
|
|
6
|
+
zodValidationResult: z.SafeParseReturnType<unknown, unknown>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const InvalidSchema: React.FC<{
|
|
9
|
+
zodValidationResult: z.SafeParseReturnType<unknown, unknown>;
|
|
10
|
+
reset: () => void;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidSchema = exports.InvalidDefaultProps = exports.NoDefaultProps = exports.NoSchemaDefined = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Button_1 = require("../../../../preview-server/error-overlay/remotion-overlay/Button");
|
|
6
|
+
const colors_1 = require("../../../helpers/colors");
|
|
7
|
+
const layout_1 = require("../../layout");
|
|
8
|
+
const SchemaEmptyStateGraphic_1 = require("./SchemaEmptyStateGraphic");
|
|
9
|
+
const ZodErrorMessages_1 = require("./ZodErrorMessages");
|
|
10
|
+
const explainer = {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flex: 1,
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
padding: '0 12px',
|
|
15
|
+
justifyContent: 'center',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
textAlign: 'center',
|
|
18
|
+
};
|
|
19
|
+
const errorExplanation = {
|
|
20
|
+
fontSize: 14,
|
|
21
|
+
color: colors_1.LIGHT_TEXT,
|
|
22
|
+
fontFamily: 'sans-serif',
|
|
23
|
+
lineHeight: 1.5,
|
|
24
|
+
};
|
|
25
|
+
const codeSnippet = {
|
|
26
|
+
fontSize: 14,
|
|
27
|
+
color: 'var(--blue)',
|
|
28
|
+
fontFamily: 'monospace',
|
|
29
|
+
};
|
|
30
|
+
const errorContainer = {
|
|
31
|
+
padding: '8px 12px',
|
|
32
|
+
overflowY: 'auto',
|
|
33
|
+
};
|
|
34
|
+
const openDocs = () => {
|
|
35
|
+
window.open(
|
|
36
|
+
// TODO: Make sure to update this link when we release v4
|
|
37
|
+
'https://v4.remotion.dev/docs/parametrized-rendering#define-a-schema-');
|
|
38
|
+
};
|
|
39
|
+
const NoSchemaDefined = () => {
|
|
40
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsx)(SchemaEmptyStateGraphic_1.SchemaEmptyStateGraphic, {}), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 5 }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Make the props of this composition interactively editable by adding a", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "schema" }), " prop to the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " component."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn how" })] }));
|
|
41
|
+
};
|
|
42
|
+
exports.NoSchemaDefined = NoSchemaDefined;
|
|
43
|
+
const NoDefaultProps = () => {
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: explainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The schema can not be edited because the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop in the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " does not exist."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1 }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Fix the schema by adding a ", (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), ' ', "prop to your composition."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 2, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: openDocs, children: "Learn more" })] }));
|
|
45
|
+
};
|
|
46
|
+
exports.NoDefaultProps = NoDefaultProps;
|
|
47
|
+
const InvalidDefaultProps = ({ zodValidationResult }) => {
|
|
48
|
+
// TODO: Does not react to when schema is updated
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["The schema can not be edited because the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop in the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: '<Composition>' }), " is not valid:"] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Fix the schema by changing the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " prop in your composition so it does not give a type error."] })] }));
|
|
50
|
+
};
|
|
51
|
+
exports.InvalidDefaultProps = InvalidDefaultProps;
|
|
52
|
+
const InvalidSchema = ({ zodValidationResult, reset }) => {
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "The data does not satisfy the schema:" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "Fix the schema using the JSON editor." }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Alternatively, reset the data to the ", (0, jsx_runtime_1.jsx)("code", { children: "defaultProps" }), " that you have defined."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: reset, children: "Reset props" })] }));
|
|
54
|
+
};
|
|
55
|
+
exports.InvalidSchema = InvalidSchema;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodArrayEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const remotion_1 = require("remotion");
|
|
7
6
|
const Button_1 = require("../../../../preview-server/error-overlay/remotion-overlay/Button");
|
|
8
7
|
const colors_1 = require("../../../helpers/colors");
|
|
8
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
9
9
|
const layout_1 = require("../../layout");
|
|
10
10
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
11
11
|
const layout_2 = require("../layout");
|
|
@@ -28,8 +28,13 @@ const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defa
|
|
|
28
28
|
};
|
|
29
29
|
});
|
|
30
30
|
const def = schema._def;
|
|
31
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
32
|
+
if (!z) {
|
|
33
|
+
throw new Error('expected zod');
|
|
34
|
+
}
|
|
35
|
+
const zColor = (0, get_zod_if_possible_1.useZodColorIfPossible)();
|
|
31
36
|
const typeName = def.typeName;
|
|
32
|
-
if (typeName !==
|
|
37
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodArray) {
|
|
33
38
|
throw new Error('expected object');
|
|
34
39
|
}
|
|
35
40
|
const isRoot = jsonPath.length === 0;
|
|
@@ -66,14 +71,14 @@ const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defa
|
|
|
66
71
|
}, [isRoot, paddingTop]);
|
|
67
72
|
const onAdd = (0, react_1.useCallback)(() => {
|
|
68
73
|
onChange((oldV) => {
|
|
69
|
-
return [...oldV, (0, create_zod_values_1.createZodValues)(def.type)];
|
|
74
|
+
return [...oldV, (0, create_zod_values_1.createZodValues)(def.type, z, zColor)];
|
|
70
75
|
}, true);
|
|
71
|
-
}, [def.type, onChange]);
|
|
76
|
+
}, [def.type, onChange, z]);
|
|
72
77
|
return ((0, jsx_runtime_1.jsx)("div", { style: style, children: (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsxs)(Element, { style: fieldset, children: [isRoot ? null : ((0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaFieldsetLabel, { jsonPath: jsonPath, onRemove: onRemove })), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: localValue.value.map((child, i) => {
|
|
73
78
|
var _a;
|
|
74
79
|
return ((0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor
|
|
75
80
|
// eslint-disable-next-line react/no-array-index-key
|
|
76
81
|
, { onChange: onChange, value: child, def: def, index: i, jsonPath: jsonPath, compact: compact, defaultValue: (_a = defaultValue[i]) !== null && _a !== void 0 ? _a : child, onSave: onSave, showSaveButton: showSaveButton }, `${i}${localValue.revision}`));
|
|
77
|
-
}) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-
|
|
82
|
+
}) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] })), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onAdd, children: "+ Add item" })] }) }) }));
|
|
78
83
|
};
|
|
79
84
|
exports.ZodArrayEditor = ZodArrayEditor;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodColorEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const remotion_1 = require("remotion");
|
|
7
6
|
const color_math_1 = require("../../../../color-math");
|
|
7
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
8
|
const layout_1 = require("../../layout");
|
|
9
9
|
const InputDragger_1 = require("../../NewComposition/InputDragger");
|
|
10
10
|
const RemInput_1 = require("../../NewComposition/RemInput");
|
|
@@ -16,6 +16,14 @@ const fullWidth = {
|
|
|
16
16
|
width: '100%',
|
|
17
17
|
};
|
|
18
18
|
const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, }) => {
|
|
19
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
20
|
+
if (!z) {
|
|
21
|
+
throw new Error('expected zod');
|
|
22
|
+
}
|
|
23
|
+
const zodColor = (0, get_zod_if_possible_1.useZodColorIfPossible)();
|
|
24
|
+
if (!zodColor) {
|
|
25
|
+
throw new Error('expected zod color');
|
|
26
|
+
}
|
|
19
27
|
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
20
28
|
return {
|
|
21
29
|
value,
|
|
@@ -34,10 +42,10 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
34
42
|
}
|
|
35
43
|
}, [schema, setValue]);
|
|
36
44
|
const { a, b, g, r } = localValue.zodValidation.success
|
|
37
|
-
?
|
|
45
|
+
? zodColor.ZColorInternals.parseColor(localValue.value)
|
|
38
46
|
: { a: 1, b: 0, g: 0, r: 0 };
|
|
39
47
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
40
|
-
const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a));
|
|
48
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a), zodColor);
|
|
41
49
|
const safeParse = schema.safeParse(newColor);
|
|
42
50
|
const newLocalState = {
|
|
43
51
|
value: newColor,
|
|
@@ -47,7 +55,7 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
47
55
|
if (safeParse.success) {
|
|
48
56
|
setValue(newColor);
|
|
49
57
|
}
|
|
50
|
-
}, [a, schema, setValue]);
|
|
58
|
+
}, [a, schema, setValue, zodColor]);
|
|
51
59
|
const onTextChange = (0, react_1.useCallback)((e) => {
|
|
52
60
|
const newValue = e.target.value;
|
|
53
61
|
const safeParse = schema.safeParse(newValue);
|
|
@@ -78,7 +86,7 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
78
86
|
};
|
|
79
87
|
}, []);
|
|
80
88
|
const onOpacityChange = (0, react_1.useCallback)((newValue) => {
|
|
81
|
-
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255));
|
|
89
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodColor);
|
|
82
90
|
const safeParse = schema.safeParse(newColor);
|
|
83
91
|
const newLocalState = {
|
|
84
92
|
value: newColor,
|
|
@@ -88,9 +96,9 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
88
96
|
if (safeParse.success) {
|
|
89
97
|
setValue(newColor);
|
|
90
98
|
}
|
|
91
|
-
}, [localValue.value, schema, setValue]);
|
|
99
|
+
}, [localValue.value, schema, setValue, zodColor]);
|
|
92
100
|
const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
|
|
93
|
-
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255));
|
|
101
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodColor);
|
|
94
102
|
const safeParse = schema.safeParse(newColor);
|
|
95
103
|
const newLocalState = {
|
|
96
104
|
value: String(newColor),
|
|
@@ -100,9 +108,9 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
100
108
|
if (safeParse.success) {
|
|
101
109
|
setValue(newColor);
|
|
102
110
|
}
|
|
103
|
-
}, [localValue.value, schema, setValue]);
|
|
111
|
+
}, [localValue.value, schema, setValue, zodColor]);
|
|
104
112
|
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: colorPicker, children: (0, jsx_runtime_1.jsx)(RemInputTypeColor_1.RemInputTypeColor, { type: "color", style: {
|
|
105
113
|
height: 39,
|
|
106
|
-
}, value: rgb, onChange: onChange, className: "__remotion_color_picker", status: status }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1, block: true }), (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: localValue.value, status: status, placeholder: jsonPath.join('.'), onChange: onTextChange }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { onTextChange: onOpacityChange, onValueChange: onOpacityValueChange, status: status, value: (a / 255) * 100, min: 0, max: 100, step: 1, formatter: (v) => `${Math.round(Number(v))}
|
|
114
|
+
}, value: rgb, onChange: onChange, className: "__remotion_color_picker", status: status }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1, block: true }), (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: localValue.value, status: status, placeholder: jsonPath.join('.'), onChange: onTextChange, rightAlign: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { onTextChange: onOpacityChange, onValueChange: onOpacityValueChange, status: status, value: (a / 255) * 100, min: 0, max: 100, step: 1, formatter: (v) => `${Math.round(Number(v))}%`, rightAlign: false })] }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
|
|
107
115
|
};
|
|
108
116
|
exports.ZodColorEditor = ZodColorEditor;
|
|
@@ -71,6 +71,6 @@ const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue
|
|
|
71
71
|
const save = (0, react_1.useCallback)(() => {
|
|
72
72
|
onSave(() => value);
|
|
73
73
|
}, [onSave, value]);
|
|
74
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value.getTime() === defaultValue.getTime(), jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: formatDate(localValue.value), type: "datetime-local", status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, style: inputStyle }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: explainer, children: "Date is in local format" }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-
|
|
74
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value.getTime() === defaultValue.getTime(), jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: formatDate(localValue.value), type: "datetime-local", status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, style: inputStyle, rightAlign: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: explainer, children: "Date is in local format" }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
|
|
75
75
|
};
|
|
76
76
|
exports.ZodDateEditor = ZodDateEditor;
|
|
@@ -3,14 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodEffectEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const remotion_1 = require("remotion");
|
|
7
6
|
const colors_1 = require("../../../helpers/colors");
|
|
7
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
8
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
9
9
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
10
10
|
const fullWidth = {
|
|
11
11
|
width: '100%',
|
|
12
12
|
};
|
|
13
13
|
const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compact, defaultValue, onSave, onRemove, showSaveButton, }) => {
|
|
14
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
15
|
+
if (!z) {
|
|
16
|
+
throw new Error('expected zod');
|
|
17
|
+
}
|
|
14
18
|
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
15
19
|
return {
|
|
16
20
|
value,
|
|
@@ -19,7 +23,7 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
|
|
|
19
23
|
});
|
|
20
24
|
const def = schema._def;
|
|
21
25
|
const typeName = def.typeName;
|
|
22
|
-
if (typeName !==
|
|
26
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
23
27
|
throw new Error('expected effect');
|
|
24
28
|
}
|
|
25
29
|
const onChange = (0, react_1.useCallback)((newValue) => {
|
|
@@ -46,6 +50,6 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
|
|
|
46
50
|
padding: 0,
|
|
47
51
|
};
|
|
48
52
|
}, [localValue.zodValidation.success]);
|
|
49
|
-
return ((0, jsx_runtime_1.jsxs)("fieldset", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { value: value, setValue: onChange, jsonPath: jsonPath, schema: def.schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsx)("legend", { children: (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)("fieldset", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { value: value, setValue: onChange, jsonPath: jsonPath, schema: def.schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsx)("legend", { children: (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" }) }))] }));
|
|
50
54
|
};
|
|
51
55
|
exports.ZodEffectEditor = ZodEffectEditor;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodEnumEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const remotion_1 = require("remotion");
|
|
7
6
|
const Checkmark_1 = require("../../../icons/Checkmark");
|
|
7
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
8
|
const layout_1 = require("../../layout");
|
|
9
9
|
const ComboBox_1 = require("../../NewComposition/ComboBox");
|
|
10
10
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
@@ -14,6 +14,10 @@ const container = {
|
|
|
14
14
|
width: '100%',
|
|
15
15
|
};
|
|
16
16
|
const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defaultValue, value, onSave, showSaveButton, onRemove, }) => {
|
|
17
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
18
|
+
if (!z) {
|
|
19
|
+
throw new Error('expected zod');
|
|
20
|
+
}
|
|
17
21
|
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
18
22
|
return {
|
|
19
23
|
value,
|
|
@@ -23,7 +27,7 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
23
27
|
});
|
|
24
28
|
const def = schema._def;
|
|
25
29
|
const typeName = def.typeName;
|
|
26
|
-
if (typeName !==
|
|
30
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodEnum) {
|
|
27
31
|
throw new Error('expected enum');
|
|
28
32
|
}
|
|
29
33
|
const isRoot = jsonPath.length === 0;
|
|
@@ -63,6 +67,6 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
63
67
|
const save = (0, react_1.useCallback)(() => {
|
|
64
68
|
onSave(() => value);
|
|
65
69
|
}, [onSave, value]);
|
|
66
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onSave: save, showSaveButton: showSaveButton, isDefaultValue: value === defaultValue, compact: compact, onReset: reset, jsonPath: jsonPath, onRemove: onRemove }), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: value, title: value }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onSave: save, showSaveButton: showSaveButton, isDefaultValue: value === defaultValue, compact: compact, onReset: reset, jsonPath: jsonPath, onRemove: onRemove }), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: value, title: value }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] }));
|
|
67
71
|
};
|
|
68
72
|
exports.ZodEnumEditor = ZodEnumEditor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodNullableEditor: React.FC<{
|
|
5
|
+
showSaveButton: boolean;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
compact: boolean;
|
|
8
|
+
value: unknown;
|
|
9
|
+
defaultValue: unknown;
|
|
10
|
+
schema: z.ZodTypeAny;
|
|
11
|
+
setValue: React.Dispatch<React.SetStateAction<unknown>>;
|
|
12
|
+
onSave: (updater: (oldNum: unknown) => unknown) => void;
|
|
13
|
+
onRemove: null | (() => void);
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodNullableEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ZodOrNullishEditor_1 = require("./ZodOrNullishEditor");
|
|
6
|
+
const ZodNullableEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, }) => {
|
|
7
|
+
const { innerType } = schema._def;
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: null }));
|
|
9
|
+
};
|
|
10
|
+
exports.ZodNullableEditor = ZodNullableEditor;
|
|
@@ -76,7 +76,6 @@ const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, compact, d
|
|
|
76
76
|
setValue(newValue);
|
|
77
77
|
}
|
|
78
78
|
}, [schema, setValue]);
|
|
79
|
-
// TODO: Error message does not align well
|
|
80
79
|
const isDefault = value === defaultValue;
|
|
81
80
|
const reset = (0, react_1.useCallback)(() => {
|
|
82
81
|
onValueChange(defaultValue);
|
|
@@ -84,6 +83,6 @@ const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, compact, d
|
|
|
84
83
|
const save = (0, react_1.useCallback)(() => {
|
|
85
84
|
onSave(() => value);
|
|
86
85
|
}, [onSave, value]);
|
|
87
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefault, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: 'number', value: localValue.value, style: fullWidth, status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onTextChange: onChange, onValueChange: onValueChange, min: getMinValue(schema), max: getMaxValue(schema), step: getStep(schema) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-
|
|
86
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefault, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: 'number', value: localValue.value, style: fullWidth, status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onTextChange: onChange, onValueChange: onValueChange, min: getMinValue(schema), max: getMaxValue(schema), step: getStep(schema), rightAlign: false }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
|
|
88
87
|
};
|
|
89
88
|
exports.ZodNumberEditor = ZodNumberEditor;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodObjectEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const remotion_1 = require("remotion");
|
|
7
6
|
const colors_1 = require("../../../helpers/colors");
|
|
7
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
8
|
const layout_1 = require("../layout");
|
|
9
9
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
10
10
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
@@ -20,9 +20,13 @@ const fieldset = {
|
|
|
20
20
|
};
|
|
21
21
|
// TODO: First validate locally
|
|
22
22
|
const ZodObjectEditor = ({ schema, jsonPath, setValue, value, compact, defaultValue, onSave, showSaveButton, onRemove, }) => {
|
|
23
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
24
|
+
if (!z) {
|
|
25
|
+
throw new Error('expected zod');
|
|
26
|
+
}
|
|
23
27
|
const def = schema._def;
|
|
24
28
|
const typeName = def.typeName;
|
|
25
|
-
if (typeName !==
|
|
29
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodObject) {
|
|
26
30
|
throw new Error('expected object');
|
|
27
31
|
}
|
|
28
32
|
const shape = def.shape();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodOptionalEditor: React.FC<{
|
|
5
|
+
showSaveButton: boolean;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
compact: boolean;
|
|
8
|
+
value: unknown;
|
|
9
|
+
defaultValue: unknown;
|
|
10
|
+
schema: z.ZodTypeAny;
|
|
11
|
+
setValue: React.Dispatch<React.SetStateAction<unknown>>;
|
|
12
|
+
onSave: (updater: (oldNum: unknown) => unknown) => void;
|
|
13
|
+
onRemove: null | (() => void);
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodOptionalEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ZodOrNullishEditor_1 = require("./ZodOrNullishEditor");
|
|
6
|
+
const ZodOptionalEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, }) => {
|
|
7
|
+
const { innerType } = schema._def;
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: undefined }));
|
|
9
|
+
};
|
|
10
|
+
exports.ZodOptionalEditor = ZodOptionalEditor;
|
|
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const colors_1 = require("../../../helpers/colors");
|
|
7
7
|
const Checkbox_1 = require("../../Checkbox");
|
|
8
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
9
|
const layout_1 = require("../../layout");
|
|
9
10
|
const create_zod_values_1 = require("./create-zod-values");
|
|
10
11
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
@@ -25,21 +26,27 @@ const checkBoxWrapper = {
|
|
|
25
26
|
marginTop: '5px',
|
|
26
27
|
};
|
|
27
28
|
const ZodOrNullishEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, nullishValue, }) => {
|
|
29
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
30
|
+
if (!z) {
|
|
31
|
+
throw new Error('expected zod');
|
|
32
|
+
}
|
|
33
|
+
const zColor = (0, get_zod_if_possible_1.useZodColorIfPossible)();
|
|
28
34
|
const isChecked = value === nullishValue;
|
|
29
35
|
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
30
36
|
setValue(newValue);
|
|
31
37
|
}, [setValue]);
|
|
32
38
|
const onCheckBoxChange = (0, react_1.useCallback)((e) => {
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
const val = e.target.checked
|
|
40
|
+
? nullishValue
|
|
41
|
+
: (0, create_zod_values_1.createZodValues)(schema, z, zColor);
|
|
35
42
|
onValueChange(val);
|
|
36
|
-
}, [nullishValue, onValueChange, schema]);
|
|
43
|
+
}, [nullishValue, onValueChange, schema, z, zColor]);
|
|
37
44
|
const reset = (0, react_1.useCallback)(() => {
|
|
38
45
|
onValueChange(defaultValue);
|
|
39
46
|
}, [defaultValue, onValueChange]);
|
|
40
47
|
const save = (0, react_1.useCallback)(() => {
|
|
41
48
|
onSave(() => value);
|
|
42
49
|
}, [onSave, value]);
|
|
43
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [value ===
|
|
50
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [value === nullishValue ? ((0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove })) : ((0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { value: value, setValue: onValueChange, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove }) })), (0, jsx_runtime_1.jsxs)("div", { style: checkBoxWrapper, children: [(0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: isChecked, onChange: onCheckBoxChange, disabled: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)("div", { style: labelStyle, children: String(nullishValue) })] })] }));
|
|
44
51
|
};
|
|
45
52
|
exports.ZodOrNullishEditor = ZodOrNullishEditor;
|