@remotion/cli 4.0.0-alpha.217 → 4.0.0-alpha10
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/benchmark.js +11 -6
- package/dist/better-opn/index.js +3 -3
- package/dist/chalk/index.d.ts +45 -54
- package/dist/chalk/index.js +2 -135
- package/dist/codemods/stringify-with-path.d.ts +5 -0
- package/dist/codemods/stringify-with-path.js +44 -0
- package/dist/codemods/update-default-props.d.ts +4 -2
- package/dist/codemods/update-default-props.js +3 -18
- package/dist/color-math.d.ts +2 -2
- package/dist/color-math.js +5 -3
- package/dist/compositions.js +1 -0
- package/dist/config/image-format.d.ts +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/log.d.ts +1 -3
- package/dist/config/log.js +2 -9
- package/dist/convert-entry-point-to-serve-url.js +2 -2
- package/dist/download-progress.d.ts +1 -1
- package/dist/download-progress.js +1 -4
- package/dist/editor/components/CanvasOrLoading.d.ts +5 -0
- package/dist/editor/components/CanvasOrLoading.js +66 -0
- package/dist/editor/components/CheckboardToggle.js +2 -1
- package/dist/editor/components/CompositionSelectorItem.js +2 -2
- package/dist/editor/components/CurrentCompositionSideEffects.js +3 -3
- package/dist/editor/components/InitialCompositionLoader.js +1 -1
- package/dist/editor/components/InlineAction.d.ts +6 -4
- package/dist/editor/components/InlineAction.js +7 -8
- package/dist/editor/components/LoopToggle.js +2 -1
- package/dist/editor/components/Menu/MenuItem.js +1 -1
- package/dist/editor/components/Menu/SubMenu.js +1 -1
- package/dist/editor/components/Menu/styles.d.ts +1 -0
- package/dist/editor/components/Menu/styles.js +6 -1
- package/dist/editor/components/MenuBuildIndicator.js +20 -1
- package/dist/editor/components/MenuToolbar.js +15 -3
- package/dist/editor/components/Modals.js +2 -2
- package/dist/editor/components/NewComposition/ComboBox.js +20 -5
- package/dist/editor/components/NewComposition/InputDragger.js +3 -2
- package/dist/editor/components/NewComposition/MenuContent.d.ts +1 -0
- package/dist/editor/components/NewComposition/MenuContent.js +12 -4
- package/dist/editor/components/Notifications/ServerDisconnected.js +2 -2
- package/dist/editor/components/OpenEditorButton.d.ts +2 -0
- package/dist/editor/components/OpenEditorButton.js +52 -0
- package/dist/editor/components/PlayPause.js +4 -2
- package/dist/editor/components/PreviewToolbar.js +2 -2
- package/dist/editor/components/QuickSwitcher/algolia-search.js +1 -1
- package/dist/editor/components/RenderButton.d.ts +1 -5
- package/dist/editor/components/RenderButton.js +48 -21
- package/dist/editor/components/RenderModal/CliCopyButton.js +51 -14
- package/dist/editor/components/RenderModal/CrfSetting.d.ts +0 -1
- package/dist/editor/components/RenderModal/CrfSetting.js +0 -1
- package/dist/editor/components/RenderModal/DataEditor.d.ts +21 -0
- package/dist/editor/components/RenderModal/DataEditor.js +287 -0
- package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.js +3 -2
- package/dist/editor/components/RenderModal/InfoBubble.js +2 -1
- package/dist/editor/components/RenderModal/InfoTooltip.d.ts +1 -0
- package/dist/editor/components/RenderModal/InfoTooltip.js +6 -5
- package/dist/editor/components/RenderModal/InlineEyeIcon.js +6 -3
- package/dist/editor/components/RenderModal/InlineRemoveButton.js +6 -1
- package/dist/editor/components/RenderModal/MutedSetting.js +3 -2
- package/dist/editor/components/RenderModal/OptionExplainer.js +14 -3
- package/dist/editor/components/RenderModal/RenderModal.d.ts +7 -3
- package/dist/editor/components/RenderModal/RenderModal.js +108 -49
- package/dist/editor/components/RenderModal/RenderModalAdvanced.js +0 -2
- package/dist/editor/components/RenderModal/RenderModalAudio.js +1 -1
- package/dist/editor/components/RenderModal/RenderModalBasic.d.ts +3 -2
- package/dist/editor/components/RenderModal/RenderModalBasic.js +4 -3
- package/dist/editor/components/RenderModal/RenderModalData.d.ts +16 -4
- package/dist/editor/components/RenderModal/RenderModalData.js +109 -42
- package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +14 -0
- package/dist/editor/components/RenderModal/{RenderModalJSONInputPropsEditor.js → RenderModalJSONPropsEditor.js} +51 -30
- package/dist/editor/components/RenderModal/RenderModalPicture.d.ts +2 -2
- package/dist/editor/components/RenderModal/RenderModalPicture.js +2 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +6 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +4 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +4 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +15 -6
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +5 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.js +5 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaResetButton.js +6 -1
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.js +7 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +19 -29
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +4 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +7 -7
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +23 -66
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +13 -21
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +17 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +10 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +4 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +20 -19
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +4 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +12 -26
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +16 -32
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +7 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +18 -11
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +44 -11
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +17 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +59 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +12 -23
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +32 -21
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +5 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.js +6 -6
- package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.d.ts +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/create-zod-values.js +22 -22
- package/dist/editor/components/RenderModal/SchemaEditor/deep-equal.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/deep-equal.js +27 -0
- package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.d.ts +3 -0
- package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.js +126 -0
- package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.d.ts +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.js +42 -0
- package/dist/editor/components/RenderModal/SchemaEditor/local-state.d.ts +16 -0
- package/dist/editor/components/RenderModal/SchemaEditor/local-state.js +38 -0
- package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +9 -1
- package/dist/editor/components/RenderModal/get-render-modal-warnings.js +42 -8
- package/dist/editor/components/RenderModal/human-readable-codec.d.ts +1 -1
- package/dist/editor/components/RenderModal/layout.js +3 -0
- package/dist/editor/components/RenderModal/out-name-checker.js +1 -11
- package/dist/editor/components/RenderQueue/RenderQueueItemCancelButton.js +5 -1
- package/dist/editor/components/RenderQueue/RenderQueueOpenInFolder.js +5 -1
- package/dist/editor/components/RenderQueue/RenderQueueRemoveItem.js +5 -1
- package/dist/editor/components/RenderQueue/RenderQueueRepeat.js +5 -1
- package/dist/editor/components/RenderQueue/actions.d.ts +4 -3
- package/dist/editor/components/RenderQueue/actions.js +8 -3
- package/dist/editor/components/RenderQueue/index.js +9 -2
- package/dist/editor/components/RightPanel.js +8 -5
- package/dist/editor/components/SidebarCollapserControls.js +22 -9
- package/dist/editor/components/SidebarRenderButton.d.ts +6 -0
- package/dist/editor/components/{RenderToolbarIcon.js → SidebarRenderButton.js} +27 -41
- package/dist/editor/components/Spinner.d.ts +5 -0
- package/dist/editor/components/Spinner.js +41 -0
- package/dist/editor/components/Tabs/index.js +12 -14
- package/dist/editor/components/Timeline/Timeline.js +3 -1
- package/dist/editor/components/Timeline/TimelinePlayCursorSyncer.js +4 -3
- package/dist/editor/components/Timeline/TimelineSequence.js +8 -6
- package/dist/editor/components/TimelineInOutToggle.js +2 -4
- package/dist/editor/components/TopPanel.js +2 -2
- package/dist/editor/components/UpdateCheck.js +2 -1
- package/dist/editor/components/get-zod-if-possible.d.ts +3 -3
- package/dist/editor/components/get-zod-if-possible.js +11 -11
- package/dist/editor/helpers/calculate-timeline.js +1 -1
- package/dist/editor/helpers/client-id.d.ts +2 -2
- package/dist/editor/helpers/client-id.js +5 -5
- package/dist/editor/helpers/colors.d.ts +4 -2
- package/dist/editor/helpers/colors.js +4 -2
- package/dist/editor/helpers/get-timeline-sequence-layout.d.ts +2 -2
- package/dist/editor/helpers/is-composition-still.d.ts +3 -2
- package/dist/editor/helpers/is-current-selected-still.js +3 -4
- package/dist/editor/helpers/use-file-existence.js +1 -1
- package/dist/editor/helpers/use-menu-structure.js +1 -1
- package/dist/editor/icons/media-volume.js +2 -1
- package/dist/editor/icons/render.d.ts +1 -0
- package/dist/editor/icons/render.js +1 -1
- package/dist/editor/state/modals.d.ts +3 -1
- package/dist/entry-point.js +17 -17
- package/dist/event-source-events.d.ts +2 -0
- package/dist/event-source.js +2 -2
- package/dist/ffmpeg.js +14 -5
- package/dist/file-watcher.js +5 -5
- package/dist/get-cli-options.d.ts +3 -3
- package/dist/get-cli-options.js +4 -4
- package/dist/get-composition-id.d.ts +14 -2
- package/dist/get-composition-id.js +32 -8
- package/dist/get-composition-with-dimension-override.d.ts +13 -2
- package/dist/get-composition-with-dimension-override.js +12 -2
- package/dist/get-config-file-name.js +6 -6
- package/dist/get-env.js +10 -10
- package/dist/get-filename.js +1 -0
- package/dist/get-input-props.d.ts +1 -1
- package/dist/get-input-props.js +9 -9
- package/dist/get-network-address.js +2 -2
- package/dist/handle-common-errors.d.ts +2 -1
- package/dist/handle-common-errors.js +2 -2
- package/dist/index.d.ts +41 -19
- package/dist/index.js +9 -6
- package/dist/list-of-remotion-packages.js +2 -1
- package/dist/load-config.js +8 -8
- package/dist/log.d.ts +5 -5
- package/dist/log.js +3 -42
- package/dist/parse-command-line.d.ts +1 -0
- package/dist/preview-server/api-types.d.ts +3 -3
- package/dist/preview-server/dev-middleware/compatible-api.d.ts +2 -2
- package/dist/preview-server/dev-middleware/middleware.d.ts +1 -1
- package/dist/preview-server/dev-middleware/middleware.js +7 -7
- package/dist/preview-server/dev-middleware/range-parser.d.ts +1 -1
- package/dist/preview-server/dev-middleware/setup-hooks.js +2 -2
- package/dist/preview-server/error-overlay/react-overlay/utils/get-file-source.js +5 -5
- package/dist/preview-server/error-overlay/react-overlay/utils/open-in-editor.js +17 -17
- package/dist/preview-server/error-overlay/remotion-overlay/CalculateMetadataErrorExplainer.d.ts +2 -0
- package/dist/preview-server/error-overlay/remotion-overlay/CalculateMetadataErrorExplainer.js +18 -0
- package/dist/preview-server/error-overlay/remotion-overlay/CodeFrame.js +30 -12
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorDisplay.d.ts +4 -0
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorDisplay.js +5 -2
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorLoader.d.ts +4 -0
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorLoader.js +5 -5
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorTitle.d.ts +1 -0
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorTitle.js +4 -3
- package/dist/preview-server/error-overlay/remotion-overlay/HelpLink.js +2 -1
- package/dist/preview-server/error-overlay/remotion-overlay/Overlay.js +1 -1
- package/dist/preview-server/error-overlay/remotion-overlay/Retry.d.ts +4 -0
- package/dist/preview-server/error-overlay/remotion-overlay/Retry.js +9 -0
- package/dist/preview-server/file-existence-watchers.js +3 -3
- package/dist/preview-server/get-absolute-public-dir.js +3 -3
- package/dist/preview-server/get-package-manager.js +3 -3
- package/dist/preview-server/handler.d.ts +1 -1
- package/dist/preview-server/hot-middleware/index.d.ts +1 -1
- package/dist/preview-server/hot-middleware/index.js +2 -2
- package/dist/preview-server/live-events.d.ts +1 -1
- package/dist/preview-server/parse-body.d.ts +1 -1
- package/dist/preview-server/project-info.js +5 -5
- package/dist/preview-server/public-folder.js +8 -8
- package/dist/preview-server/render-queue/job.d.ts +11 -2
- package/dist/preview-server/render-queue/make-retry-payload.js +5 -1
- package/dist/preview-server/render-queue/open-directory-in-finder.js +8 -8
- package/dist/preview-server/render-queue/process-still.js +1 -0
- package/dist/preview-server/render-queue/queue.js +4 -4
- package/dist/preview-server/routes/can-update-default-props.js +3 -2
- package/dist/preview-server/routes/update-default-props.d.ts +2 -2
- package/dist/preview-server/routes/update-default-props.js +26 -15
- package/dist/preview-server/routes.d.ts +3 -2
- package/dist/preview-server/routes.js +10 -10
- package/dist/preview-server/serve-static.d.ts +1 -1
- package/dist/preview-server/serve-static.js +7 -7
- package/dist/preview-server/start-server.js +3 -3
- package/dist/preview.js +6 -4
- package/dist/print-error.d.ts +2 -1
- package/dist/print-error.js +8 -5
- package/dist/print-help.js +1 -1
- package/dist/progress-bar.d.ts +5 -4
- package/dist/progress-bar.js +42 -29
- package/dist/render-flows/render.d.ts +1 -1
- package/dist/render-flows/render.js +62 -35
- package/dist/render-flows/still.d.ts +3 -2
- package/dist/render-flows/still.js +34 -28
- package/dist/resolve-from.js +5 -5
- package/dist/setup-cache.d.ts +2 -1
- package/dist/setup-cache.js +10 -6
- package/dist/should-use-non-overlaying-logger.d.ts +4 -0
- package/dist/should-use-non-overlaying-logger.js +12 -0
- package/dist/show-compositions-picker.d.ts +8 -0
- package/dist/show-compositions-picker.js +51 -0
- package/dist/still.js +1 -0
- package/dist/studio.d.ts +1 -0
- package/dist/studio.js +140 -0
- package/dist/upgrade.js +2 -2
- package/dist/user-passed-output-location.d.ts +3 -2
- package/dist/user-passed-output-location.js +10 -5
- package/dist/versions.js +2 -2
- package/dist/watch-root-file.d.ts +1 -0
- package/dist/watch-root-file.js +22 -0
- package/package.json +89 -88
- package/styles/styles.css +4 -5
- package/dist/editor/components/CollapsableOptions.d.ts +0 -6
- package/dist/editor/components/CollapsableOptions.js +0 -35
- package/dist/editor/components/RenderModal/RenderModalJSONInputPropsEditor.d.ts +0 -10
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.d.ts +0 -2
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.js +0 -21
- package/dist/editor/components/RenderToolbarIcon.d.ts +0 -2
- package/dist/editor/icons/RenderStillIcon.d.ts +0 -3
- package/dist/editor/icons/RenderStillIcon.js +0 -8
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SchemaSaveButton = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const InlineAction_1 = require("../../InlineAction");
|
|
6
7
|
const icon = {
|
|
7
8
|
height: 14,
|
|
9
|
+
color: 'currentColor',
|
|
8
10
|
};
|
|
9
|
-
const SchemaSaveButton = ({ onClick }) => {
|
|
10
|
-
|
|
11
|
+
const SchemaSaveButton = ({ onClick, disabled }) => {
|
|
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: disabled ? '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
|
+
}, [disabled]);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(InlineAction_1.InlineAction, { renderAction: renderAction, onClick: onClick, disabled: disabled }));
|
|
11
16
|
};
|
|
12
17
|
exports.SchemaSaveButton = SchemaSaveButton;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodArrayEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: unknown[];
|
|
8
9
|
defaultValue: unknown[];
|
|
9
|
-
setValue:
|
|
10
|
-
onSave:
|
|
10
|
+
setValue: UpdaterFunction<unknown[]>;
|
|
11
|
+
onSave: UpdaterFunction<unknown[]>;
|
|
11
12
|
compact: boolean;
|
|
12
13
|
showSaveButton: boolean;
|
|
13
14
|
onRemove: null | (() => void);
|
|
15
|
+
saving: boolean;
|
|
16
|
+
saveDisabledByParent: boolean;
|
|
14
17
|
}>;
|
|
@@ -10,6 +10,8 @@ const layout_1 = require("../../layout");
|
|
|
10
10
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
11
11
|
const layout_2 = require("../layout");
|
|
12
12
|
const create_zod_values_1 = require("./create-zod-values");
|
|
13
|
+
const deep_equal_1 = require("./deep-equal");
|
|
14
|
+
const local_state_1 = require("./local-state");
|
|
13
15
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
14
16
|
const ZodArrayItemEditor_1 = require("./ZodArrayItemEditor");
|
|
15
17
|
const container = {
|
|
@@ -18,21 +20,18 @@ const container = {
|
|
|
18
20
|
const fullWidth = {
|
|
19
21
|
width: '100%',
|
|
20
22
|
};
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
zodValidation: schema.safeParse(value),
|
|
27
|
-
revision: 0,
|
|
28
|
-
};
|
|
23
|
+
const ZodArrayEditor = ({ schema, jsonPath, compact, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
|
|
24
|
+
const { localValue, onChange } = (0, local_state_1.useLocalState)({
|
|
25
|
+
value,
|
|
26
|
+
schema,
|
|
27
|
+
setValue,
|
|
29
28
|
});
|
|
30
29
|
const def = schema._def;
|
|
31
30
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
32
31
|
if (!z) {
|
|
33
32
|
throw new Error('expected zod');
|
|
34
33
|
}
|
|
35
|
-
const
|
|
34
|
+
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
36
35
|
const typeName = def.typeName;
|
|
37
36
|
if (typeName !== z.ZodFirstPartyTypeKind.ZodArray) {
|
|
38
37
|
throw new Error('expected object');
|
|
@@ -48,21 +47,6 @@ const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defa
|
|
|
48
47
|
: colors_1.FAIL_COLOR,
|
|
49
48
|
};
|
|
50
49
|
}, [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
50
|
const style = (0, react_1.useMemo)(() => {
|
|
67
51
|
if (isRoot) {
|
|
68
52
|
return undefined;
|
|
@@ -71,14 +55,20 @@ const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defa
|
|
|
71
55
|
}, [isRoot, paddingTop]);
|
|
72
56
|
const onAdd = (0, react_1.useCallback)(() => {
|
|
73
57
|
onChange((oldV) => {
|
|
74
|
-
return [...oldV, (0, create_zod_values_1.createZodValues)(def.type, z,
|
|
75
|
-
},
|
|
76
|
-
}, [def.type, onChange, z]);
|
|
77
|
-
|
|
58
|
+
return [...oldV, (0, create_zod_values_1.createZodValues)(def.type, z, zodTypes)];
|
|
59
|
+
}, false);
|
|
60
|
+
}, [def.type, onChange, z, zodTypes]);
|
|
61
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
62
|
+
onChange(() => defaultValue, true);
|
|
63
|
+
}, [defaultValue, onChange]);
|
|
64
|
+
const isDefaultValue = (0, react_1.useMemo)(() => {
|
|
65
|
+
return (0, deep_equal_1.deepEqual)(localValue.value, defaultValue);
|
|
66
|
+
}, [defaultValue, localValue]);
|
|
67
|
+
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, { onReset: reset, isDefaultValue: isDefaultValue, jsonPath: jsonPath, onRemove: onRemove })), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: localValue.value.map((child, i) => {
|
|
78
68
|
var _a;
|
|
79
69
|
return ((0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor
|
|
80
70
|
// 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 }, `${i}${localValue.revision}`));
|
|
71
|
+
, { 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, saveDisabledByParent: saveDisabledByParent }, `${i}${localValue.revision}`));
|
|
82
72
|
}) }), !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
73
|
};
|
|
84
74
|
exports.ZodArrayEditor = ZodArrayEditor;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { JSONPath } from './zod-types';
|
|
3
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
3
4
|
export declare const ZodArrayItemEditor: React.FC<{
|
|
4
5
|
jsonPath: JSONPath;
|
|
5
|
-
onChange:
|
|
6
|
+
onChange: UpdaterFunction<unknown[]>;
|
|
6
7
|
def: any;
|
|
7
8
|
index: number;
|
|
8
9
|
value: unknown;
|
|
9
10
|
compact: boolean;
|
|
10
11
|
defaultValue: unknown;
|
|
11
|
-
onSave:
|
|
12
|
+
onSave: UpdaterFunction<unknown[]>;
|
|
12
13
|
showSaveButton: boolean;
|
|
14
|
+
saving: boolean;
|
|
15
|
+
saveDisabledByParent: boolean;
|
|
13
16
|
}>;
|
|
@@ -4,9 +4,9 @@ exports.ZodArrayItemEditor = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
7
|
-
const ZodArrayItemEditor = ({ def, onChange, jsonPath, index, value, compact, defaultValue, onSave: onSaveObject, showSaveButton, }) => {
|
|
7
|
+
const ZodArrayItemEditor = ({ def, onChange, jsonPath, index, value, compact, defaultValue, onSave: onSaveObject, showSaveButton, saving, saveDisabledByParent, }) => {
|
|
8
8
|
const onRemove = (0, react_1.useCallback)(() => {
|
|
9
|
-
onChange((oldV) => [...oldV.slice(0, index), ...oldV.slice(index + 1)],
|
|
9
|
+
onChange((oldV) => [...oldV.slice(0, index), ...oldV.slice(index + 1)], false);
|
|
10
10
|
}, [index, onChange]);
|
|
11
11
|
const setValue = (0, react_1.useCallback)((val) => {
|
|
12
12
|
onChange((oldV) => [
|
|
@@ -21,8 +21,8 @@ const ZodArrayItemEditor = ({ def, onChange, jsonPath, index, value, compact, de
|
|
|
21
21
|
...oldV.slice(0, index),
|
|
22
22
|
updater(oldV[index]),
|
|
23
23
|
...oldV.slice(index + 1),
|
|
24
|
-
]);
|
|
24
|
+
], false);
|
|
25
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 }));
|
|
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, saveDisabledByParent: saveDisabledByParent }));
|
|
27
27
|
};
|
|
28
28
|
exports.ZodArrayItemEditor = ZodArrayItemEditor;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { JSONPath } from './zod-types';
|
|
3
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
3
4
|
export declare const ZodBooleanEditor: React.FC<{
|
|
4
5
|
jsonPath: JSONPath;
|
|
5
6
|
value: boolean;
|
|
6
|
-
setValue:
|
|
7
|
+
setValue: UpdaterFunction<boolean>;
|
|
7
8
|
compact: boolean;
|
|
8
9
|
defaultValue: boolean;
|
|
9
|
-
onSave:
|
|
10
|
+
onSave: UpdaterFunction<boolean>;
|
|
10
11
|
onRemove: null | (() => void);
|
|
11
12
|
showSaveButton: boolean;
|
|
13
|
+
saving: boolean;
|
|
14
|
+
saveDisabledByParent: boolean;
|
|
12
15
|
}>;
|
|
@@ -9,19 +9,19 @@ const SchemaLabel_1 = require("./SchemaLabel");
|
|
|
9
9
|
const fullWidth = {
|
|
10
10
|
width: '100%',
|
|
11
11
|
};
|
|
12
|
-
const ZodBooleanEditor = ({ jsonPath, value, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, }) => {
|
|
13
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
14
|
-
setValue(newValue);
|
|
12
|
+
const ZodBooleanEditor = ({ jsonPath, value, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, saveDisabledByParent, }) => {
|
|
13
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
14
|
+
setValue(() => newValue, forceApply);
|
|
15
15
|
}, [setValue]);
|
|
16
16
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
17
|
-
onValueChange(e.target.checked);
|
|
17
|
+
onValueChange(e.target.checked, false);
|
|
18
18
|
}, [onValueChange]);
|
|
19
19
|
const reset = (0, react_1.useCallback)(() => {
|
|
20
|
-
onValueChange(defaultValue);
|
|
20
|
+
onValueChange(defaultValue, true);
|
|
21
21
|
}, [defaultValue, onValueChange]);
|
|
22
22
|
const save = (0, react_1.useCallback)(() => {
|
|
23
|
-
onSave(() => value);
|
|
23
|
+
onSave(() => value, false);
|
|
24
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 }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: value, onChange: onChange, disabled: false }) })] }));
|
|
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, valid: true, saveDisabledByParent: saveDisabledByParent }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: value, onChange: onChange, disabled: false }) })] }));
|
|
26
26
|
};
|
|
27
27
|
exports.ZodBooleanEditor = ZodBooleanEditor;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodColorEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: string;
|
|
8
9
|
defaultValue: string;
|
|
9
|
-
setValue:
|
|
10
|
-
onSave:
|
|
10
|
+
setValue: UpdaterFunction<string>;
|
|
11
|
+
onSave: UpdaterFunction<string>;
|
|
11
12
|
onRemove: null | (() => void);
|
|
12
13
|
compact: boolean;
|
|
13
14
|
showSaveButton: boolean;
|
|
15
|
+
saving: boolean;
|
|
16
|
+
saveDisabledByParent: boolean;
|
|
14
17
|
}>;
|
|
@@ -11,68 +11,41 @@ const RemInput_1 = require("../../NewComposition/RemInput");
|
|
|
11
11
|
const RemInputTypeColor_1 = require("../../NewComposition/RemInputTypeColor");
|
|
12
12
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
13
13
|
const layout_2 = require("../layout");
|
|
14
|
+
const local_state_1 = require("./local-state");
|
|
14
15
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
15
16
|
const fullWidth = {
|
|
16
17
|
width: '100%',
|
|
17
18
|
};
|
|
18
|
-
const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, }) => {
|
|
19
|
+
const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, saveDisabledByParent, }) => {
|
|
19
20
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
20
21
|
if (!z) {
|
|
21
22
|
throw new Error('expected zod');
|
|
22
23
|
}
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
24
|
+
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
25
|
+
if (!zodTypes) {
|
|
25
26
|
throw new Error('expected zod color');
|
|
26
27
|
}
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
28
|
+
const { localValue, onChange: onValueChange } = (0, local_state_1.useLocalState)({
|
|
29
|
+
schema,
|
|
30
|
+
setValue,
|
|
31
|
+
value,
|
|
32
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
33
|
const { a, b, g, r } = localValue.zodValidation.success
|
|
45
|
-
?
|
|
34
|
+
? zodTypes.ZodZypesInternals.parseColor(localValue.value)
|
|
46
35
|
: { a: 1, b: 0, g: 0, r: 0 };
|
|
47
36
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
48
|
-
const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
value: newColor,
|
|
52
|
-
zodValidation: safeParse,
|
|
53
|
-
};
|
|
54
|
-
setLocalValue(newLocalState);
|
|
55
|
-
if (safeParse.success) {
|
|
56
|
-
setValue(newColor);
|
|
57
|
-
}
|
|
58
|
-
}, [a, schema, setValue, zodColor]);
|
|
37
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a), zodTypes);
|
|
38
|
+
onValueChange(() => newColor, false);
|
|
39
|
+
}, [a, onValueChange, zodTypes]);
|
|
59
40
|
const onTextChange = (0, react_1.useCallback)((e) => {
|
|
60
41
|
const newValue = e.target.value;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
value: newValue,
|
|
64
|
-
zodValidation: safeParse,
|
|
65
|
-
};
|
|
66
|
-
setLocalValue(newLocalState);
|
|
67
|
-
if (safeParse.success) {
|
|
68
|
-
setValue(newValue);
|
|
69
|
-
}
|
|
70
|
-
}, [schema, setValue]);
|
|
42
|
+
onValueChange(() => newValue, false);
|
|
43
|
+
}, [onValueChange]);
|
|
71
44
|
const reset = (0, react_1.useCallback)(() => {
|
|
72
|
-
onValueChange(defaultValue);
|
|
45
|
+
onValueChange(() => defaultValue, true);
|
|
73
46
|
}, [defaultValue, onValueChange]);
|
|
74
47
|
const save = (0, react_1.useCallback)(() => {
|
|
75
|
-
onSave(() => value);
|
|
48
|
+
onSave(() => value, false);
|
|
76
49
|
}, [onSave, value]);
|
|
77
50
|
const rgb = `#${r.toString(16).padStart(2, '0')}${g
|
|
78
51
|
.toString(16)
|
|
@@ -86,30 +59,14 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
86
59
|
};
|
|
87
60
|
}, []);
|
|
88
61
|
const onOpacityChange = (0, react_1.useCallback)((newValue) => {
|
|
89
|
-
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
value: newColor,
|
|
93
|
-
zodValidation: safeParse,
|
|
94
|
-
};
|
|
95
|
-
setLocalValue(newLocalState);
|
|
96
|
-
if (safeParse.success) {
|
|
97
|
-
setValue(newColor);
|
|
98
|
-
}
|
|
99
|
-
}, [localValue.value, schema, setValue, zodColor]);
|
|
62
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
|
|
63
|
+
onValueChange(() => newColor, false);
|
|
64
|
+
}, [localValue.value, onValueChange, zodTypes]);
|
|
100
65
|
const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
|
|
101
|
-
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
zodValidation: safeParse,
|
|
106
|
-
};
|
|
107
|
-
setLocalValue(newLocalState);
|
|
108
|
-
if (safeParse.success) {
|
|
109
|
-
setValue(newColor);
|
|
110
|
-
}
|
|
111
|
-
}, [localValue.value, schema, setValue, zodColor]);
|
|
112
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: colorPicker, children: (0, jsx_runtime_1.jsx)(RemInputTypeColor_1.RemInputTypeColor, { type: "color", style: {
|
|
66
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
|
|
67
|
+
onValueChange(() => newColor, false);
|
|
68
|
+
}, [localValue.value, onValueChange, zodTypes]);
|
|
69
|
+
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, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent }), (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
70
|
height: 39,
|
|
114
71
|
}, 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
72
|
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodDateEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: Date;
|
|
8
9
|
defaultValue: Date;
|
|
9
|
-
setValue:
|
|
10
|
-
onSave:
|
|
10
|
+
setValue: UpdaterFunction<Date>;
|
|
11
|
+
onSave: UpdaterFunction<Date>;
|
|
11
12
|
onRemove: null | (() => void);
|
|
12
13
|
compact: boolean;
|
|
13
14
|
showSaveButton: boolean;
|
|
15
|
+
saving: boolean;
|
|
16
|
+
saveDisabledByParent: boolean;
|
|
14
17
|
}>;
|
|
@@ -8,6 +8,7 @@ const layout_1 = require("../../layout");
|
|
|
8
8
|
const RemInput_1 = require("../../NewComposition/RemInput");
|
|
9
9
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
10
10
|
const layout_2 = require("../layout");
|
|
11
|
+
const local_state_1 = require("./local-state");
|
|
11
12
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
12
13
|
const fullWidth = {
|
|
13
14
|
width: '100%',
|
|
@@ -43,34 +44,25 @@ const formatDate = (date) => {
|
|
|
43
44
|
.padStart(3, '0')}`;
|
|
44
45
|
return formattedDate;
|
|
45
46
|
};
|
|
46
|
-
const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, }) => {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
47
|
+
const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, saveDisabledByParent, }) => {
|
|
48
|
+
const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
|
|
49
|
+
schema,
|
|
50
|
+
setValue,
|
|
51
|
+
value,
|
|
52
52
|
});
|
|
53
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
value: newValue,
|
|
57
|
-
zodValidation: safeParse,
|
|
58
|
-
};
|
|
59
|
-
setLocalValue(newLocalState);
|
|
60
|
-
if (safeParse.success) {
|
|
61
|
-
setValue(newValue);
|
|
62
|
-
}
|
|
63
|
-
}, [schema, setValue]);
|
|
53
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
54
|
+
setLocalValue(() => newValue, forceApply);
|
|
55
|
+
}, [setLocalValue]);
|
|
64
56
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
65
57
|
// React does not support e.target.valueAsDate :(
|
|
66
|
-
onValueChange(new Date(e.target.value));
|
|
58
|
+
onValueChange(new Date(e.target.value), false);
|
|
67
59
|
}, [onValueChange]);
|
|
68
60
|
const reset = (0, react_1.useCallback)(() => {
|
|
69
|
-
onValueChange(defaultValue);
|
|
61
|
+
onValueChange(defaultValue, true);
|
|
70
62
|
}, [defaultValue, onValueChange]);
|
|
71
63
|
const save = (0, react_1.useCallback)(() => {
|
|
72
|
-
onSave(() => value);
|
|
64
|
+
onSave(() => value, false);
|
|
73
65
|
}, [onSave, value]);
|
|
74
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value.getTime() === defaultValue.getTime(), jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: formatDate(localValue.value), type: "datetime-local", status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, style: inputStyle, 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" })] }))] })] }));
|
|
66
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value.getTime() === defaultValue.getTime(), jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent }), (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
67
|
};
|
|
76
68
|
exports.ZodDateEditor = ZodDateEditor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
|
+
export declare const ZodDefaultEditor: React.FC<{
|
|
6
|
+
showSaveButton: boolean;
|
|
7
|
+
jsonPath: JSONPath;
|
|
8
|
+
compact: boolean;
|
|
9
|
+
value: unknown;
|
|
10
|
+
defaultValue: unknown;
|
|
11
|
+
schema: z.ZodTypeAny;
|
|
12
|
+
setValue: UpdaterFunction<unknown>;
|
|
13
|
+
onSave: UpdaterFunction<unknown>;
|
|
14
|
+
onRemove: null | (() => void);
|
|
15
|
+
saving: boolean;
|
|
16
|
+
saveDisabledByParent: boolean;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodDefaultEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ZodSwitch_1 = require("./ZodSwitch");
|
|
6
|
+
const ZodDefaultEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
|
|
7
|
+
const { innerType } = schema._def;
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
9
|
+
};
|
|
10
|
+
exports.ZodDefaultEditor = ZodDefaultEditor;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodEffectEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: unknown;
|
|
8
|
-
setValue:
|
|
9
|
+
setValue: UpdaterFunction<unknown>;
|
|
9
10
|
compact: boolean;
|
|
10
11
|
defaultValue: unknown;
|
|
11
|
-
onSave:
|
|
12
|
+
onSave: UpdaterFunction<unknown>;
|
|
12
13
|
showSaveButton: boolean;
|
|
13
14
|
onRemove: null | (() => void);
|
|
15
|
+
saving: boolean;
|
|
14
16
|
}>;
|
|
@@ -5,39 +5,38 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const colors_1 = require("../../../helpers/colors");
|
|
7
7
|
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
|
+
const layout_1 = require("../../layout");
|
|
8
9
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
10
|
+
const InfoBubble_1 = require("../InfoBubble");
|
|
11
|
+
const local_state_1 = require("./local-state");
|
|
9
12
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
10
13
|
const fullWidth = {
|
|
11
14
|
width: '100%',
|
|
12
15
|
};
|
|
13
|
-
const
|
|
16
|
+
const stackTrace = {
|
|
17
|
+
padding: 10,
|
|
18
|
+
};
|
|
19
|
+
const stackTraceLabel = {
|
|
20
|
+
fontSize: 14,
|
|
21
|
+
};
|
|
22
|
+
const legend = {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
};
|
|
25
|
+
const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compact, defaultValue, onSave, onRemove, showSaveButton, saving, }) => {
|
|
14
26
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
15
27
|
if (!z) {
|
|
16
28
|
throw new Error('expected zod');
|
|
17
29
|
}
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
30
|
+
const { localValue, onChange } = (0, local_state_1.useLocalState)({
|
|
31
|
+
value,
|
|
32
|
+
schema,
|
|
33
|
+
setValue: updateValue,
|
|
23
34
|
});
|
|
24
35
|
const def = schema._def;
|
|
25
36
|
const typeName = def.typeName;
|
|
26
37
|
if (typeName !== z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
27
38
|
throw new Error('expected effect');
|
|
28
39
|
}
|
|
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
40
|
const container = (0, react_1.useMemo)(() => {
|
|
42
41
|
if (!localValue.zodValidation.success) {
|
|
43
42
|
return {
|
|
@@ -50,6 +49,8 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
|
|
|
50
49
|
padding: 0,
|
|
51
50
|
};
|
|
52
51
|
}, [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 }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.
|
|
52
|
+
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, saveDisabledByParent: !localValue.zodValidation.success }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)("legend", { style: legend, children: [(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, { x: 0.5 }), (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Zod validation failure", children: (0, jsx_runtime_1.jsxs)("div", { style: stackTrace, children: [(0, jsx_runtime_1.jsx)("div", { style: stackTraceLabel, children: "Zod Validation has failed:" }), localValue.zodValidation.error.errors.map((error, index) => (
|
|
53
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
54
|
+
(0, jsx_runtime_1.jsxs)("div", { style: stackTraceLabel, children: ["Type: ", error.code, " ", (0, jsx_runtime_1.jsx)("br", {}), "Message: ", error.message] }, index)))] }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 })] }))] }));
|
|
54
55
|
};
|
|
55
56
|
exports.ZodEffectEditor = ZodEffectEditor;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodEnumEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: string;
|
|
8
9
|
defaultValue: string;
|
|
9
|
-
setValue:
|
|
10
|
-
onSave:
|
|
10
|
+
setValue: UpdaterFunction<string>;
|
|
11
|
+
onSave: UpdaterFunction<string>;
|
|
11
12
|
compact: boolean;
|
|
12
13
|
showSaveButton: boolean;
|
|
13
14
|
onRemove: null | (() => void);
|
|
15
|
+
saving: boolean;
|
|
14
16
|
}>;
|