@remotion/studio 4.0.236 → 4.0.237
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/.turbo/turbo-make.log +1 -1
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.d.ts +1 -0
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.js +17 -4
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.js +4 -0
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.d.ts +17 -0
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.js +75 -0
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.d.ts +15 -0
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.js +30 -0
- package/dist/esm/internals.mjs +2087 -1891
- package/package.json +8 -8
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-make.log
CHANGED
|
@@ -6,5 +6,6 @@ export declare const SchemaArrayItemSeparationLine: React.FC<{
|
|
|
6
6
|
readonly onChange: (updater: (oldV: unknown[]) => unknown[], forceApply: boolean, increment: boolean) => void;
|
|
7
7
|
readonly index: number;
|
|
8
8
|
readonly schema: z.ZodTypeAny;
|
|
9
|
+
readonly showAddButton: boolean;
|
|
9
10
|
readonly isLast: boolean;
|
|
10
11
|
}>;
|
|
@@ -22,8 +22,9 @@ const arraySeparationLine = {
|
|
|
22
22
|
marginTop: -exports.VERTICAL_GUIDE_HEIGHT / 2,
|
|
23
23
|
pointerEvents: 'none',
|
|
24
24
|
width: '100%',
|
|
25
|
+
flexBasis: '100%',
|
|
25
26
|
};
|
|
26
|
-
const SchemaArrayItemSeparationLine = ({ onChange, index, schema, isLast }) => {
|
|
27
|
+
const SchemaArrayItemSeparationLine = ({ onChange, index, schema, isLast, showAddButton }) => {
|
|
27
28
|
const [outerHovered, setOuterHovered] = (0, react_1.useState)(false);
|
|
28
29
|
const [innerHovered, setInnerHovered] = (0, react_1.useState)(false);
|
|
29
30
|
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
@@ -47,8 +48,10 @@ const SchemaArrayItemSeparationLine = ({ onChange, index, schema, isLast }) => {
|
|
|
47
48
|
justifyContent: 'center',
|
|
48
49
|
height: exports.VERTICAL_GUIDE_HEIGHT,
|
|
49
50
|
opacity: outerHovered || isLast ? 1 : 0,
|
|
50
|
-
position: '
|
|
51
|
-
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
top: '50%',
|
|
53
|
+
left: '50%',
|
|
54
|
+
transform: 'translate(-50%, -50%)',
|
|
52
55
|
};
|
|
53
56
|
}, [isLast, outerHovered]);
|
|
54
57
|
const inner = (0, react_1.useMemo)(() => {
|
|
@@ -70,7 +73,17 @@ const SchemaArrayItemSeparationLine = ({ onChange, index, schema, isLast }) => {
|
|
|
70
73
|
const onInnerMouseLeave = (0, react_1.useCallback)(() => {
|
|
71
74
|
setInnerHovered(false);
|
|
72
75
|
}, []);
|
|
73
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
76
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexDirection: 'row',
|
|
79
|
+
height: exports.VERTICAL_GUIDE_HEIGHT,
|
|
80
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
81
|
+
flex: 1,
|
|
82
|
+
position: 'relative',
|
|
83
|
+
display: 'flex',
|
|
84
|
+
flexDirection: 'column',
|
|
85
|
+
alignItems: 'flex-end',
|
|
86
|
+
}, children: [showAddButton && ((0, jsx_runtime_1.jsx)("div", { style: dynamicAddButtonStyle, onMouseEnter: onOuterMouseEnter, onMouseLeave: onOuterMouseLeave, children: (0, jsx_runtime_1.jsx)("div", { onClick: onAdd, style: inner, onMouseEnter: onInnerMouseEnter, onMouseLeave: onInnerMouseLeave, children: (0, jsx_runtime_1.jsx)(plus_1.Plus, { color: innerHovered ? 'white' : colors_1.LIGHT_TEXT, style: { height: exports.VERTICAL_GUIDE_HEIGHT / 2 } }) }) })), (0, jsx_runtime_1.jsx)("div", { style: arraySeparationLine })] }), isLast ? ((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)("div", { style: {
|
|
74
87
|
...layout_2.fieldSetText,
|
|
75
88
|
alignItems: 'center',
|
|
76
89
|
display: 'flex',
|
|
@@ -69,7 +69,7 @@ const ZodArrayEditor = ({ schema, jsonPath, setValue, defaultValue, value, onSav
|
|
|
69
69
|
var _a;
|
|
70
70
|
return (
|
|
71
71
|
// eslint-disable-next-line react/no-array-index-key
|
|
72
|
-
(0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor, { onChange: onChange, value: child, def: def, index: i, jsonPath: jsonPath, defaultValue: (_a = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue[i]) !== null && _a !== void 0 ? _a : (0, create_zod_values_1.createZodValues)(def.type, z, zodTypes), onSave: onSave, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad }), (0, jsx_runtime_1.jsx)(SchemaSeparationLine_1.SchemaArrayItemSeparationLine, { schema: schema, index: i, onChange: onChange, isLast: i === localValue.value.length - 1 })] }, `${i}${localValue.keyStabilityRevision}`));
|
|
73
|
-
}), value.length === 0 ? ((0, jsx_runtime_1.jsx)(SchemaSeparationLine_1.SchemaArrayItemSeparationLine, { schema: schema, index: 0, onChange: onChange, isLast: true })) : null] }) })) : null, (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] }));
|
|
72
|
+
(0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(ZodArrayItemEditor_1.ZodArrayItemEditor, { onChange: onChange, value: child, def: def, index: i, jsonPath: jsonPath, defaultValue: (_a = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue[i]) !== null && _a !== void 0 ? _a : (0, create_zod_values_1.createZodValues)(def.type, z, zodTypes), onSave: onSave, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad }), (0, jsx_runtime_1.jsx)(SchemaSeparationLine_1.SchemaArrayItemSeparationLine, { schema: schema, index: i, onChange: onChange, isLast: i === localValue.value.length - 1, showAddButton: true })] }, `${i}${localValue.keyStabilityRevision}`));
|
|
73
|
+
}), value.length === 0 ? ((0, jsx_runtime_1.jsx)(SchemaSeparationLine_1.SchemaArrayItemSeparationLine, { schema: schema, index: 0, onChange: onChange, isLast: true, showAddButton: true })) : null] }) })) : null, (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] }));
|
|
74
74
|
};
|
|
75
75
|
exports.ZodArrayEditor = ZodArrayEditor;
|
|
@@ -19,6 +19,7 @@ const ZodOptionalEditor_1 = require("./ZodOptionalEditor");
|
|
|
19
19
|
const ZodStaticFileEditor_1 = require("./ZodStaticFileEditor");
|
|
20
20
|
const ZodStringEditor_1 = require("./ZodStringEditor");
|
|
21
21
|
const ZodTextareaEditor_1 = require("./ZodTextareaEditor");
|
|
22
|
+
const ZodTupleEditor_1 = require("./ZodTupleEditor");
|
|
22
23
|
const ZodUnionEditor_1 = require("./ZodUnionEditor");
|
|
23
24
|
const ZodSwitch = ({ schema, jsonPath, value, setValue, defaultValue, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
|
|
24
25
|
const def = schema._def;
|
|
@@ -96,6 +97,9 @@ const ZodSwitch = ({ schema, jsonPath, value, setValue, defaultValue, onSave, sh
|
|
|
96
97
|
if (typeName === z.ZodFirstPartyTypeKind.ZodDiscriminatedUnion) {
|
|
97
98
|
return ((0, jsx_runtime_1.jsx)(ZodDiscriminatedUnionEditor_1.ZodDiscriminatedUnionEditor, { defaultValue: defaultValue, mayPad: mayPad, schema: schema, setValue: setValue, value: value, jsonPath: jsonPath, onRemove: onRemove, onSave: onSave, saving: saving, saveDisabledByParent: saveDisabledByParent, showSaveButton: showSaveButton }));
|
|
98
99
|
}
|
|
100
|
+
if (typeName === z.ZodFirstPartyTypeKind.ZodTuple) {
|
|
101
|
+
return ((0, jsx_runtime_1.jsx)(ZodTupleEditor_1.ZodTupleEditor, { setValue: setValue, value: value, jsonPath: jsonPath, schema: schema, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: onRemove, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad }));
|
|
102
|
+
}
|
|
99
103
|
return ((0, jsx_runtime_1.jsx)(ZodNonEditableValue_1.ZonNonEditableValue, { jsonPath: jsonPath, showSaveButton: showSaveButton, label: `${typeName} (not editable)`, saving: saving, mayPad: mayPad }));
|
|
100
104
|
};
|
|
101
105
|
exports.ZodSwitch = ZodSwitch;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { JSONPath } from './zod-types';
|
|
4
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
5
|
+
export declare const ZodTupleEditor: React.FC<{
|
|
6
|
+
readonly schema: z.ZodTypeAny;
|
|
7
|
+
readonly jsonPath: JSONPath;
|
|
8
|
+
readonly value: unknown[];
|
|
9
|
+
readonly defaultValue: unknown[];
|
|
10
|
+
readonly setValue: UpdaterFunction<unknown[]>;
|
|
11
|
+
readonly onSave: UpdaterFunction<unknown[]>;
|
|
12
|
+
readonly showSaveButton: boolean;
|
|
13
|
+
readonly onRemove: null | (() => void);
|
|
14
|
+
readonly saving: boolean;
|
|
15
|
+
readonly saveDisabledByParent: boolean;
|
|
16
|
+
readonly mayPad: boolean;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ZodTupleEditor = void 0;
|
|
27
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
30
|
+
const create_zod_values_1 = require("./create-zod-values");
|
|
31
|
+
const deep_equal_1 = require("./deep-equal");
|
|
32
|
+
const Fieldset_1 = require("./Fieldset");
|
|
33
|
+
const local_state_1 = require("./local-state");
|
|
34
|
+
const SchemaLabel_1 = require("./SchemaLabel");
|
|
35
|
+
const SchemaSeparationLine_1 = require("./SchemaSeparationLine");
|
|
36
|
+
const SchemaVerticalGuide_1 = require("./SchemaVerticalGuide");
|
|
37
|
+
const ZodFieldValidation_1 = require("./ZodFieldValidation");
|
|
38
|
+
const ZodTupleItemEditor_1 = require("./ZodTupleItemEditor");
|
|
39
|
+
const ZodTupleEditor = ({ schema, jsonPath, setValue, defaultValue, value, onSave, showSaveButton, onRemove, saving, saveDisabledByParent, mayPad, }) => {
|
|
40
|
+
const { localValue, onChange, RevisionContextProvider, reset } = (0, local_state_1.useLocalState)({
|
|
41
|
+
unsavedValue: value,
|
|
42
|
+
schema,
|
|
43
|
+
setValue,
|
|
44
|
+
savedValue: defaultValue,
|
|
45
|
+
});
|
|
46
|
+
const [expanded, setExpanded] = (0, react_1.useState)(true);
|
|
47
|
+
const def = schema._def;
|
|
48
|
+
const suffix = (0, react_1.useMemo)(() => {
|
|
49
|
+
return expanded ? ' [' : ' [...] ';
|
|
50
|
+
}, [expanded]);
|
|
51
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
52
|
+
if (!z) {
|
|
53
|
+
throw new Error('expected zod');
|
|
54
|
+
}
|
|
55
|
+
const zodTypes = (0, get_zod_if_possible_1.useZodTypesIfPossible)();
|
|
56
|
+
const typeName = def.typeName;
|
|
57
|
+
if (typeName !== z.ZodFirstPartyTypeKind.ZodTuple) {
|
|
58
|
+
throw new Error('expected object');
|
|
59
|
+
}
|
|
60
|
+
const isDefaultValue = (0, react_1.useMemo)(() => {
|
|
61
|
+
return (0, deep_equal_1.deepEqual)(localValue.value, defaultValue);
|
|
62
|
+
}, [defaultValue, localValue]);
|
|
63
|
+
return ((0, jsx_runtime_1.jsxs)(Fieldset_1.Fieldset, { shouldPad: mayPad, success: localValue.zodValidation.success, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
64
|
+
display: 'flex',
|
|
65
|
+
flexDirection: 'row',
|
|
66
|
+
}, children: (0, jsx_runtime_1.jsx)(SchemaLabel_1.SchemaLabel, { onReset: reset, isDefaultValue: isDefaultValue, jsonPath: jsonPath, onRemove: onRemove, suffix: suffix, onSave: () => {
|
|
67
|
+
onSave(() => localValue.value, false, false);
|
|
68
|
+
}, saveDisabledByParent: saveDisabledByParent, saving: saving, showSaveButton: showSaveButton, valid: localValue.zodValidation.success, handleClick: () => setExpanded(!expanded) }) }), expanded ? ((0, jsx_runtime_1.jsx)(RevisionContextProvider, { children: (0, jsx_runtime_1.jsxs)(SchemaVerticalGuide_1.SchemaVerticalGuide, { isRoot: false, children: [localValue.value.map((child, i) => {
|
|
69
|
+
var _a;
|
|
70
|
+
return (
|
|
71
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
72
|
+
(0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(ZodTupleItemEditor_1.ZodTupleItemEditor, { onChange: onChange, value: child, def: def, index: i, jsonPath: jsonPath, defaultValue: (_a = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue[i]) !== null && _a !== void 0 ? _a : (0, create_zod_values_1.createZodValues)(def.items[i], z, zodTypes), onSave: onSave, showSaveButton: showSaveButton, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad }), (0, jsx_runtime_1.jsx)(SchemaSeparationLine_1.SchemaArrayItemSeparationLine, { schema: schema, index: i, onChange: onChange, isLast: i === localValue.value.length - 1, showAddButton: false })] }, `${i}${localValue.keyStabilityRevision}`));
|
|
73
|
+
}), value.length === 0 ? ((0, jsx_runtime_1.jsx)(SchemaSeparationLine_1.SchemaArrayItemSeparationLine, { schema: schema, index: 0, onChange: onChange, isLast: true, showAddButton: false })) : null] }) })) : null, (0, jsx_runtime_1.jsx)(ZodFieldValidation_1.ZodFieldValidation, { path: jsonPath, localValue: localValue })] }));
|
|
74
|
+
};
|
|
75
|
+
exports.ZodTupleEditor = ZodTupleEditor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { UpdaterFunction } from './ZodSwitch';
|
|
2
|
+
import type { JSONPath } from './zod-types';
|
|
3
|
+
export declare const ZodTupleItemEditor: React.FC<{
|
|
4
|
+
jsonPath: JSONPath;
|
|
5
|
+
onChange: UpdaterFunction<unknown[]>;
|
|
6
|
+
def: any;
|
|
7
|
+
index: number;
|
|
8
|
+
value: unknown;
|
|
9
|
+
defaultValue: unknown;
|
|
10
|
+
onSave: UpdaterFunction<unknown[]>;
|
|
11
|
+
showSaveButton: boolean;
|
|
12
|
+
saving: boolean;
|
|
13
|
+
saveDisabledByParent: boolean;
|
|
14
|
+
mayPad: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZodTupleItemEditor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const get_zod_if_possible_1 = require("../../get-zod-if-possible");
|
|
7
|
+
const ZodSwitch_1 = require("./ZodSwitch");
|
|
8
|
+
const ZodTupleItemEditor = ({ def, onChange, jsonPath, index, value, defaultValue, onSave: onSaveObject, showSaveButton, saving, saveDisabledByParent, mayPad, }) => {
|
|
9
|
+
const z = (0, get_zod_if_possible_1.useZodIfPossible)();
|
|
10
|
+
if (!z) {
|
|
11
|
+
throw new Error('expected zod');
|
|
12
|
+
}
|
|
13
|
+
const setValue = (0, react_1.useCallback)((val) => {
|
|
14
|
+
onChange((oldV) => [
|
|
15
|
+
...oldV.slice(0, index),
|
|
16
|
+
typeof val === 'function' ? val(oldV[index]) : val,
|
|
17
|
+
...oldV.slice(index + 1),
|
|
18
|
+
], false, false);
|
|
19
|
+
}, [index, onChange]);
|
|
20
|
+
const newJsonPath = (0, react_1.useMemo)(() => [...jsonPath, index], [index, jsonPath]);
|
|
21
|
+
const onSave = (0, react_1.useCallback)((updater) => {
|
|
22
|
+
onSaveObject((oldV) => [
|
|
23
|
+
...oldV.slice(0, index),
|
|
24
|
+
updater(oldV[index]),
|
|
25
|
+
...oldV.slice(index + 1),
|
|
26
|
+
], false, false);
|
|
27
|
+
}, [index, onSaveObject]);
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(ZodSwitch_1.ZodSwitch, { jsonPath: newJsonPath, schema: def.items[index], value: value, setValue: setValue, defaultValue: defaultValue, onSave: onSave, showSaveButton: showSaveButton, onRemove: null, saving: saving, saveDisabledByParent: saveDisabledByParent, mayPad: mayPad }) }));
|
|
29
|
+
};
|
|
30
|
+
exports.ZodTupleItemEditor = ZodTupleItemEditor;
|