@remotion/cli 4.0.0-alpha13 → 4.0.0-alpha14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ansi/ansi-diff.d.ts +1 -1
- package/dist/ansi/ansi-regex.d.ts +2 -0
- package/dist/ansi/ansi-regex.js +18 -0
- package/dist/benchmark.js +29 -14
- package/dist/cleanup-before-quit.js +3 -0
- package/dist/composition-prompts.d.ts +2 -2
- package/dist/compositions.js +8 -7
- package/dist/config/concurrency.d.ts +1 -1
- package/dist/config/ffmpeg-executable.d.ts +5 -0
- package/dist/config/ffmpeg-executable.js +21 -0
- package/dist/config/index.d.ts +2 -2
- package/dist/config/jpeg-quality.d.ts +1 -1
- package/dist/config/jpeg-quality.js +1 -1
- package/dist/config/number-of-gif-loops.d.ts +1 -1
- package/dist/config/override-webpack.d.ts +1 -1
- package/dist/config/quality.d.ts +2 -0
- package/dist/config/quality.js +17 -0
- package/dist/config/scale.d.ts +1 -1
- package/dist/config/user-agent.d.ts +1 -1
- package/dist/editor/components/CanvasOrLoading.js +3 -0
- package/dist/editor/components/Checkbox.d.ts +1 -0
- package/dist/editor/components/Checkbox.js +2 -2
- package/dist/editor/components/ClipboardIcon.d.ts +2 -0
- package/dist/editor/components/ClipboardIcon.js +12 -0
- package/dist/editor/components/CollapsedCompositionSelector.d.ts +4 -0
- package/dist/editor/components/CollapsedCompositionSelector.js +39 -0
- package/dist/editor/components/CompositionSelectorItem.d.ts +1 -1
- package/dist/editor/components/InlineAction.d.ts +1 -1
- package/dist/editor/components/Menu/MenuItem.d.ts +2 -2
- package/dist/editor/components/Menu/MenuSubItem.d.ts +1 -1
- package/dist/editor/components/NewComposition/ComboBox.d.ts +4 -4
- package/dist/editor/components/NewComposition/CopyHint.js +1 -1
- package/dist/editor/components/NewComposition/InputDragger.d.ts +1 -1
- package/dist/editor/components/NewComposition/RemInput.d.ts +2 -2
- package/dist/editor/components/NewComposition/RemInputTypeColor.d.ts +2 -1
- package/dist/editor/components/NewComposition/RemInputTypeColor.js +1 -1
- package/dist/editor/components/NewComposition/RemTextarea.d.ts +1 -1
- package/dist/editor/components/Notifications/NotificationCenter.d.ts +2 -2
- package/dist/editor/components/QuickSwitcher/NoResults.d.ts +1 -1
- package/dist/editor/components/QuickSwitcher/QuickSwitcherResult.d.ts +2 -2
- package/dist/editor/components/RenderModal/DataEditor.d.ts +2 -3
- package/dist/editor/components/RenderModal/DataEditor.js +14 -5
- package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.js +1 -1
- package/dist/editor/components/RenderModal/MutedSetting.js +1 -1
- package/dist/editor/components/RenderModal/RenderModal.d.ts +1 -1
- package/dist/editor/components/RenderModal/RenderModal.js +2 -2
- package/dist/editor/components/RenderModal/RenderModalAdvanced.d.ts +1 -1
- package/dist/editor/components/RenderModal/RenderModalAdvanced.js +1 -1
- package/dist/editor/components/RenderModal/RenderModalAudio.js +1 -1
- package/dist/editor/components/RenderModal/RenderModalData.d.ts +3 -2
- package/dist/editor/components/RenderModal/RenderModalData.js +23 -34
- package/dist/editor/components/RenderModal/RenderModalGif.js +1 -1
- package/dist/editor/components/RenderModal/RenderModalInput.d.ts +1 -1
- package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/RenderModalPicture.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/Fieldset.d.ts +7 -0
- package/dist/editor/components/RenderModal/SchemaEditor/Fieldset.js +26 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +0 -1
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +2 -3
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +1 -3
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +1 -7
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.js +14 -22
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSeparationLine.d.ts +2 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSeparationLine.js +11 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaVerticalGuide.d.ts +5 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaVerticalGuide.js +13 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +51 -42
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +5 -5
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +3 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +14 -13
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +12 -14
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +9 -15
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +5 -30
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +0 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +8 -11
- package/dist/editor/components/RenderModal/SchemaEditor/ZodFieldValidation.d.ts +7 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodFieldValidation.js +27 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +3 -3
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +10 -13
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +39 -45
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +13 -48
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +7 -10
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +8 -11
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +21 -21
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.js +6 -6
- package/dist/editor/components/RenderModal/SchemaEditor/deep-equal.js +3 -0
- package/dist/editor/components/RenderModal/SchemaEditor/extract-enum-json-paths.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/get-schema-label.js +3 -3
- package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/local-state.d.ts +10 -5
- package/dist/editor/components/RenderModal/SchemaEditor/local-state.js +56 -15
- package/dist/editor/components/RenderModal/SchemaEditor/zod-types.d.ts +1 -1
- package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +1 -1
- package/dist/editor/components/RenderModal/layout.d.ts +0 -1
- package/dist/editor/components/RenderModal/layout.js +1 -7
- package/dist/editor/components/RenderQueue/actions.d.ts +2 -1
- package/dist/editor/components/RenderQueue/actions.js +7 -2
- package/dist/editor/components/RenderQueue/context.d.ts +1 -1
- package/dist/editor/components/RichTimelineToggle.d.ts +2 -0
- package/dist/editor/components/RichTimelineToggle.js +29 -0
- package/dist/editor/components/RightPanel.d.ts +1 -1
- package/dist/editor/components/RightPanel.js +1 -1
- package/dist/editor/components/SegmentedControl.d.ts +1 -1
- package/dist/editor/components/SegmentedControl.js +2 -0
- package/dist/editor/components/Splitter/SplitterContext.d.ts +3 -3
- package/dist/editor/components/Thumbnail.d.ts +8 -0
- package/dist/editor/components/Thumbnail.js +76 -0
- package/dist/editor/components/Timeline/LoopedIndicator.js +6 -6
- package/dist/editor/components/Timeline/TimelineWidthProvider.d.ts +1 -1
- package/dist/editor/components/Timeline/TimelineZoomControls.js +1 -1
- package/dist/editor/components/Timeline/timeline-state-reducer.d.ts +2 -2
- package/dist/editor/components/UpdateCheck.d.ts +1 -1
- package/dist/editor/components/UpdateCheck.js +2 -4
- package/dist/editor/components/get-zod-if-possible.d.ts +2 -2
- package/dist/editor/helpers/client-id.d.ts +1 -1
- package/dist/editor/helpers/get-timeline-sequence-sort-key.d.ts +3 -3
- package/dist/editor/helpers/persist-open-folders.d.ts +1 -1
- package/dist/editor/helpers/render-modal-sections.d.ts +1 -2
- package/dist/editor/helpers/use-compact-ui.d.ts +1 -0
- package/dist/editor/helpers/use-compact-ui.js +18 -0
- package/dist/editor/helpers/use-menu-structure.d.ts +1 -1
- package/dist/editor/icons/film.d.ts +3 -0
- package/dist/editor/icons/film.js +8 -0
- package/dist/editor/icons/plus.d.ts +3 -1
- package/dist/editor/icons/plus.js +2 -2
- package/dist/editor/icons/timeline.d.ts +3 -0
- package/dist/editor/icons/timeline.js +9 -0
- package/dist/editor/state/checkerboard.d.ts +1 -1
- package/dist/editor/state/editor-zoom-gestures.d.ts +1 -1
- package/dist/editor/state/folders.d.ts +1 -1
- package/dist/editor/state/highest-z-index.d.ts +1 -1
- package/dist/editor/state/in-out.d.ts +2 -2
- package/dist/editor/state/keybindings.d.ts +4 -4
- package/dist/editor/state/modals.d.ts +4 -4
- package/dist/editor/state/preview-size.d.ts +1 -1
- package/dist/editor/state/rich-timeline.d.ts +9 -0
- package/dist/editor/state/rich-timeline.js +17 -0
- package/dist/editor/state/sidebar.d.ts +3 -3
- package/dist/editor/state/timeline-ref.d.ts +1 -1
- package/dist/event-source-events.d.ts +1 -1
- package/dist/file-watcher.d.ts +1 -1
- package/dist/get-cli-options.d.ts +1 -1
- package/dist/get-composition-id.d.ts +10 -11
- package/dist/get-composition-id.js +9 -6
- package/dist/get-composition-with-dimension-override.d.ts +4 -4
- package/dist/get-composition-with-dimension-override.js +2 -2
- package/dist/get-render-media-options.d.ts +8 -0
- package/dist/get-render-media-options.js +55 -0
- package/dist/index.d.ts +5 -4
- package/dist/install.d.ts +2 -0
- package/dist/install.js +36 -0
- package/dist/is-javascript.d.ts +2 -0
- package/dist/is-javascript.js +9 -0
- package/dist/log.d.ts +1 -0
- package/dist/parse-command-line.d.ts +1 -1
- package/dist/preview-server/api-routes.js +2 -0
- package/dist/preview-server/api-types.d.ts +5 -4
- package/dist/preview-server/dev-middleware/get-paths.d.ts +1 -1
- package/dist/preview-server/dev-middleware/is-color-supported.d.ts +1 -0
- package/dist/preview-server/dev-middleware/is-color-supported.js +37 -0
- package/dist/preview-server/dev-middleware/middleware.d.ts +1 -1
- package/dist/preview-server/dev-middleware/range-parser.d.ts +2 -2
- package/dist/preview-server/dev-middleware/types.d.ts +1 -1
- package/dist/preview-server/error-overlay/react-overlay/effects/map-error-to-react-stack.d.ts +1 -1
- package/dist/preview-server/error-overlay/react-overlay/effects/proxy-console.d.ts +3 -3
- package/dist/preview-server/error-overlay/react-overlay/effects/unhandled-error.d.ts +1 -1
- package/dist/preview-server/error-overlay/react-overlay/effects/unhandled-rejection.d.ts +1 -1
- package/dist/preview-server/error-overlay/react-overlay/listen-to-runtime-errors.d.ts +1 -1
- package/dist/preview-server/error-overlay/react-overlay/utils/get-source-map.js +1 -0
- package/dist/preview-server/error-overlay/react-overlay/utils/open-in-editor.d.ts +2 -2
- package/dist/preview-server/error-overlay/react-overlay/utils/stack-frame.d.ts +4 -4
- package/dist/preview-server/error-overlay/remotion-overlay/ErrorDisplay.d.ts +1 -1
- package/dist/preview-server/error-overlay/remotion-overlay/Overlay.d.ts +2 -2
- package/dist/preview-server/error-overlay/remotion-overlay/get-help-link.d.ts +1 -1
- package/dist/preview-server/get-package-manager.d.ts +2 -2
- package/dist/preview-server/hot-middleware/client.d.ts +1 -1
- package/dist/preview-server/hot-middleware/strip-ansi.d.ts +1 -0
- package/dist/preview-server/hot-middleware/strip-ansi.js +21 -0
- package/dist/preview-server/hot-middleware/types.d.ts +4 -4
- package/dist/preview-server/live-events.d.ts +1 -1
- package/dist/preview-server/live-events.js +10 -1
- package/dist/preview-server/project-info.d.ts +1 -1
- package/dist/preview-server/render-queue/job.d.ts +30 -21
- package/dist/preview-server/render-queue/process-still.js +1 -2
- package/dist/preview-server/routes/update-available.d.ts +3 -0
- package/dist/preview-server/routes/update-available.js +9 -0
- package/dist/preview-server/routes.d.ts +0 -1
- package/dist/preview-server/routes.js +1 -11
- package/dist/preview-server/update-available.d.ts +2 -10
- package/dist/preview.js +2 -0
- package/dist/progress-bar.d.ts +4 -4
- package/dist/progress-bar.js +3 -2
- package/dist/progress-types.d.ts +4 -4
- package/dist/render-flows/render.js +35 -28
- package/dist/render-flows/still.d.ts +1 -1
- package/dist/render-flows/still.js +23 -10
- package/dist/required-chromium-options.d.ts +2 -2
- package/dist/server-ready-comment.d.ts +1 -1
- package/dist/server-ready-comment.js +2 -2
- package/dist/setup-cache.js +10 -0
- package/dist/show-compositions-picker.d.ts +1 -1
- package/dist/step.d.ts +1 -1
- package/dist/studio.js +3 -3
- package/dist/truthy.d.ts +1 -1
- package/package.json +10 -12
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodFieldValidation = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
6
|
+
const layout_1 = require("../../layout");
|
|
7
|
+
const InfoBubble_1 = require("../InfoBubble");
|
|
8
|
+
const legend = {
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
};
|
|
13
|
+
const stackTrace = {
|
|
14
|
+
padding: 10,
|
|
15
|
+
};
|
|
16
|
+
const stackTraceLabel = {
|
|
17
|
+
fontSize: 14,
|
|
18
|
+
};
|
|
19
|
+
const ZodFieldValidation = ({ localValue, path }) => {
|
|
20
|
+
if (localValue.zodValidation.success) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", { 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) => (
|
|
24
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
25
|
+
(0, jsx_runtime_1.jsxs)("div", { style: stackTraceLabel, children: ["Type: ", error.code, " ", (0, jsx_runtime_1.jsx)("br", {}), "Message: ", error.message, (0, jsx_runtime_1.jsx)("br", {}), "Path: ", path.join('.')] }, index)))] }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 })] }));
|
|
26
|
+
};
|
|
27
|
+
exports.ZodFieldValidation = ZodFieldValidation;
|
|
@@ -4,8 +4,8 @@ exports.ZonNonEditableValue = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const colors_1 = require("../../../helpers/colors");
|
|
7
|
-
const layout_1 = require("../layout");
|
|
8
7
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
8
|
+
const Fieldset_1 = require("./Fieldset");
|
|
9
9
|
const fullWidth = {
|
|
10
10
|
width: '100%',
|
|
11
11
|
};
|
|
@@ -19,9 +19,9 @@ const wideEmptyLabel = {
|
|
|
19
19
|
...emptyLabel,
|
|
20
20
|
lineHeight: '37px',
|
|
21
21
|
};
|
|
22
|
-
const ZonNonEditableValue = ({ jsonPath, label,
|
|
22
|
+
const ZonNonEditableValue = ({ jsonPath, label, showSaveButton, saving, mayPad }) => {
|
|
23
23
|
const save = (0, react_1.useCallback)(() => undefined, []);
|
|
24
24
|
const reset = (0, react_1.useCallback)(() => undefined, []);
|
|
25
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: true, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: true, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: null, saving: saving, valid: true, saveDisabledByParent: true, suffix: null }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)("em", { style: wideEmptyLabel, children: label }) })] }));
|
|
26
26
|
};
|
|
27
27
|
exports.ZonNonEditableValue = ZonNonEditableValue;
|
|
@@ -5,7 +5,6 @@ import type { UpdaterFunction } from './ZodSwitch';
|
|
|
5
5
|
export declare const ZodNullableEditor: React.FC<{
|
|
6
6
|
showSaveButton: boolean;
|
|
7
7
|
jsonPath: JSONPath;
|
|
8
|
-
compact: boolean;
|
|
9
8
|
value: unknown;
|
|
10
9
|
defaultValue: unknown;
|
|
11
10
|
schema: z.ZodTypeAny;
|
|
@@ -14,4 +13,5 @@ export declare const ZodNullableEditor: React.FC<{
|
|
|
14
13
|
onRemove: null | (() => void);
|
|
15
14
|
saving: boolean;
|
|
16
15
|
saveDisabledByParent: boolean;
|
|
16
|
+
mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodNullableEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const ZodOrNullishEditor_1 = require("./ZodOrNullishEditor");
|
|
6
|
-
const ZodNullableEditor = ({ jsonPath,
|
|
6
|
+
const ZodNullableEditor = ({ jsonPath, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
|
|
7
7
|
const { innerType } = schema._def;
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: schema, innerSchema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: null, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad }));
|
|
9
9
|
};
|
|
10
10
|
exports.ZodNullableEditor = ZodNullableEditor;
|
|
@@ -7,11 +7,11 @@ export declare const ZodNumberEditor: React.FC<{
|
|
|
7
7
|
jsonPath: JSONPath;
|
|
8
8
|
value: number;
|
|
9
9
|
setValue: UpdaterFunction<number>;
|
|
10
|
-
compact: boolean;
|
|
11
10
|
defaultValue: number;
|
|
12
11
|
onSave: UpdaterFunction<number>;
|
|
13
12
|
onRemove: null | (() => void);
|
|
14
13
|
showSaveButton: boolean;
|
|
15
14
|
saving: boolean;
|
|
16
15
|
saveDisabledByParent: boolean;
|
|
16
|
+
mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodNumberEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const layout_1 = require("../../layout");
|
|
7
6
|
const InputDragger_1 = require("../../NewComposition/InputDragger");
|
|
8
|
-
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
9
|
-
const layout_2 = require("../layout");
|
|
10
7
|
const local_state_1 = require("./local-state");
|
|
11
8
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
9
|
+
const Fieldset_1 = require("./Fieldset");
|
|
10
|
+
const ZodFieldValidation_1 = require("./ZodFieldValidation");
|
|
12
11
|
const fullWidth = {
|
|
13
12
|
width: '100%',
|
|
14
13
|
};
|
|
@@ -48,25 +47,23 @@ const getStep = (schema) => {
|
|
|
48
47
|
}
|
|
49
48
|
return multipleStep.value;
|
|
50
49
|
};
|
|
51
|
-
const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave,
|
|
52
|
-
const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
|
|
50
|
+
const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, defaultValue, onRemove, showSaveButton, saving, saveDisabledByParent, mayPad, }) => {
|
|
51
|
+
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
53
52
|
value,
|
|
54
53
|
schema,
|
|
55
54
|
setValue,
|
|
55
|
+
defaultValue,
|
|
56
56
|
});
|
|
57
57
|
const onNumberChange = (0, react_1.useCallback)((newValue) => {
|
|
58
|
-
setLocalValue(() => newValue, false);
|
|
58
|
+
setLocalValue(() => newValue, false, false);
|
|
59
59
|
}, [setLocalValue]);
|
|
60
|
-
const isDefault = value === defaultValue;
|
|
61
|
-
const reset = (0, react_1.useCallback)(() => {
|
|
62
|
-
setLocalValue(() => defaultValue, true);
|
|
63
|
-
}, [defaultValue, setLocalValue]);
|
|
60
|
+
const isDefault = localValue.value === defaultValue;
|
|
64
61
|
const onTextChange = (0, react_1.useCallback)((newValue) => {
|
|
65
|
-
setLocalValue(() => Number(newValue), false);
|
|
62
|
+
setLocalValue(() => Number(newValue), false, false);
|
|
66
63
|
}, [setLocalValue]);
|
|
67
64
|
const save = (0, react_1.useCallback)(() => {
|
|
68
|
-
onSave(() => value, false);
|
|
65
|
+
onSave(() => value, false, false);
|
|
69
66
|
}, [onSave, value]);
|
|
70
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
67
|
+
return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefault, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent, suffix: null }), (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: onTextChange, onValueChange: onNumberChange, min: getMinValue(schema), max: getMaxValue(schema), step: getStep(schema), rightAlign: false }), (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] })] }));
|
|
71
68
|
};
|
|
72
69
|
exports.ZodNumberEditor = ZodNumberEditor;
|
|
@@ -8,10 +8,10 @@ export declare const ZodObjectEditor: React.FC<{
|
|
|
8
8
|
value: Record<string, unknown>;
|
|
9
9
|
defaultValue: Record<string, unknown>;
|
|
10
10
|
setValue: UpdaterFunction<Record<string, unknown>>;
|
|
11
|
-
compact: boolean;
|
|
12
11
|
onSave: UpdaterFunction<Record<string, unknown>>;
|
|
13
12
|
showSaveButton: boolean;
|
|
14
13
|
onRemove: null | (() => void);
|
|
15
14
|
saving: boolean;
|
|
16
15
|
saveDisabledByParent: boolean;
|
|
16
|
+
mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.ZodObjectEditor = void 0;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
8
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
9
|
+
const react_2 = __importDefault(require("react"));
|
|
7
10
|
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
|
-
const layout_1 = require("../layout");
|
|
9
11
|
const local_state_1 = require("./local-state");
|
|
10
|
-
const SchemaLabel_1 = require("./SchemaLabel");
|
|
11
12
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
borderRadius: 4,
|
|
20
|
-
borderColor: colors_1.INPUT_BORDER_COLOR_UNHOVERED,
|
|
21
|
-
};
|
|
22
|
-
const ZodObjectEditor = ({ schema, jsonPath, setValue, value, compact, defaultValue, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
|
|
13
|
+
const Fieldset_1 = require("./Fieldset");
|
|
14
|
+
const SchemaSeparationLine_1 = require("./SchemaSeparationLine");
|
|
15
|
+
const layout_1 = require("../layout");
|
|
16
|
+
const SchemaVerticalGuide_1 = require("./SchemaVerticalGuide");
|
|
17
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
18
|
+
const deep_equal_1 = require("./deep-equal");
|
|
19
|
+
const ZodObjectEditor = ({ schema, jsonPath, setValue, value, defaultValue, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
|
|
23
20
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
24
21
|
if (!z) {
|
|
25
22
|
throw new Error('expected zod');
|
|
26
23
|
}
|
|
27
|
-
const { localValue, onChange } = (0, local_state_1.useLocalState)({
|
|
24
|
+
const { localValue, onChange, RevisionContextProvider, reset } = (0, local_state_1.useLocalState)({
|
|
28
25
|
schema,
|
|
29
26
|
setValue,
|
|
30
27
|
value,
|
|
28
|
+
defaultValue,
|
|
31
29
|
});
|
|
32
30
|
const def = schema._def;
|
|
33
31
|
const typeName = def.typeName;
|
|
@@ -37,35 +35,31 @@ const ZodObjectEditor = ({ schema, jsonPath, setValue, value, compact, defaultVa
|
|
|
37
35
|
const shape = def.shape();
|
|
38
36
|
const keys = Object.keys(shape);
|
|
39
37
|
const isRoot = jsonPath.length === 0;
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
}, forceApply);
|
|
68
|
-
}, onRemove: null, compact: compact, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent }, key));
|
|
69
|
-
}) })] }) }) }));
|
|
38
|
+
const isDefaultValue = (0, react_1.useMemo)(() => {
|
|
39
|
+
return (0, deep_equal_1.deepEqual)(localValue.value, defaultValue);
|
|
40
|
+
}, [defaultValue, localValue]);
|
|
41
|
+
return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: !isRoot && mayPad, success: localValue.zodValidation.success, children: [isRoot ? null : ((0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefaultValue, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, suffix: ' {', onSave: () => {
|
|
42
|
+
onSave(() => {
|
|
43
|
+
return localValue.value;
|
|
44
|
+
}, false, false);
|
|
45
|
+
}, saveDisabledByParent: saveDisabledByParent, saving: saving, showSaveButton: showSaveButton, valid: localValue.zodValidation.success })), (0, jsx_runtime_1.jsx)(RevisionContextProvider, { children: (0, jsx_runtime_1.jsx)(SchemaVerticalGuide_1.SchemaVerticalGuide, { isRoot: isRoot, children: keys.map((key, i) => {
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { mayPad: true, jsonPath: [...jsonPath, key], schema: shape[key], value: localValue.value[key],
|
|
47
|
+
// In case of null | {a: string, b: string} type, we need to fallback to the default value
|
|
48
|
+
defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : value)[key], setValue: (val, forceApply) => {
|
|
49
|
+
onChange((oldVal) => {
|
|
50
|
+
return {
|
|
51
|
+
...oldVal,
|
|
52
|
+
[key]: typeof val === 'function' ? val(oldVal[key]) : val,
|
|
53
|
+
};
|
|
54
|
+
}, forceApply, false);
|
|
55
|
+
}, onSave: (val, forceApply) => {
|
|
56
|
+
onSave((oldVal) => {
|
|
57
|
+
return {
|
|
58
|
+
...oldVal,
|
|
59
|
+
[key]: typeof val === 'function' ? val(oldVal[key]) : val,
|
|
60
|
+
};
|
|
61
|
+
}, forceApply, false);
|
|
62
|
+
}, onRemove: null, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent }), i === keys.length - 1 ? null : (0, jsx_runtime_1.jsx)(SchemaSeparationLine_1.SchemaSeparationLine, {})] }, key));
|
|
63
|
+
}) }) }), isRoot ? null : (0, jsx_runtime_1.jsx)("div", { style: layout_1.fieldsetLabel, children: '}' })] }));
|
|
70
64
|
};
|
|
71
65
|
exports.ZodObjectEditor = ZodObjectEditor;
|
|
@@ -5,7 +5,6 @@ import type { UpdaterFunction } from './ZodSwitch';
|
|
|
5
5
|
export declare const ZodOptionalEditor: React.FC<{
|
|
6
6
|
showSaveButton: boolean;
|
|
7
7
|
jsonPath: JSONPath;
|
|
8
|
-
compact: boolean;
|
|
9
8
|
value: unknown;
|
|
10
9
|
defaultValue: unknown;
|
|
11
10
|
schema: z.ZodTypeAny;
|
|
@@ -14,4 +13,5 @@ export declare const ZodOptionalEditor: React.FC<{
|
|
|
14
13
|
onRemove: null | (() => void);
|
|
15
14
|
saving: boolean;
|
|
16
15
|
saveDisabledByParent: boolean;
|
|
16
|
+
mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodOptionalEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const ZodOrNullishEditor_1 = require("./ZodOrNullishEditor");
|
|
6
|
-
const ZodOptionalEditor = ({ jsonPath,
|
|
6
|
+
const ZodOptionalEditor = ({ jsonPath, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
|
|
7
7
|
const { innerType } = schema._def;
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: schema, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: undefined, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad, innerSchema: innerType }));
|
|
9
9
|
};
|
|
10
10
|
exports.ZodOptionalEditor = ZodOptionalEditor;
|
|
@@ -5,14 +5,15 @@ import type { UpdaterFunction } from './ZodSwitch';
|
|
|
5
5
|
export declare const ZodOrNullishEditor: React.FC<{
|
|
6
6
|
showSaveButton: boolean;
|
|
7
7
|
jsonPath: JSONPath;
|
|
8
|
-
compact: boolean;
|
|
9
8
|
value: unknown;
|
|
10
9
|
defaultValue: unknown;
|
|
11
10
|
schema: z.ZodTypeAny;
|
|
11
|
+
innerSchema: z.ZodTypeAny;
|
|
12
12
|
setValue: UpdaterFunction<unknown>;
|
|
13
13
|
onSave: UpdaterFunction<unknown>;
|
|
14
14
|
onRemove: null | (() => void);
|
|
15
15
|
nullishValue: null | undefined;
|
|
16
16
|
saving: boolean;
|
|
17
17
|
saveDisabledByParent: boolean;
|
|
18
|
+
mayPad: boolean;
|
|
18
19
|
}>;
|
|
@@ -10,76 +10,41 @@ const layout_1 = require("../../layout");
|
|
|
10
10
|
const create_zod_values_1 = require("./create-zod-values");
|
|
11
11
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
12
12
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
};
|
|
13
|
+
const Fieldset_1 = require("./Fieldset");
|
|
14
|
+
const local_state_1 = require("./local-state");
|
|
16
15
|
const labelStyle = {
|
|
17
16
|
fontFamily: 'sans-serif',
|
|
18
17
|
fontSize: 14,
|
|
19
18
|
color: colors_1.LIGHT_TEXT,
|
|
20
19
|
};
|
|
21
20
|
const checkBoxWrapper = {
|
|
22
|
-
margin: '2px',
|
|
23
21
|
display: 'flex',
|
|
24
22
|
flexDirection: 'row',
|
|
25
23
|
alignItems: 'center',
|
|
26
24
|
marginTop: '5px',
|
|
27
25
|
};
|
|
28
|
-
const ZodOrNullishEditor = ({ jsonPath,
|
|
26
|
+
const ZodOrNullishEditor = ({ jsonPath, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, nullishValue, saving, saveDisabledByParent, mayPad, innerSchema, }) => {
|
|
29
27
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
30
28
|
if (!z) {
|
|
31
29
|
throw new Error('expected zod');
|
|
32
30
|
}
|
|
33
31
|
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
34
32
|
const isChecked = value === nullishValue;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
: schema.safeParse(value),
|
|
41
|
-
};
|
|
33
|
+
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
34
|
+
schema,
|
|
35
|
+
setValue,
|
|
36
|
+
value,
|
|
37
|
+
defaultValue,
|
|
42
38
|
});
|
|
43
|
-
const onValueChange = (0, react_1.useCallback)((updater) => {
|
|
44
|
-
setLocalNonNullishValue((oldState) => {
|
|
45
|
-
const newValue = updater(oldState.value);
|
|
46
|
-
if (newValue === nullishValue) {
|
|
47
|
-
return oldState;
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
value: newValue,
|
|
51
|
-
zodValidation: schema.safeParse(newValue),
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
setValue(updater, false);
|
|
55
|
-
}, [nullishValue, schema, setValue]);
|
|
56
39
|
const onCheckBoxChange = (0, react_1.useCallback)((e) => {
|
|
57
40
|
const val = e.target.checked
|
|
58
41
|
? nullishValue
|
|
59
|
-
:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (val !== nullishValue) {
|
|
63
|
-
setLocalNonNullishValue({
|
|
64
|
-
value: val,
|
|
65
|
-
zodValidation: schema.safeParse(val),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
onValueChange(() => val, false);
|
|
69
|
-
}, [
|
|
70
|
-
localNonNullishValueValue,
|
|
71
|
-
nullishValue,
|
|
72
|
-
onValueChange,
|
|
73
|
-
schema,
|
|
74
|
-
z,
|
|
75
|
-
zodTypes,
|
|
76
|
-
]);
|
|
77
|
-
const reset = (0, react_1.useCallback)(() => {
|
|
78
|
-
onValueChange(() => defaultValue, true);
|
|
79
|
-
}, [defaultValue, onValueChange]);
|
|
42
|
+
: (0, create_zod_values_1.createZodValues)(innerSchema, z, zodTypes);
|
|
43
|
+
setLocalValue(() => val, false, false);
|
|
44
|
+
}, [innerSchema, nullishValue, setLocalValue, z, zodTypes]);
|
|
80
45
|
const save = (0, react_1.useCallback)(() => {
|
|
81
|
-
onSave(() => value, false);
|
|
46
|
+
onSave(() => value, false, false);
|
|
82
47
|
}, [onSave, value]);
|
|
83
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
48
|
+
return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [localValue.value === nullishValue ? ((0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: localValue.value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent, suffix: null })) : ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { value: localValue.value, setValue: setLocalValue, jsonPath: jsonPath, schema: innerSchema, defaultValue: value, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: false })), (0, jsx_runtime_1.jsxs)("div", { style: checkBoxWrapper, children: [(0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: isChecked, onChange: onCheckBoxChange, disabled: false, name: jsonPath.join('.') }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)("div", { style: labelStyle, children: String(nullishValue) })] })] }));
|
|
84
49
|
};
|
|
85
50
|
exports.ZodOrNullishEditor = ZodOrNullishEditor;
|
|
@@ -9,9 +9,9 @@ export declare const ZodStaticFileEditor: React.FC<{
|
|
|
9
9
|
defaultValue: string;
|
|
10
10
|
setValue: UpdaterFunction<string>;
|
|
11
11
|
onSave: (updater: (oldState: string) => string) => void;
|
|
12
|
-
compact: boolean;
|
|
13
12
|
showSaveButton: boolean;
|
|
14
13
|
onRemove: null | (() => void);
|
|
15
14
|
saving: boolean;
|
|
16
15
|
saveDisabledByParent: boolean;
|
|
16
|
+
mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -6,24 +6,24 @@ const react_1 = require("react");
|
|
|
6
6
|
const remotion_1 = require("remotion");
|
|
7
7
|
const Checkmark_1 = require("../../../icons/Checkmark");
|
|
8
8
|
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
9
|
-
const layout_1 = require("../../layout");
|
|
10
9
|
const ComboBox_1 = require("../../NewComposition/ComboBox");
|
|
11
|
-
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
12
|
-
const layout_2 = require("../layout");
|
|
13
10
|
const local_state_1 = require("./local-state");
|
|
14
11
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
12
|
+
const Fieldset_1 = require("./Fieldset");
|
|
13
|
+
const ZodFieldValidation_1 = require("./ZodFieldValidation");
|
|
15
14
|
const container = {
|
|
16
15
|
width: '100%',
|
|
17
16
|
};
|
|
18
|
-
const ZodStaticFileEditor = ({ schema, jsonPath,
|
|
17
|
+
const ZodStaticFileEditor = ({ schema, jsonPath, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
|
|
19
18
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
20
19
|
if (!z) {
|
|
21
20
|
throw new Error('expected zod');
|
|
22
21
|
}
|
|
23
|
-
const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
|
|
22
|
+
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
24
23
|
schema,
|
|
25
24
|
setValue,
|
|
26
25
|
value,
|
|
26
|
+
defaultValue,
|
|
27
27
|
});
|
|
28
28
|
const def = schema._def;
|
|
29
29
|
const typeName = def.typeName;
|
|
@@ -31,9 +31,6 @@ const ZodStaticFileEditor = ({ schema, jsonPath, compact, setValue, defaultValue
|
|
|
31
31
|
throw new Error('expected enum');
|
|
32
32
|
}
|
|
33
33
|
const isRoot = jsonPath.length === 0;
|
|
34
|
-
const reset = (0, react_1.useCallback)(() => {
|
|
35
|
-
setLocalValue(() => defaultValue, true);
|
|
36
|
-
}, [defaultValue, setLocalValue]);
|
|
37
34
|
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
38
35
|
return (0, remotion_1.getStaticFiles)().map((option) => {
|
|
39
36
|
return {
|
|
@@ -43,7 +40,7 @@ const ZodStaticFileEditor = ({ schema, jsonPath, compact, setValue, defaultValue
|
|
|
43
40
|
keyHint: null,
|
|
44
41
|
leftItem: option.src === value ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
|
|
45
42
|
onClick: (id) => {
|
|
46
|
-
setLocalValue(() => id, false);
|
|
43
|
+
setLocalValue(() => id, false, false);
|
|
47
44
|
},
|
|
48
45
|
quickSwitcherLabel: null,
|
|
49
46
|
subMenu: null,
|
|
@@ -54,6 +51,6 @@ const ZodStaticFileEditor = ({ schema, jsonPath, compact, setValue, defaultValue
|
|
|
54
51
|
const save = (0, react_1.useCallback)(() => {
|
|
55
52
|
onSave(() => value);
|
|
56
53
|
}, [onSave, value]);
|
|
57
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onSave: save, showSaveButton: showSaveButton, isDefaultValue: localValue.value === defaultValue, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent, suffix: null }), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: localValue.value, title: value }) }), (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] }));
|
|
58
55
|
};
|
|
59
56
|
exports.ZodStaticFileEditor = ZodStaticFileEditor;
|
|
@@ -10,8 +10,8 @@ export declare const ZodStringEditor: React.FC<{
|
|
|
10
10
|
setValue: UpdaterFunction<string>;
|
|
11
11
|
onSave: UpdaterFunction<string>;
|
|
12
12
|
onRemove: null | (() => void);
|
|
13
|
-
compact: boolean;
|
|
14
13
|
showSaveButton: boolean;
|
|
15
14
|
saving: boolean;
|
|
16
15
|
saveDisabledByParent: boolean;
|
|
16
|
+
mayPad: boolean;
|
|
17
17
|
}>;
|
|
@@ -4,34 +4,31 @@ exports.ZodStringEditor = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
7
|
-
const layout_1 = require("../../layout");
|
|
8
7
|
const RemInput_1 = require("../../NewComposition/RemInput");
|
|
9
|
-
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
10
|
-
const layout_2 = require("../layout");
|
|
11
8
|
const local_state_1 = require("./local-state");
|
|
12
9
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
10
|
+
const Fieldset_1 = require("./Fieldset");
|
|
11
|
+
const ZodFieldValidation_1 = require("./ZodFieldValidation");
|
|
13
12
|
const fullWidth = {
|
|
14
13
|
width: '100%',
|
|
15
14
|
};
|
|
16
|
-
const ZodStringEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema,
|
|
15
|
+
const ZodStringEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, onSave, onRemove, saving, saveDisabledByParent, mayPad, }) => {
|
|
17
16
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
18
17
|
if (!z) {
|
|
19
18
|
throw new Error('expected zod');
|
|
20
19
|
}
|
|
21
|
-
const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
|
|
20
|
+
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
22
21
|
schema,
|
|
23
22
|
setValue,
|
|
24
23
|
value,
|
|
24
|
+
defaultValue,
|
|
25
25
|
});
|
|
26
26
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
27
|
-
setLocalValue(() => e.target.value, false);
|
|
27
|
+
setLocalValue(() => e.target.value, false, false);
|
|
28
28
|
}, [setLocalValue]);
|
|
29
|
-
const reset = (0, react_1.useCallback)(() => {
|
|
30
|
-
setLocalValue(() => defaultValue, true);
|
|
31
|
-
}, [defaultValue, setLocalValue]);
|
|
32
29
|
const save = (0, react_1.useCallback)(() => {
|
|
33
|
-
onSave(() => value, false);
|
|
30
|
+
onSave(() => value, false, false);
|
|
34
31
|
}, [onSave, value]);
|
|
35
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: false, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: localValue.value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent, suffix: null }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: localValue.value, status: localValue.zodValidation ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, rightAlign: false, name: jsonPath.join('.') }), (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] })] }));
|
|
36
33
|
};
|
|
37
34
|
exports.ZodStringEditor = ZodStringEditor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
-
export
|
|
4
|
+
export type UpdaterFunction<T> = (updater: (oldValue: T) => T, forceApply: boolean, increment: boolean) => void;
|
|
5
5
|
export declare const ZodSwitch: React.FC<{
|
|
6
6
|
schema: z.ZodTypeAny;
|
|
7
7
|
jsonPath: JSONPath;
|
|
@@ -9,9 +9,9 @@ export declare const ZodSwitch: React.FC<{
|
|
|
9
9
|
defaultValue: unknown;
|
|
10
10
|
setValue: UpdaterFunction<unknown>;
|
|
11
11
|
onSave: UpdaterFunction<unknown>;
|
|
12
|
-
compact: boolean;
|
|
13
12
|
showSaveButton: boolean;
|
|
14
13
|
onRemove: null | (() => void);
|
|
15
14
|
saving: boolean;
|
|
16
15
|
saveDisabledByParent: boolean;
|
|
16
|
+
mayPad: boolean;
|
|
17
17
|
}>;
|