@remotion/cli 4.0.0-alpha8 → 4.0.0-alpha9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codemods/update-default-props.d.ts +1 -1
- package/dist/codemods/update-default-props.js +0 -1
- package/dist/editor/components/CheckboardToggle.js +2 -1
- package/dist/editor/components/InlineAction.d.ts +1 -1
- package/dist/editor/components/InlineAction.js +6 -3
- package/dist/editor/components/LoopToggle.js +2 -1
- package/dist/editor/components/Menu/MenuItem.js +1 -1
- package/dist/editor/components/Menu/SubMenu.js +1 -1
- package/dist/editor/components/NewComposition/ComboBox.js +19 -4
- package/dist/editor/components/NewComposition/InputDragger.js +3 -2
- package/dist/editor/components/NewComposition/MenuContent.d.ts +1 -0
- package/dist/editor/components/NewComposition/MenuContent.js +11 -3
- package/dist/editor/components/RenderModal/EnforceAudioTrackSetting.js +3 -2
- package/dist/editor/components/RenderModal/MutedSetting.js +3 -2
- package/dist/editor/components/RenderModal/RenderModal.d.ts +1 -1
- package/dist/editor/components/RenderModal/RenderModal.js +6 -4
- package/dist/editor/components/RenderModal/RenderModalAdvanced.js +0 -2
- package/dist/editor/components/RenderModal/RenderModalAudio.js +1 -1
- package/dist/editor/components/RenderModal/RenderModalBasic.js +3 -2
- package/dist/editor/components/RenderModal/RenderModalData.d.ts +3 -3
- package/dist/editor/components/RenderModal/RenderModalData.js +16 -5
- package/dist/editor/components/RenderModal/RenderModalJSONPropsEditor.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +5 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaEditor.js +4 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +3 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +6 -2
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +4 -0
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaLabel.js +5 -4
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/SchemaSaveButton.js +4 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.js +38 -26
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +4 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +4 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +7 -7
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodColorEditor.js +17 -60
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodDateEditor.js +10 -18
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +3 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEffectEditor.js +6 -19
- package/dist/editor/components/RenderModal/SchemaEditor/ZodEnumEditor.js +12 -26
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +1 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +4 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodNumberEditor.js +15 -34
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +6 -4
- package/dist/editor/components/RenderModal/SchemaEditor/ZodObjectEditor.js +17 -10
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +4 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +4 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +6 -6
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +1 -0
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +11 -25
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +2 -1
- package/dist/editor/components/RenderModal/SchemaEditor/ZodStringEditor.js +12 -23
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +3 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodSwitch.js +12 -12
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +4 -2
- package/dist/editor/components/RenderModal/SchemaEditor/ZodUnionEditor.js +2 -2
- package/dist/editor/components/RenderModal/SchemaEditor/local-state.d.ts +16 -0
- package/dist/editor/components/RenderModal/SchemaEditor/local-state.js +44 -0
- package/dist/editor/components/RenderModal/out-name-checker.js +1 -11
- package/dist/editor/components/RenderQueue/actions.d.ts +3 -3
- package/dist/editor/components/RightPanel.js +3 -3
- package/dist/editor/components/Tabs/index.js +12 -14
- package/dist/editor/components/Timeline/TimelineSequence.js +2 -2
- package/dist/editor/components/TimelineInOutToggle.js +2 -1
- package/dist/editor/components/UpdateCheck.js +2 -1
- package/dist/editor/helpers/colors.d.ts +2 -0
- package/dist/editor/helpers/colors.js +3 -1
- package/dist/editor/icons/media-volume.js +2 -1
- package/dist/editor/state/modals.d.ts +1 -1
- package/dist/get-cli-options.d.ts +1 -1
- package/dist/get-input-props.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/list-of-remotion-packages.js +1 -0
- package/dist/preview-server/api-types.d.ts +2 -2
- package/dist/preview-server/error-overlay/remotion-overlay/HelpLink.js +2 -1
- package/dist/preview-server/render-queue/job.d.ts +9 -2
- package/dist/preview-server/render-queue/make-retry-payload.js +1 -1
- package/dist/preview-server/render-queue/queue.js +0 -1
- package/dist/preview-server/routes/update-default-props.d.ts +2 -2
- package/dist/preview-server/routes/update-default-props.js +23 -13
- package/dist/preview-server/routes.d.ts +2 -1
- package/dist/preview-server/start-server.js +1 -1
- package/dist/render-flows/render.d.ts +1 -1
- package/dist/render-flows/still.d.ts +1 -1
- package/package.json +13 -11
- package/styles/styles.css +4 -5
|
@@ -8,10 +8,10 @@ const icon = {
|
|
|
8
8
|
height: 14,
|
|
9
9
|
color: 'currentColor',
|
|
10
10
|
};
|
|
11
|
-
const SchemaSaveButton = ({ onClick,
|
|
11
|
+
const SchemaSaveButton = ({ onClick, disabled }) => {
|
|
12
12
|
const renderAction = (0, react_1.useCallback)((color) => {
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)("svg", { style: icon, viewBox: "0 0 448 512", children: (0, jsx_runtime_1.jsx)("path", { fill:
|
|
14
|
-
}, [
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(InlineAction_1.InlineAction, { renderAction: renderAction, onClick: onClick, disabled:
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("svg", { style: icon, viewBox: "0 0 448 512", children: (0, jsx_runtime_1.jsx)("path", { fill: disabled ? 'grey' : color, d: "M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V173.3c0-17-6.7-33.3-18.7-45.3L352 50.7C340 38.7 323.7 32 306.7 32H64zm0 96c0-17.7 14.3-32 32-32H288c17.7 0 32 14.3 32 32v64c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V128zM224 288a64 64 0 1 1 0 128 64 64 0 1 1 0-128z" }) }));
|
|
14
|
+
}, [disabled]);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(InlineAction_1.InlineAction, { renderAction: renderAction, onClick: onClick, disabled: disabled }));
|
|
16
16
|
};
|
|
17
17
|
exports.SchemaSaveButton = SchemaSaveButton;
|
|
@@ -10,6 +10,7 @@ const layout_1 = require("../../layout");
|
|
|
10
10
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
11
11
|
const layout_2 = require("../layout");
|
|
12
12
|
const create_zod_values_1 = require("./create-zod-values");
|
|
13
|
+
const local_state_1 = require("./local-state");
|
|
13
14
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
14
15
|
const ZodArrayItemEditor_1 = require("./ZodArrayItemEditor");
|
|
15
16
|
const container = {
|
|
@@ -18,14 +19,11 @@ const container = {
|
|
|
18
19
|
const fullWidth = {
|
|
19
20
|
width: '100%',
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
zodValidation: schema.safeParse(value),
|
|
27
|
-
revision: 0,
|
|
28
|
-
};
|
|
22
|
+
const ZodArrayEditor = ({ schema, jsonPath, compact, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
|
|
23
|
+
const { localValue, onChange } = (0, local_state_1.useLocalState)({
|
|
24
|
+
value,
|
|
25
|
+
schema,
|
|
26
|
+
setValue,
|
|
29
27
|
});
|
|
30
28
|
const def = schema._def;
|
|
31
29
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
@@ -48,21 +46,6 @@ const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defa
|
|
|
48
46
|
: colors_1.FAIL_COLOR,
|
|
49
47
|
};
|
|
50
48
|
}, [localValue.zodValidation.success]);
|
|
51
|
-
const onChange = (0, react_1.useCallback)((updater, incrementRevision) => {
|
|
52
|
-
setLocalValue((oldLocalState) => {
|
|
53
|
-
const newValue = updater(oldLocalState.value);
|
|
54
|
-
const safeParse = schema.safeParse(newValue);
|
|
55
|
-
// TODO: This logs an error to the console
|
|
56
|
-
if (safeParse.success) {
|
|
57
|
-
updateValue(updater);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
revision: oldLocalState.revision + (incrementRevision ? 1 : 0),
|
|
61
|
-
value: newValue,
|
|
62
|
-
zodValidation: safeParse,
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
}, [schema, updateValue]);
|
|
66
49
|
const style = (0, react_1.useMemo)(() => {
|
|
67
50
|
if (isRoot) {
|
|
68
51
|
return undefined;
|
|
@@ -72,13 +55,42 @@ const ZodArrayEditor = ({ schema, jsonPath, compact, setValue: updateValue, defa
|
|
|
72
55
|
const onAdd = (0, react_1.useCallback)(() => {
|
|
73
56
|
onChange((oldV) => {
|
|
74
57
|
return [...oldV, (0, create_zod_values_1.createZodValues)(def.type, z, zodTypes)];
|
|
75
|
-
},
|
|
58
|
+
}, false);
|
|
76
59
|
}, [def.type, onChange, z, zodTypes]);
|
|
77
|
-
|
|
60
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
61
|
+
onChange(() => defaultValue, true);
|
|
62
|
+
}, [defaultValue, onChange]);
|
|
63
|
+
const isDefaultValue = (0, react_1.useMemo)(() => {
|
|
64
|
+
return deepEqual(localValue.value, defaultValue);
|
|
65
|
+
}, [defaultValue, localValue]);
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: style, children: (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsxs)(Element, { style: fieldset, children: [isRoot ? null : ((0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaFieldsetLabel, { onReset: reset, isDefaultValue: isDefaultValue, jsonPath: jsonPath, onRemove: onRemove })), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: localValue.value.map((child, i) => {
|
|
78
67
|
var _a;
|
|
79
68
|
return ((0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor
|
|
80
69
|
// eslint-disable-next-line react/no-array-index-key
|
|
81
|
-
, { onChange: onChange, value: child, def: def, index: i, jsonPath: jsonPath, compact: compact, defaultValue: (_a = defaultValue[i]) !== null && _a !== void 0 ? _a : child, onSave: onSave, showSaveButton: showSaveButton, saving: saving }, `${i}${localValue.revision}`));
|
|
70
|
+
, { onChange: onChange, value: child, def: def, index: i, jsonPath: jsonPath, compact: compact, defaultValue: (_a = defaultValue[i]) !== null && _a !== void 0 ? _a : child, onSave: onSave, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent }, `${i}${localValue.revision}`));
|
|
82
71
|
}) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] })), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onAdd, children: "+ Add item" })] }) }) }));
|
|
83
72
|
};
|
|
84
73
|
exports.ZodArrayEditor = ZodArrayEditor;
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
function deepEqual(a, b) {
|
|
76
|
+
if (a === b) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (typeof a !== 'object' ||
|
|
80
|
+
a === null ||
|
|
81
|
+
typeof b !== 'object' ||
|
|
82
|
+
b === null) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
const keysA = Object.keys(a);
|
|
86
|
+
const keysB = Object.keys(b);
|
|
87
|
+
if (keysA.length !== keysB.length) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
for (const key of keysA) {
|
|
91
|
+
if (!keysB.includes(key) || !deepEqual(a[key], b[key])) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { JSONPath } from './zod-types';
|
|
3
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
3
4
|
export declare const ZodArrayItemEditor: React.FC<{
|
|
4
5
|
jsonPath: JSONPath;
|
|
5
|
-
onChange:
|
|
6
|
+
onChange: UpdaterFunction<unknown[]>;
|
|
6
7
|
def: any;
|
|
7
8
|
index: number;
|
|
8
9
|
value: unknown;
|
|
9
10
|
compact: boolean;
|
|
10
11
|
defaultValue: unknown;
|
|
11
|
-
onSave:
|
|
12
|
+
onSave: UpdaterFunction<unknown[]>;
|
|
12
13
|
showSaveButton: boolean;
|
|
13
14
|
saving: boolean;
|
|
15
|
+
saveDisabledByParent: boolean;
|
|
14
16
|
}>;
|
|
@@ -4,9 +4,9 @@ exports.ZodArrayItemEditor = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
7
|
-
const ZodArrayItemEditor = ({ def, onChange, jsonPath, index, value, compact, defaultValue, onSave: onSaveObject, showSaveButton, saving, }) => {
|
|
7
|
+
const ZodArrayItemEditor = ({ def, onChange, jsonPath, index, value, compact, defaultValue, onSave: onSaveObject, showSaveButton, saving, saveDisabledByParent, }) => {
|
|
8
8
|
const onRemove = (0, react_1.useCallback)(() => {
|
|
9
|
-
onChange((oldV) => [...oldV.slice(0, index), ...oldV.slice(index + 1)],
|
|
9
|
+
onChange((oldV) => [...oldV.slice(0, index), ...oldV.slice(index + 1)], false);
|
|
10
10
|
}, [index, onChange]);
|
|
11
11
|
const setValue = (0, react_1.useCallback)((val) => {
|
|
12
12
|
onChange((oldV) => [
|
|
@@ -21,8 +21,8 @@ const ZodArrayItemEditor = ({ def, onChange, jsonPath, index, value, compact, de
|
|
|
21
21
|
...oldV.slice(0, index),
|
|
22
22
|
updater(oldV[index]),
|
|
23
23
|
...oldV.slice(index + 1),
|
|
24
|
-
]);
|
|
24
|
+
], false);
|
|
25
25
|
}, [index, onSaveObject]);
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { jsonPath: newJsonPath, schema: def.type, value: value, setValue: setValue, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }));
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { jsonPath: newJsonPath, schema: def.type, value: value, setValue: setValue, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
27
27
|
};
|
|
28
28
|
exports.ZodArrayItemEditor = ZodArrayItemEditor;
|
|
@@ -7,8 +7,9 @@ export declare const ZodBooleanEditor: React.FC<{
|
|
|
7
7
|
setValue: UpdaterFunction<boolean>;
|
|
8
8
|
compact: boolean;
|
|
9
9
|
defaultValue: boolean;
|
|
10
|
-
onSave:
|
|
10
|
+
onSave: UpdaterFunction<boolean>;
|
|
11
11
|
onRemove: null | (() => void);
|
|
12
12
|
showSaveButton: boolean;
|
|
13
13
|
saving: boolean;
|
|
14
|
+
saveDisabledByParent: boolean;
|
|
14
15
|
}>;
|
|
@@ -9,19 +9,19 @@ const SchemaLabel_1 = require("./SchemaLabel");
|
|
|
9
9
|
const fullWidth = {
|
|
10
10
|
width: '100%',
|
|
11
11
|
};
|
|
12
|
-
const ZodBooleanEditor = ({ jsonPath, value, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, }) => {
|
|
13
|
-
const onValueChange = (0, react_1.useCallback)((newValue) => {
|
|
14
|
-
setValue(() => newValue);
|
|
12
|
+
const ZodBooleanEditor = ({ jsonPath, value, setValue, onSave, compact, defaultValue, onRemove, showSaveButton, saving, saveDisabledByParent, }) => {
|
|
13
|
+
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
14
|
+
setValue(() => newValue, forceApply);
|
|
15
15
|
}, [setValue]);
|
|
16
16
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
17
|
-
onValueChange(e.target.checked);
|
|
17
|
+
onValueChange(e.target.checked, false);
|
|
18
18
|
}, [onValueChange]);
|
|
19
19
|
const reset = (0, react_1.useCallback)(() => {
|
|
20
|
-
onValueChange(defaultValue);
|
|
20
|
+
onValueChange(defaultValue, true);
|
|
21
21
|
}, [defaultValue, onValueChange]);
|
|
22
22
|
const save = (0, react_1.useCallback)(() => {
|
|
23
|
-
onSave(() => value);
|
|
23
|
+
onSave(() => value, false);
|
|
24
24
|
}, [onSave, value]);
|
|
25
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_1.narrowOption : layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: value, onChange: onChange, disabled: false }) })] }));
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_1.narrowOption : layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: onRemove, saving: saving, valid: true, saveDisabledByParent: saveDisabledByParent }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { checked: value, onChange: onChange, disabled: false }) })] }));
|
|
26
26
|
};
|
|
27
27
|
exports.ZodBooleanEditor = ZodBooleanEditor;
|
|
@@ -8,9 +8,10 @@ export declare const ZodColorEditor: React.FC<{
|
|
|
8
8
|
value: string;
|
|
9
9
|
defaultValue: string;
|
|
10
10
|
setValue: UpdaterFunction<string>;
|
|
11
|
-
onSave:
|
|
11
|
+
onSave: UpdaterFunction<string>;
|
|
12
12
|
onRemove: null | (() => void);
|
|
13
13
|
compact: boolean;
|
|
14
14
|
showSaveButton: boolean;
|
|
15
15
|
saving: boolean;
|
|
16
|
+
saveDisabledByParent: boolean;
|
|
16
17
|
}>;
|
|
@@ -11,11 +11,12 @@ const RemInput_1 = require("../../NewComposition/RemInput");
|
|
|
11
11
|
const RemInputTypeColor_1 = require("../../NewComposition/RemInputTypeColor");
|
|
12
12
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
13
13
|
const layout_2 = require("../layout");
|
|
14
|
+
const local_state_1 = require("./local-state");
|
|
14
15
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
15
16
|
const fullWidth = {
|
|
16
17
|
width: '100%',
|
|
17
18
|
};
|
|
18
|
-
const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, }) => {
|
|
19
|
+
const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, saveDisabledByParent, }) => {
|
|
19
20
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
20
21
|
if (!z) {
|
|
21
22
|
throw new Error('expected zod');
|
|
@@ -24,55 +25,27 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
24
25
|
if (!zodTypes) {
|
|
25
26
|
throw new Error('expected zod color');
|
|
26
27
|
}
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
28
|
+
const { localValue, onChange: onValueChange } = (0, local_state_1.useLocalState)({
|
|
29
|
+
schema,
|
|
30
|
+
setValue,
|
|
31
|
+
value,
|
|
32
32
|
});
|
|
33
|
-
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
34
|
-
const safeParse = schema.safeParse(newValue);
|
|
35
|
-
const newLocalState = {
|
|
36
|
-
value: newValue,
|
|
37
|
-
zodValidation: safeParse,
|
|
38
|
-
};
|
|
39
|
-
setLocalValue(newLocalState);
|
|
40
|
-
if (safeParse.success || forceApply) {
|
|
41
|
-
setValue(() => newValue);
|
|
42
|
-
}
|
|
43
|
-
}, [schema, setValue]);
|
|
44
33
|
const { a, b, g, r } = localValue.zodValidation.success
|
|
45
34
|
? zodTypes.ZodZypesInternals.parseColor(localValue.value)
|
|
46
35
|
: { a: 1, b: 0, g: 0, r: 0 };
|
|
47
36
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
48
37
|
const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a), zodTypes);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
value: newColor,
|
|
52
|
-
zodValidation: safeParse,
|
|
53
|
-
};
|
|
54
|
-
setLocalValue(newLocalState);
|
|
55
|
-
if (safeParse.success) {
|
|
56
|
-
setValue(() => newColor);
|
|
57
|
-
}
|
|
58
|
-
}, [a, schema, setValue, zodTypes]);
|
|
38
|
+
onValueChange(() => newColor, false);
|
|
39
|
+
}, [a, onValueChange, zodTypes]);
|
|
59
40
|
const onTextChange = (0, react_1.useCallback)((e) => {
|
|
60
41
|
const newValue = e.target.value;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
value: newValue,
|
|
64
|
-
zodValidation: safeParse,
|
|
65
|
-
};
|
|
66
|
-
setLocalValue(newLocalState);
|
|
67
|
-
if (safeParse.success) {
|
|
68
|
-
setValue(() => newValue);
|
|
69
|
-
}
|
|
70
|
-
}, [schema, setValue]);
|
|
42
|
+
onValueChange(() => newValue, false);
|
|
43
|
+
}, [onValueChange]);
|
|
71
44
|
const reset = (0, react_1.useCallback)(() => {
|
|
72
|
-
onValueChange(defaultValue, true);
|
|
45
|
+
onValueChange(() => defaultValue, true);
|
|
73
46
|
}, [defaultValue, onValueChange]);
|
|
74
47
|
const save = (0, react_1.useCallback)(() => {
|
|
75
|
-
onSave(() => value);
|
|
48
|
+
onSave(() => value, false);
|
|
76
49
|
}, [onSave, value]);
|
|
77
50
|
const rgb = `#${r.toString(16).padStart(2, '0')}${g
|
|
78
51
|
.toString(16)
|
|
@@ -87,29 +60,13 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
87
60
|
}, []);
|
|
88
61
|
const onOpacityChange = (0, react_1.useCallback)((newValue) => {
|
|
89
62
|
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
value: newColor,
|
|
93
|
-
zodValidation: safeParse,
|
|
94
|
-
};
|
|
95
|
-
setLocalValue(newLocalState);
|
|
96
|
-
if (safeParse.success) {
|
|
97
|
-
setValue(() => newColor);
|
|
98
|
-
}
|
|
99
|
-
}, [localValue.value, schema, setValue, zodTypes]);
|
|
63
|
+
onValueChange(() => newColor, false);
|
|
64
|
+
}, [localValue.value, onValueChange, zodTypes]);
|
|
100
65
|
const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
|
|
101
66
|
const newColor = (0, color_math_1.colorWithNewOpacity)(localValue.value, Math.round((Number(newValue) / 100) * 255), zodTypes);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
zodValidation: safeParse,
|
|
106
|
-
};
|
|
107
|
-
setLocalValue(newLocalState);
|
|
108
|
-
if (safeParse.success) {
|
|
109
|
-
setValue(() => newColor);
|
|
110
|
-
}
|
|
111
|
-
}, [localValue.value, schema, setValue, zodTypes]);
|
|
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: {
|
|
67
|
+
onValueChange(() => newColor, false);
|
|
68
|
+
}, [localValue.value, onValueChange, zodTypes]);
|
|
69
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: colorPicker, children: (0, jsx_runtime_1.jsx)(RemInputTypeColor_1.RemInputTypeColor, { type: "color", style: {
|
|
113
70
|
height: 39,
|
|
114
71
|
}, value: rgb, onChange: onChange, className: "__remotion_color_picker", status: status }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1, block: true }), (0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: localValue.value, status: status, placeholder: jsonPath.join('.'), onChange: onTextChange, rightAlign: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(InputDragger_1.InputDragger, { onTextChange: onOpacityChange, onValueChange: onOpacityValueChange, status: status, value: (a / 255) * 100, min: 0, max: 100, step: 1, formatter: (v) => `${Math.round(Number(v))}%`, rightAlign: false })] }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
|
|
115
72
|
};
|
|
@@ -8,9 +8,10 @@ export declare const ZodDateEditor: React.FC<{
|
|
|
8
8
|
value: Date;
|
|
9
9
|
defaultValue: Date;
|
|
10
10
|
setValue: UpdaterFunction<Date>;
|
|
11
|
-
onSave:
|
|
11
|
+
onSave: UpdaterFunction<Date>;
|
|
12
12
|
onRemove: null | (() => void);
|
|
13
13
|
compact: boolean;
|
|
14
14
|
showSaveButton: boolean;
|
|
15
15
|
saving: boolean;
|
|
16
|
+
saveDisabledByParent: boolean;
|
|
16
17
|
}>;
|
|
@@ -8,6 +8,7 @@ const layout_1 = require("../../layout");
|
|
|
8
8
|
const RemInput_1 = require("../../NewComposition/RemInput");
|
|
9
9
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
10
10
|
const layout_2 = require("../layout");
|
|
11
|
+
const local_state_1 = require("./local-state");
|
|
11
12
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
12
13
|
const fullWidth = {
|
|
13
14
|
width: '100%',
|
|
@@ -43,24 +44,15 @@ const formatDate = (date) => {
|
|
|
43
44
|
.padStart(3, '0')}`;
|
|
44
45
|
return formattedDate;
|
|
45
46
|
};
|
|
46
|
-
const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, }) => {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
47
|
+
const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue, schema, compact, onSave, onRemove, saving, saveDisabledByParent, }) => {
|
|
48
|
+
const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
|
|
49
|
+
schema,
|
|
50
|
+
setValue,
|
|
51
|
+
value,
|
|
52
52
|
});
|
|
53
53
|
const onValueChange = (0, react_1.useCallback)((newValue, forceApply) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
value: newValue,
|
|
57
|
-
zodValidation: safeParse,
|
|
58
|
-
};
|
|
59
|
-
setLocalValue(newLocalState);
|
|
60
|
-
if (safeParse.success || forceApply) {
|
|
61
|
-
setValue(() => newValue);
|
|
62
|
-
}
|
|
63
|
-
}, [schema, setValue]);
|
|
54
|
+
setLocalValue(() => newValue, forceApply);
|
|
55
|
+
}, [setLocalValue]);
|
|
64
56
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
65
57
|
// React does not support e.target.valueAsDate :(
|
|
66
58
|
onValueChange(new Date(e.target.value), false);
|
|
@@ -69,8 +61,8 @@ const ZodDateEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValue
|
|
|
69
61
|
onValueChange(defaultValue, true);
|
|
70
62
|
}, [defaultValue, onValueChange]);
|
|
71
63
|
const save = (0, react_1.useCallback)(() => {
|
|
72
|
-
onSave(() => value);
|
|
64
|
+
onSave(() => value, false);
|
|
73
65
|
}, [onSave, value]);
|
|
74
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value.getTime() === defaultValue.getTime(), jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: formatDate(localValue.value), type: "datetime-local", status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, style: inputStyle, rightAlign: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: explainer, children: "Date is in local format" }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
|
|
66
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { compact: compact, isDefaultValue: value.getTime() === defaultValue.getTime(), jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: saveDisabledByParent }), (0, jsx_runtime_1.jsxs)("div", { style: fullWidth, children: [(0, jsx_runtime_1.jsx)(RemInput_1.RemotionInput, { value: formatDate(localValue.value), type: "datetime-local", status: localValue.zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, style: inputStyle, rightAlign: false }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)("div", { style: explainer, children: "Date is in local format" }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { y: 1, block: true }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] })] }));
|
|
75
67
|
};
|
|
76
68
|
exports.ZodDateEditor = ZodDateEditor;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
5
|
export declare const ZodEffectEditor: React.FC<{
|
|
5
6
|
schema: z.ZodTypeAny;
|
|
6
7
|
jsonPath: JSONPath;
|
|
7
8
|
value: unknown;
|
|
8
|
-
setValue:
|
|
9
|
+
setValue: UpdaterFunction<unknown>;
|
|
9
10
|
compact: boolean;
|
|
10
11
|
defaultValue: unknown;
|
|
11
|
-
onSave:
|
|
12
|
+
onSave: UpdaterFunction<unknown>;
|
|
12
13
|
showSaveButton: boolean;
|
|
13
14
|
onRemove: null | (() => void);
|
|
14
15
|
saving: boolean;
|
|
@@ -6,6 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const colors_1 = require("../../../helpers/colors");
|
|
7
7
|
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
8
8
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
9
|
+
const local_state_1 = require("./local-state");
|
|
9
10
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
10
11
|
const fullWidth = {
|
|
11
12
|
width: '100%',
|
|
@@ -15,30 +16,16 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
|
|
|
15
16
|
if (!z) {
|
|
16
17
|
throw new Error('expected zod');
|
|
17
18
|
}
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
19
|
+
const { localValue, onChange } = (0, local_state_1.useLocalState)({
|
|
20
|
+
value,
|
|
21
|
+
schema,
|
|
22
|
+
setValue: updateValue,
|
|
23
23
|
});
|
|
24
24
|
const def = schema._def;
|
|
25
25
|
const typeName = def.typeName;
|
|
26
26
|
if (typeName !== z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
27
27
|
throw new Error('expected effect');
|
|
28
28
|
}
|
|
29
|
-
const onChange = (0, react_1.useCallback)((updater) => {
|
|
30
|
-
setLocalValue((oldLocalState) => {
|
|
31
|
-
const newValue = updater(oldLocalState.value);
|
|
32
|
-
const safeParse = schema.safeParse(newValue);
|
|
33
|
-
if (safeParse.success) {
|
|
34
|
-
updateValue(() => newValue);
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
value: newValue,
|
|
38
|
-
zodValidation: safeParse,
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
}, [schema, updateValue]);
|
|
42
29
|
const container = (0, react_1.useMemo)(() => {
|
|
43
30
|
if (!localValue.zodValidation.success) {
|
|
44
31
|
return {
|
|
@@ -51,6 +38,6 @@ const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, compa
|
|
|
51
38
|
padding: 0,
|
|
52
39
|
};
|
|
53
40
|
}, [localValue.zodValidation.success]);
|
|
54
|
-
return ((0, jsx_runtime_1.jsxs)("fieldset", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { value: value, setValue: onChange, jsonPath: jsonPath, schema: def.schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsx)("legend", { children: (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" }) }))] }));
|
|
41
|
+
return ((0, jsx_runtime_1.jsxs)("fieldset", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { value: value, setValue: onChange, jsonPath: jsonPath, schema: def.schema, compact: compact, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: !localValue.zodValidation.success }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsx)("legend", { children: (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" }) }))] }));
|
|
55
42
|
};
|
|
56
43
|
exports.ZodEffectEditor = ZodEffectEditor;
|
|
@@ -9,21 +9,20 @@ const layout_1 = require("../../layout");
|
|
|
9
9
|
const ComboBox_1 = require("../../NewComposition/ComboBox");
|
|
10
10
|
const ValidationMessage_1 = require("../../NewComposition/ValidationMessage");
|
|
11
11
|
const layout_2 = require("../layout");
|
|
12
|
+
const local_state_1 = require("./local-state");
|
|
12
13
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
13
14
|
const container = {
|
|
14
15
|
width: '100%',
|
|
15
16
|
};
|
|
16
|
-
const ZodEnumEditor = ({ schema, jsonPath, compact, setValue
|
|
17
|
+
const ZodEnumEditor = ({ schema, jsonPath, compact, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, }) => {
|
|
17
18
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
18
19
|
if (!z) {
|
|
19
20
|
throw new Error('expected zod');
|
|
20
21
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
revision: 0,
|
|
26
|
-
};
|
|
22
|
+
const { localValue, onChange: setLocalValue } = (0, local_state_1.useLocalState)({
|
|
23
|
+
schema,
|
|
24
|
+
setValue,
|
|
25
|
+
value,
|
|
27
26
|
});
|
|
28
27
|
const def = schema._def;
|
|
29
28
|
const typeName = def.typeName;
|
|
@@ -31,22 +30,9 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
31
30
|
throw new Error('expected enum');
|
|
32
31
|
}
|
|
33
32
|
const isRoot = jsonPath.length === 0;
|
|
34
|
-
const onChange = (0, react_1.useCallback)((updater, forceApply) => {
|
|
35
|
-
setLocalValue((oldLocalState) => {
|
|
36
|
-
const newValue = updater(oldLocalState.value);
|
|
37
|
-
const safeParse = schema.safeParse(newValue);
|
|
38
|
-
if (safeParse.success || forceApply) {
|
|
39
|
-
updateValue(updater);
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
value: newValue,
|
|
43
|
-
zodValidation: safeParse,
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
}, [schema, updateValue]);
|
|
47
33
|
const reset = (0, react_1.useCallback)(() => {
|
|
48
|
-
|
|
49
|
-
}, [defaultValue,
|
|
34
|
+
setLocalValue(() => defaultValue, true);
|
|
35
|
+
}, [defaultValue, setLocalValue]);
|
|
50
36
|
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
51
37
|
return def.values.map((option) => {
|
|
52
38
|
return {
|
|
@@ -56,17 +42,17 @@ const ZodEnumEditor = ({ schema, jsonPath, compact, setValue: updateValue, defau
|
|
|
56
42
|
keyHint: null,
|
|
57
43
|
leftItem: option === value ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
|
|
58
44
|
onClick: (id) => {
|
|
59
|
-
|
|
45
|
+
setLocalValue(() => id, false);
|
|
60
46
|
},
|
|
61
47
|
quickSwitcherLabel: null,
|
|
62
48
|
subMenu: null,
|
|
63
49
|
type: 'item',
|
|
64
50
|
};
|
|
65
51
|
});
|
|
66
|
-
}, [def.values,
|
|
52
|
+
}, [def.values, setLocalValue, value]);
|
|
67
53
|
const save = (0, react_1.useCallback)(() => {
|
|
68
|
-
onSave(() => value);
|
|
54
|
+
onSave(() => value, false);
|
|
69
55
|
}, [onSave, value]);
|
|
70
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onSave: save, showSaveButton: showSaveButton, isDefaultValue: value === defaultValue, compact: compact, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, saving: saving }), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: value, title: value }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] }));
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_2.narrowOption : layout_2.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onSave: save, showSaveButton: showSaveButton, isDefaultValue: value === defaultValue, compact: compact, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: !localValue.zodValidation.success }), (0, jsx_runtime_1.jsx)("div", { style: isRoot ? undefined : container, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: value, title: value }) }), !localValue.zodValidation.success && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1 }), (0, jsx_runtime_1.jsx)(ValidationMessage_1.ValidationMessage, { align: "flex-start", message: localValue.zodValidation.error.format()._errors[0], type: "error" })] }))] }));
|
|
71
57
|
};
|
|
72
58
|
exports.ZodEnumEditor = ZodEnumEditor;
|
|
@@ -22,6 +22,6 @@ const wideEmptyLabel = {
|
|
|
22
22
|
const ZonNonEditableValue = ({ jsonPath, label, compact, showSaveButton, saving }) => {
|
|
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)("div", { style: compact ? layout_1.narrowOption : layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: true, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: null, saving: saving }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)("em", { style: compact ? emptyLabel : wideEmptyLabel, children: label }) })] }));
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: compact ? layout_1.narrowOption : layout_1.optionRow, children: [(0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { isDefaultValue: true, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, compact: compact, onRemove: null, saving: saving, valid: true, saveDisabledByParent: true }), (0, jsx_runtime_1.jsx)("div", { style: fullWidth, children: (0, jsx_runtime_1.jsx)("em", { style: compact ? emptyLabel : wideEmptyLabel, children: label }) })] }));
|
|
26
26
|
};
|
|
27
27
|
exports.ZonNonEditableValue = ZonNonEditableValue;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="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 ZodNullableEditor: React.FC<{
|
|
5
6
|
showSaveButton: boolean;
|
|
6
7
|
jsonPath: JSONPath;
|
|
@@ -8,8 +9,9 @@ export declare const ZodNullableEditor: React.FC<{
|
|
|
8
9
|
value: unknown;
|
|
9
10
|
defaultValue: unknown;
|
|
10
11
|
schema: z.ZodTypeAny;
|
|
11
|
-
setValue:
|
|
12
|
-
onSave:
|
|
12
|
+
setValue: UpdaterFunction<unknown>;
|
|
13
|
+
onSave: UpdaterFunction<unknown>;
|
|
13
14
|
onRemove: null | (() => void);
|
|
14
15
|
saving: boolean;
|
|
16
|
+
saveDisabledByParent: boolean;
|
|
15
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, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, }) => {
|
|
6
|
+
const ZodNullableEditor = ({ jsonPath, compact, schema, setValue, onSave, defaultValue, value, showSaveButton, onRemove, saving, saveDisabledByParent, }) => {
|
|
7
7
|
const { innerType } = schema._def;
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: null, saving: saving }));
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(ZodOrNullishEditor_1.ZodOrNullishEditor, { compact: compact, defaultValue: defaultValue, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, schema: innerType, setValue: setValue, showSaveButton: showSaveButton, value: value, nullishValue: null, saving: saving, saveDisabledByParent: saveDisabledByParent }));
|
|
9
9
|
};
|
|
10
10
|
exports.ZodNullableEditor = ZodNullableEditor;
|
|
@@ -9,8 +9,9 @@ export declare const ZodNumberEditor: React.FC<{
|
|
|
9
9
|
setValue: UpdaterFunction<number>;
|
|
10
10
|
compact: boolean;
|
|
11
11
|
defaultValue: number;
|
|
12
|
-
onSave:
|
|
12
|
+
onSave: UpdaterFunction<number>;
|
|
13
13
|
onRemove: null | (() => void);
|
|
14
14
|
showSaveButton: boolean;
|
|
15
15
|
saving: boolean;
|
|
16
|
+
saveDisabledByParent: boolean;
|
|
16
17
|
}>;
|