@remotion/cli 3.3.88 → 3.3.90
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,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZonNonEditableValue = 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 SchemaLabel_1 = require("./SchemaLabel");
|
|
9
|
+
const fullWidth = {
|
|
10
|
+
width: '100%',
|
|
11
|
+
};
|
|
12
|
+
const emptyLabel = {
|
|
13
|
+
width: '100%',
|
|
14
|
+
color: colors_1.VERY_LIGHT_TEXT,
|
|
15
|
+
fontFamily: 'sans-serif',
|
|
16
|
+
fontSize: 14,
|
|
17
|
+
};
|
|
18
|
+
const wideEmptyLabel = {
|
|
19
|
+
...emptyLabel,
|
|
20
|
+
lineHeight: '37px',
|
|
21
|
+
};
|
|
22
|
+
const ZonNonEditableValue = ({ jsonPath, label, compact, showSaveButton, saving }) => {
|
|
23
|
+
const save = (0, react_1.useCallback)(() => undefined, []);
|
|
24
|
+
const reset = (0, react_1.useCallback)(() => undefined, []);
|
|
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: true, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: null, saving: saving }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)("em", { style: compact ? emptyLabel : wideEmptyLabel, children: label }) })] }));
|
|
26
|
+
};
|
|
27
|
+
exports.ZonNonEditableValue = ZonNonEditableValue;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -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, saving, }) => {
|
|
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, saving: saving }));
|
|
9
|
+
};
|
|
10
|
+
exports.ZodNullableEditor = ZodNullableEditor;
|
|
@@ -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 ZodNumberEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: number;
|
|
8
|
+
setValue: React.Dispatch<React.SetStateAction<number>>;
|
|
9
|
+
compact: boolean;
|
|
10
|
+
defaultValue: number;
|
|
11
|
+
onSave: (updater: (oldNum: unknown) => number) => void;
|
|
12
|
+
onRemove: null | (() => void);
|
|
13
|
+
showSaveButton: boolean;
|
|
14
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodNumberEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const layout_1 = require("../../layout");
|
|
7
|
+
const InputDragger_1 = require("../../NewComposition/InputDragger");
|
|
8
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
9
|
+
const layout_2 = require("../layout");
|
|
10
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
11
|
+
const fullWidth = {
|
|
12
|
+
width: '100%',
|
|
13
|
+
};
|
|
14
|
+
const getMinValue = (schema) => {
|
|
15
|
+
const minCheck = schema._def.checks.find((c) => c.kind === 'min');
|
|
16
|
+
if (!minCheck) {
|
|
17
|
+
return -Infinity;
|
|
18
|
+
}
|
|
19
|
+
if (minCheck.kind !== 'min') {
|
|
20
|
+
throw new Error('Expected min check');
|
|
21
|
+
}
|
|
22
|
+
if (!minCheck.inclusive) {
|
|
23
|
+
return -Infinity;
|
|
24
|
+
}
|
|
25
|
+
return minCheck.value;
|
|
26
|
+
};
|
|
27
|
+
const getMaxValue = (schema) => {
|
|
28
|
+
const maxCheck = schema._def.checks.find((c) => c.kind === 'max');
|
|
29
|
+
if (!maxCheck) {
|
|
30
|
+
return Infinity;
|
|
31
|
+
}
|
|
32
|
+
if (maxCheck.kind !== 'max') {
|
|
33
|
+
throw new Error('Expected max check');
|
|
34
|
+
}
|
|
35
|
+
if (!maxCheck.inclusive) {
|
|
36
|
+
return Infinity;
|
|
37
|
+
}
|
|
38
|
+
return maxCheck.value;
|
|
39
|
+
};
|
|
40
|
+
const getStep = (schema) => {
|
|
41
|
+
const multipleStep = schema._def.checks.find((c) => c.kind === 'multipleOf');
|
|
42
|
+
if (!multipleStep) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
if (multipleStep.kind !== 'multipleOf') {
|
|
46
|
+
throw new Error('Expected multipleOf check');
|
|
47
|
+
}
|
|
48
|
+
return multipleStep.value;
|
|
49
|
+
};
|
|
50
|
+
const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, }) => {
|
|
51
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
52
|
+
return {
|
|
53
|
+
value: String(value),
|
|
54
|
+
zodValidation: schema.safeParse(value),
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const onChange = (0, react_1.useCallback)((newValue) => {
|
|
58
|
+
const safeParse = schema.safeParse(Number(newValue));
|
|
59
|
+
const newLocalState = {
|
|
60
|
+
value: newValue,
|
|
61
|
+
zodValidation: safeParse,
|
|
62
|
+
};
|
|
63
|
+
setLocalValue(newLocalState);
|
|
64
|
+
if (safeParse.success) {
|
|
65
|
+
setValue(Number(newValue));
|
|
66
|
+
}
|
|
67
|
+
}, [schema, setValue]);
|
|
68
|
+
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
69
|
+
const safeParse = schema.safeParse(newValue);
|
|
70
|
+
const newLocalState = {
|
|
71
|
+
value: String(newValue),
|
|
72
|
+
zodValidation: safeParse,
|
|
73
|
+
};
|
|
74
|
+
setLocalValue(newLocalState);
|
|
75
|
+
if (safeParse.success) {
|
|
76
|
+
setValue(newValue);
|
|
77
|
+
}
|
|
78
|
+
}, [schema, setValue]);
|
|
79
|
+
const isDefault = value === defaultValue;
|
|
80
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
81
|
+
onValueChange(defaultValue);
|
|
82
|
+
}, [defaultValue, onValueChange]);
|
|
83
|
+
const save = (0, react_1.useCallback)(() => {
|
|
84
|
+
onSave(() => value);
|
|
85
|
+
}, [onSave, value]);
|
|
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, saving: saving }), (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" })] }))] })] }));
|
|
87
|
+
};
|
|
88
|
+
exports.ZodNumberEditor = ZodNumberEditor;
|
|
@@ -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 ZodObjectEditor: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: unknown;
|
|
8
|
+
defaultValue: unknown;
|
|
9
|
+
setValue: React.Dispatch<React.SetStateAction<unknown>>;
|
|
10
|
+
compact: boolean;
|
|
11
|
+
onSave: (updater: (oldVal: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
12
|
+
showSaveButton: boolean;
|
|
13
|
+
onRemove: null | (() => void);
|
|
14
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodObjectEditor = 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 layout_1 = require("../layout");
|
|
9
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
10
|
+
const ZodSwitch_1 = require("./ZodSwitch");
|
|
11
|
+
const container = {
|
|
12
|
+
width: '100%',
|
|
13
|
+
};
|
|
14
|
+
const fullWidth = {
|
|
15
|
+
width: '100%',
|
|
16
|
+
};
|
|
17
|
+
const fieldset = {
|
|
18
|
+
borderRadius: 4,
|
|
19
|
+
borderColor: colors_1.INPUT_BORDER_COLOR_UNHOVERED,
|
|
20
|
+
};
|
|
21
|
+
// TODO: First validate locally
|
|
22
|
+
const ZodObjectEditor = ({ schema, jsonPath, setValue, value, compact, defaultValue, onSave, showSaveButton, onRemove, saving, }) => {
|
|
23
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
24
|
+
if (!z) {
|
|
25
|
+
throw new Error('expected zod');
|
|
26
|
+
}
|
|
27
|
+
const def = schema._def;
|
|
28
|
+
const typeName = def.typeName;
|
|
29
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodObject) {
|
|
30
|
+
throw new Error('expected object');
|
|
31
|
+
}
|
|
32
|
+
const shape = def.shape();
|
|
33
|
+
const keys = Object.keys(shape);
|
|
34
|
+
const isRoot = jsonPath.length === 0;
|
|
35
|
+
const Element = isRoot ? 'div' : 'fieldset';
|
|
36
|
+
const { paddingTop } = layout_1.optionRow;
|
|
37
|
+
const style = (0, react_1.useMemo)(() => {
|
|
38
|
+
if (isRoot) {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
return { paddingTop };
|
|
42
|
+
}, [isRoot, paddingTop]);
|
|
43
|
+
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: keys.map((key) => {
|
|
44
|
+
var _a;
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { jsonPath: [...jsonPath, key], schema: shape[key], value: value[key],
|
|
46
|
+
// In case of null | {a: string, b: string} type, we need to fallback to the default value
|
|
47
|
+
defaultValue: ((_a = defaultValue) !== null && _a !== void 0 ? _a : value)[key], setValue: (val) => {
|
|
48
|
+
setValue((oldVal) => {
|
|
49
|
+
return {
|
|
50
|
+
...oldVal,
|
|
51
|
+
[key]: typeof val === 'function' ? val(oldVal[key]) : val,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}, onSave: (val) => {
|
|
55
|
+
onSave((oldVal) => {
|
|
56
|
+
return {
|
|
57
|
+
...oldVal,
|
|
58
|
+
[key]: typeof val === 'function' ? val(oldVal[key]) : val,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}, onRemove: null, compact: compact, showSaveButton: showSaveButton, saving: saving }, key));
|
|
62
|
+
}) })] }) }) }));
|
|
63
|
+
};
|
|
64
|
+
exports.ZodObjectEditor = ZodObjectEditor;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -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, saving, }) => {
|
|
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, saving: saving }));
|
|
9
|
+
};
|
|
10
|
+
exports.ZodOptionalEditor = ZodOptionalEditor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodOrNullishEditor: 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
|
+
nullishValue: null | undefined;
|
|
15
|
+
saving: boolean;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodOrNullishEditor = 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 Checkbox_1 = require("../../Checkbox");
|
|
8
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
9
|
+
const layout_1 = require("../../layout");
|
|
10
|
+
const create_zod_values_1 = require("./create-zod-values");
|
|
11
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
12
|
+
const ZodSwitch_1 = require("./ZodSwitch");
|
|
13
|
+
const fullWidth = {
|
|
14
|
+
width: '100%',
|
|
15
|
+
};
|
|
16
|
+
const labelStyle = {
|
|
17
|
+
fontFamily: 'sans-serif',
|
|
18
|
+
fontSize: 14,
|
|
19
|
+
color: colors_1.LIGHT_TEXT,
|
|
20
|
+
};
|
|
21
|
+
const checkBoxWrapper = {
|
|
22
|
+
margin: '2px',
|
|
23
|
+
display: 'flex',
|
|
24
|
+
flexDirection: 'row',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
marginTop: '5px',
|
|
27
|
+
};
|
|
28
|
+
const ZodOrNullishEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, nullishValue, saving, }) => {
|
|
29
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
30
|
+
if (!z) {
|
|
31
|
+
throw new Error('expected zod');
|
|
32
|
+
}
|
|
33
|
+
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
34
|
+
const isChecked = value === nullishValue;
|
|
35
|
+
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
36
|
+
setValue(newValue);
|
|
37
|
+
}, [setValue]);
|
|
38
|
+
const onCheckBoxChange = (0, react_1.useCallback)((e) => {
|
|
39
|
+
const val = e.target.checked
|
|
40
|
+
? nullishValue
|
|
41
|
+
: (0, create_zod_values_1.createZodValues)(schema, z, zodTypes);
|
|
42
|
+
onValueChange(val);
|
|
43
|
+
}, [nullishValue, onValueChange, schema, z, zodTypes]);
|
|
44
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
45
|
+
onValueChange(defaultValue);
|
|
46
|
+
}, [defaultValue, onValueChange]);
|
|
47
|
+
const save = (0, react_1.useCallback)(() => {
|
|
48
|
+
onSave(() => value);
|
|
49
|
+
}, [onSave, 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, saving: saving })) : ((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, saving: saving }) })), (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) })] })] }));
|
|
51
|
+
};
|
|
52
|
+
exports.ZodOrNullishEditor = ZodOrNullishEditor;
|
|
@@ -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 ZodStringEditor: 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,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodStringEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
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 ZodStringEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, }) => {
|
|
16
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
17
|
+
if (!z) {
|
|
18
|
+
throw new Error('expected zod');
|
|
19
|
+
}
|
|
20
|
+
const [localValue, setLocalValue] = (0, react_1.useState)(() => {
|
|
21
|
+
return {
|
|
22
|
+
value,
|
|
23
|
+
zodValidation: schema.safeParse(value),
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
27
|
+
const safeParse = schema.safeParse(newValue);
|
|
28
|
+
const newLocalState = {
|
|
29
|
+
value: newValue,
|
|
30
|
+
zodValidation: safeParse,
|
|
31
|
+
};
|
|
32
|
+
setLocalValue(newLocalState);
|
|
33
|
+
if (safeParse.success) {
|
|
34
|
+
setValue(newValue);
|
|
35
|
+
}
|
|
36
|
+
}, [schema, setValue]);
|
|
37
|
+
const onChange = (0, react_1.useCallback)((e) => {
|
|
38
|
+
onValueChange(e.target.value);
|
|
39
|
+
}, [onValueChange]);
|
|
40
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
41
|
+
onValueChange(defaultValue);
|
|
42
|
+
}, [defaultValue, onValueChange]);
|
|
43
|
+
const save = (0, react_1.useCallback)(() => {
|
|
44
|
+
onSave(() => value);
|
|
45
|
+
}, [onSave, value]);
|
|
46
|
+
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.jsx)(RemInput_1.RemotionInput, { value: localValue.value, status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, 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" })] }))] })] }));
|
|
47
|
+
};
|
|
48
|
+
exports.ZodStringEditor = ZodStringEditor;
|
|
@@ -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 ZodSwitch: React.FC<{
|
|
5
|
+
schema: z.ZodTypeAny;
|
|
6
|
+
jsonPath: JSONPath;
|
|
7
|
+
value: unknown;
|
|
8
|
+
defaultValue: unknown;
|
|
9
|
+
setValue: React.Dispatch<React.SetStateAction<unknown>>;
|
|
10
|
+
onSave: (newValue: (oldVal: 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.ZodSwitch = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
6
|
+
const ZodArrayEditor_1 = require("./ZodArrayEditor");
|
|
7
|
+
const ZodBooleanEditor_1 = require("./ZodBooleanEditor");
|
|
8
|
+
const ZodColorEditor_1 = require("./ZodColorEditor");
|
|
9
|
+
const ZodDateEditor_1 = require("./ZodDateEditor");
|
|
10
|
+
const ZodEffectEditor_1 = require("./ZodEffectEditor");
|
|
11
|
+
const ZodEnumEditor_1 = require("./ZodEnumEditor");
|
|
12
|
+
const ZodNonEditableValue_1 = require("./ZodNonEditableValue");
|
|
13
|
+
const ZodNullableEditor_1 = require("./ZodNullableEditor");
|
|
14
|
+
const ZodNumberEditor_1 = require("./ZodNumberEditor");
|
|
15
|
+
const ZodObjectEditor_1 = require("./ZodObjectEditor");
|
|
16
|
+
const ZodOptionalEditor_1 = require("./ZodOptionalEditor");
|
|
17
|
+
const ZodStringEditor_1 = require("./ZodStringEditor");
|
|
18
|
+
const ZodUnionEditor_1 = require("./ZodUnionEditor");
|
|
19
|
+
const ZodSwitch = ({ schema, jsonPath, compact, value, setValue, defaultValue, onSave, showSaveButton, onRemove, saving, }) => {
|
|
20
|
+
const def = schema._def;
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
const typeName = def.typeName;
|
|
23
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
24
|
+
if (!z) {
|
|
25
|
+
throw new Error('expected zod');
|
|
26
|
+
}
|
|
27
|
+
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
28
|
+
// TODO: (Maybe?) enable saving of inserted input props by cmd+s /ctrl + s (also for JSON view)
|
|
29
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodObject) {
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(ZodObjectEditor_1.ZodObjectEditor, { setValue: setValue, value: value, defaultValue: defaultValue, jsonPath: jsonPath, schema: schema, compact: compact, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
31
|
+
}
|
|
32
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodString) {
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(ZodStringEditor_1.ZodStringEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, onSave: onSave, defaultValue: defaultValue, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
34
|
+
}
|
|
35
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodDate) {
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(ZodDateEditor_1.ZodDateEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, onSave: onSave, defaultValue: defaultValue, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
37
|
+
}
|
|
38
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodNumber) {
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(ZodNumberEditor_1.ZodNumberEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
40
|
+
}
|
|
41
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodBoolean) {
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(ZodBooleanEditor_1.ZodBooleanEditor, { value: value, setValue: setValue, jsonPath: jsonPath, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
43
|
+
}
|
|
44
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodUndefined) {
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'undefined', saving: saving }));
|
|
46
|
+
}
|
|
47
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodNull) {
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'null', saving: saving }));
|
|
49
|
+
}
|
|
50
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodAny) {
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'any (not editable)', saving: saving }));
|
|
52
|
+
}
|
|
53
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodBigInt) {
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'BigInt (not editable)', saving: saving }));
|
|
55
|
+
}
|
|
56
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodUnknown) {
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: 'unknown (not editable)', saving: saving }));
|
|
58
|
+
}
|
|
59
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodArray) {
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)(ZodArrayEditor_1.ZodArrayEditor, { setValue: setValue, value: value, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
61
|
+
}
|
|
62
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodEnum) {
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)(ZodEnumEditor_1.ZodEnumEditor, { setValue: setValue, value: value, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
64
|
+
}
|
|
65
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
66
|
+
if (zodTypes &&
|
|
67
|
+
schema._def.description ===
|
|
68
|
+
zodTypes.ZodZypesInternals.REMOTION_COLOR_BRAND) {
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)(ZodColorEditor_1.ZodColorEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, onSave: onSave, defaultValue: defaultValue, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
70
|
+
}
|
|
71
|
+
return ((0, jsx_runtime_1.jsx)(ZodEffectEditor_1.ZodEffectEditor, { value: value, setValue: setValue, jsonPath: jsonPath, schema: schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
72
|
+
}
|
|
73
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodUnion) {
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)(ZodUnionEditor_1.ZodUnionEditor, { schema: schema, showSaveButton: showSaveButton, jsonPath: jsonPath, compact: compact, value: value, defaultValue: defaultValue, setValue: setValue, onSave: onSave, onRemove: onRemove, saving: saving }));
|
|
75
|
+
}
|
|
76
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodOptional) {
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)(ZodOptionalEditor_1.ZodOptionalEditor, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, defaultValue: defaultValue, value: value, setValue: setValue, onSave: onSave, onRemove: onRemove, schema: schema, saving: saving }));
|
|
78
|
+
}
|
|
79
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodNullable) {
|
|
80
|
+
return ((0, jsx_runtime_1.jsx)(ZodNullableEditor_1.ZodNullableEditor, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, defaultValue: defaultValue, value: value, setValue: setValue, onSave: onSave, onRemove: onRemove, schema: schema, saving: saving }));
|
|
81
|
+
}
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { compact: compact, jsonPath: jsonPath, showSaveButton: showSaveButton, label: `${typeName} (not editable)`, saving: saving }));
|
|
83
|
+
};
|
|
84
|
+
exports.ZodSwitch = ZodSwitch;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
export declare const ZodUnionEditor: 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
|
+
saving: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodUnionEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
6
|
+
const ZodNonEditableValue_1 = require("./ZodNonEditableValue");
|
|
7
|
+
const ZodOrNullishEditor_1 = require("./ZodOrNullishEditor");
|
|
8
|
+
const findNull = (value, zodType) => {
|
|
9
|
+
const nullIndex = value.findIndex((v) => v._def.typeName === zodType.ZodFirstPartyTypeKind.ZodNull ||
|
|
10
|
+
v._def.typeName === zodType.ZodFirstPartyTypeKind.ZodUndefined);
|
|
11
|
+
if (nullIndex === -1) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const nullishValue = value[nullIndex]._def.typeName === zodType.ZodFirstPartyTypeKind.ZodNull
|
|
15
|
+
? null
|
|
16
|
+
: undefined;
|
|
17
|
+
const otherSchema = value[nullIndex === 0 ? 1 : 0];
|
|
18
|
+
const otherSchemaIsAlsoNullish = otherSchema._def.typeName === zodType.ZodFirstPartyTypeKind.ZodNull ||
|
|
19
|
+
otherSchema._def.typeName === zodType.ZodFirstPartyTypeKind.ZodUndefined;
|
|
20
|
+
return {
|
|
21
|
+
nullIndex,
|
|
22
|
+
nullishValue,
|
|
23
|
+
otherSchema,
|
|
24
|
+
otherSchemaIsAlsoNullish,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const ZodUnionEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, }) => {
|
|
28
|
+
const { options } = schema._def;
|
|
29
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
30
|
+
if (!z) {
|
|
31
|
+
throw new Error('expected zod');
|
|
32
|
+
}
|
|
33
|
+
if (options.length > 2) {
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Union with more than 2 options not editable', compact: compact, showSaveButton: showSaveButton, saving: saving }));
|
|
35
|
+
}
|
|
36
|
+
if (options.length < 2) {
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Union with less than 2 options not editable', compact: compact, showSaveButton: showSaveButton, saving: saving }));
|
|
38
|
+
}
|
|
39
|
+
const nullResult = findNull(options, z);
|
|
40
|
+
if (!nullResult) {
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Union only editable with 1 value being null', compact: compact, showSaveButton: showSaveButton, saving: saving }));
|
|
42
|
+
}
|
|
43
|
+
const { otherSchema, nullishValue, otherSchemaIsAlsoNullish } = nullResult;
|
|
44
|
+
if (otherSchemaIsAlsoNullish) {
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, label: 'Not editable - both union values are nullish', compact: compact, showSaveButton: showSaveButton, saving: saving }));
|
|
46
|
+
}
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: otherSchema, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: nullishValue, saving: saving }));
|
|
48
|
+
};
|
|
49
|
+
exports.ZodUnionEditor = ZodUnionEditor;
|