@remotion/studio 4.0.438 → 4.0.439
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/Studio.js +2 -2
- package/dist/api/helpers/calc-new-props.js +5 -8
- package/dist/api/update-default-props.d.ts +7 -3
- package/dist/api/update-default-props.js +7 -21
- package/dist/api/visual-control.js +6 -0
- package/dist/components/DefaultPropsEditor.d.ts +8 -0
- package/dist/components/DefaultPropsEditor.js +15 -0
- package/dist/components/Editor.js +0 -14
- package/dist/components/EditorContexts.js +6 -3
- package/dist/components/KeyboardShortcutsExplainer.js +6 -2
- package/dist/components/MenuBuildIndicator.js +1 -0
- package/dist/components/MenuToolbar.js +3 -1
- package/dist/components/NewComposition/InputDragger.js +2 -2
- package/dist/components/NewComposition/RemTextarea.js +4 -0
- package/dist/components/ObserveDefaultPropsContext.d.ts +11 -0
- package/dist/components/ObserveDefaultPropsContext.js +120 -0
- package/dist/components/OptionsPanel.js +90 -28
- package/dist/components/RenderModal/DataEditor.d.ts +4 -5
- package/dist/components/RenderModal/DataEditor.js +9 -111
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.d.ts +1 -1
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +52 -48
- package/dist/components/RenderModal/SchemaEditor/Fieldset.d.ts +0 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +4 -9
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.js +2 -61
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +0 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +2 -3
- package/dist/components/RenderModal/SchemaEditor/SchemaLabel.d.ts +0 -6
- package/dist/components/RenderModal/SchemaEditor/SchemaLabel.js +2 -5
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.d.ts +3 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.js +1 -1
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.js +15 -26
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +7 -12
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +0 -7
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.js +5 -15
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.js +30 -28
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.js +13 -17
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.js +13 -28
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +1 -5
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.js +11 -12
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +1 -5
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.js +12 -16
- package/dist/components/RenderModal/SchemaEditor/ZodFieldValidation.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodFieldValidation.js +1 -2
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.js +20 -30
- package/dist/components/RenderModal/SchemaEditor/ZodNonEditableValue.d.ts +0 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNonEditableValue.js +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.js +16 -21
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +2 -7
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.js +27 -49
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.js +8 -15
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +10 -15
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.js +13 -17
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.js +27 -27
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.js +45 -17
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.d.ts +1 -6
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.js +15 -26
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.js +4 -11
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.js +6 -6
- package/dist/components/RenderModal/ServerRenderModal.js +9 -3
- package/dist/components/RenderModal/WebRenderModal.js +9 -3
- package/dist/components/RenderModal/get-render-modal-warnings.d.ts +1 -2
- package/dist/components/RenderModal/get-render-modal-warnings.js +4 -6
- package/dist/components/RenderQueue/actions.d.ts +1 -2
- package/dist/components/RenderQueue/actions.js +1 -13
- package/dist/components/Timeline/TimelineExpandedSection.js +7 -1
- package/dist/components/Timeline/TimelineFieldRow.d.ts +1 -0
- package/dist/components/Timeline/TimelineFieldRow.js +25 -3
- package/dist/components/Timeline/TimelineNumberField.js +4 -6
- package/dist/components/Timeline/TimelineRotationField.js +4 -6
- package/dist/components/Timeline/TimelineTranslateField.js +28 -13
- package/dist/components/TopPanel.js +10 -5
- package/dist/components/UndoRedoButtons.d.ts +2 -0
- package/dist/components/UndoRedoButtons.js +116 -0
- package/dist/components/VisualControls/VisualControlHandle.js +18 -18
- package/dist/components/VisualControls/VisualControlsUndoSync.d.ts +2 -0
- package/dist/components/VisualControls/VisualControlsUndoSync.js +23 -0
- package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +0 -1
- package/dist/esm/{chunk-ba0scebn.js → chunk-nnz9f1vq.js} +4233 -5091
- package/dist/esm/index.mjs +25 -28
- package/dist/esm/internals.mjs +4233 -5091
- package/dist/esm/previewEntry.mjs +4427 -5292
- package/dist/esm/renderEntry.mjs +6 -6
- package/dist/helpers/client-id.js +9 -0
- package/dist/helpers/document-title.d.ts +0 -1
- package/dist/helpers/document-title.js +1 -17
- package/dist/hot-middleware-client/process-update.js +6 -14
- package/dist/icons/redo.d.ts +3 -0
- package/dist/icons/redo.js +8 -0
- package/dist/icons/undo.d.ts +3 -0
- package/dist/icons/undo.js +8 -0
- package/dist/renderEntry.js +7 -6
- package/dist/visual-controls/VisualControls.js +9 -5
- package/dist/visual-controls/get-current-edited-value.js +5 -4
- package/dist/visual-controls/visual-control-store.d.ts +7 -0
- package/dist/visual-controls/visual-control-store.js +22 -0
- package/package.json +9 -9
- package/dist/components/GlobalPropsEditorUpdateButton.d.ts +0 -5
- package/dist/components/GlobalPropsEditorUpdateButton.js +0 -78
- package/dist/components/RenderModal/SchemaEditor/SchemaSaveButton.d.ts +0 -5
- package/dist/components/RenderModal/SchemaEditor/SchemaSaveButton.js +0 -18
- package/dist/components/RenderModal/SchemaEditor/local-state.d.ts +0 -25
- package/dist/components/RenderModal/SchemaEditor/local-state.js +0 -107
|
@@ -7,11 +7,6 @@ export declare const ZodArrayItemEditor: React.FC<{
|
|
|
7
7
|
elementSchema: AnyZodSchema;
|
|
8
8
|
index: number;
|
|
9
9
|
value: unknown;
|
|
10
|
-
defaultValue: unknown;
|
|
11
|
-
onSave: UpdaterFunction<unknown[]>;
|
|
12
|
-
showSaveButton: boolean;
|
|
13
|
-
saving: boolean;
|
|
14
|
-
saveDisabledByParent: boolean;
|
|
15
10
|
mayPad: boolean;
|
|
16
11
|
mayRemove: boolean;
|
|
17
12
|
}>;
|
|
@@ -5,29 +5,24 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
7
7
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
8
|
-
const ZodArrayItemEditor = ({ elementSchema, onChange, jsonPath, index, value,
|
|
8
|
+
const ZodArrayItemEditor = ({ elementSchema, onChange, jsonPath, index, value, mayPad, mayRemove }) => {
|
|
9
9
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
10
10
|
if (!z) {
|
|
11
11
|
throw new Error('expected zod');
|
|
12
12
|
}
|
|
13
13
|
const onRemove = (0, react_1.useCallback)(() => {
|
|
14
|
-
onChange((oldV) => [...oldV.slice(0, index), ...oldV.slice(index + 1)],
|
|
14
|
+
onChange((oldV) => [...oldV.slice(0, index), ...oldV.slice(index + 1)], {
|
|
15
|
+
shouldSave: true,
|
|
16
|
+
});
|
|
15
17
|
}, [index, onChange]);
|
|
16
|
-
const setValue = (0, react_1.useCallback)((val) => {
|
|
18
|
+
const setValue = (0, react_1.useCallback)((val, { shouldSave }) => {
|
|
17
19
|
onChange((oldV) => [
|
|
18
20
|
...oldV.slice(0, index),
|
|
19
21
|
typeof val === 'function' ? val(oldV[index]) : val,
|
|
20
22
|
...oldV.slice(index + 1),
|
|
21
|
-
],
|
|
23
|
+
], { shouldSave });
|
|
22
24
|
}, [index, onChange]);
|
|
23
25
|
const newJsonPath = (0, react_1.useMemo)(() => [...jsonPath, index], [index, jsonPath]);
|
|
24
|
-
|
|
25
|
-
onSaveObject((oldV) => [
|
|
26
|
-
...oldV.slice(0, index),
|
|
27
|
-
updater(oldV[index]),
|
|
28
|
-
...oldV.slice(index + 1),
|
|
29
|
-
], false, false);
|
|
30
|
-
}, [index, onSaveObject]);
|
|
31
|
-
return (jsx_runtime_1.jsx("div", { children: jsx_runtime_1.jsx(ZodSwitch_1.ZodSwitch, { jsonPath: newJsonPath, schema: elementSchema, value: value, setValue: setValue, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: mayRemove ? onRemove : null, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad }) }));
|
|
26
|
+
return (jsx_runtime_1.jsx("div", { children: jsx_runtime_1.jsx(ZodSwitch_1.ZodSwitch, { jsonPath: newJsonPath, schema: elementSchema, value: value, setValue: setValue, onRemove: mayRemove ? onRemove : null, mayPad: mayPad }) }));
|
|
32
27
|
};
|
|
33
28
|
exports.ZodArrayItemEditor = ZodArrayItemEditor;
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { AnyZodSchema } from './zod-schema-type';
|
|
3
2
|
import type { JSONPath } from './zod-types';
|
|
4
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
4
|
export declare const ZodBooleanEditor: React.FC<{
|
|
6
|
-
readonly schema: AnyZodSchema;
|
|
7
5
|
readonly jsonPath: JSONPath;
|
|
8
6
|
readonly value: boolean;
|
|
9
7
|
readonly setValue: UpdaterFunction<boolean>;
|
|
10
|
-
readonly defaultValue: boolean;
|
|
11
|
-
readonly onSave: UpdaterFunction<boolean>;
|
|
12
8
|
readonly onRemove: null | (() => void);
|
|
13
|
-
readonly showSaveButton: boolean;
|
|
14
|
-
readonly saving: boolean;
|
|
15
|
-
readonly saveDisabledByParent: boolean;
|
|
16
9
|
readonly mayPad: boolean;
|
|
17
10
|
}>;
|
|
@@ -5,26 +5,16 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const Checkbox_1 = require("../../Checkbox");
|
|
7
7
|
const Fieldset_1 = require("./Fieldset");
|
|
8
|
-
const local_state_1 = require("./local-state");
|
|
9
8
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
10
9
|
const fullWidth = {
|
|
11
10
|
width: '100%',
|
|
12
11
|
};
|
|
13
|
-
const ZodBooleanEditor = ({
|
|
14
|
-
const { localValue, onChange, reset } = (0, local_state_1.useLocalState)({
|
|
15
|
-
schema,
|
|
16
|
-
setValue,
|
|
17
|
-
unsavedValue: value,
|
|
18
|
-
savedValue: defaultValue,
|
|
19
|
-
});
|
|
12
|
+
const ZodBooleanEditor = ({ jsonPath, value, setValue, onRemove, mayPad }) => {
|
|
20
13
|
const onToggle = (0, react_1.useCallback)((e) => {
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, [onSave, value]);
|
|
26
|
-
return (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [
|
|
27
|
-
jsx_runtime_1.jsx(SchemaLabel_1.SchemaLabel, { handleClick: null, isDefaultValue: localValue.value === defaultValue, jsonPath: jsonPath, onReset: reset, onSave: save, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, valid: true, saveDisabledByParent: saveDisabledByParent, suffix: null }), jsx_runtime_1.jsx("div", { style: fullWidth, children: jsx_runtime_1.jsx(Checkbox_1.Checkbox, { name: jsonPath.join('.'), checked: localValue.value, onChange: onToggle, disabled: false }) })
|
|
14
|
+
setValue(() => e.target.checked, { shouldSave: true });
|
|
15
|
+
}, [setValue]);
|
|
16
|
+
return (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: mayPad, children: [
|
|
17
|
+
jsx_runtime_1.jsx(SchemaLabel_1.SchemaLabel, { handleClick: null, jsonPath: jsonPath, onRemove: onRemove, valid: true, suffix: null }), jsx_runtime_1.jsx("div", { style: fullWidth, children: jsx_runtime_1.jsx(Checkbox_1.Checkbox, { name: jsonPath.join('.'), checked: value, onChange: onToggle, disabled: false }) })
|
|
28
18
|
] }));
|
|
29
19
|
};
|
|
30
20
|
exports.ZodBooleanEditor = ZodBooleanEditor;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type AnyZodSchema } from './zod-schema-type';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
4
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
5
|
export declare const ZodColorEditor: React.FC<{
|
|
6
6
|
readonly schema: AnyZodSchema;
|
|
7
7
|
readonly jsonPath: JSONPath;
|
|
8
8
|
readonly value: string;
|
|
9
|
-
readonly defaultValue: string;
|
|
10
9
|
readonly setValue: UpdaterFunction<string>;
|
|
11
|
-
readonly onSave: UpdaterFunction<string>;
|
|
12
10
|
readonly onRemove: null | (() => void);
|
|
13
|
-
readonly showSaveButton: boolean;
|
|
14
|
-
readonly saving: boolean;
|
|
15
|
-
readonly saveDisabledByParent: boolean;
|
|
16
11
|
readonly mayPad: boolean;
|
|
17
12
|
}>;
|
|
@@ -10,13 +10,13 @@ const InputDragger_1 = require("../../NewComposition/InputDragger");
|
|
|
10
10
|
const RemInput_1 = require("../../NewComposition/RemInput");
|
|
11
11
|
const RemInputTypeColor_1 = require("../../NewComposition/RemInputTypeColor");
|
|
12
12
|
const Fieldset_1 = require("./Fieldset");
|
|
13
|
-
const local_state_1 = require("./local-state");
|
|
14
13
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
14
|
+
const zod_schema_type_1 = require("./zod-schema-type");
|
|
15
15
|
const ZodFieldValidation_1 = require("./ZodFieldValidation");
|
|
16
16
|
const fullWidth = {
|
|
17
17
|
width: '100%',
|
|
18
18
|
};
|
|
19
|
-
const ZodColorEditor = ({ jsonPath, value, setValue,
|
|
19
|
+
const ZodColorEditor = ({ jsonPath, value, setValue, schema, onRemove, mayPad }) => {
|
|
20
20
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
21
21
|
if (!z) {
|
|
22
22
|
throw new Error('expected zod');
|
|
@@ -25,30 +25,28 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
25
25
|
if (!zodTypes) {
|
|
26
26
|
throw new Error('expected zod color');
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
unsavedValue: value,
|
|
32
|
-
savedValue: defaultValue,
|
|
33
|
-
});
|
|
34
|
-
const { a, b, g, r } = localValue.zodValidation.success
|
|
35
|
-
? zodTypes.ZodZypesInternals.parseColor(localValue.value)
|
|
28
|
+
const localValue = (0, react_1.useMemo)(() => (0, zod_schema_type_1.zodSafeParse)(schema, value), [schema, value]);
|
|
29
|
+
const { a, b, g, r } = localValue.success
|
|
30
|
+
? zodTypes.ZodZypesInternals.parseColor(value)
|
|
36
31
|
: { a: 1, b: 0, g: 0, r: 0 };
|
|
37
32
|
const onChange = (0, react_1.useCallback)((e) => {
|
|
38
33
|
const newColor = (0, color_math_1.colorWithNewOpacity)(e.target.value, Math.round(a), zodTypes);
|
|
39
|
-
|
|
40
|
-
}, [a,
|
|
34
|
+
setValue(() => newColor, { shouldSave: false });
|
|
35
|
+
}, [a, setValue, zodTypes]);
|
|
36
|
+
const onColorBlur = (0, react_1.useCallback)(() => {
|
|
37
|
+
setValue(() => value, { shouldSave: true });
|
|
38
|
+
}, [setValue, value]);
|
|
41
39
|
const onTextChange = (0, react_1.useCallback)((e) => {
|
|
42
40
|
const newValue = e.target.value;
|
|
43
|
-
|
|
44
|
-
}, [
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
}, [
|
|
41
|
+
setValue(() => newValue, { shouldSave: false });
|
|
42
|
+
}, [setValue]);
|
|
43
|
+
const onTextBlur = (0, react_1.useCallback)(() => {
|
|
44
|
+
setValue(() => value, { shouldSave: true });
|
|
45
|
+
}, [setValue, value]);
|
|
48
46
|
const rgb = `#${r.toString(16).padStart(2, '0')}${g
|
|
49
47
|
.toString(16)
|
|
50
48
|
.padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
|
|
51
|
-
const status = localValue.
|
|
49
|
+
const status = localValue.success ? 'ok' : 'error';
|
|
52
50
|
const colorPicker = (0, react_1.useMemo)(() => {
|
|
53
51
|
return {
|
|
54
52
|
height: 39,
|
|
@@ -57,20 +55,24 @@ const ZodColorEditor = ({ jsonPath, value, setValue, showSaveButton, defaultValu
|
|
|
57
55
|
};
|
|
58
56
|
}, []);
|
|
59
57
|
const onOpacityChange = (0, react_1.useCallback)((newValue) => {
|
|
60
|
-
const newColor = (0, color_math_1.colorWithNewOpacity)(
|
|
61
|
-
|
|
62
|
-
}, [
|
|
58
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(value, Math.round((Number(newValue) / 100) * 255), zodTypes);
|
|
59
|
+
setValue(() => newColor, { shouldSave: true });
|
|
60
|
+
}, [setValue, value, zodTypes]);
|
|
63
61
|
const onOpacityValueChange = (0, react_1.useCallback)((newValue) => {
|
|
64
|
-
const newColor = (0, color_math_1.colorWithNewOpacity)(
|
|
65
|
-
|
|
66
|
-
}, [
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(value, Math.round((Number(newValue) / 100) * 255), zodTypes);
|
|
63
|
+
setValue(() => newColor, { shouldSave: false });
|
|
64
|
+
}, [setValue, value, zodTypes]);
|
|
65
|
+
const onOpacityValueChangeEnd = (0, react_1.useCallback)((newValue) => {
|
|
66
|
+
const newColor = (0, color_math_1.colorWithNewOpacity)(value, Math.round((Number(newValue) / 100) * 255), zodTypes);
|
|
67
|
+
setValue(() => newColor, { shouldSave: true });
|
|
68
|
+
}, [setValue, value, zodTypes]);
|
|
69
|
+
return (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: mayPad, children: [
|
|
70
|
+
jsx_runtime_1.jsx(SchemaLabel_1.SchemaLabel, { handleClick: null, jsonPath: jsonPath, onRemove: onRemove, valid: localValue.success, suffix: null }), jsx_runtime_1.jsxs("div", { style: fullWidth, children: [
|
|
69
71
|
jsx_runtime_1.jsxs(layout_1.Row, { align: "center", children: [
|
|
70
72
|
jsx_runtime_1.jsx("div", { style: colorPicker, children: jsx_runtime_1.jsx(RemInputTypeColor_1.RemInputTypeColor, { type: "color", style: {
|
|
71
73
|
height: 39,
|
|
72
|
-
}, value: rgb, onChange: onChange, className: "__remotion_color_picker", status: status, name: jsonPath.join('.') }) }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1, block: true }), jsx_runtime_1.jsx(RemInput_1.RemotionInput, { value:
|
|
73
|
-
] }), jsx_runtime_1.jsx(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath,
|
|
74
|
+
}, value: rgb, onChange: onChange, onBlur: onColorBlur, className: "__remotion_color_picker", status: status, name: jsonPath.join('.') }) }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1, block: true }), jsx_runtime_1.jsx(RemInput_1.RemotionInput, { value: value, status: status, placeholder: jsonPath.join('.'), onChange: onTextChange, onBlur: onTextBlur, rightAlign: false }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx(InputDragger_1.InputDragger, { onTextChange: onOpacityChange, onValueChange: onOpacityValueChange, onValueChangeEnd: onOpacityValueChangeEnd, status: status, value: (a / 255) * 100, min: 0, max: 100, step: 1, formatter: (v) => `${Math.round(Number(v))}%`, rightAlign: false })
|
|
75
|
+
] }), jsx_runtime_1.jsx(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, zodValidation: localValue })
|
|
74
76
|
] })
|
|
75
77
|
] }));
|
|
76
78
|
};
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type AnyZodSchema } from './zod-schema-type';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
4
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
5
|
export declare const ZodDateEditor: React.FC<{
|
|
6
6
|
readonly schema: AnyZodSchema;
|
|
7
7
|
readonly jsonPath: JSONPath;
|
|
8
8
|
readonly value: Date;
|
|
9
|
-
readonly defaultValue: Date;
|
|
10
9
|
readonly setValue: UpdaterFunction<Date>;
|
|
11
|
-
readonly onSave: UpdaterFunction<Date>;
|
|
12
10
|
readonly onRemove: null | (() => void);
|
|
13
|
-
readonly showSaveButton: boolean;
|
|
14
|
-
readonly saving: boolean;
|
|
15
|
-
readonly saveDisabledByParent: boolean;
|
|
16
11
|
readonly mayPad: boolean;
|
|
17
12
|
}>;
|
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodDateEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("react");
|
|
6
7
|
const colors_1 = require("../../../helpers/colors");
|
|
7
8
|
const layout_1 = require("../../layout");
|
|
8
9
|
const RemInput_1 = require("../../NewComposition/RemInput");
|
|
9
10
|
const Fieldset_1 = require("./Fieldset");
|
|
10
|
-
const local_state_1 = require("./local-state");
|
|
11
11
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
12
|
+
const zod_schema_type_1 = require("./zod-schema-type");
|
|
12
13
|
const ZodFieldValidation_1 = require("./ZodFieldValidation");
|
|
13
14
|
const fullWidth = {
|
|
14
15
|
width: '100%',
|
|
@@ -43,23 +44,18 @@ const formatDate = (date) => {
|
|
|
43
44
|
.padStart(3, '0')}`;
|
|
44
45
|
return formattedDate;
|
|
45
46
|
};
|
|
46
|
-
const ZodDateEditor = ({ jsonPath, value, setValue,
|
|
47
|
-
const
|
|
48
|
-
schema,
|
|
49
|
-
setValue,
|
|
50
|
-
unsavedValue: value,
|
|
51
|
-
savedValue: defaultValue,
|
|
52
|
-
});
|
|
53
|
-
const onChange = (0, react_1.useCallback)((e) => {
|
|
47
|
+
const ZodDateEditor = ({ jsonPath, value, setValue, schema, onRemove, mayPad }) => {
|
|
48
|
+
const onChange = (0, react_2.useCallback)((e) => {
|
|
54
49
|
// React does not support e.target.valueAsDate :(
|
|
55
|
-
|
|
56
|
-
}, [
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
}, [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
setValue(() => new Date(e.target.value), { shouldSave: false });
|
|
51
|
+
}, [setValue]);
|
|
52
|
+
const onBlur = (0, react_2.useCallback)(() => {
|
|
53
|
+
setValue((v) => v, { shouldSave: true });
|
|
54
|
+
}, [setValue]);
|
|
55
|
+
const zodValidation = (0, react_1.useMemo)(() => (0, zod_schema_type_1.zodSafeParse)(schema, value), [schema, value]);
|
|
56
|
+
return (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: mayPad, children: [
|
|
57
|
+
jsx_runtime_1.jsx(SchemaLabel_1.SchemaLabel, { handleClick: null, jsonPath: jsonPath, onRemove: onRemove, valid: zodValidation.success, suffix: null }), jsx_runtime_1.jsxs("div", { style: fullWidth, children: [
|
|
58
|
+
jsx_runtime_1.jsx(RemInput_1.RemotionInput, { value: formatDate(value), type: "datetime-local", status: zodValidation.success ? 'ok' : 'error', placeholder: jsonPath.join('.'), onChange: onChange, onBlur: onBlur, style: inputStyle, rightAlign: false }), jsx_runtime_1.jsx(layout_1.Spacing, { y: 1, block: true }), jsx_runtime_1.jsx("div", { style: explainer, children: "Date is in local format" }), jsx_runtime_1.jsx(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, zodValidation: zodValidation })
|
|
63
59
|
] })
|
|
64
60
|
] }));
|
|
65
61
|
};
|
|
@@ -3,15 +3,10 @@ import type { AnyZodSchema } from './zod-schema-type';
|
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
4
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
5
|
export declare const ZodDefaultEditor: React.FC<{
|
|
6
|
-
readonly showSaveButton: boolean;
|
|
7
6
|
readonly jsonPath: JSONPath;
|
|
8
7
|
readonly value: unknown;
|
|
9
|
-
readonly defaultValue: unknown;
|
|
10
8
|
readonly schema: AnyZodSchema;
|
|
11
9
|
readonly setValue: UpdaterFunction<unknown>;
|
|
12
|
-
readonly onSave: UpdaterFunction<unknown>;
|
|
13
10
|
readonly onRemove: null | (() => void);
|
|
14
|
-
readonly saving: boolean;
|
|
15
|
-
readonly saveDisabledByParent: boolean;
|
|
16
11
|
readonly mayPad: boolean;
|
|
17
12
|
}>;
|
|
@@ -4,8 +4,8 @@ exports.ZodDefaultEditor = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const zod_schema_type_1 = require("./zod-schema-type");
|
|
6
6
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
7
|
-
const ZodDefaultEditor = ({ jsonPath, schema, setValue,
|
|
7
|
+
const ZodDefaultEditor = ({ jsonPath, schema, setValue, value, onRemove, mayPad }) => {
|
|
8
8
|
const innerType = (0, zod_schema_type_1.getInnerType)(schema);
|
|
9
|
-
return (jsx_runtime_1.jsx(ZodSwitch_1.ZodSwitch, {
|
|
9
|
+
return (jsx_runtime_1.jsx(ZodSwitch_1.ZodSwitch, { jsonPath: jsonPath, onRemove: onRemove, schema: innerType, setValue: setValue, value: value, mayPad: mayPad }));
|
|
10
10
|
};
|
|
11
11
|
exports.ZodDefaultEditor = ZodDefaultEditor;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnyZodSchema } from './zod-schema-type';
|
|
2
2
|
import type { JSONPath } from './zod-types';
|
|
3
3
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
4
4
|
export declare const ZodDiscriminatedUnionEditor: React.FC<{
|
|
5
5
|
schema: AnyZodSchema;
|
|
6
6
|
setValue: UpdaterFunction<Record<string, unknown>>;
|
|
7
7
|
value: Record<string, unknown>;
|
|
8
|
-
defaultValue: Record<string, unknown>;
|
|
9
8
|
mayPad: boolean;
|
|
10
9
|
jsonPath: JSONPath;
|
|
11
10
|
onRemove: null | (() => void);
|
|
12
|
-
onSave: UpdaterFunction<unknown>;
|
|
13
|
-
showSaveButton: boolean;
|
|
14
|
-
saving: boolean;
|
|
15
|
-
saveDisabledByParent: boolean;
|
|
16
11
|
}>;
|
|
@@ -8,24 +8,18 @@ const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
|
8
8
|
const ComboBox_1 = require("../../NewComposition/ComboBox");
|
|
9
9
|
const create_zod_values_1 = require("./create-zod-values");
|
|
10
10
|
const Fieldset_1 = require("./Fieldset");
|
|
11
|
-
const local_state_1 = require("./local-state");
|
|
12
11
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
13
12
|
const zod_schema_type_1 = require("./zod-schema-type");
|
|
13
|
+
const zod_schema_type_2 = require("./zod-schema-type");
|
|
14
14
|
const ZodObjectEditor_1 = require("./ZodObjectEditor");
|
|
15
|
-
const ZodDiscriminatedUnionEditor = ({ schema, setValue,
|
|
15
|
+
const ZodDiscriminatedUnionEditor = ({ schema, setValue, value, mayPad, jsonPath, onRemove }) => {
|
|
16
16
|
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
17
17
|
if (!z) {
|
|
18
18
|
throw new Error('expected zod');
|
|
19
19
|
}
|
|
20
20
|
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
21
|
-
const discriminator = (0,
|
|
22
|
-
const options = (0, react_1.useMemo)(() => (0,
|
|
23
|
-
const { localValue, onChange: setLocalValue, reset, } = (0, local_state_1.useLocalState)({
|
|
24
|
-
schema,
|
|
25
|
-
setValue,
|
|
26
|
-
unsavedValue: value,
|
|
27
|
-
savedValue: defaultValue,
|
|
28
|
-
});
|
|
21
|
+
const discriminator = (0, zod_schema_type_2.getDiscriminator)(schema);
|
|
22
|
+
const options = (0, react_1.useMemo)(() => (0, zod_schema_type_2.getDiscriminatedOptionKeys)(schema), [schema]);
|
|
29
23
|
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
30
24
|
return options.map((option) => {
|
|
31
25
|
return {
|
|
@@ -35,51 +29,42 @@ const ZodDiscriminatedUnionEditor = ({ schema, setValue, showSaveButton, saving,
|
|
|
35
29
|
keyHint: null,
|
|
36
30
|
leftItem: option === value[discriminator] ? jsx_runtime_1.jsx(Checkmark_1.Checkmark, {}) : null,
|
|
37
31
|
onClick: () => {
|
|
38
|
-
const optionSchema = (0,
|
|
32
|
+
const optionSchema = (0, zod_schema_type_2.getDiscriminatedOption)(schema, option);
|
|
39
33
|
if (!optionSchema) {
|
|
40
34
|
throw new Error(`No schema found for discriminator value: ${option}`);
|
|
41
35
|
}
|
|
42
36
|
const val = (0, create_zod_values_1.createZodValues)(optionSchema, z, zodTypes);
|
|
43
|
-
|
|
37
|
+
setValue(() => val, { shouldSave: true });
|
|
44
38
|
},
|
|
45
39
|
quickSwitcherLabel: null,
|
|
46
40
|
subMenu: null,
|
|
47
41
|
type: 'item',
|
|
48
42
|
};
|
|
49
43
|
});
|
|
50
|
-
}, [options,
|
|
51
|
-
const
|
|
52
|
-
onSave(() => value, false, false);
|
|
53
|
-
}, [onSave, value]);
|
|
44
|
+
}, [options, setValue, discriminator, schema, value, z, zodTypes]);
|
|
45
|
+
const zodValidation = (0, react_1.useMemo)(() => (0, zod_schema_type_1.zodSafeParse)(schema, value), [schema, value]);
|
|
54
46
|
const discriminatedUnionReplacement = (0, react_1.useMemo)(() => {
|
|
55
47
|
return {
|
|
56
48
|
discriminator,
|
|
57
|
-
markup: (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: mayPad,
|
|
58
|
-
jsx_runtime_1.jsx(SchemaLabel_1.SchemaLabel, { handleClick: null,
|
|
49
|
+
markup: (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: mayPad, children: [
|
|
50
|
+
jsx_runtime_1.jsx(SchemaLabel_1.SchemaLabel, { handleClick: null, jsonPath: [...jsonPath, discriminator], onRemove: onRemove, suffix: null, valid: zodValidation.success }), jsx_runtime_1.jsx(ComboBox_1.Combobox, { title: "Select type", values: comboBoxValues, selectedId: value[discriminator] })
|
|
59
51
|
] }, 'replacement')),
|
|
60
52
|
};
|
|
61
53
|
}, [
|
|
62
54
|
comboBoxValues,
|
|
63
|
-
defaultValue,
|
|
64
55
|
jsonPath,
|
|
65
|
-
localValue.value,
|
|
66
|
-
localValue.zodValidation.success,
|
|
67
56
|
mayPad,
|
|
68
57
|
onRemove,
|
|
69
|
-
reset,
|
|
70
|
-
save,
|
|
71
|
-
saveDisabledByParent,
|
|
72
|
-
saving,
|
|
73
|
-
showSaveButton,
|
|
74
58
|
discriminator,
|
|
75
59
|
value,
|
|
60
|
+
zodValidation.success,
|
|
76
61
|
]);
|
|
77
|
-
const currentOptionSchema = (0,
|
|
62
|
+
const currentOptionSchema = (0, zod_schema_type_2.getDiscriminatedOption)(schema, value[discriminator]);
|
|
78
63
|
if (!currentOptionSchema) {
|
|
79
64
|
throw new Error('No matching option found for discriminated union');
|
|
80
65
|
}
|
|
81
66
|
return (jsx_runtime_1.jsx(ZodObjectEditor_1.ZodObjectEditor
|
|
82
67
|
// Re-render the object editor when the discriminator changes
|
|
83
|
-
, { jsonPath: jsonPath, mayPad: mayPad,
|
|
68
|
+
, { jsonPath: jsonPath, mayPad: mayPad, onRemove: onRemove, schema: currentOptionSchema, setValue: setValue, value: value, discriminatedUnionReplacement: discriminatedUnionReplacement }, value[discriminator]));
|
|
84
69
|
};
|
|
85
70
|
exports.ZodDiscriminatedUnionEditor = ZodDiscriminatedUnionEditor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type AnyZodSchema } from './zod-schema-type';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
4
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
5
|
export declare const ZodEffectEditor: React.FC<{
|
|
@@ -7,10 +7,6 @@ export declare const ZodEffectEditor: React.FC<{
|
|
|
7
7
|
readonly jsonPath: JSONPath;
|
|
8
8
|
readonly value: unknown;
|
|
9
9
|
readonly setValue: UpdaterFunction<unknown>;
|
|
10
|
-
readonly defaultValue: unknown;
|
|
11
|
-
readonly onSave: UpdaterFunction<unknown>;
|
|
12
|
-
readonly showSaveButton: boolean;
|
|
13
10
|
readonly onRemove: null | (() => void);
|
|
14
|
-
readonly saving: boolean;
|
|
15
11
|
readonly mayPad: boolean;
|
|
16
12
|
}>;
|
|
@@ -2,28 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZodEffectEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
5
6
|
const Fieldset_1 = require("./Fieldset");
|
|
6
|
-
const local_state_1 = require("./local-state");
|
|
7
7
|
const zod_schema_type_1 = require("./zod-schema-type");
|
|
8
|
+
const zod_schema_type_2 = require("./zod-schema-type");
|
|
8
9
|
const ZodFieldValidation_1 = require("./ZodFieldValidation");
|
|
9
10
|
const ZodSwitch_1 = require("./ZodSwitch");
|
|
10
11
|
const fullWidth = {
|
|
11
12
|
width: '100%',
|
|
12
13
|
};
|
|
13
|
-
const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue,
|
|
14
|
-
const typeName = (0,
|
|
14
|
+
const ZodEffectEditor = ({ schema, jsonPath, value, setValue: updateValue, onRemove, mayPad }) => {
|
|
15
|
+
const typeName = (0, zod_schema_type_2.getZodSchemaType)(schema);
|
|
15
16
|
if (typeName !== 'effects') {
|
|
16
17
|
throw new Error('expected effect');
|
|
17
18
|
}
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [
|
|
26
|
-
jsx_runtime_1.jsx("div", { style: fullWidth, children: jsx_runtime_1.jsx(ZodSwitch_1.ZodSwitch, { value: value, setValue: onChange, jsonPath: jsonPath, schema: innerSchema, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: !localValue.zodValidation.success, mayPad: false }) }), jsx_runtime_1.jsx(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })
|
|
19
|
+
const onChange = (0, react_1.useCallback)((updater, { shouldSave }) => {
|
|
20
|
+
updateValue(updater, { shouldSave });
|
|
21
|
+
}, [updateValue]);
|
|
22
|
+
const zodValidation = (0, react_1.useMemo)(() => (0, zod_schema_type_1.zodSafeParse)(schema, value), [schema, value]);
|
|
23
|
+
const innerSchema = (0, zod_schema_type_2.getEffectsInner)(schema);
|
|
24
|
+
return (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: mayPad, children: [
|
|
25
|
+
jsx_runtime_1.jsx("div", { style: fullWidth, children: jsx_runtime_1.jsx(ZodSwitch_1.ZodSwitch, { value: value, setValue: onChange, jsonPath: jsonPath, schema: innerSchema, onRemove: onRemove, mayPad: false }) }), jsx_runtime_1.jsx(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, zodValidation: zodValidation })
|
|
27
26
|
] }));
|
|
28
27
|
};
|
|
29
28
|
exports.ZodEffectEditor = ZodEffectEditor;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type AnyZodSchema } from './zod-schema-type';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
4
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
5
|
export declare const ZodEnumEditor: React.FC<{
|
|
6
6
|
readonly schema: AnyZodSchema;
|
|
7
7
|
readonly jsonPath: JSONPath;
|
|
8
8
|
readonly value: string;
|
|
9
|
-
readonly defaultValue: string;
|
|
10
9
|
readonly setValue: UpdaterFunction<string>;
|
|
11
|
-
readonly onSave: UpdaterFunction<string>;
|
|
12
|
-
readonly showSaveButton: boolean;
|
|
13
10
|
readonly onRemove: null | (() => void);
|
|
14
|
-
readonly saving: boolean;
|
|
15
11
|
}>;
|
|
@@ -3,24 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodEnumEditor = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("react");
|
|
6
7
|
const Checkmark_1 = require("../../../icons/Checkmark");
|
|
7
8
|
const ComboBox_1 = require("../../NewComposition/ComboBox");
|
|
8
9
|
const Fieldset_1 = require("./Fieldset");
|
|
9
|
-
const local_state_1 = require("./local-state");
|
|
10
10
|
const SchemaLabel_1 = require("./SchemaLabel");
|
|
11
11
|
const zod_schema_type_1 = require("./zod-schema-type");
|
|
12
|
+
const zod_schema_type_2 = require("./zod-schema-type");
|
|
12
13
|
const ZodFieldValidation_1 = require("./ZodFieldValidation");
|
|
13
14
|
const container = {
|
|
14
15
|
width: '100%',
|
|
15
16
|
};
|
|
16
|
-
const ZodEnumEditor = ({ schema, jsonPath, setValue,
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
savedValue: defaultValue,
|
|
22
|
-
});
|
|
23
|
-
const enumValues = (0, zod_schema_type_1.getEnumValues)(schema);
|
|
17
|
+
const ZodEnumEditor = ({ schema, jsonPath, setValue, value, onRemove }) => {
|
|
18
|
+
const onChange = (0, react_2.useCallback)((updater, { shouldSave }) => {
|
|
19
|
+
setValue(updater, { shouldSave });
|
|
20
|
+
}, [setValue]);
|
|
21
|
+
const enumValues = (0, zod_schema_type_2.getEnumValues)(schema);
|
|
24
22
|
const isRoot = jsonPath.length === 0;
|
|
25
23
|
const comboBoxValues = (0, react_1.useMemo)(() => {
|
|
26
24
|
return enumValues.map((option) => {
|
|
@@ -31,19 +29,17 @@ const ZodEnumEditor = ({ schema, jsonPath, setValue, defaultValue, value, onSave
|
|
|
31
29
|
keyHint: null,
|
|
32
30
|
leftItem: option === value ? jsx_runtime_1.jsx(Checkmark_1.Checkmark, {}) : null,
|
|
33
31
|
onClick: (id) => {
|
|
34
|
-
|
|
32
|
+
onChange(() => id, { shouldSave: true });
|
|
35
33
|
},
|
|
36
34
|
quickSwitcherLabel: null,
|
|
37
35
|
subMenu: null,
|
|
38
36
|
type: 'item',
|
|
39
37
|
};
|
|
40
38
|
});
|
|
41
|
-
}, [enumValues,
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: true, success: localValue.zodValidation.success, children: [
|
|
46
|
-
jsx_runtime_1.jsx(SchemaLabel_1.SchemaLabel, { handleClick: null, onSave: save, showSaveButton: showSaveButton, isDefaultValue: localValue.value === defaultValue, onReset: reset, jsonPath: jsonPath, onRemove: onRemove, saving: saving, valid: localValue.zodValidation.success, saveDisabledByParent: !localValue.zodValidation.success, suffix: null }), jsx_runtime_1.jsx("div", { style: isRoot ? undefined : container, children: jsx_runtime_1.jsx(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: value, title: value }) }), jsx_runtime_1.jsx(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })
|
|
39
|
+
}, [enumValues, onChange, value]);
|
|
40
|
+
const zodValidation = (0, react_1.useMemo)(() => (0, zod_schema_type_1.zodSafeParse)(schema, value), [schema, value]);
|
|
41
|
+
return (jsx_runtime_1.jsxs(Fieldset_1.Fieldset, { shouldPad: true, children: [
|
|
42
|
+
jsx_runtime_1.jsx(SchemaLabel_1.SchemaLabel, { handleClick: null, jsonPath: jsonPath, onRemove: onRemove, valid: zodValidation.success, suffix: null }), jsx_runtime_1.jsx("div", { style: isRoot ? undefined : container, children: jsx_runtime_1.jsx(ComboBox_1.Combobox, { values: comboBoxValues, selectedId: value, title: value }) }), jsx_runtime_1.jsx(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, zodValidation: zodValidation })
|
|
47
43
|
] }));
|
|
48
44
|
};
|
|
49
45
|
exports.ZodEnumEditor = ZodEnumEditor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ZodSafeParseResult } from './zod-schema-type';
|
|
2
2
|
import type { JSONPath } from './zod-types';
|
|
3
3
|
export declare const ZodFieldValidation: React.FC<{
|
|
4
|
-
|
|
4
|
+
zodValidation: ZodSafeParseResult;
|
|
5
5
|
path: JSONPath;
|
|
6
6
|
}>;
|
|
@@ -16,8 +16,7 @@ const stackTrace = {
|
|
|
16
16
|
const stackTraceLabel = {
|
|
17
17
|
fontSize: 14,
|
|
18
18
|
};
|
|
19
|
-
const ZodFieldValidation = ({
|
|
20
|
-
const { zodValidation } = localValue;
|
|
19
|
+
const ZodFieldValidation = ({ zodValidation, path }) => {
|
|
21
20
|
if (zodValidation.success) {
|
|
22
21
|
return null;
|
|
23
22
|
}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type AnyZodSchema } from './zod-schema-type';
|
|
3
3
|
import type { JSONPath } from './zod-types';
|
|
4
4
|
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
5
|
export declare const ZodMatrixEditor: React.FC<{
|
|
6
6
|
readonly schema: AnyZodSchema;
|
|
7
7
|
readonly jsonPath: JSONPath;
|
|
8
8
|
readonly value: unknown[];
|
|
9
|
-
readonly defaultValue: unknown[];
|
|
10
9
|
readonly setValue: UpdaterFunction<unknown[]>;
|
|
11
|
-
readonly onSave: UpdaterFunction<unknown[]>;
|
|
12
|
-
readonly showSaveButton: boolean;
|
|
13
10
|
readonly onRemove: null | (() => void);
|
|
14
|
-
readonly saving: boolean;
|
|
15
|
-
readonly saveDisabledByParent: boolean;
|
|
16
11
|
readonly mayPad: boolean;
|
|
17
12
|
}>;
|