@remotion/cli 3.3.87 → 3.3.89
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/codemods/update-default-props.d.ts +5 -0
- package/dist/codemods/update-default-props.js +143 -0
- package/dist/color-math.d.ts +2 -0
- package/dist/color-math.js +11 -0
- package/dist/config/jpeg-quality.d.ts +2 -0
- package/dist/config/jpeg-quality.js +17 -0
- package/dist/convert-entry-point-to-serve-url.d.ts +1 -0
- package/dist/convert-entry-point-to-serve-url.js +15 -0
- package/dist/editor/components/Checkbox.d.ts +6 -0
- package/dist/editor/components/Checkbox.js +42 -0
- package/dist/editor/components/CheckerboardProvider.d.ts +4 -0
- package/dist/editor/components/CheckerboardProvider.js +24 -0
- package/dist/editor/components/CurrentCompositionSideEffects.d.ts +3 -0
- package/dist/editor/components/CurrentCompositionSideEffects.js +51 -0
- package/dist/editor/components/InlineAction.d.ts +7 -0
- package/dist/editor/components/InlineAction.js +31 -0
- package/dist/editor/components/MediaVolumeProvider.d.ts +4 -0
- package/dist/editor/components/MediaVolumeProvider.js +25 -0
- package/dist/editor/components/Modals.d.ts +2 -0
- package/dist/editor/components/Modals.js +23 -0
- package/dist/editor/components/ModalsProvider.d.ts +4 -0
- package/dist/editor/components/ModalsProvider.js +17 -0
- package/dist/editor/components/NewComposition/RemInputTypeColor.d.ts +7 -0
- package/dist/editor/components/NewComposition/RemInputTypeColor.js +53 -0
- package/dist/editor/components/NewComposition/RemTextarea.d.ts +7 -0
- package/dist/editor/components/NewComposition/RemTextarea.js +92 -0
- package/dist/editor/components/PlayerEmitterContext.d.ts +4 -0
- package/dist/editor/components/PlayerEmitterContext.js +11 -0
- package/dist/editor/components/RenderButton.d.ts +2 -0
- package/dist/editor/components/RenderButton.js +103 -0
- package/dist/editor/components/RenderModal/CliCopyButton.d.ts +4 -0
- package/dist/editor/components/RenderModal/CliCopyButton.js +22 -0
- package/dist/editor/components/RenderModal/CrfSetting.d.ts +15 -0
- package/dist/editor/components/RenderModal/CrfSetting.js +42 -0
- package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.d.ts +8 -0
- package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.js +16 -0
- package/dist/editor/components/RenderModal/EnvInput.d.ts +11 -0
- package/dist/editor/components/RenderModal/EnvInput.js +74 -0
- package/dist/editor/components/RenderModal/FrameRangeSetting.d.ts +8 -0
- package/dist/editor/components/RenderModal/FrameRangeSetting.js +42 -0
- package/dist/editor/components/RenderModal/GuiRenderStatus.d.ts +5 -0
- package/dist/editor/components/RenderModal/GuiRenderStatus.js +78 -0
- package/dist/editor/components/RenderModal/InfoBubble.d.ts +5 -0
- package/dist/editor/components/RenderModal/InfoBubble.js +115 -0
- package/dist/editor/components/RenderModal/InfoTooltip.d.ts +5 -0
- package/dist/editor/components/RenderModal/InfoTooltip.js +40 -0
- package/dist/editor/components/RenderModal/InlineEyeIcon.d.ts +5 -0
- package/dist/editor/components/RenderModal/InlineEyeIcon.js +17 -0
- package/dist/editor/components/RenderModal/InlineRemoveButton.d.ts +4 -0
- package/dist/editor/components/RenderModal/InlineRemoveButton.js +17 -0
- package/dist/editor/components/RenderModal/JpegQualitySetting.d.ts +5 -0
- package/dist/editor/components/RenderModal/JpegQualitySetting.js +12 -0
- package/dist/editor/components/RenderModal/MutedSetting.d.ts +8 -0
- package/dist/editor/components/RenderModal/MutedSetting.js +16 -0
- package/dist/editor/components/RenderModal/NumberOfLoopsSetting.d.ts +5 -0
- package/dist/editor/components/RenderModal/NumberOfLoopsSetting.js +26 -0
- package/dist/editor/components/RenderModal/NumberSetting.d.ts +12 -0
- package/dist/editor/components/RenderModal/NumberSetting.js +29 -0
- package/dist/editor/components/RenderModal/OptionExplainer.d.ts +5 -0
- package/dist/editor/components/RenderModal/OptionExplainer.js +45 -0
- package/dist/editor/components/RenderModal/RenderModal.d.ts +35 -0
- package/dist/editor/components/RenderModal/RenderModal.js +597 -0
- package/dist/editor/components/RenderModal/RenderModalAdvanced.d.ts +26 -0
- package/dist/editor/components/RenderModal/RenderModalAdvanced.js +61 -0
- package/dist/editor/components/RenderModal/RenderModalAudio.d.ts +17 -0
- package/dist/editor/components/RenderModal/RenderModalAudio.js +46 -0
- package/dist/editor/components/RenderModal/RenderModalBasic.d.ts +23 -0
- package/dist/editor/components/RenderModal/RenderModalBasic.js +79 -0
- package/dist/editor/components/RenderModal/RenderModalData.d.ts +20 -0
- package/dist/editor/components/RenderModal/RenderModalData.js +249 -0
- package/dist/editor/components/RenderModal/RenderModalEnvironmentVariables.d.ts +5 -0
- package/dist/editor/components/RenderModal/RenderModalEnvironmentVariables.js +55 -0
- package/dist/editor/components/RenderModal/RenderModalGif.d.ts +9 -0
- package/dist/editor/components/RenderModal/RenderModalGif.js +19 -0
- package/dist/editor/components/RenderModal/RenderModalHr.d.ts +2 -0
- package/dist/editor/components/RenderModal/RenderModalHr.js +18 -0
- package/dist/editor/components/RenderModal/RenderModalInput.d.ts +10 -0
- package/dist/editor/components/RenderModal/RenderModalInput.js +13 -0
- package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.js +109 -0
- package/dist/editor/components/RenderModal/RenderModalPicture.d.ts +28 -0
- package/dist/editor/components/RenderModal/RenderModalPicture.js +54 -0
- package/dist/editor/components/RenderModal/RenderStatusModal.d.ts +4 -0
- package/dist/editor/components/RenderModal/RenderStatusModal.js +72 -0
- package/dist/editor/components/RenderModal/ScaleSetting.d.ts +5 -0
- package/dist/editor/components/RenderModal/ScaleSetting.js +17 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +13 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +39 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEmptyStateGraphic.d.ts +2 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEmptyStateGraphic.js +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +12 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +59 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +16 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.js +40 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaResetButton.d.ts +4 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaResetButton.js +17 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +5 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.js +17 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +84 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +28 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +13 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +27 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +116 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +76 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +55 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +72 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodErrorMessages.d.ts +5 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodErrorMessages.js +23 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +9 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +27 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.js +10 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +88 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +64 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +10 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +16 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +52 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +48 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +84 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.js +49 -0
- package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.d.ts +2 -0
- package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.js +158 -0
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.d.ts +6 -0
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.js +24 -0
- package/dist/editor/components/RenderModal/SchemaEditor/get-schema-label.d.ts +2 -0
- package/dist/editor/components/RenderModal/SchemaEditor/get-schema-label.js +15 -0
- package/dist/editor/components/RenderModal/SchemaEditor/zod-types.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/zod-types.js +2 -0
- 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 +15 -0
- package/dist/editor/components/RenderModal/get-render-modal-warnings.js +34 -0
- package/dist/editor/components/RenderModal/human-readable-audio-codecs.d.ts +2 -0
- package/dist/editor/components/RenderModal/human-readable-audio-codecs.js +18 -0
- package/dist/editor/components/RenderModal/human-readable-codec.d.ts +2 -0
- package/dist/editor/components/RenderModal/human-readable-codec.js +36 -0
- package/dist/editor/components/RenderModal/layout.d.ts +7 -0
- package/dist/editor/components/RenderModal/layout.js +45 -0
- package/dist/editor/components/RenderModal/out-name-checker.d.ts +14 -0
- package/dist/editor/components/RenderModal/out-name-checker.js +80 -0
- package/dist/editor/components/RenderQueue/CircularProgress.d.ts +5 -0
- package/dist/editor/components/RenderQueue/CircularProgress.js +18 -0
- package/dist/editor/components/RenderQueue/RenderQueueError.d.ts +5 -0
- package/dist/editor/components/RenderQueue/RenderQueueError.js +26 -0
- package/dist/editor/components/RenderQueue/RenderQueueItem.d.ts +5 -0
- package/dist/editor/components/RenderQueue/RenderQueueItem.js +40 -0
- package/dist/editor/components/RenderQueue/RenderQueueItemCancelButton.d.ts +5 -0
- package/dist/editor/components/RenderQueue/RenderQueueItemCancelButton.js +26 -0
- package/dist/editor/components/RenderQueue/RenderQueueItemStatus.d.ts +5 -0
- package/dist/editor/components/RenderQueue/RenderQueueItemStatus.js +43 -0
- package/dist/editor/components/RenderQueue/RenderQueueOpenInFolder.d.ts +5 -0
- package/dist/editor/components/RenderQueue/RenderQueueOpenInFolder.js +26 -0
- package/dist/editor/components/RenderQueue/RenderQueueOutputName.d.ts +5 -0
- package/dist/editor/components/RenderQueue/RenderQueueOutputName.js +26 -0
- package/dist/editor/components/RenderQueue/RenderQueueProgressMessage.d.ts +5 -0
- package/dist/editor/components/RenderQueue/RenderQueueProgressMessage.js +26 -0
- package/dist/editor/components/RenderQueue/RenderQueueRemoveItem.d.ts +5 -0
- package/dist/editor/components/RenderQueue/RenderQueueRemoveItem.js +37 -0
- package/dist/editor/components/RenderQueue/RenderQueueRepeat.d.ts +5 -0
- package/dist/editor/components/RenderQueue/RenderQueueRepeat.js +26 -0
- package/dist/editor/components/RenderQueue/SuccessIcon.d.ts +2 -0
- package/dist/editor/components/RenderQueue/SuccessIcon.js +14 -0
- package/dist/editor/components/RenderQueue/actions.d.ts +58 -0
- package/dist/editor/components/RenderQueue/actions.js +120 -0
- package/dist/editor/components/RenderQueue/context.d.ts +18 -0
- package/dist/editor/components/RenderQueue/context.js +49 -0
- package/dist/editor/components/RenderQueue/index.d.ts +2 -0
- package/dist/editor/components/RenderQueue/index.js +43 -0
- package/dist/editor/components/RenderQueue/item-style.d.ts +2 -0
- package/dist/editor/components/RenderQueue/item-style.js +21 -0
- package/dist/editor/components/RendersTab.d.ts +6 -0
- package/dist/editor/components/RendersTab.js +43 -0
- package/dist/editor/components/RightPanel.d.ts +8 -0
- package/dist/editor/components/RightPanel.js +76 -0
- package/dist/editor/components/SegmentedControl.d.ts +11 -0
- package/dist/editor/components/SegmentedControl.js +62 -0
- package/dist/editor/components/SetTimelineInOutProvider.d.ts +4 -0
- package/dist/editor/components/SetTimelineInOutProvider.js +19 -0
- package/dist/editor/components/SidebarCollapserControls.d.ts +2 -0
- package/dist/editor/components/SidebarCollapserControls.js +135 -0
- package/dist/editor/components/SidebarRenderButton.d.ts +6 -0
- package/dist/editor/components/SidebarRenderButton.js +85 -0
- package/dist/editor/components/Tabs/index.d.ts +11 -0
- package/dist/editor/components/Tabs/index.js +58 -0
- package/dist/editor/components/Tabs/vertical.d.ts +7 -0
- package/dist/editor/components/Tabs/vertical.js +43 -0
- package/dist/editor/components/ZoomGesturesProvider.d.ts +4 -0
- package/dist/editor/components/ZoomGesturesProvider.js +24 -0
- 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/client-id.d.ts +17 -0
- package/dist/editor/helpers/client-id.js +46 -0
- package/dist/editor/helpers/convert-env-variables.d.ts +2 -0
- package/dist/editor/helpers/convert-env-variables.js +20 -0
- package/dist/editor/helpers/prores-labels.d.ts +2 -0
- package/dist/editor/helpers/prores-labels.js +25 -0
- package/dist/editor/helpers/render-modal-sections.d.ts +10 -0
- package/dist/editor/helpers/render-modal-sections.js +32 -0
- package/dist/editor/helpers/use-breakpoint.d.ts +1 -0
- package/dist/editor/helpers/use-breakpoint.js +17 -0
- package/dist/editor/helpers/use-file-existence.d.ts +1 -0
- package/dist/editor/helpers/use-file-existence.js +66 -0
- package/dist/editor/icons/audio.d.ts +2 -0
- package/dist/editor/icons/audio.js +6 -0
- package/dist/editor/icons/data.d.ts +2 -0
- package/dist/editor/icons/data.js +8 -0
- package/dist/editor/icons/file.d.ts +2 -0
- package/dist/editor/icons/file.js +6 -0
- package/dist/editor/icons/frame.d.ts +2 -0
- package/dist/editor/icons/frame.js +6 -0
- package/dist/editor/icons/gear.d.ts +2 -0
- package/dist/editor/icons/gear.js +6 -0
- package/dist/editor/icons/gif.d.ts +2 -0
- package/dist/editor/icons/gif.js +6 -0
- package/dist/editor/icons/render.d.ts +9 -0
- package/dist/editor/icons/render.js +12 -0
- package/dist/editor/icons/video.d.ts +5 -0
- package/dist/editor/icons/video.js +8 -0
- package/dist/ffmpeg.d.ts +2 -0
- package/dist/ffmpeg.js +21 -0
- package/dist/file-watcher.d.ts +9 -0
- package/dist/file-watcher.js +35 -0
- package/dist/get-default-out-name.d.ts +5 -0
- package/dist/get-default-out-name.js +10 -0
- package/dist/preview-server/api-routes.d.ts +4 -0
- package/dist/preview-server/api-routes.js +21 -0
- package/dist/preview-server/api-types.d.ts +25 -0
- package/dist/preview-server/api-types.js +2 -0
- package/dist/preview-server/file-existence-watchers.d.ts +13 -0
- package/dist/preview-server/file-existence-watchers.js +62 -0
- package/dist/preview-server/handler.d.ts +9 -0
- package/dist/preview-server/handler.js +34 -0
- package/dist/preview-server/parse-body.d.ts +2 -0
- package/dist/preview-server/parse-body.js +16 -0
- package/dist/preview-server/render-queue/get-default-video-contexts.d.ts +10 -0
- package/dist/preview-server/render-queue/get-default-video-contexts.js +13 -0
- package/dist/preview-server/render-queue/job.d.ts +138 -0
- package/dist/preview-server/render-queue/job.js +2 -0
- package/dist/preview-server/render-queue/make-retry-payload.d.ts +3 -0
- package/dist/preview-server/render-queue/make-retry-payload.js +91 -0
- package/dist/preview-server/render-queue/open-directory-in-finder.d.ts +1 -0
- package/dist/preview-server/render-queue/open-directory-in-finder.js +43 -0
- package/dist/preview-server/render-queue/process-still.d.ts +8 -0
- package/dist/preview-server/render-queue/process-still.js +46 -0
- package/dist/preview-server/render-queue/process-video.d.ts +8 -0
- package/dist/preview-server/render-queue/process-video.js +63 -0
- package/dist/preview-server/render-queue/queue.d.ts +9 -0
- package/dist/preview-server/render-queue/queue.js +212 -0
- package/dist/preview-server/routes/add-render.d.ts +3 -0
- package/dist/preview-server/routes/add-render.js +76 -0
- package/dist/preview-server/routes/can-update-default-props.d.ts +4 -0
- package/dist/preview-server/routes/can-update-default-props.js +39 -0
- package/dist/preview-server/routes/cancel-render.d.ts +3 -0
- package/dist/preview-server/routes/cancel-render.js +9 -0
- package/dist/preview-server/routes/open-in-file-explorer.d.ts +3 -0
- package/dist/preview-server/routes/open-in-file-explorer.js +8 -0
- package/dist/preview-server/routes/remove-render.d.ts +3 -0
- package/dist/preview-server/routes/remove-render.js +9 -0
- package/dist/preview-server/routes/subscribe-to-file-existence.d.ts +3 -0
- package/dist/preview-server/routes/subscribe-to-file-existence.js +13 -0
- package/dist/preview-server/routes/unsubscribe-from-file-existence.d.ts +3 -0
- package/dist/preview-server/routes/unsubscribe-from-file-existence.js +13 -0
- package/dist/preview-server/routes/update-default-props.d.ts +3 -0
- package/dist/preview-server/routes/update-default-props.js +24 -0
- package/dist/progress-types.d.ts +32 -0
- package/dist/progress-types.js +17 -0
- package/dist/render-flows/render.d.ts +47 -0
- package/dist/render-flows/render.js +293 -0
- package/dist/render-flows/still.d.ts +29 -0
- package/dist/render-flows/still.js +174 -0
- package/dist/required-chromium-options.d.ts +3 -0
- package/dist/required-chromium-options.js +2 -0
- package/package.json +6 -6
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaSaveButton = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const InlineAction_1 = require("../../InlineAction");
|
|
7
|
+
const icon = {
|
|
8
|
+
height: 14,
|
|
9
|
+
color: 'currentColor',
|
|
10
|
+
};
|
|
11
|
+
const SchemaSaveButton = ({ onClick, isSaving }) => {
|
|
12
|
+
const renderAction = (0, react_1.useCallback)((color) => {
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("svg", { style: icon, viewBox: "0 0 448 512", children: (0, jsx_runtime_1.jsx)("path", { fill: isSaving ? 'grey' : color, d: "M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V173.3c0-17-6.7-33.3-18.7-45.3L352 50.7C340 38.7 323.7 32 306.7 32H64zm0 96c0-17.7 14.3-32 32-32H288c17.7 0 32 14.3 32 32v64c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V128zM224 288a64 64 0 1 1 0 128 64 64 0 1 1 0-128z" }) }));
|
|
14
|
+
}, [isSaving]);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(InlineAction_1.InlineAction, { renderAction: renderAction, onClick: onClick, disabled: isSaving }));
|
|
16
|
+
};
|
|
17
|
+
exports.SchemaSaveButton = SchemaSaveButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodArrayEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: unknown[];
|
|
8
|
+
defaultValue: unknown[];
|
|
9
|
+
setValue: React.Dispatch<React.SetStateAction<unknown[]>>;
|
|
10
|
+
onSave: (updater: (oldState: unknown[]) => unknown[]) => void;
|
|
11
|
+
compact: boolean;
|
|
12
|
+
showSaveButton: boolean;
|
|
13
|
+
onRemove: null | (() => void);
|
|
14
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodArrayEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Button_1 = require("../../../../preview-server/error-overlay/remotion-overlay/Button");
|
|
7
|
+
const colors_1 = require("../../../helpers/colors");
|
|
8
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
9
|
+
const layout_1 = require("../../layout");
|
|
10
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
11
|
+
const layout_2 = require("../layout");
|
|
12
|
+
const create_zod_values_1 = require("./create-zod-values");
|
|
13
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
14
|
+
const ZodArrayItemEditor_1 = require("./ZodArrayItemEditor");
|
|
15
|
+
const container = {
|
|
16
|
+
width: '100%',
|
|
17
|
+
};
|
|
18
|
+
const fullWidth = {
|
|
19
|
+
width: '100%',
|
|
20
|
+
};
|
|
21
|
+
// TODO: Ability to revert a change (e.g entry deletion )
|
|
22
|
+
const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, }) => {
|
|
23
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
24
|
+
return {
|
|
25
|
+
value,
|
|
26
|
+
zodValidation: schema.safeParse(value),
|
|
27
|
+
revision: 0,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
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 zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
36
|
+
const typeName = def.typeName;
|
|
37
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodArray) {
|
|
38
|
+
throw new Error('expected object');
|
|
39
|
+
}
|
|
40
|
+
const isRoot = jsonPath.length === 0;
|
|
41
|
+
const Element = isRoot ? 'div' : 'fieldset';
|
|
42
|
+
const { paddingTop } = layout_2.optionRow;
|
|
43
|
+
const fieldset = (0, react_1.useMemo)(() => {
|
|
44
|
+
return {
|
|
45
|
+
borderRadius: 4,
|
|
46
|
+
borderColor: localValue.zodValidation.success
|
|
47
|
+
? colors_1.INPUT_BORDER_COLOR_UNHOVERED
|
|
48
|
+
: colors_1.FAIL_COLOR,
|
|
49
|
+
};
|
|
50
|
+
}, [localValue.zodValidation.success]);
|
|
51
|
+
const onChange = (0, react_1.useCallback)((updater, incrementRevision) => {
|
|
52
|
+
setLocalValue((oldLocalState) => {
|
|
53
|
+
const newValue = updater(oldLocalState.value);
|
|
54
|
+
const safeParse = schema.safeParse(newValue);
|
|
55
|
+
// TODO: This logs an error to the console
|
|
56
|
+
if (safeParse.success) {
|
|
57
|
+
updateValue(updater);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
revision: oldLocalState.revision + (incrementRevision ? 1 : 0),
|
|
61
|
+
value: newValue,
|
|
62
|
+
zodValidation: safeParse,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}, [schema, updateValue]);
|
|
66
|
+
const style = (0, react_1.useMemo)(() => {
|
|
67
|
+
if (isRoot) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return { paddingTop };
|
|
71
|
+
}, [isRoot, paddingTop]);
|
|
72
|
+
const onAdd = (0, react_1.useCallback)(() => {
|
|
73
|
+
onChange((oldV) => {
|
|
74
|
+
return [...oldV, (0, create_zod_values_1.createZodValues)(def.type, z, zodTypes)];
|
|
75
|
+
}, true);
|
|
76
|
+
}, [def.type, onChange, z]);
|
|
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) => {
|
|
78
|
+
var _a;
|
|
79
|
+
return ((0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor
|
|
80
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
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, saving: saving }, `${i}${localValue.revision}`));
|
|
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" })] }) }) }));
|
|
83
|
+
};
|
|
84
|
+
exports.ZodArrayEditor = ZodArrayEditor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { JSONPath } from './zod-types';
|
|
3
|
+
export declare const ZodArrayItemEditor: React.FC<{
|
|
4
|
+
jsonPath: JSONPath;
|
|
5
|
+
onChange: (updater: (oldV: unknown[]) => unknown[], incrementRevision: boolean) => void;
|
|
6
|
+
def: any;
|
|
7
|
+
index: number;
|
|
8
|
+
value: unknown;
|
|
9
|
+
compact: boolean;
|
|
10
|
+
defaultValue: unknown;
|
|
11
|
+
onSave: (updater: (oldState: unknown[]) => unknown[]) => void;
|
|
12
|
+
showSaveButton: boolean;
|
|
13
|
+
saving: boolean;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodArrayItemEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ZodSwitch_1 = require("./ZodSwitch");
|
|
7
|
+
const ZodArrayItemEditor = ({ def, onChange, jsonPath, index, value, compact, defaultValue, onSave: onSaveObject, showSaveButton, saving, }) => {
|
|
8
|
+
const onRemove = (0, react_1.useCallback)(() => {
|
|
9
|
+
onChange((oldV) => [...oldV.slice(0, index), ...oldV.slice(index + 1)], true);
|
|
10
|
+
}, [index, onChange]);
|
|
11
|
+
const setValue = (0, react_1.useCallback)((val) => {
|
|
12
|
+
onChange((oldV) => [
|
|
13
|
+
...oldV.slice(0, index),
|
|
14
|
+
typeof val === 'function' ? val(oldV[index]) : val,
|
|
15
|
+
...oldV.slice(index + 1),
|
|
16
|
+
], false);
|
|
17
|
+
}, [index, onChange]);
|
|
18
|
+
const newJsonPath = (0, react_1.useMemo)(() => [...jsonPath, index], [index, jsonPath]);
|
|
19
|
+
const onSave = (0, react_1.useCallback)((updater) => {
|
|
20
|
+
onSaveObject((oldV) => [
|
|
21
|
+
...oldV.slice(0, index),
|
|
22
|
+
updater(oldV[index]),
|
|
23
|
+
...oldV.slice(index + 1),
|
|
24
|
+
]);
|
|
25
|
+
}, [index, onSaveObject]);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { jsonPath: newJsonPath, schema: def.type, value: value, setValue: setValue, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
27
|
+
};
|
|
28
|
+
exports.ZodArrayItemEditor = ZodArrayItemEditor;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { JSONPath } from './zod-types';
|
|
3
|
+
export declare const ZodBooleanEditor: React.FC<{
|
|
4
|
+
jsonPath: JSONPath;
|
|
5
|
+
value: boolean;
|
|
6
|
+
setValue: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
|
+
compact: boolean;
|
|
8
|
+
defaultValue: boolean;
|
|
9
|
+
onSave: (updater: (oldNum: unknown) => boolean) => void;
|
|
10
|
+
onRemove: null | (() => void);
|
|
11
|
+
showSaveButton: boolean;
|
|
12
|
+
saving: boolean;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodBooleanEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Checkbox_1 = require("../../Checkbox");
|
|
7
|
+
const layout_1 = require("../layout");
|
|
8
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
9
|
+
const fullWidth = {
|
|
10
|
+
width: '100%',
|
|
11
|
+
};
|
|
12
|
+
const ZodBooleanEditor = ({ jsonPath, value, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, }) => {
|
|
13
|
+
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
14
|
+
setValue(newValue);
|
|
15
|
+
}, [setValue]);
|
|
16
|
+
const onChange = (0, react_1.useCallback)((e) => {
|
|
17
|
+
onValueChange(e.target.checked);
|
|
18
|
+
}, [onValueChange]);
|
|
19
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
20
|
+
onValueChange(defaultValue);
|
|
21
|
+
}, [defaultValue, onValueChange]);
|
|
22
|
+
const save = (0, react_1.useCallback)(() => {
|
|
23
|
+
onSave(() => value);
|
|
24
|
+
}, [onSave, value]);
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_1.narrowOption : layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: value, onChange: onChange, disabled: false }) })] }));
|
|
26
|
+
};
|
|
27
|
+
exports.ZodBooleanEditor = ZodBooleanEditor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodColorEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: string;
|
|
8
|
+
defaultValue: string;
|
|
9
|
+
setValue: React.Dispatch<React.SetStateAction<string>>;
|
|
10
|
+
onSave: (updater: (oldNum: unknown) => string) => void;
|
|
11
|
+
onRemove: null | (() => void);
|
|
12
|
+
compact: boolean;
|
|
13
|
+
showSaveButton: boolean;
|
|
14
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodColorEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const color_math_1 = require("../../../../color-math");
|
|
7
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
|
+
const layout_1 = require("../../layout");
|
|
9
|
+
const InputDragger_1 = require("../../NewComposition/InputDragger");
|
|
10
|
+
const RemInput_1 = require("../../NewComposition/RemInput");
|
|
11
|
+
const RemInputTypeColor_1 = require("../../NewComposition/RemInputTypeColor");
|
|
12
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
13
|
+
const layout_2 = require("../layout");
|
|
14
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
15
|
+
const fullWidth = {
|
|
16
|
+
width: '100%',
|
|
17
|
+
};
|
|
18
|
+
const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, }) => {
|
|
19
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
20
|
+
if (!z) {
|
|
21
|
+
throw new Error('expected zod');
|
|
22
|
+
}
|
|
23
|
+
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
24
|
+
if (!zodTypes) {
|
|
25
|
+
throw new Error('expected zod color');
|
|
26
|
+
}
|
|
27
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
28
|
+
return {
|
|
29
|
+
value,
|
|
30
|
+
zodValidation: schema.safeParse(value),
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
34
|
+
const safeParse = schema.safeParse(newValue);
|
|
35
|
+
const newLocalState = {
|
|
36
|
+
value: newValue,
|
|
37
|
+
zodValidation: safeParse,
|
|
38
|
+
};
|
|
39
|
+
setLocalValue(newLocalState);
|
|
40
|
+
if (safeParse.success) {
|
|
41
|
+
setValue(newValue);
|
|
42
|
+
}
|
|
43
|
+
}, [schema, setValue]);
|
|
44
|
+
const { a, b, g, r } = localValue.zodValidation.success
|
|
45
|
+
? zodTypes.ZodZypesInternals.parseColor(localValue.value)
|
|
46
|
+
: { a: 1, b: 0, g: 0, r: 0 };
|
|
47
|
+
const onChange = (0, react_1.useCallback)((e) => {
|
|
48
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a), zodTypes);
|
|
49
|
+
const safeParse = schema.safeParse(newColor);
|
|
50
|
+
const newLocalState = {
|
|
51
|
+
value: newColor,
|
|
52
|
+
zodValidation: safeParse,
|
|
53
|
+
};
|
|
54
|
+
setLocalValue(newLocalState);
|
|
55
|
+
if (safeParse.success) {
|
|
56
|
+
setValue(newColor);
|
|
57
|
+
}
|
|
58
|
+
}, [a, schema, setValue, zodTypes]);
|
|
59
|
+
const onTextChange = (0, react_1.useCallback)((e) => {
|
|
60
|
+
const newValue = e.target.value;
|
|
61
|
+
const safeParse = schema.safeParse(newValue);
|
|
62
|
+
const newLocalState = {
|
|
63
|
+
value: newValue,
|
|
64
|
+
zodValidation: safeParse,
|
|
65
|
+
};
|
|
66
|
+
setLocalValue(newLocalState);
|
|
67
|
+
if (safeParse.success) {
|
|
68
|
+
setValue(newValue);
|
|
69
|
+
}
|
|
70
|
+
}, [schema, setValue]);
|
|
71
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
72
|
+
onValueChange(defaultValue);
|
|
73
|
+
}, [defaultValue, onValueChange]);
|
|
74
|
+
const save = (0, react_1.useCallback)(() => {
|
|
75
|
+
onSave(() => value);
|
|
76
|
+
}, [onSave, value]);
|
|
77
|
+
const rgb = `#${r.toString(16).padStart(2, '0')}${g
|
|
78
|
+
.toString(16)
|
|
79
|
+
.padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
|
|
80
|
+
const status = localValue.zodValidation.success ? 'ok' : 'error';
|
|
81
|
+
const colorPicker = (0, react_1.useMemo)(() => {
|
|
82
|
+
return {
|
|
83
|
+
height: 39,
|
|
84
|
+
width: 45,
|
|
85
|
+
display: 'inline-block',
|
|
86
|
+
};
|
|
87
|
+
}, []);
|
|
88
|
+
const onOpacityChange = (0, react_1.useCallback)((newValue) => {
|
|
89
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
|
|
90
|
+
const safeParse = schema.safeParse(newColor);
|
|
91
|
+
const newLocalState = {
|
|
92
|
+
value: newColor,
|
|
93
|
+
zodValidation: safeParse,
|
|
94
|
+
};
|
|
95
|
+
setLocalValue(newLocalState);
|
|
96
|
+
if (safeParse.success) {
|
|
97
|
+
setValue(newColor);
|
|
98
|
+
}
|
|
99
|
+
}, [localValue.value, schema, setValue, zodTypes]);
|
|
100
|
+
const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
|
|
101
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
|
|
102
|
+
const safeParse = schema.safeParse(newColor);
|
|
103
|
+
const newLocalState = {
|
|
104
|
+
value: String(newColor),
|
|
105
|
+
zodValidation: safeParse,
|
|
106
|
+
};
|
|
107
|
+
setLocalValue(newLocalState);
|
|
108
|
+
if (safeParse.success) {
|
|
109
|
+
setValue(newColor);
|
|
110
|
+
}
|
|
111
|
+
}, [localValue.value, schema, setValue, zodTypes]);
|
|
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, saving: saving }), (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: {
|
|
113
|
+
height: 39,
|
|
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" })] }))] })] }));
|
|
115
|
+
};
|
|
116
|
+
exports.ZodColorEditor = ZodColorEditor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodDateEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: Date;
|
|
8
|
+
defaultValue: Date;
|
|
9
|
+
setValue: React.Dispatch<React.SetStateAction<Date>>;
|
|
10
|
+
onSave: (updater: (oldNum: unknown) => Date) => void;
|
|
11
|
+
onRemove: null | (() => void);
|
|
12
|
+
compact: boolean;
|
|
13
|
+
showSaveButton: boolean;
|
|
14
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodDateEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const colors_1 = require("../../../helpers/colors");
|
|
7
|
+
const layout_1 = require("../../layout");
|
|
8
|
+
const RemInput_1 = require("../../NewComposition/RemInput");
|
|
9
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
10
|
+
const layout_2 = require("../layout");
|
|
11
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
12
|
+
const fullWidth = {
|
|
13
|
+
width: '100%',
|
|
14
|
+
};
|
|
15
|
+
const explainer = {
|
|
16
|
+
fontFamily: 'sans-serif',
|
|
17
|
+
fontSize: 12,
|
|
18
|
+
color: colors_1.VERY_LIGHT_TEXT,
|
|
19
|
+
marginBottom: layout_1.SPACING_UNIT,
|
|
20
|
+
};
|
|
21
|
+
// This will do 2 things:
|
|
22
|
+
// - Make the calendar icon white
|
|
23
|
+
// Turn the input popup a dark mode input
|
|
24
|
+
const inputStyle = {
|
|
25
|
+
colorScheme: 'dark',
|
|
26
|
+
};
|
|
27
|
+
const formatDate = (date) => {
|
|
28
|
+
// Get the year, month, day, hours, minutes, seconds, and milliseconds
|
|
29
|
+
const year = date.getFullYear();
|
|
30
|
+
const month = date.getMonth() + 1; // Month is zero-indexed, so we add 1
|
|
31
|
+
const day = date.getDate();
|
|
32
|
+
const hours = date.getHours();
|
|
33
|
+
const minutes = date.getMinutes();
|
|
34
|
+
const seconds = date.getSeconds();
|
|
35
|
+
const milliseconds = date.getMilliseconds();
|
|
36
|
+
// Format the date as a string
|
|
37
|
+
const formattedDate = `${year}-${month.toString().padStart(2, '0')}-${day
|
|
38
|
+
.toString()
|
|
39
|
+
.padStart(2, '0')}T${hours.toString().padStart(2, '0')}:${minutes
|
|
40
|
+
.toString()
|
|
41
|
+
.padStart(2, '0')}:${seconds.toString().padStart(2, '0')}.${milliseconds
|
|
42
|
+
.toString()
|
|
43
|
+
.padStart(3, '0')}`;
|
|
44
|
+
return formattedDate;
|
|
45
|
+
};
|
|
46
|
+
const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, }) => {
|
|
47
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
48
|
+
return {
|
|
49
|
+
value,
|
|
50
|
+
zodValidation: schema.safeParse(value),
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
54
|
+
const safeParse = schema.safeParse(newValue);
|
|
55
|
+
const newLocalState = {
|
|
56
|
+
value: newValue,
|
|
57
|
+
zodValidation: safeParse,
|
|
58
|
+
};
|
|
59
|
+
setLocalValue(newLocalState);
|
|
60
|
+
if (safeParse.success) {
|
|
61
|
+
setValue(newValue);
|
|
62
|
+
}
|
|
63
|
+
}, [schema, setValue]);
|
|
64
|
+
const onChange = (0, react_1.useCallback)((e) => {
|
|
65
|
+
// React does not support e.target.valueAsDate :(
|
|
66
|
+
onValueChange(new Date(e.target.value));
|
|
67
|
+
}, [onValueChange]);
|
|
68
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
69
|
+
onValueChange(defaultValue);
|
|
70
|
+
}, [defaultValue, onValueChange]);
|
|
71
|
+
const save = (0, react_1.useCallback)(() => {
|
|
72
|
+
onSave(() => value);
|
|
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, saving: saving }), (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
|
+
};
|
|
76
|
+
exports.ZodDateEditor = ZodDateEditor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodEffectEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: unknown;
|
|
8
|
+
setValue: (value: unknown) => void;
|
|
9
|
+
compact: boolean;
|
|
10
|
+
defaultValue: unknown;
|
|
11
|
+
onSave: (updater: (oldState: unknown) => unknown) => void;
|
|
12
|
+
showSaveButton: boolean;
|
|
13
|
+
onRemove: null | (() => void);
|
|
14
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodEffectEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const colors_1 = require("../../../helpers/colors");
|
|
7
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
9
|
+
const ZodSwitch_1 = require("./ZodSwitch");
|
|
10
|
+
const fullWidth = {
|
|
11
|
+
width: '100%',
|
|
12
|
+
};
|
|
13
|
+
const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compact, defaultValue, onSave, onRemove, showSaveButton, saving, }) => {
|
|
14
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
15
|
+
if (!z) {
|
|
16
|
+
throw new Error('expected zod');
|
|
17
|
+
}
|
|
18
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
19
|
+
return {
|
|
20
|
+
value,
|
|
21
|
+
zodValidation: schema.safeParse(value),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
const def = schema._def;
|
|
25
|
+
const typeName = def.typeName;
|
|
26
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
27
|
+
throw new Error('expected effect');
|
|
28
|
+
}
|
|
29
|
+
const onChange = (0, react_1.useCallback)((newValue) => {
|
|
30
|
+
setLocalValue(() => {
|
|
31
|
+
const safeParse = schema.safeParse(newValue);
|
|
32
|
+
if (safeParse.success) {
|
|
33
|
+
updateValue(() => newValue);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
value: newValue,
|
|
37
|
+
zodValidation: safeParse,
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
}, [schema, updateValue]);
|
|
41
|
+
const container = (0, react_1.useMemo)(() => {
|
|
42
|
+
if (!localValue.zodValidation.success) {
|
|
43
|
+
return {
|
|
44
|
+
border: `1px solid ${colors_1.FAIL_COLOR}`,
|
|
45
|
+
borderRadius: 4,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
border: 'none',
|
|
50
|
+
padding: 0,
|
|
51
|
+
};
|
|
52
|
+
}, [localValue.zodValidation.success]);
|
|
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, saving: saving }) }), !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" }) }))] }));
|
|
54
|
+
};
|
|
55
|
+
exports.ZodEffectEditor = ZodEffectEditor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodEnumEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: string;
|
|
8
|
+
defaultValue: string;
|
|
9
|
+
setValue: React.Dispatch<React.SetStateAction<string>>;
|
|
10
|
+
onSave: (updater: (oldState: string) => string) => void;
|
|
11
|
+
compact: boolean;
|
|
12
|
+
showSaveButton: boolean;
|
|
13
|
+
onRemove: null | (() => void);
|
|
14
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodEnumEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Checkmark_1 = require("../../../icons/Checkmark");
|
|
7
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
|
+
const layout_1 = require("../../layout");
|
|
9
|
+
const ComboBox_1 = require("../../NewComposition/ComboBox");
|
|
10
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
11
|
+
const layout_2 = require("../layout");
|
|
12
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
13
|
+
const container = {
|
|
14
|
+
width: '100%',
|
|
15
|
+
};
|
|
16
|
+
const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, }) => {
|
|
17
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
18
|
+
if (!z) {
|
|
19
|
+
throw new Error('expected zod');
|
|
20
|
+
}
|
|
21
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
22
|
+
return {
|
|
23
|
+
value,
|
|
24
|
+
zodValidation: schema.safeParse(value),
|
|
25
|
+
revision: 0,
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
const def = schema._def;
|
|
29
|
+
const typeName = def.typeName;
|
|
30
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodEnum) {
|
|
31
|
+
throw new Error('expected enum');
|
|
32
|
+
}
|
|
33
|
+
const isRoot = jsonPath.length === 0;
|
|
34
|
+
const onChange = (0, react_1.useCallback)((updater) => {
|
|
35
|
+
setLocalValue((oldLocalState) => {
|
|
36
|
+
const newValue = updater(oldLocalState.value);
|
|
37
|
+
const safeParse = schema.safeParse(newValue);
|
|
38
|
+
if (safeParse.success) {
|
|
39
|
+
updateValue(updater);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
value: newValue,
|
|
43
|
+
zodValidation: safeParse,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}, [schema, updateValue]);
|
|
47
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
48
|
+
onChange(() => defaultValue);
|
|
49
|
+
}, [defaultValue, onChange]);
|
|
50
|
+
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
51
|
+
return def.values.map((option) => {
|
|
52
|
+
return {
|
|
53
|
+
value: option,
|
|
54
|
+
label: option,
|
|
55
|
+
id: option,
|
|
56
|
+
keyHint: null,
|
|
57
|
+
leftItem: option === value ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
|
|
58
|
+
onClick: (id) => {
|
|
59
|
+
onChange(() => id);
|
|
60
|
+
},
|
|
61
|
+
quickSwitcherLabel: null,
|
|
62
|
+
subMenu: null,
|
|
63
|
+
type: 'item',
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}, [def.values, onChange, value]);
|
|
67
|
+
const save = (0, react_1.useCallback)(() => {
|
|
68
|
+
onSave(() => value);
|
|
69
|
+
}, [onSave, value]);
|
|
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, saving: saving }), (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" })] }))] }));
|
|
71
|
+
};
|
|
72
|
+
exports.ZodEnumEditor = ZodEnumEditor;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodErrorMessages = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const colors_1 = require("../../../helpers/colors");
|
|
6
|
+
const label = {
|
|
7
|
+
fontSize: 14,
|
|
8
|
+
color: colors_1.LIGHT_TEXT,
|
|
9
|
+
fontFamily: 'sans-serif',
|
|
10
|
+
};
|
|
11
|
+
const code = {
|
|
12
|
+
...label,
|
|
13
|
+
fontFamily: 'monospace',
|
|
14
|
+
};
|
|
15
|
+
const ZodErrorMessages = ({ zodValidationResult }) => {
|
|
16
|
+
if (zodValidationResult.success) {
|
|
17
|
+
throw new Error('Expected error');
|
|
18
|
+
}
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: zodValidationResult.error.errors.map((error) => {
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: label, children: ["-", ' ', (0, jsx_runtime_1.jsx)("code", { style: code, children: error.path.length === 0 ? 'Root' : error.path.join('.') }), ": ", error.message] }, error.path.join('.')));
|
|
21
|
+
}) }));
|
|
22
|
+
};
|
|
23
|
+
exports.ZodErrorMessages = ZodErrorMessages;
|