@remotion/cli 4.0.0-alpha5 → 4.0.0-alpha7
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 +9 -4
- 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 +3 -1
- package/dist/codemods/update-default-props.js +3 -17
- package/dist/color-math.js +3 -1
- package/dist/compositions.js +1 -0
- 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 -5
- package/dist/editor/components/MenuToolbar.js +15 -3
- package/dist/editor/components/NewComposition/ComboBox.js +2 -2
- package/dist/editor/components/NewComposition/MenuContent.js +1 -1
- package/dist/editor/components/NewComposition/RemInput.d.ts +1 -1
- package/dist/editor/components/NewComposition/RemInputTypeColor.d.ts +1 -1
- package/dist/editor/components/NewComposition/RemTextarea.d.ts +1 -1
- package/dist/editor/components/RenderModal/CliCopyButton.js +42 -9
- package/dist/editor/components/RenderModal/InfoTooltip.js +2 -1
- package/dist/editor/components/RenderModal/OptionExplainer.js +13 -3
- package/dist/editor/components/RenderModal/RenderModalData.js +21 -7
- package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +2 -2
- package/dist/editor/components/RenderModal/RenderModalPicture.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +3 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +8 -8
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +5 -5
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +3 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +3 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +4 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +9 -6
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +40 -7
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +16 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +73 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +5 -5
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +4 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +1 -1
- 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 +12 -0
- package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.js +32 -0
- package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +3 -2
- package/dist/editor/components/RenderModal/get-render-modal-warnings.js +9 -2
- package/dist/editor/components/RenderQueue/actions.d.ts +2 -1
- package/dist/editor/components/RenderQueue/actions.js +8 -4
- package/dist/editor/components/SidebarCollapserControls.js +12 -6
- package/dist/editor/components/Timeline/TimelineSequence.js +6 -4
- package/dist/editor/helpers/calculate-timeline.js +1 -1
- package/dist/editor/helpers/colors.d.ts +1 -1
- package/dist/editor/helpers/colors.js +1 -1
- package/dist/entry-point.js +17 -17
- package/dist/ffmpeg.js +12 -3
- package/dist/file-watcher.js +5 -5
- package/dist/get-cli-options.js +4 -4
- package/dist/get-config-file-name.js +6 -6
- package/dist/get-env.js +10 -10
- 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 +9 -5
- package/dist/index.js +4 -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 +1 -1
- 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/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/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 +2 -0
- package/dist/preview-server/render-queue/open-directory-in-finder.js +8 -8
- package/dist/preview-server/render-queue/queue.js +4 -3
- package/dist/preview-server/routes/can-update-default-props.js +3 -2
- package/dist/preview-server/routes/update-default-props.js +7 -6
- package/dist/preview-server/routes.d.ts +1 -1
- package/dist/preview-server/routes.js +8 -8
- 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 +2 -2
- package/dist/preview.js +4 -4
- package/dist/print-error.d.ts +2 -1
- package/dist/print-error.js +8 -5
- package/dist/progress-bar.d.ts +5 -4
- package/dist/progress-bar.js +42 -29
- package/dist/render-flows/render.js +50 -23
- package/dist/render-flows/still.js +20 -15
- package/dist/resolve-from.js +5 -5
- package/dist/setup-cache.d.ts +2 -1
- package/dist/setup-cache.js +8 -4
- package/dist/should-use-non-overlaying-logger.d.ts +4 -0
- package/dist/should-use-non-overlaying-logger.js +12 -0
- package/dist/upgrade.js +2 -2
- package/dist/user-passed-output-location.js +7 -2
- package/dist/versions.js +2 -2
- package/package.json +7 -7
- package/dist/ansi/ansi-regex.d.ts +0 -2
- package/dist/ansi/ansi-regex.js +0 -18
- package/dist/config/ffmpeg-executable.d.ts +0 -5
- package/dist/config/ffmpeg-executable.js +0 -21
- package/dist/config/quality.d.ts +0 -2
- package/dist/config/quality.js +0 -17
- package/dist/editor/components/ClipboardIcon.d.ts +0 -2
- package/dist/editor/components/ClipboardIcon.js +0 -12
- package/dist/editor/components/CollapsedCompositionSelector.d.ts +0 -4
- package/dist/editor/components/CollapsedCompositionSelector.js +0 -39
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.d.ts +0 -6
- package/dist/editor/components/RenderModal/SchemaEditor/date-serialization.js +0 -24
- package/dist/editor/components/RichTimelineToggle.d.ts +0 -2
- package/dist/editor/components/RichTimelineToggle.js +0 -29
- package/dist/editor/components/Thumbnail.d.ts +0 -8
- package/dist/editor/components/Thumbnail.js +0 -76
- package/dist/editor/helpers/use-compact-ui.d.ts +0 -1
- package/dist/editor/helpers/use-compact-ui.js +0 -18
- package/dist/editor/icons/film.d.ts +0 -3
- package/dist/editor/icons/film.js +0 -8
- package/dist/editor/icons/timeline.d.ts +0 -3
- package/dist/editor/icons/timeline.js +0 -9
- package/dist/editor/state/rich-timeline.d.ts +0 -9
- package/dist/editor/state/rich-timeline.js +0 -17
- package/dist/get-render-media-options.d.ts +0 -8
- package/dist/get-render-media-options.js +0 -55
- package/dist/install.d.ts +0 -2
- package/dist/install.js +0 -36
- package/dist/is-javascript.d.ts +0 -2
- package/dist/is-javascript.js +0 -9
- package/dist/preview-server/dev-middleware/is-color-supported.d.ts +0 -1
- package/dist/preview-server/dev-middleware/is-color-supported.js +0 -37
- package/dist/preview-server/hot-middleware/strip-ansi.d.ts +0 -1
- package/dist/preview-server/hot-middleware/strip-ansi.js +0 -21
|
@@ -2,21 +2,54 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CliCopyButton = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const colors_1 = require("../../helpers/colors");
|
|
7
|
+
const svgStyle = {
|
|
8
|
+
width: 16,
|
|
9
|
+
height: 16,
|
|
10
|
+
verticalAlign: 'sub',
|
|
11
|
+
};
|
|
12
|
+
const copiedStyle = {
|
|
13
|
+
fontSize: '14px',
|
|
14
|
+
minHeight: '30px',
|
|
15
|
+
minWidth: '30px',
|
|
16
|
+
display: 'flex',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
};
|
|
5
20
|
const CliCopyButton = ({ valueToCopy, }) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
const
|
|
13
|
-
|
|
21
|
+
const [copied, setCopied] = (0, react_1.useState)(false);
|
|
22
|
+
const [hovered, setHovered] = (0, react_1.useState)(false);
|
|
23
|
+
const fillColor = (0, react_1.useMemo)(() => {
|
|
24
|
+
return hovered ? 'white' : colors_1.LIGHT_TEXT;
|
|
25
|
+
}, [hovered]);
|
|
26
|
+
const clipboardIcon = ((0, jsx_runtime_1.jsx)("svg", { "aria-hidden": "true", focusable: "false", "data-prefix": "far", "data-icon": "clipboard", className: "svg-inline--fa fa-clipboard fa-w-12", role: "img", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 384 512", style: svgStyle, children: (0, jsx_runtime_1.jsx)("path", { fill: fillColor, d: "M336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM192 40c13.3 0 24 10.7 24 24s-10.7 24-24 24-24-10.7-24-24 10.7-24 24-24zm144 418c0 3.3-2.7 6-6 6H54c-3.3 0-6-2.7-6-6V118c0-3.3 2.7-6 6-6h42v36c0 6.6 5.4 12 12 12h168c6.6 0 12-5.4 12-12v-36h42c3.3 0 6 2.7 6 6z" }) }));
|
|
27
|
+
const checkSvg = ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 448 512", style: svgStyle, children: (0, jsx_runtime_1.jsx)("path", { fill: fillColor, d: "M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z" }) }));
|
|
28
|
+
const onPointerEnter = (0, react_1.useCallback)(() => {
|
|
29
|
+
setHovered(true);
|
|
30
|
+
}, []);
|
|
31
|
+
const onPointerLeave = (0, react_1.useCallback)(() => {
|
|
32
|
+
setHovered(false);
|
|
33
|
+
}, []);
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
if (!copied) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const handleClear = () => {
|
|
39
|
+
setCopied(false);
|
|
40
|
+
setHovered(false);
|
|
41
|
+
};
|
|
42
|
+
const to = setTimeout(() => handleClear(), 2000);
|
|
43
|
+
return () => clearTimeout(to);
|
|
44
|
+
}, [copied]);
|
|
45
|
+
return copied ? ((0, jsx_runtime_1.jsx)("span", { style: copiedStyle, children: checkSvg })) : ((0, jsx_runtime_1.jsx)("button", { type: "button", onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, style: {
|
|
14
46
|
width: '30px',
|
|
15
47
|
height: '30px',
|
|
16
48
|
border: 'none',
|
|
17
49
|
cursor: 'pointer',
|
|
18
50
|
}, onClick: () => {
|
|
19
51
|
navigator.clipboard.writeText(valueToCopy);
|
|
20
|
-
|
|
52
|
+
setCopied(true);
|
|
53
|
+
}, children: clipboardIcon }));
|
|
21
54
|
};
|
|
22
55
|
exports.CliCopyButton = CliCopyButton;
|
|
@@ -29,12 +29,13 @@ const InfoTooltip = ({ children, arrowDirection }) => {
|
|
|
29
29
|
border: '0.5px solid ' + colors_1.BORDER_COLOR,
|
|
30
30
|
maxHeight: 200,
|
|
31
31
|
overflow: 'auto',
|
|
32
|
+
borderRadius: '4px',
|
|
32
33
|
};
|
|
33
34
|
}, [arrowDirection]);
|
|
34
35
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
35
36
|
display: 'flex',
|
|
36
37
|
flexDirection: arrowDirection === 'up' ? 'column-reverse' : 'column',
|
|
37
38
|
alignItems: 'flex-start',
|
|
38
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: container, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: children }), arrowDirection === 'down' ? ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 14 7", style: arrowDown, children: (0, jsx_runtime_1.jsx)("path", { d: `M 14 0 L 7 7 L 0 0`, fill: colors_1.
|
|
39
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: container, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: children }), arrowDirection === 'down' ? ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 14 7", style: arrowDown, children: (0, jsx_runtime_1.jsx)("path", { d: `M 14 0 L 7 7 L 0 0`, fill: colors_1.INPUT_BACKGROUND, strokeLinecap: "butt", stroke: colors_1.BORDER_COLOR, strokeWidth: 0.5 }) })) : null, arrowDirection === 'up' ? ((0, jsx_runtime_1.jsx)("svg", { viewBox: "0 0 14 7", style: arrowUp, children: (0, jsx_runtime_1.jsx)("path", { d: `M 0 7 L 7 0 L 14 7`, fill: colors_1.INPUT_BACKGROUND, strokeLinecap: "butt", stroke: colors_1.BORDER_COLOR, strokeWidth: 0.5 }) })) : null] }));
|
|
39
40
|
};
|
|
40
41
|
exports.InfoTooltip = InfoTooltip;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OptionExplainer = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const colors_1 = require("../../helpers/colors");
|
|
5
6
|
const layout_1 = require("../layout");
|
|
6
7
|
const MenuDivider_1 = require("../Menu/MenuDivider");
|
|
7
8
|
const CliCopyButton_1 = require("./CliCopyButton");
|
|
@@ -9,10 +10,11 @@ const container = {
|
|
|
9
10
|
fontSize: 14,
|
|
10
11
|
paddingTop: 10,
|
|
11
12
|
paddingBottom: 10,
|
|
13
|
+
backgroundColor: colors_1.INPUT_BACKGROUND,
|
|
12
14
|
};
|
|
13
15
|
const padding = {
|
|
14
|
-
paddingLeft:
|
|
15
|
-
paddingRight:
|
|
16
|
+
paddingLeft: 20,
|
|
17
|
+
paddingRight: 20,
|
|
16
18
|
};
|
|
17
19
|
const title = {
|
|
18
20
|
fontSize: 14,
|
|
@@ -39,7 +41,15 @@ const infoRowLabel = {
|
|
|
39
41
|
fontSize: 14,
|
|
40
42
|
color: 'white',
|
|
41
43
|
};
|
|
44
|
+
const flexSpacer = {
|
|
45
|
+
display: 'flex',
|
|
46
|
+
flex: 1,
|
|
47
|
+
};
|
|
48
|
+
const copyWrapper = {
|
|
49
|
+
display: 'flex',
|
|
50
|
+
justifyContent: 'flex-end',
|
|
51
|
+
};
|
|
42
52
|
const OptionExplainer = ({ option }) => {
|
|
43
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: container, className: "__remotion-info-button-container", children: [(0, jsx_runtime_1.jsxs)("div", { style: padding, children: [(0, jsx_runtime_1.
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: container, className: "__remotion-info-button-container", children: [(0, jsx_runtime_1.jsxs)("div", { style: padding, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("strong", { style: title, children: option.name }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)("a", { style: link, href: option.docLink, target: "_blank", children: "Docs" })] }), (0, jsx_runtime_1.jsx)("div", { style: description, children: option.description })] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 0.5, block: true }), (0, jsx_runtime_1.jsx)(MenuDivider_1.MenuDivider, {}), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 0.5, block: true }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: infoRow, children: [(0, jsx_runtime_1.jsx)("div", { style: infoRowLabel, children: "CLI flag" }), (0, jsx_runtime_1.jsx)("div", { style: flexSpacer }), (0, jsx_runtime_1.jsx)("code", { children: option.cliFlag }), (0, jsx_runtime_1.jsx)("div", { style: copyWrapper, children: (0, jsx_runtime_1.jsx)(CliCopyButton_1.CliCopyButton, { valueToCopy: option.cliFlag }) })] }), (0, jsx_runtime_1.jsxs)("div", { style: infoRow, children: [(0, jsx_runtime_1.jsx)("div", { style: infoRowLabel, children: "Node.JS option" }), (0, jsx_runtime_1.jsx)("div", { style: flexSpacer }), (0, jsx_runtime_1.jsx)("code", { children: option.ssrName }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 3.75 })] }), (0, jsx_runtime_1.jsx)("div", { style: infoRow })] })] }));
|
|
44
54
|
};
|
|
45
55
|
exports.OptionExplainer = OptionExplainer;
|
|
@@ -37,7 +37,8 @@ const actions_1 = require("../RenderQueue/actions");
|
|
|
37
37
|
const SegmentedControl_1 = require("../SegmentedControl");
|
|
38
38
|
const get_render_modal_warnings_1 = require("./get-render-modal-warnings");
|
|
39
39
|
const RenderModalJSONPropsEditor_1 = require("./RenderModalJSONPropsEditor");
|
|
40
|
-
const
|
|
40
|
+
const extract_enum_json_paths_1 = require("./SchemaEditor/extract-enum-json-paths");
|
|
41
|
+
const input_props_serialization_1 = require("./SchemaEditor/input-props-serialization");
|
|
41
42
|
const SchemaEditor_1 = require("./SchemaEditor/SchemaEditor");
|
|
42
43
|
const SchemaErrorMessages_1 = require("./SchemaEditor/SchemaErrorMessages");
|
|
43
44
|
const WarningIndicatorButton_1 = require("./WarningIndicatorButton");
|
|
@@ -77,7 +78,7 @@ const tabWrapper = {
|
|
|
77
78
|
const persistanceKey = 'remotion.show-render-modalwarning';
|
|
78
79
|
const parseJSON = (str) => {
|
|
79
80
|
try {
|
|
80
|
-
const value = (0,
|
|
81
|
+
const value = (0, input_props_serialization_1.deserializeJSONWithCustomFields)(str);
|
|
81
82
|
return { str, value, validJSON: true };
|
|
82
83
|
}
|
|
83
84
|
catch (e) {
|
|
@@ -105,7 +106,11 @@ const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayS
|
|
|
105
106
|
return null;
|
|
106
107
|
}
|
|
107
108
|
const value = inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
108
|
-
return (0,
|
|
109
|
+
return (0, input_props_serialization_1.serializeJSONWithDate)({
|
|
110
|
+
data: value,
|
|
111
|
+
indent: 2,
|
|
112
|
+
staticBase: window.remotion_staticBase,
|
|
113
|
+
});
|
|
109
114
|
}, [inJSONEditor, inputProps]);
|
|
110
115
|
const cliProps = (0, remotion_1.getInputProps)();
|
|
111
116
|
const [canSaveDefaultProps, setCanSaveDefaultProps] = (0, react_1.useState)({
|
|
@@ -192,25 +197,34 @@ const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayS
|
|
|
192
197
|
setMode('schema');
|
|
193
198
|
}, []);
|
|
194
199
|
const onUpdate = (0, react_1.useCallback)(() => {
|
|
200
|
+
if (schema === 'no-zod' || z === null) {
|
|
201
|
+
(0, NotificationCenter_1.sendErrorNotification)('Cannot update default props: No Zod schema');
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
195
204
|
setValBeforeSafe(inputProps);
|
|
196
|
-
(0, actions_1.updateDefaultProps)(composition.id, inputProps);
|
|
197
|
-
}, [composition.id, inputProps]);
|
|
205
|
+
(0, actions_1.updateDefaultProps)(composition.id, inputProps, (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, []));
|
|
206
|
+
}, [composition.id, inputProps, schema, z]);
|
|
198
207
|
(0, react_1.useEffect)(() => {
|
|
199
208
|
setSaving(false);
|
|
200
209
|
}, [fastRefreshes]);
|
|
201
210
|
const onSave = (0, react_1.useCallback)((updater) => {
|
|
211
|
+
if (schema === 'no-zod' || z === null) {
|
|
212
|
+
(0, NotificationCenter_1.sendErrorNotification)('Cannot update default props: No Zod schema');
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
202
215
|
setSaving(true);
|
|
203
|
-
(0, actions_1.updateDefaultProps)(composition.id, updater(composition.defaultProps)).catch((err) => {
|
|
216
|
+
(0, actions_1.updateDefaultProps)(composition.id, updater(composition.defaultProps), (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, [])).catch((err) => {
|
|
204
217
|
(0, NotificationCenter_1.sendErrorNotification)(`Cannot update default props: ${err.message}`);
|
|
205
218
|
setSaving(false);
|
|
206
219
|
});
|
|
207
|
-
}, [composition.defaultProps, composition.id]);
|
|
220
|
+
}, [composition.defaultProps, composition.id, schema, z]);
|
|
208
221
|
const connectionStatus = (0, react_1.useContext)(client_id_1.PreviewServerConnectionCtx).type;
|
|
209
222
|
const warnings = (0, react_1.useMemo)(() => {
|
|
210
223
|
return (0, get_render_modal_warnings_1.getRenderModalWarnings)({
|
|
211
224
|
canSaveDefaultProps,
|
|
212
225
|
cliProps,
|
|
213
226
|
isCustomDateUsed: serializedJSON ? serializedJSON.customDateUsed : false,
|
|
227
|
+
customFileUsed: serializedJSON ? serializedJSON.customFileUsed : false,
|
|
214
228
|
inJSONEditor,
|
|
215
229
|
propsEditType,
|
|
216
230
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { State } from './RenderModalData';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SerializedJSONWithCustomFields } from './SchemaEditor/input-props-serialization';
|
|
4
4
|
export declare type EditType = 'inputProps' | 'defaultProps';
|
|
5
5
|
export declare const RenderModalJSONPropsEditor: React.FC<{
|
|
6
6
|
value: unknown;
|
|
@@ -11,5 +11,5 @@ export declare const RenderModalJSONPropsEditor: React.FC<{
|
|
|
11
11
|
valBeforeSafe: unknown;
|
|
12
12
|
showSaveButton: boolean;
|
|
13
13
|
parseJSON: (str: string) => State;
|
|
14
|
-
serializedJSON:
|
|
14
|
+
serializedJSON: SerializedJSONWithCustomFields | null;
|
|
15
15
|
}>;
|
|
@@ -49,6 +49,6 @@ const RenderModalPicture = ({ renderMode, scale, setScale, pixelFormat, setPixel
|
|
|
49
49
|
const onTargetVideoBitrateChanged = (0, react_1.useCallback)((e) => {
|
|
50
50
|
setCustomTargetVideoBitrateValue(e.target.value);
|
|
51
51
|
}, [setCustomTargetVideoBitrateValue]);
|
|
52
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Image Format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: false }) })] })) : null, renderMode === 'video' && videoImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'still' && stillImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'video' && qualityControlType !== null ? ((0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {})) : null, shouldDisplayQualityControlPicker && renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Quality control" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: qualityControlOptions, needsWrapping: true }) })] })) : null, qualityControlType === 'crf' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(CrfSetting_1.CrfSetting, { crf: crf, min: minCrf, max: maxCrf, setCrf: setCrf, option: client_1.BrowserSafeApis.options.crfOption })) : null, qualityControlType === 'bitrate' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.
|
|
52
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Image Format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: imageFormatOptions, needsWrapping: false }) })] })) : null, renderMode === 'video' && videoImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'still' && stillImageFormat === 'jpeg' && ((0, jsx_runtime_1.jsx)(JpegQualitySetting_1.JpegQualitySetting, { jpegQuality: jpegQuality, setJpegQuality: setJpegQuality })), renderMode === 'video' && qualityControlType !== null ? ((0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {})) : null, shouldDisplayQualityControlPicker && renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Quality control" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(SegmentedControl_1.SegmentedControl, { items: qualityControlOptions, needsWrapping: true }) })] })) : null, qualityControlType === 'crf' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsx)(CrfSetting_1.CrfSetting, { crf: crf, min: minCrf, max: maxCrf, setCrf: setCrf, option: client_1.BrowserSafeApis.options.crfOption })) : null, qualityControlType === 'bitrate' && renderMode !== 'still' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsxs)("div", { style: layout_1.label, children: ["Target video bitrate", (0, jsx_runtime_1.jsx)(InfoBubble_1.InfoBubble, { title: "Learn more about this option", children: (0, jsx_runtime_1.jsx)(OptionExplainer_1.OptionExplainer, { option: client_1.BrowserSafeApis.options.videoBitrate }) })] }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { style: layout_1.input, value: customTargetVideoBitrate, onChange: onTargetVideoBitrateChanged, status: "ok", rightAlign: true }) }) })] })) : null, renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, (0, jsx_runtime_1.jsx)(ScaleSetting_1.ScaleSetting, { scale: scale, setScale: setScale }), renderMode === 'video' ? (0, jsx_runtime_1.jsx)(RenderModalHr_1.RenderModalHr, {}) : null, renderMode === 'video' ? ((0, jsx_runtime_1.jsxs)("div", { style: layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)("div", { style: layout_1.label, children: "Pixel format" }), (0, jsx_runtime_1.jsx)("div", { style: layout_1.rightRow, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: pixelFormatOptions, selectedId: pixelFormat, title: "Pixel Format" }) })] })) : null] }));
|
|
53
53
|
};
|
|
54
54
|
exports.RenderModalPicture = RenderModalPicture;
|
|
@@ -54,6 +54,6 @@ const InvalidDefaultProps = ({ zodValidationResult }) => {
|
|
|
54
54
|
};
|
|
55
55
|
exports.InvalidDefaultProps = InvalidDefaultProps;
|
|
56
56
|
const InvalidSchema = ({ zodValidationResult, reset }) => {
|
|
57
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "The data does not satisfy the schema:" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "Fix the schema using the JSON editor." }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Alternatively, reset the data to the
|
|
57
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: errorContainer, children: [(0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "The data does not satisfy the schema:" }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ZodErrorMessages_1.ZodErrorMessages, { zodValidationResult: zodValidationResult }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: errorExplanation, children: "Fix the schema using the JSON editor." }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsxs)("div", { style: errorExplanation, children: ["Alternatively, reset the data to the", ' ', (0, jsx_runtime_1.jsx)("code", { style: codeSnippet, children: "defaultProps" }), " that you have defined."] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: reset, children: "Reset props" })] }));
|
|
58
58
|
};
|
|
59
59
|
exports.InvalidSchema = InvalidSchema;
|
|
@@ -1,13 +1,14 @@
|
|
|
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);
|
|
@@ -73,7 +73,7 @@ const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defa
|
|
|
73
73
|
onChange((oldV) => {
|
|
74
74
|
return [...oldV, (0, create_zod_values_1.createZodValues)(def.type, z, zodTypes)];
|
|
75
75
|
}, true);
|
|
76
|
-
}, [def.type, onChange, z]);
|
|
76
|
+
}, [def.type, onChange, z, zodTypes]);
|
|
77
77
|
return ((0, jsx_runtime_1.jsx)("div", { style: style, children: (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsxs)(Element, { style: fieldset, children: [isRoot ? null : ((0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaFieldsetLabel, { jsonPath: jsonPath, onRemove: onRemove })), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: localValue.value.map((child, i) => {
|
|
78
78
|
var _a;
|
|
79
79
|
return ((0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor
|
|
@@ -1,9 +1,10 @@
|
|
|
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
10
|
onSave: (updater: (oldNum: unknown) => boolean) => void;
|
|
@@ -11,7 +11,7 @@ const fullWidth = {
|
|
|
11
11
|
};
|
|
12
12
|
const ZodBooleanEditor = ({ jsonPath, value, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, }) => {
|
|
13
13
|
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
14
|
-
setValue(newValue);
|
|
14
|
+
setValue(() => newValue);
|
|
15
15
|
}, [setValue]);
|
|
16
16
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
17
17
|
onValueChange(e.target.checked);
|
|
@@ -1,12 +1,13 @@
|
|
|
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
|
+
setValue: UpdaterFunction<string>;
|
|
10
11
|
onSave: (updater: (oldNum: unknown) => string) => void;
|
|
11
12
|
onRemove: null | (() => void);
|
|
12
13
|
compact: boolean;
|
|
@@ -30,15 +30,15 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
30
30
|
zodValidation: schema.safeParse(value),
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
33
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
34
34
|
const safeParse = schema.safeParse(newValue);
|
|
35
35
|
const newLocalState = {
|
|
36
36
|
value: newValue,
|
|
37
37
|
zodValidation: safeParse,
|
|
38
38
|
};
|
|
39
39
|
setLocalValue(newLocalState);
|
|
40
|
-
if (safeParse.success) {
|
|
41
|
-
setValue(newValue);
|
|
40
|
+
if (safeParse.success || forceApply) {
|
|
41
|
+
setValue(() => newValue);
|
|
42
42
|
}
|
|
43
43
|
}, [schema, setValue]);
|
|
44
44
|
const { a, b, g, r } = localValue.zodValidation.success
|
|
@@ -53,7 +53,7 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
53
53
|
};
|
|
54
54
|
setLocalValue(newLocalState);
|
|
55
55
|
if (safeParse.success) {
|
|
56
|
-
setValue(newColor);
|
|
56
|
+
setValue(() => newColor);
|
|
57
57
|
}
|
|
58
58
|
}, [a, schema, setValue, zodTypes]);
|
|
59
59
|
const onTextChange = (0, react_1.useCallback)((e) => {
|
|
@@ -65,11 +65,11 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
65
65
|
};
|
|
66
66
|
setLocalValue(newLocalState);
|
|
67
67
|
if (safeParse.success) {
|
|
68
|
-
setValue(newValue);
|
|
68
|
+
setValue(() => newValue);
|
|
69
69
|
}
|
|
70
70
|
}, [schema, setValue]);
|
|
71
71
|
const reset = (0, react_1.useCallback)(() => {
|
|
72
|
-
onValueChange(defaultValue);
|
|
72
|
+
onValueChange(defaultValue, true);
|
|
73
73
|
}, [defaultValue, onValueChange]);
|
|
74
74
|
const save = (0, react_1.useCallback)(() => {
|
|
75
75
|
onSave(() => value);
|
|
@@ -94,7 +94,7 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
94
94
|
};
|
|
95
95
|
setLocalValue(newLocalState);
|
|
96
96
|
if (safeParse.success) {
|
|
97
|
-
setValue(newColor);
|
|
97
|
+
setValue(() => newColor);
|
|
98
98
|
}
|
|
99
99
|
}, [localValue.value, schema, setValue, zodTypes]);
|
|
100
100
|
const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
|
|
@@ -106,7 +106,7 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
106
106
|
};
|
|
107
107
|
setLocalValue(newLocalState);
|
|
108
108
|
if (safeParse.success) {
|
|
109
|
-
setValue(newColor);
|
|
109
|
+
setValue(() => newColor);
|
|
110
110
|
}
|
|
111
111
|
}, [localValue.value, schema, setValue, zodTypes]);
|
|
112
112
|
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: colorPicker, children: (0, jsx_runtime_1.jsx)(RemInputTypeColor_1.RemInputTypeColor, { type: "color", style: {
|
|
@@ -1,12 +1,13 @@
|
|
|
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
|
+
setValue: UpdaterFunction<Date>;
|
|
10
11
|
onSave: (updater: (oldNum: unknown) => Date) => void;
|
|
11
12
|
onRemove: null | (() => void);
|
|
12
13
|
compact: boolean;
|
|
@@ -50,23 +50,23 @@ const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue
|
|
|
50
50
|
zodValidation: schema.safeParse(value),
|
|
51
51
|
};
|
|
52
52
|
});
|
|
53
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
53
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
54
54
|
const safeParse = schema.safeParse(newValue);
|
|
55
55
|
const newLocalState = {
|
|
56
56
|
value: newValue,
|
|
57
57
|
zodValidation: safeParse,
|
|
58
58
|
};
|
|
59
59
|
setLocalValue(newLocalState);
|
|
60
|
-
if (safeParse.success) {
|
|
61
|
-
setValue(newValue);
|
|
60
|
+
if (safeParse.success || forceApply) {
|
|
61
|
+
setValue(() => newValue);
|
|
62
62
|
}
|
|
63
63
|
}, [schema, setValue]);
|
|
64
64
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
65
65
|
// React does not support e.target.valueAsDate :(
|
|
66
|
-
onValueChange(new Date(e.target.value));
|
|
66
|
+
onValueChange(new Date(e.target.value), false);
|
|
67
67
|
}, [onValueChange]);
|
|
68
68
|
const reset = (0, react_1.useCallback)(() => {
|
|
69
|
-
onValueChange(defaultValue);
|
|
69
|
+
onValueChange(defaultValue, true);
|
|
70
70
|
}, [defaultValue, onValueChange]);
|
|
71
71
|
const save = (0, react_1.useCallback)(() => {
|
|
72
72
|
onSave(() => value);
|
|
@@ -5,7 +5,7 @@ export declare const ZodEffectEditor: React.FC<{
|
|
|
5
5
|
schema: z.ZodTypeAny;
|
|
6
6
|
jsonPath: JSONPath;
|
|
7
7
|
value: unknown;
|
|
8
|
-
setValue: (
|
|
8
|
+
setValue: (updater: (oldState: unknown) => unknown) => void;
|
|
9
9
|
compact: boolean;
|
|
10
10
|
defaultValue: unknown;
|
|
11
11
|
onSave: (updater: (oldState: unknown) => unknown) => void;
|
|
@@ -26,8 +26,9 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
|
|
|
26
26
|
if (typeName !== z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
27
27
|
throw new Error('expected effect');
|
|
28
28
|
}
|
|
29
|
-
const onChange = (0, react_1.useCallback)((
|
|
30
|
-
setLocalValue(() => {
|
|
29
|
+
const onChange = (0, react_1.useCallback)((updater) => {
|
|
30
|
+
setLocalValue((oldLocalState) => {
|
|
31
|
+
const newValue = updater(oldLocalState.value);
|
|
31
32
|
const safeParse = schema.safeParse(newValue);
|
|
32
33
|
if (safeParse.success) {
|
|
33
34
|
updateValue(() => newValue);
|
|
@@ -1,13 +1,14 @@
|
|
|
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);
|
|
@@ -31,11 +31,11 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
31
31
|
throw new Error('expected enum');
|
|
32
32
|
}
|
|
33
33
|
const isRoot = jsonPath.length === 0;
|
|
34
|
-
const onChange = (0, react_1.useCallback)((updater) => {
|
|
34
|
+
const onChange = (0, react_1.useCallback)((updater, forceApply) => {
|
|
35
35
|
setLocalValue((oldLocalState) => {
|
|
36
36
|
const newValue = updater(oldLocalState.value);
|
|
37
37
|
const safeParse = schema.safeParse(newValue);
|
|
38
|
-
if (safeParse.success) {
|
|
38
|
+
if (safeParse.success || forceApply) {
|
|
39
39
|
updateValue(updater);
|
|
40
40
|
}
|
|
41
41
|
return {
|
|
@@ -45,7 +45,7 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
45
45
|
});
|
|
46
46
|
}, [schema, updateValue]);
|
|
47
47
|
const reset = (0, react_1.useCallback)(() => {
|
|
48
|
-
onChange(() => defaultValue);
|
|
48
|
+
onChange(() => defaultValue, true);
|
|
49
49
|
}, [defaultValue, onChange]);
|
|
50
50
|
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
51
51
|
return def.values.map((option) => {
|
|
@@ -56,7 +56,7 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
56
56
|
keyHint: null,
|
|
57
57
|
leftItem: option === value ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
|
|
58
58
|
onClick: (id) => {
|
|
59
|
-
onChange(() => id);
|
|
59
|
+
onChange(() => id, false);
|
|
60
60
|
},
|
|
61
61
|
quickSwitcherLabel: null,
|
|
62
62
|
subMenu: null,
|
|
@@ -8,7 +8,7 @@ export declare const ZodNullableEditor: React.FC<{
|
|
|
8
8
|
value: unknown;
|
|
9
9
|
defaultValue: unknown;
|
|
10
10
|
schema: z.ZodTypeAny;
|
|
11
|
-
setValue:
|
|
11
|
+
setValue: (updater: (oldNum: unknown) => unknown) => void;
|
|
12
12
|
onSave: (updater: (oldNum: unknown) => unknown) => void;
|
|
13
13
|
onRemove: null | (() => void);
|
|
14
14
|
saving: boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
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 ZodNumberEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: number;
|
|
8
|
-
setValue:
|
|
9
|
+
setValue: UpdaterFunction<number>;
|
|
9
10
|
compact: boolean;
|
|
10
11
|
defaultValue: number;
|
|
11
12
|
onSave: (updater: (oldNum: unknown) => number) => void;
|
|
@@ -62,27 +62,30 @@ const ZodNumberEditor = ({ jsonPath, value, schema, setValue, onSave, compact, d
|
|
|
62
62
|
};
|
|
63
63
|
setLocalValue(newLocalState);
|
|
64
64
|
if (safeParse.success) {
|
|
65
|
-
setValue(Number(newValue));
|
|
65
|
+
setValue(() => Number(newValue));
|
|
66
66
|
}
|
|
67
67
|
}, [schema, setValue]);
|
|
68
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
68
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
69
69
|
const safeParse = schema.safeParse(newValue);
|
|
70
70
|
const newLocalState = {
|
|
71
71
|
value: String(newValue),
|
|
72
72
|
zodValidation: safeParse,
|
|
73
73
|
};
|
|
74
74
|
setLocalValue(newLocalState);
|
|
75
|
-
if (safeParse.success) {
|
|
76
|
-
setValue(newValue);
|
|
75
|
+
if (safeParse.success || forceApply) {
|
|
76
|
+
setValue(() => newValue);
|
|
77
77
|
}
|
|
78
78
|
}, [schema, setValue]);
|
|
79
|
+
const onNumberChange = (0, react_1.useCallback)((newValue) => {
|
|
80
|
+
onValueChange(newValue, false);
|
|
81
|
+
}, [onValueChange]);
|
|
79
82
|
const isDefault = value === defaultValue;
|
|
80
83
|
const reset = (0, react_1.useCallback)(() => {
|
|
81
|
-
onValueChange(defaultValue);
|
|
84
|
+
onValueChange(defaultValue, true);
|
|
82
85
|
}, [defaultValue, onValueChange]);
|
|
83
86
|
const save = (0, react_1.useCallback)(() => {
|
|
84
87
|
onSave(() => value);
|
|
85
88
|
}, [onSave, value]);
|
|
86
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefault, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: 'number', value: localValue.value, style: fullWidth, status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onTextChange: onChange, onValueChange:
|
|
89
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: isDefault, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { type: 'number', value: localValue.value, style: fullWidth, status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onTextChange: onChange, onValueChange: onNumberChange, min: getMinValue(schema), max: getMaxValue(schema), step: getStep(schema), rightAlign: false }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
|
|
87
90
|
};
|
|
88
91
|
exports.ZodNumberEditor = ZodNumberEditor;
|
|
@@ -6,7 +6,7 @@ export declare const ZodObjectEditor: React.FC<{
|
|
|
6
6
|
jsonPath: JSONPath;
|
|
7
7
|
value: unknown;
|
|
8
8
|
defaultValue: unknown;
|
|
9
|
-
setValue:
|
|
9
|
+
setValue: (updater: (oldState: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
10
10
|
compact: boolean;
|
|
11
11
|
onSave: (updater: (oldVal: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
12
12
|
showSaveButton: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ZodOptionalEditor: React.FC<{
|
|
|
8
8
|
value: unknown;
|
|
9
9
|
defaultValue: unknown;
|
|
10
10
|
schema: z.ZodTypeAny;
|
|
11
|
-
setValue:
|
|
11
|
+
setValue: (updater: (oldNum: unknown) => unknown) => void;
|
|
12
12
|
onSave: (updater: (oldNum: unknown) => unknown) => void;
|
|
13
13
|
onRemove: null | (() => void);
|
|
14
14
|
saving: boolean;
|
|
@@ -8,7 +8,7 @@ export declare const ZodOrNullishEditor: React.FC<{
|
|
|
8
8
|
value: unknown;
|
|
9
9
|
defaultValue: unknown;
|
|
10
10
|
schema: z.ZodTypeAny;
|
|
11
|
-
setValue:
|
|
11
|
+
setValue: (updater: (oldState: unknown) => unknown) => void;
|
|
12
12
|
onSave: (updater: (oldNum: unknown) => unknown) => void;
|
|
13
13
|
onRemove: null | (() => void);
|
|
14
14
|
nullishValue: null | undefined;
|