@remotion/cli 4.0.0-alpha6 → 4.0.0-alpha8
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/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/compositions.js +1 -0
- package/dist/config/log.d.ts +1 -3
- package/dist/config/log.js +2 -9
- package/dist/download-progress.d.ts +1 -1
- package/dist/download-progress.js +1 -5
- package/dist/editor/components/MenuBuildIndicator.js +20 -1
- package/dist/editor/components/Modals.js +1 -1
- 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/OpenEditorButton.d.ts +2 -0
- package/dist/editor/components/OpenEditorButton.js +52 -0
- package/dist/editor/components/RenderButton.js +5 -1
- package/dist/editor/components/RenderModal/CliCopyButton.js +7 -6
- package/dist/editor/components/RenderModal/OptionExplainer.js +1 -0
- package/dist/editor/components/RenderModal/RenderModal.d.ts +2 -0
- package/dist/editor/components/RenderModal/RenderModal.js +3 -3
- package/dist/editor/components/RenderModal/RenderModalData.js +55 -27
- package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +2 -2
- 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 +14 -0
- package/dist/editor/components/RenderModal/SchemaEditor/input-props-serialization.js +42 -0
- package/dist/editor/components/RenderModal/get-render-modal-warnings.d.ts +6 -2
- package/dist/editor/components/RenderModal/get-render-modal-warnings.js +29 -3
- package/dist/editor/components/RenderQueue/actions.d.ts +2 -1
- package/dist/editor/components/RenderQueue/actions.js +8 -4
- package/dist/editor/components/SidebarRenderButton.js +2 -0
- package/dist/editor/components/Spinner.d.ts +4 -0
- package/dist/editor/components/Spinner.js +42 -0
- package/dist/editor/components/Timeline/TimelineSequence.js +6 -4
- package/dist/editor/helpers/calculate-timeline.js +1 -1
- package/dist/editor/state/modals.d.ts +2 -0
- package/dist/ffmpeg.js +6 -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 -5
- 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/dev-middleware/setup-hooks.js +2 -2
- package/dist/preview-server/render-queue/job.d.ts +2 -0
- package/dist/preview-server/render-queue/make-retry-payload.js +4 -0
- package/dist/preview-server/render-queue/queue.js +2 -1
- package/dist/preview-server/routes/can-update-default-props.js +1 -0
- package/dist/preview-server/routes/update-default-props.js +4 -3
- 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 +46 -19
- package/dist/render-flows/still.js +17 -12
- 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/user-passed-output-location.js +7 -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/cloudrun-command.d.ts +0 -1
- package/dist/cloudrun-command.js +0 -27
- 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
|
@@ -11,6 +11,7 @@ const get_default_video_contexts_1 = require("../../preview-server/render-queue/
|
|
|
11
11
|
const client_id_1 = require("../helpers/client-id");
|
|
12
12
|
const use_keybinding_1 = require("../helpers/use-keybinding");
|
|
13
13
|
const render_1 = require("../icons/render");
|
|
14
|
+
const in_out_1 = require("../state/in-out");
|
|
14
15
|
const modals_1 = require("../state/modals");
|
|
15
16
|
const layout_1 = require("./layout");
|
|
16
17
|
const button = {
|
|
@@ -23,6 +24,7 @@ const label = {
|
|
|
23
24
|
fontSize: 14,
|
|
24
25
|
};
|
|
25
26
|
const RenderButton = () => {
|
|
27
|
+
const { inFrame, outFrame } = (0, in_out_1.useTimelineInOutFramePosition)();
|
|
26
28
|
const { setSelectedModal } = (0, react_1.useContext)(modals_1.ModalsContext);
|
|
27
29
|
const { type } = (0, react_1.useContext)(client_id_1.PreviewServerConnectionCtx);
|
|
28
30
|
const connectionStatus = (0, react_1.useContext)(client_id_1.PreviewServerConnectionCtx).type;
|
|
@@ -93,8 +95,10 @@ const RenderButton = () => {
|
|
|
93
95
|
initialHeadless: defaults.headless,
|
|
94
96
|
initialIgnoreCertificateErrors: defaults.ignoreCertificateErrors,
|
|
95
97
|
defaultProps: (_c = props[video.id]) !== null && _c !== void 0 ? _c : video.defaultProps,
|
|
98
|
+
inFrameMark: inFrame,
|
|
99
|
+
outFrameMark: outFrame,
|
|
96
100
|
});
|
|
97
|
-
}, [video, setSelectedModal, frame, props]);
|
|
101
|
+
}, [video, setSelectedModal, frame, props, inFrame, outFrame]);
|
|
98
102
|
if (!video) {
|
|
99
103
|
return null;
|
|
100
104
|
}
|
|
@@ -17,6 +17,12 @@ const copiedStyle = {
|
|
|
17
17
|
alignItems: 'center',
|
|
18
18
|
justifyContent: 'center',
|
|
19
19
|
};
|
|
20
|
+
const buttonStyle = {
|
|
21
|
+
width: '30px',
|
|
22
|
+
height: '30px',
|
|
23
|
+
border: 'none',
|
|
24
|
+
cursor: 'pointer',
|
|
25
|
+
};
|
|
20
26
|
const CliCopyButton = ({ valueToCopy, }) => {
|
|
21
27
|
const [copied, setCopied] = (0, react_1.useState)(false);
|
|
22
28
|
const [hovered, setHovered] = (0, react_1.useState)(false);
|
|
@@ -42,12 +48,7 @@ const CliCopyButton = ({ valueToCopy, }) => {
|
|
|
42
48
|
const to = setTimeout(() => handleClear(), 2000);
|
|
43
49
|
return () => clearTimeout(to);
|
|
44
50
|
}, [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: {
|
|
46
|
-
width: '30px',
|
|
47
|
-
height: '30px',
|
|
48
|
-
border: 'none',
|
|
49
|
-
cursor: 'pointer',
|
|
50
|
-
}, onClick: () => {
|
|
51
|
+
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: buttonStyle, onClick: () => {
|
|
51
52
|
navigator.clipboard.writeText(valueToCopy);
|
|
52
53
|
setCopied(true);
|
|
53
54
|
}, children: clipboardIcon }));
|
|
@@ -108,7 +108,7 @@ const outer = {
|
|
|
108
108
|
height: (0, ModalContainer_1.getMaxModalHeight)(640),
|
|
109
109
|
overflow: 'hidden',
|
|
110
110
|
};
|
|
111
|
-
const RenderModal = ({ compositionId, initialFrame, initialVideoImageFormat, initialStillImageFormat, initialJpegQuality, initialScale, initialVerbose, initialOutName, initialRenderType, initialVideoCodecForAudioTab, initialVideoCodecForVideoTab, initialConcurrency, maxConcurrency, minConcurrency, initialMuted, initialEnforceAudioTrack, initialProResProfile, initialPixelFormat, initialVideoBitrate, initialAudioBitrate, initialEveryNthFrame, initialNumberOfGifLoops, initialDelayRenderTimeout, initialAudioCodec, initialEnvVariables, initialDisableWebSecurity, initialGl, initialHeadless, initialIgnoreCertificateErrors, defaultProps, }) => {
|
|
111
|
+
const RenderModal = ({ compositionId, initialFrame, initialVideoImageFormat, initialStillImageFormat, initialJpegQuality, initialScale, initialVerbose, initialOutName, initialRenderType, initialVideoCodecForAudioTab, initialVideoCodecForVideoTab, initialConcurrency, maxConcurrency, minConcurrency, initialMuted, initialEnforceAudioTrack, initialProResProfile, initialPixelFormat, initialVideoBitrate, initialAudioBitrate, initialEveryNthFrame, initialNumberOfGifLoops, initialDelayRenderTimeout, initialAudioCodec, initialEnvVariables, initialDisableWebSecurity, initialGl, initialHeadless, initialIgnoreCertificateErrors, defaultProps, inFrameMark, outFrameMark, }) => {
|
|
112
112
|
const { setSelectedModal } = (0, react_1.useContext)(modals_1.ModalsContext);
|
|
113
113
|
const onQuit = (0, react_1.useCallback)(() => {
|
|
114
114
|
setSelectedModal(null);
|
|
@@ -145,8 +145,8 @@ const RenderModal = ({ compositionId, initialFrame, initialVideoImageFormat, ini
|
|
|
145
145
|
};
|
|
146
146
|
}, [headless, disableWebSecurity, ignoreCertificateErrors, openGlOption]);
|
|
147
147
|
const [outName, setOutName] = (0, react_1.useState)(() => initialOutName);
|
|
148
|
-
const [endFrameOrNull, setEndFrame] = (0, react_1.useState)(() => null);
|
|
149
|
-
const [startFrameOrNull, setStartFrame] = (0, react_1.useState)(() => null);
|
|
148
|
+
const [endFrameOrNull, setEndFrame] = (0, react_1.useState)(() => outFrameMark !== null && outFrameMark !== void 0 ? outFrameMark : null);
|
|
149
|
+
const [startFrameOrNull, setStartFrame] = (0, react_1.useState)(() => inFrameMark !== null && inFrameMark !== void 0 ? inFrameMark : null);
|
|
150
150
|
const [proResProfileSetting, setProResProfile] = (0, react_1.useState)(() => initialProResProfile);
|
|
151
151
|
const [pixelFormat, setPixelFormat] = (0, react_1.useState)(() => initialPixelFormat);
|
|
152
152
|
const [preferredQualityControlType, setQualityControl] = (0, react_1.useState)(() => initialVideoBitrate === null ? 'crf' : 'bitrate');
|
|
@@ -27,17 +27,18 @@ exports.RenderModalData = void 0;
|
|
|
27
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
28
|
const react_1 = __importStar(require("react"));
|
|
29
29
|
const remotion_1 = require("remotion");
|
|
30
|
-
const colors_1 = require("../../helpers/colors");
|
|
31
|
-
const ValidationMessage_1 = require("../NewComposition/ValidationMessage");
|
|
32
30
|
const client_id_1 = require("../../helpers/client-id");
|
|
31
|
+
const colors_1 = require("../../helpers/colors");
|
|
33
32
|
const get_zod_if_possible_1 = require("../get-zod-if-possible");
|
|
34
33
|
const layout_1 = require("../layout");
|
|
34
|
+
const ValidationMessage_1 = require("../NewComposition/ValidationMessage");
|
|
35
35
|
const NotificationCenter_1 = require("../Notifications/NotificationCenter");
|
|
36
36
|
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,13 +106,15 @@ 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
|
-
const [
|
|
112
|
-
|
|
113
|
-
reason: 'Loading...',
|
|
114
|
-
determined: false,
|
|
116
|
+
const [canSaveDefaultPropsObjectState, setCanSaveDefaultProps] = (0, react_1.useState)({
|
|
117
|
+
[composition.id]: get_render_modal_warnings_1.defaultTypeCanSaveState,
|
|
115
118
|
});
|
|
116
119
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
117
120
|
const schema = (0, react_1.useMemo)(() => {
|
|
@@ -142,30 +145,44 @@ const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayS
|
|
|
142
145
|
return val(prevVal);
|
|
143
146
|
});
|
|
144
147
|
}, []);
|
|
148
|
+
const canSaveDefaultProps = (0, react_1.useMemo)(() => {
|
|
149
|
+
return canSaveDefaultPropsObjectState[composition.id]
|
|
150
|
+
? canSaveDefaultPropsObjectState[composition.id]
|
|
151
|
+
: get_render_modal_warnings_1.defaultTypeCanSaveState;
|
|
152
|
+
}, [canSaveDefaultPropsObjectState, composition.id]);
|
|
145
153
|
const showSaveButton = mayShowSaveButton && canSaveDefaultProps.canUpdate;
|
|
146
154
|
const { fastRefreshes } = (0, react_1.useContext)(remotion_1.Internals.NonceContext);
|
|
147
155
|
(0, react_1.useEffect)(() => {
|
|
148
156
|
(0, actions_1.canUpdateDefaultProps)(composition.id)
|
|
149
157
|
.then((can) => {
|
|
150
158
|
if (can.canUpdate) {
|
|
151
|
-
setCanSaveDefaultProps({
|
|
152
|
-
|
|
153
|
-
|
|
159
|
+
setCanSaveDefaultProps((prevState) => ({
|
|
160
|
+
...prevState,
|
|
161
|
+
[composition.id]: {
|
|
162
|
+
canUpdate: true,
|
|
163
|
+
},
|
|
164
|
+
}));
|
|
154
165
|
}
|
|
155
166
|
else {
|
|
156
|
-
setCanSaveDefaultProps({
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
setCanSaveDefaultProps((prevState) => ({
|
|
168
|
+
...prevState,
|
|
169
|
+
[composition.id]: {
|
|
170
|
+
canUpdate: false,
|
|
171
|
+
reason: can.reason,
|
|
172
|
+
determined: true,
|
|
173
|
+
},
|
|
174
|
+
}));
|
|
161
175
|
}
|
|
162
176
|
})
|
|
163
177
|
.catch((err) => {
|
|
164
|
-
setCanSaveDefaultProps({
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
setCanSaveDefaultProps((prevState) => ({
|
|
179
|
+
...prevState,
|
|
180
|
+
[composition.id]: {
|
|
181
|
+
canUpdate: false,
|
|
182
|
+
reason: err.message,
|
|
183
|
+
determined: true,
|
|
184
|
+
},
|
|
185
|
+
}));
|
|
169
186
|
});
|
|
170
187
|
}, [composition.id]);
|
|
171
188
|
const modeItems = (0, react_1.useMemo)(() => {
|
|
@@ -192,31 +209,42 @@ const RenderModalData = ({ composition, inputProps, setInputProps, compact, mayS
|
|
|
192
209
|
setMode('schema');
|
|
193
210
|
}, []);
|
|
194
211
|
const onUpdate = (0, react_1.useCallback)(() => {
|
|
212
|
+
if (schema === 'no-zod' || z === null) {
|
|
213
|
+
(0, NotificationCenter_1.sendErrorNotification)('Cannot update default props: No Zod schema');
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
195
216
|
setValBeforeSafe(inputProps);
|
|
196
|
-
(0, actions_1.updateDefaultProps)(composition.id, inputProps);
|
|
197
|
-
}, [composition.id, inputProps]);
|
|
217
|
+
(0, actions_1.updateDefaultProps)(composition.id, inputProps, (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, []));
|
|
218
|
+
}, [composition.id, inputProps, schema, z]);
|
|
198
219
|
(0, react_1.useEffect)(() => {
|
|
199
220
|
setSaving(false);
|
|
200
221
|
}, [fastRefreshes]);
|
|
201
222
|
const onSave = (0, react_1.useCallback)((updater) => {
|
|
223
|
+
if (schema === 'no-zod' || z === null) {
|
|
224
|
+
(0, NotificationCenter_1.sendErrorNotification)('Cannot update default props: No Zod schema');
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
202
227
|
setSaving(true);
|
|
203
|
-
(0, actions_1.updateDefaultProps)(composition.id, updater(composition.defaultProps)).catch((err) => {
|
|
228
|
+
(0, actions_1.updateDefaultProps)(composition.id, updater(composition.defaultProps), (0, extract_enum_json_paths_1.extractEnumJsonPaths)(schema, z, [])).catch((err) => {
|
|
204
229
|
(0, NotificationCenter_1.sendErrorNotification)(`Cannot update default props: ${err.message}`);
|
|
205
230
|
setSaving(false);
|
|
206
231
|
});
|
|
207
|
-
}, [composition.defaultProps, composition.id]);
|
|
232
|
+
}, [composition.defaultProps, composition.id, schema, z]);
|
|
208
233
|
const connectionStatus = (0, react_1.useContext)(client_id_1.PreviewServerConnectionCtx).type;
|
|
209
234
|
const warnings = (0, react_1.useMemo)(() => {
|
|
210
235
|
return (0, get_render_modal_warnings_1.getRenderModalWarnings)({
|
|
211
236
|
canSaveDefaultProps,
|
|
212
237
|
cliProps,
|
|
213
238
|
isCustomDateUsed: serializedJSON ? serializedJSON.customDateUsed : false,
|
|
239
|
+
customFileUsed: serializedJSON ? serializedJSON.customFileUsed : false,
|
|
214
240
|
inJSONEditor,
|
|
215
241
|
propsEditType,
|
|
242
|
+
jsMapUsed: serializedJSON ? serializedJSON.mapUsed : false,
|
|
243
|
+
jsSetUsed: serializedJSON ? serializedJSON.setUsed : false,
|
|
216
244
|
});
|
|
217
245
|
}, [
|
|
218
|
-
canSaveDefaultProps,
|
|
219
246
|
cliProps,
|
|
247
|
+
canSaveDefaultProps,
|
|
220
248
|
inJSONEditor,
|
|
221
249
|
propsEditType,
|
|
222
250
|
serializedJSON,
|
|
@@ -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
|
}>;
|
|
@@ -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;
|