@remotion/studio 4.0.425 → 4.0.426
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/api/create-composition.d.ts +1 -2
- package/dist/api/helpers/calc-new-props.d.ts +1 -2
- package/dist/components/AssetSelector.js +1 -1
- package/dist/components/AssetSelectorItem.d.ts +1 -0
- package/dist/components/AssetSelectorItem.js +9 -8
- package/dist/components/InitialCompositionLoader.js +13 -1
- package/dist/components/NewComposition/CodemodFooter.d.ts +1 -0
- package/dist/components/NewComposition/CodemodFooter.js +3 -1
- package/dist/components/NewComposition/DeleteComposition.js +1 -1
- package/dist/components/NewComposition/DuplicateComposition.js +5 -1
- package/dist/components/NewComposition/RenameComposition.js +1 -1
- package/dist/components/RenderModal/DataEditor.d.ts +2 -1
- package/dist/components/RenderModal/DataEditor.js +6 -6
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.d.ts +2 -2
- package/dist/components/RenderModal/RenderModalJSONPropsEditor.js +3 -2
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/SchemaEditor.js +4 -5
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/SchemaErrorMessages.js +1 -0
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/SchemaSeparationLine.js +4 -3
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodArrayEditor.js +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.d.ts +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodArrayItemEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodBooleanEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodColorEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDateEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/ZodDefaultEditor.js +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodDiscriminatedUnionEditor.js +18 -18
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodEffectEditor.js +6 -10
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodEnumEditor.js +4 -12
- package/dist/components/RenderModal/SchemaEditor/ZodErrorMessages.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodErrorMessages.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodFieldValidation.js +4 -3
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodMatrixEditor.js +3 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNullableEditor.js +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodNumberEditor.js +49 -21
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodObjectEditor.js +4 -9
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodOptionalEditor.js +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodOrNullishEditor.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodStaticFileEditor.js +0 -10
- package/dist/components/RenderModal/SchemaEditor/ZodStringEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodSwitch.js +38 -33
- package/dist/components/RenderModal/SchemaEditor/ZodTextareaEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodTupleEditor.js +3 -6
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.d.ts +2 -1
- package/dist/components/RenderModal/SchemaEditor/ZodTupleItemEditor.js +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/ZodUnionEditor.js +11 -15
- package/dist/components/RenderModal/SchemaEditor/create-zod-values.d.ts +2 -2
- package/dist/components/RenderModal/SchemaEditor/create-zod-values.js +108 -110
- package/dist/components/RenderModal/SchemaEditor/extract-enum-json-paths.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/extract-enum-json-paths.js +72 -87
- package/dist/components/RenderModal/SchemaEditor/local-state.d.ts +3 -3
- package/dist/components/RenderModal/SchemaEditor/local-state.js +5 -4
- package/dist/components/RenderModal/SchemaEditor/zod-schema-type.d.ts +176 -0
- package/dist/components/RenderModal/SchemaEditor/zod-schema-type.js +330 -0
- package/dist/components/get-zod-if-possible.d.ts +3 -0
- package/dist/components/get-zod-if-possible.js +23 -2
- package/dist/esm/{chunk-5wcqz8k8.js → chunk-kde77jse.js} +574 -367
- package/dist/esm/index.mjs +170 -81
- package/dist/esm/internals.mjs +574 -367
- package/dist/esm/previewEntry.mjs +574 -367
- package/dist/esm/renderEntry.mjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/visual-controls/VisualControls.d.ts +4 -4
- package/dist/visual-controls/VisualControls.js +1 -1
- package/package.json +10 -10
|
@@ -3693,7 +3693,8 @@ var AssetFolderItem = ({
|
|
|
3693
3693
|
parentFolder,
|
|
3694
3694
|
toggleFolder,
|
|
3695
3695
|
dropLocation,
|
|
3696
|
-
setDropLocation
|
|
3696
|
+
setDropLocation,
|
|
3697
|
+
readOnlyStudio
|
|
3697
3698
|
}) => {
|
|
3698
3699
|
const [hovered, setHovered] = useState15(false);
|
|
3699
3700
|
const openFolderTimerRef = useRef12(null);
|
|
@@ -3776,7 +3777,8 @@ var AssetFolderItem = ({
|
|
|
3776
3777
|
tabIndex,
|
|
3777
3778
|
toggleFolder,
|
|
3778
3779
|
dropLocation,
|
|
3779
|
-
setDropLocation
|
|
3780
|
+
setDropLocation,
|
|
3781
|
+
readOnlyStudio
|
|
3780
3782
|
}, item.name) : null
|
|
3781
3783
|
]
|
|
3782
3784
|
});
|
|
@@ -3789,7 +3791,8 @@ var AssetFolderTree = ({
|
|
|
3789
3791
|
toggleFolder,
|
|
3790
3792
|
tabIndex,
|
|
3791
3793
|
dropLocation,
|
|
3792
|
-
setDropLocation
|
|
3794
|
+
setDropLocation,
|
|
3795
|
+
readOnlyStudio
|
|
3793
3796
|
}) => {
|
|
3794
3797
|
const combinedParents = useMemo23(() => {
|
|
3795
3798
|
return [parentFolder, name].filter(NoReactInternals3.truthy).join("/");
|
|
@@ -3804,7 +3807,8 @@ var AssetFolderTree = ({
|
|
|
3804
3807
|
parentFolder: combinedParents,
|
|
3805
3808
|
toggleFolder,
|
|
3806
3809
|
dropLocation,
|
|
3807
|
-
setDropLocation
|
|
3810
|
+
setDropLocation,
|
|
3811
|
+
readOnlyStudio
|
|
3808
3812
|
}, folder.name);
|
|
3809
3813
|
}),
|
|
3810
3814
|
item.files.map((file) => {
|
|
@@ -3812,13 +3816,14 @@ var AssetFolderTree = ({
|
|
|
3812
3816
|
item: file,
|
|
3813
3817
|
tabIndex,
|
|
3814
3818
|
level,
|
|
3815
|
-
parentFolder: combinedParents
|
|
3819
|
+
parentFolder: combinedParents,
|
|
3820
|
+
readOnlyStudio
|
|
3816
3821
|
}, file.src);
|
|
3817
3822
|
})
|
|
3818
3823
|
]
|
|
3819
3824
|
});
|
|
3820
3825
|
};
|
|
3821
|
-
var AssetSelectorItem = ({ item, tabIndex, level, parentFolder }) => {
|
|
3826
|
+
var AssetSelectorItem = ({ item, tabIndex, level, parentFolder, readOnlyStudio }) => {
|
|
3822
3827
|
const isMobileLayout = useMobileLayout();
|
|
3823
3828
|
const [hovered, setHovered] = useState15(false);
|
|
3824
3829
|
const { setSidebarCollapsedState } = useContext10(SidebarContext);
|
|
@@ -3925,13 +3930,17 @@ var AssetSelectorItem = ({ item, tabIndex, level, parentFolder }) => {
|
|
|
3925
3930
|
renderAction: renderCopyAction,
|
|
3926
3931
|
onClick: copyToClipboard
|
|
3927
3932
|
}),
|
|
3928
|
-
/* @__PURE__ */
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3933
|
+
readOnlyStudio ? null : /* @__PURE__ */ jsxs9(Fragment5, {
|
|
3934
|
+
children: [
|
|
3935
|
+
/* @__PURE__ */ jsx35(Spacing, {
|
|
3936
|
+
x: 0.5
|
|
3937
|
+
}),
|
|
3938
|
+
/* @__PURE__ */ jsx35(InlineAction, {
|
|
3939
|
+
title: "Open in Explorer",
|
|
3940
|
+
renderAction: renderFileExplorerAction,
|
|
3941
|
+
onClick: revealInExplorer
|
|
3942
|
+
})
|
|
3943
|
+
]
|
|
3935
3944
|
})
|
|
3936
3945
|
]
|
|
3937
3946
|
}) : null
|
|
@@ -4286,7 +4295,8 @@ var AssetSelector = ({ readOnlyStudio }) => {
|
|
|
4286
4295
|
tabIndex,
|
|
4287
4296
|
toggleFolder,
|
|
4288
4297
|
dropLocation,
|
|
4289
|
-
setDropLocation
|
|
4298
|
+
setDropLocation,
|
|
4299
|
+
readOnlyStudio
|
|
4290
4300
|
})
|
|
4291
4301
|
})
|
|
4292
4302
|
]
|
|
@@ -4579,10 +4589,16 @@ var InitialCompositionLoader = () => {
|
|
|
4579
4589
|
const selectAsset = useSelectAsset();
|
|
4580
4590
|
const staticFiles = useStaticFiles();
|
|
4581
4591
|
useEffect15(() => {
|
|
4592
|
+
const canvasContentFromUrl = deriveCanvasContentFromUrl();
|
|
4582
4593
|
if (canvasContent) {
|
|
4594
|
+
if (canvasContentFromUrl && canvasContentFromUrl.type === "composition" && canvasContent.type === "composition" && canvasContentFromUrl.compositionId !== canvasContent.compositionId) {
|
|
4595
|
+
const exists = compositions.find((c) => c.id === canvasContentFromUrl.compositionId);
|
|
4596
|
+
if (exists) {
|
|
4597
|
+
selectComposition(exists, false);
|
|
4598
|
+
}
|
|
4599
|
+
}
|
|
4583
4600
|
return;
|
|
4584
4601
|
}
|
|
4585
|
-
const canvasContentFromUrl = deriveCanvasContentFromUrl();
|
|
4586
4602
|
if (canvasContentFromUrl && canvasContentFromUrl.type === "composition") {
|
|
4587
4603
|
const exists = compositions.find((c) => c.id === canvasContentFromUrl.compositionId);
|
|
4588
4604
|
if (exists) {
|
|
@@ -10841,6 +10857,14 @@ async function getZodIfPossible() {
|
|
|
10841
10857
|
return null;
|
|
10842
10858
|
}
|
|
10843
10859
|
}
|
|
10860
|
+
var getZodV3IfPossible = async () => {
|
|
10861
|
+
try {
|
|
10862
|
+
const mod = await import("zod/v3");
|
|
10863
|
+
return mod;
|
|
10864
|
+
} catch {
|
|
10865
|
+
return null;
|
|
10866
|
+
}
|
|
10867
|
+
};
|
|
10844
10868
|
var getZTypesIfPossible = async () => {
|
|
10845
10869
|
try {
|
|
10846
10870
|
const mod = await import("@remotion/zod-types");
|
|
@@ -10860,19 +10884,24 @@ var useZodTypesIfPossible = () => {
|
|
|
10860
10884
|
var ZodContext = createContext16(null);
|
|
10861
10885
|
var ZodProvider = ({ children }) => {
|
|
10862
10886
|
const [zod, setZod] = useState39(null);
|
|
10887
|
+
const [zodV3, setZodV3] = useState39(null);
|
|
10863
10888
|
const [zodTypes, setZodTypes] = useState39(null);
|
|
10864
10889
|
useEffect39(() => {
|
|
10865
10890
|
getZodIfPossible().then((z) => setZod(z));
|
|
10866
10891
|
}, []);
|
|
10892
|
+
useEffect39(() => {
|
|
10893
|
+
getZodV3IfPossible().then((z) => setZodV3(z));
|
|
10894
|
+
}, []);
|
|
10867
10895
|
useEffect39(() => {
|
|
10868
10896
|
getZTypesIfPossible().then((z) => setZodTypes(z));
|
|
10869
10897
|
}, []);
|
|
10870
10898
|
const contextValue = useMemo53(() => {
|
|
10871
10899
|
return {
|
|
10872
10900
|
zod,
|
|
10901
|
+
zodV3,
|
|
10873
10902
|
zodTypes
|
|
10874
10903
|
};
|
|
10875
|
-
}, [zod, zodTypes]);
|
|
10904
|
+
}, [zod, zodV3, zodTypes]);
|
|
10876
10905
|
return /* @__PURE__ */ jsx95(ZodContext.Provider, {
|
|
10877
10906
|
value: contextValue,
|
|
10878
10907
|
children
|
|
@@ -11014,6 +11043,184 @@ import { Internals as Internals30 } from "remotion";
|
|
|
11014
11043
|
// src/api/save-default-props.ts
|
|
11015
11044
|
import { getRemotionEnvironment as getRemotionEnvironment4 } from "remotion";
|
|
11016
11045
|
|
|
11046
|
+
// src/components/RenderModal/SchemaEditor/zod-schema-type.ts
|
|
11047
|
+
var zodSafeParse = (schema, data) => {
|
|
11048
|
+
return schema.safeParse(data);
|
|
11049
|
+
};
|
|
11050
|
+
var getZodDef = (schema) => {
|
|
11051
|
+
if (schema._def)
|
|
11052
|
+
return schema._def;
|
|
11053
|
+
if (schema._zod)
|
|
11054
|
+
return schema._zod.def;
|
|
11055
|
+
throw new Error("Invalid zod schema: missing _def and _zod");
|
|
11056
|
+
};
|
|
11057
|
+
var v3TypeNameMap = {
|
|
11058
|
+
ZodString: "string",
|
|
11059
|
+
ZodNumber: "number",
|
|
11060
|
+
ZodBoolean: "boolean",
|
|
11061
|
+
ZodObject: "object",
|
|
11062
|
+
ZodArray: "array",
|
|
11063
|
+
ZodEnum: "enum",
|
|
11064
|
+
ZodUnion: "union",
|
|
11065
|
+
ZodDiscriminatedUnion: "discriminatedUnion",
|
|
11066
|
+
ZodOptional: "optional",
|
|
11067
|
+
ZodNullable: "nullable",
|
|
11068
|
+
ZodDefault: "default",
|
|
11069
|
+
ZodTuple: "tuple",
|
|
11070
|
+
ZodDate: "date",
|
|
11071
|
+
ZodAny: "any",
|
|
11072
|
+
ZodUnknown: "unknown",
|
|
11073
|
+
ZodBigInt: "bigint",
|
|
11074
|
+
ZodNull: "null",
|
|
11075
|
+
ZodUndefined: "undefined",
|
|
11076
|
+
ZodEffects: "effects",
|
|
11077
|
+
ZodLiteral: "literal",
|
|
11078
|
+
ZodRecord: "record",
|
|
11079
|
+
ZodNever: "never",
|
|
11080
|
+
ZodVoid: "void",
|
|
11081
|
+
ZodNaN: "nan",
|
|
11082
|
+
ZodSymbol: "symbol",
|
|
11083
|
+
ZodIntersection: "intersection",
|
|
11084
|
+
ZodMap: "map",
|
|
11085
|
+
ZodSet: "set",
|
|
11086
|
+
ZodLazy: "lazy",
|
|
11087
|
+
ZodFunction: "function",
|
|
11088
|
+
ZodNativeEnum: "nativeEnum",
|
|
11089
|
+
ZodCatch: "catch",
|
|
11090
|
+
ZodPromise: "promise",
|
|
11091
|
+
ZodBranded: "branded",
|
|
11092
|
+
ZodPipeline: "pipeline"
|
|
11093
|
+
};
|
|
11094
|
+
var isZodV3Schema = (schema) => {
|
|
11095
|
+
const def = getZodDef(schema);
|
|
11096
|
+
return "typeName" in def;
|
|
11097
|
+
};
|
|
11098
|
+
var getZodSchemaType = (schema) => {
|
|
11099
|
+
const def = getZodDef(schema);
|
|
11100
|
+
if ("typeName" in def) {
|
|
11101
|
+
const { typeName } = def;
|
|
11102
|
+
return v3TypeNameMap[typeName] ?? typeName;
|
|
11103
|
+
}
|
|
11104
|
+
const { type } = def;
|
|
11105
|
+
if (type === "union" && def.discriminator !== undefined) {
|
|
11106
|
+
return "discriminatedUnion";
|
|
11107
|
+
}
|
|
11108
|
+
return type;
|
|
11109
|
+
};
|
|
11110
|
+
var getZodSchemaDescription = (schema) => {
|
|
11111
|
+
if (isZodV3Schema(schema)) {
|
|
11112
|
+
return getZodDef(schema).description;
|
|
11113
|
+
}
|
|
11114
|
+
return schema.description;
|
|
11115
|
+
};
|
|
11116
|
+
var getObjectShape = (schema) => {
|
|
11117
|
+
const { shape } = getZodDef(schema);
|
|
11118
|
+
return typeof shape === "function" ? shape() : shape;
|
|
11119
|
+
};
|
|
11120
|
+
var getArrayElement = (schema) => {
|
|
11121
|
+
const def = getZodDef(schema);
|
|
11122
|
+
return isZodV3Schema(schema) ? def.type : def.element;
|
|
11123
|
+
};
|
|
11124
|
+
var getInnerType = (schema) => {
|
|
11125
|
+
return getZodDef(schema).innerType;
|
|
11126
|
+
};
|
|
11127
|
+
var getEffectsInner = (schema) => {
|
|
11128
|
+
return getZodDef(schema).schema;
|
|
11129
|
+
};
|
|
11130
|
+
var getLiteralValue = (schema) => {
|
|
11131
|
+
const def = getZodDef(schema);
|
|
11132
|
+
if (isZodV3Schema(schema)) {
|
|
11133
|
+
return def.value;
|
|
11134
|
+
}
|
|
11135
|
+
return def.values?.[0];
|
|
11136
|
+
};
|
|
11137
|
+
var getEnumValues = (schema) => {
|
|
11138
|
+
const def = getZodDef(schema);
|
|
11139
|
+
if (isZodV3Schema(schema)) {
|
|
11140
|
+
return def.values;
|
|
11141
|
+
}
|
|
11142
|
+
const { entries } = def;
|
|
11143
|
+
return Object.values(entries);
|
|
11144
|
+
};
|
|
11145
|
+
var getFirstEnumValue = (schema) => {
|
|
11146
|
+
const def = getZodDef(schema);
|
|
11147
|
+
if (isZodV3Schema(schema)) {
|
|
11148
|
+
if (def.typeName === "ZodNativeEnum") {
|
|
11149
|
+
const vals = Object.values(def.values);
|
|
11150
|
+
return vals[0];
|
|
11151
|
+
}
|
|
11152
|
+
return def.values[0];
|
|
11153
|
+
}
|
|
11154
|
+
const { entries } = def;
|
|
11155
|
+
const pairs = Object.entries(entries);
|
|
11156
|
+
const hasReverseMapping = pairs.some(([key, value]) => key !== String(value));
|
|
11157
|
+
if (hasReverseMapping) {
|
|
11158
|
+
const forwardPairs = pairs.filter(([key]) => Number.isNaN(Number(key)));
|
|
11159
|
+
if (forwardPairs.length > 0) {
|
|
11160
|
+
return forwardPairs[0][1];
|
|
11161
|
+
}
|
|
11162
|
+
}
|
|
11163
|
+
return Object.values(entries)[0];
|
|
11164
|
+
};
|
|
11165
|
+
var getUnionOptions = (schema) => {
|
|
11166
|
+
return getZodDef(schema).options;
|
|
11167
|
+
};
|
|
11168
|
+
var getDefaultValue = (schema) => {
|
|
11169
|
+
const dv = getZodDef(schema).defaultValue;
|
|
11170
|
+
return typeof dv === "function" ? dv() : dv;
|
|
11171
|
+
};
|
|
11172
|
+
var getDiscriminator = (schema) => {
|
|
11173
|
+
return getZodDef(schema).discriminator;
|
|
11174
|
+
};
|
|
11175
|
+
var getDiscriminatedOptionKeys = (schema) => {
|
|
11176
|
+
const def = getZodDef(schema);
|
|
11177
|
+
const discriminator = getDiscriminator(schema);
|
|
11178
|
+
if (isZodV3Schema(schema) && def.optionsMap) {
|
|
11179
|
+
return [...def.optionsMap.keys()];
|
|
11180
|
+
}
|
|
11181
|
+
const options = getUnionOptions(schema);
|
|
11182
|
+
return options.map((option) => {
|
|
11183
|
+
const shape = getObjectShape(option);
|
|
11184
|
+
const discriminatorSchema = shape[discriminator];
|
|
11185
|
+
return getLiteralValue(discriminatorSchema);
|
|
11186
|
+
});
|
|
11187
|
+
};
|
|
11188
|
+
var getDiscriminatedOption = (schema, discriminatorValue) => {
|
|
11189
|
+
const def = getZodDef(schema);
|
|
11190
|
+
const discriminator = getDiscriminator(schema);
|
|
11191
|
+
if (isZodV3Schema(schema) && def.optionsMap) {
|
|
11192
|
+
return def.optionsMap.get(discriminatorValue);
|
|
11193
|
+
}
|
|
11194
|
+
const options = getUnionOptions(schema);
|
|
11195
|
+
return options.find((option) => {
|
|
11196
|
+
const shape = getObjectShape(option);
|
|
11197
|
+
const discriminatorSchema = shape[discriminator];
|
|
11198
|
+
return getLiteralValue(discriminatorSchema) === discriminatorValue;
|
|
11199
|
+
});
|
|
11200
|
+
};
|
|
11201
|
+
var getIntersectionSchemas = (schema) => {
|
|
11202
|
+
const def = getZodDef(schema);
|
|
11203
|
+
return { left: def.left, right: def.right };
|
|
11204
|
+
};
|
|
11205
|
+
var getTupleItems = (schema) => {
|
|
11206
|
+
return getZodDef(schema).items;
|
|
11207
|
+
};
|
|
11208
|
+
var getRecordValueType = (schema) => {
|
|
11209
|
+
return getZodDef(schema).valueType;
|
|
11210
|
+
};
|
|
11211
|
+
var getRecordKeyType = (schema) => {
|
|
11212
|
+
return getZodDef(schema).keyType;
|
|
11213
|
+
};
|
|
11214
|
+
var getPipelineOutput = (schema) => {
|
|
11215
|
+
return getZodDef(schema).out;
|
|
11216
|
+
};
|
|
11217
|
+
var getPipelineInput = (schema) => {
|
|
11218
|
+
return getZodDef(schema).in;
|
|
11219
|
+
};
|
|
11220
|
+
var getBrandedInner = (schema) => {
|
|
11221
|
+
return isZodV3Schema(schema) ? getZodDef(schema).type : schema;
|
|
11222
|
+
};
|
|
11223
|
+
|
|
11017
11224
|
// src/components/RenderModal/SchemaEditor/extract-enum-json-paths.ts
|
|
11018
11225
|
var extractEnumJsonPaths = ({
|
|
11019
11226
|
schema,
|
|
@@ -11021,11 +11228,14 @@ var extractEnumJsonPaths = ({
|
|
|
11021
11228
|
currentPath,
|
|
11022
11229
|
zodTypes
|
|
11023
11230
|
}) => {
|
|
11024
|
-
const
|
|
11025
|
-
|
|
11231
|
+
const description = getZodSchemaDescription(schema);
|
|
11232
|
+
if (zodTypes && description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND) {
|
|
11233
|
+
return [currentPath];
|
|
11234
|
+
}
|
|
11235
|
+
const typeName = getZodSchemaType(schema);
|
|
11026
11236
|
switch (typeName) {
|
|
11027
|
-
case
|
|
11028
|
-
const shape =
|
|
11237
|
+
case "object": {
|
|
11238
|
+
const shape = getObjectShape(schema);
|
|
11029
11239
|
const keys = Object.keys(shape);
|
|
11030
11240
|
return keys.map((key) => {
|
|
11031
11241
|
return extractEnumJsonPaths({
|
|
@@ -11036,16 +11246,16 @@ var extractEnumJsonPaths = ({
|
|
|
11036
11246
|
});
|
|
11037
11247
|
}).flat(1);
|
|
11038
11248
|
}
|
|
11039
|
-
case
|
|
11249
|
+
case "array": {
|
|
11040
11250
|
return extractEnumJsonPaths({
|
|
11041
|
-
schema:
|
|
11251
|
+
schema: getArrayElement(schema),
|
|
11042
11252
|
zodRuntime,
|
|
11043
11253
|
currentPath: [...currentPath, "[]"],
|
|
11044
11254
|
zodTypes
|
|
11045
11255
|
});
|
|
11046
11256
|
}
|
|
11047
|
-
case
|
|
11048
|
-
return
|
|
11257
|
+
case "union": {
|
|
11258
|
+
return getUnionOptions(schema).map((option) => {
|
|
11049
11259
|
return extractEnumJsonPaths({
|
|
11050
11260
|
schema: option,
|
|
11051
11261
|
zodRuntime,
|
|
@@ -11054,8 +11264,8 @@ var extractEnumJsonPaths = ({
|
|
|
11054
11264
|
});
|
|
11055
11265
|
}).flat(1);
|
|
11056
11266
|
}
|
|
11057
|
-
case
|
|
11058
|
-
return
|
|
11267
|
+
case "discriminatedUnion": {
|
|
11268
|
+
return getUnionOptions(schema).map((op) => {
|
|
11059
11269
|
return extractEnumJsonPaths({
|
|
11060
11270
|
schema: op,
|
|
11061
11271
|
zodRuntime,
|
|
@@ -11064,22 +11274,19 @@ var extractEnumJsonPaths = ({
|
|
|
11064
11274
|
});
|
|
11065
11275
|
}).flat(1);
|
|
11066
11276
|
}
|
|
11067
|
-
case
|
|
11277
|
+
case "literal": {
|
|
11068
11278
|
return [currentPath];
|
|
11069
11279
|
}
|
|
11070
|
-
case
|
|
11071
|
-
if (zodTypes && schema._def.description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND) {
|
|
11072
|
-
return [currentPath];
|
|
11073
|
-
}
|
|
11280
|
+
case "effects": {
|
|
11074
11281
|
return extractEnumJsonPaths({
|
|
11075
|
-
schema:
|
|
11282
|
+
schema: getEffectsInner(schema),
|
|
11076
11283
|
zodRuntime,
|
|
11077
11284
|
currentPath,
|
|
11078
11285
|
zodTypes
|
|
11079
11286
|
});
|
|
11080
11287
|
}
|
|
11081
|
-
case
|
|
11082
|
-
const { left: left3, right } =
|
|
11288
|
+
case "intersection": {
|
|
11289
|
+
const { left: left3, right } = getIntersectionSchemas(schema);
|
|
11083
11290
|
const leftValue = extractEnumJsonPaths({
|
|
11084
11291
|
schema: left3,
|
|
11085
11292
|
zodRuntime,
|
|
@@ -11094,109 +11301,94 @@ var extractEnumJsonPaths = ({
|
|
|
11094
11301
|
});
|
|
11095
11302
|
return [...leftValue, ...rightValue];
|
|
11096
11303
|
}
|
|
11097
|
-
case
|
|
11098
|
-
return
|
|
11304
|
+
case "tuple": {
|
|
11305
|
+
return getTupleItems(schema).map((item, i) => extractEnumJsonPaths({
|
|
11099
11306
|
schema: item,
|
|
11100
11307
|
zodRuntime,
|
|
11101
11308
|
currentPath: [...currentPath, i],
|
|
11102
11309
|
zodTypes
|
|
11103
11310
|
})).flat(1);
|
|
11104
11311
|
}
|
|
11105
|
-
case
|
|
11106
|
-
const
|
|
11107
|
-
|
|
11312
|
+
case "record": {
|
|
11313
|
+
const recordPath = [...currentPath, "{}"];
|
|
11314
|
+
const keyResults = extractEnumJsonPaths({
|
|
11315
|
+
schema: getRecordKeyType(schema),
|
|
11108
11316
|
zodRuntime,
|
|
11109
|
-
currentPath:
|
|
11317
|
+
currentPath: recordPath,
|
|
11110
11318
|
zodTypes
|
|
11111
11319
|
});
|
|
11112
|
-
|
|
11320
|
+
const valueResults = extractEnumJsonPaths({
|
|
11321
|
+
schema: getRecordValueType(schema),
|
|
11322
|
+
zodRuntime,
|
|
11323
|
+
currentPath: recordPath,
|
|
11324
|
+
zodTypes
|
|
11325
|
+
});
|
|
11326
|
+
return [...keyResults, ...valueResults];
|
|
11113
11327
|
}
|
|
11114
|
-
case
|
|
11328
|
+
case "function": {
|
|
11115
11329
|
throw new Error("Cannot create a value for type function");
|
|
11116
11330
|
}
|
|
11117
|
-
case
|
|
11331
|
+
case "enum": {
|
|
11118
11332
|
return [currentPath];
|
|
11119
11333
|
}
|
|
11120
|
-
case
|
|
11334
|
+
case "nativeEnum": {
|
|
11121
11335
|
return [];
|
|
11122
11336
|
}
|
|
11123
|
-
case
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
schema: defType.innerType,
|
|
11127
|
-
zodRuntime,
|
|
11128
|
-
currentPath,
|
|
11129
|
-
zodTypes
|
|
11130
|
-
});
|
|
11131
|
-
return value;
|
|
11132
|
-
}
|
|
11133
|
-
case zodRuntime.ZodFirstPartyTypeKind.ZodNullable: {
|
|
11134
|
-
const defType = def;
|
|
11135
|
-
const value = extractEnumJsonPaths({
|
|
11136
|
-
schema: defType.innerType,
|
|
11137
|
-
zodRuntime,
|
|
11138
|
-
currentPath,
|
|
11139
|
-
zodTypes
|
|
11140
|
-
});
|
|
11141
|
-
return value;
|
|
11142
|
-
}
|
|
11143
|
-
case zodRuntime.ZodFirstPartyTypeKind.ZodDefault: {
|
|
11144
|
-
const defType = def;
|
|
11337
|
+
case "optional":
|
|
11338
|
+
case "nullable":
|
|
11339
|
+
case "catch": {
|
|
11145
11340
|
return extractEnumJsonPaths({
|
|
11146
|
-
schema:
|
|
11341
|
+
schema: getInnerType(schema),
|
|
11147
11342
|
zodRuntime,
|
|
11148
11343
|
currentPath,
|
|
11149
11344
|
zodTypes
|
|
11150
11345
|
});
|
|
11151
11346
|
}
|
|
11152
|
-
case
|
|
11153
|
-
const defType = def;
|
|
11347
|
+
case "default": {
|
|
11154
11348
|
return extractEnumJsonPaths({
|
|
11155
|
-
schema:
|
|
11349
|
+
schema: getInnerType(schema),
|
|
11156
11350
|
zodRuntime,
|
|
11157
11351
|
currentPath,
|
|
11158
11352
|
zodTypes
|
|
11159
11353
|
});
|
|
11160
11354
|
}
|
|
11161
|
-
case
|
|
11355
|
+
case "promise": {
|
|
11162
11356
|
return [];
|
|
11163
11357
|
}
|
|
11164
|
-
case
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
schema: defType.type,
|
|
11358
|
+
case "branded": {
|
|
11359
|
+
return extractEnumJsonPaths({
|
|
11360
|
+
schema: getBrandedInner(schema),
|
|
11168
11361
|
zodRuntime,
|
|
11169
11362
|
currentPath,
|
|
11170
11363
|
zodTypes
|
|
11171
11364
|
});
|
|
11172
|
-
return value;
|
|
11173
11365
|
}
|
|
11174
|
-
case
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
schema:
|
|
11366
|
+
case "pipeline":
|
|
11367
|
+
case "pipe": {
|
|
11368
|
+
return extractEnumJsonPaths({
|
|
11369
|
+
schema: getPipelineOutput(schema),
|
|
11178
11370
|
zodRuntime,
|
|
11179
11371
|
currentPath,
|
|
11180
11372
|
zodTypes
|
|
11181
11373
|
});
|
|
11182
|
-
return value;
|
|
11183
11374
|
}
|
|
11184
|
-
case
|
|
11185
|
-
case
|
|
11186
|
-
case
|
|
11187
|
-
case
|
|
11188
|
-
case
|
|
11189
|
-
case
|
|
11190
|
-
case
|
|
11191
|
-
case
|
|
11192
|
-
case
|
|
11193
|
-
case
|
|
11194
|
-
case
|
|
11195
|
-
case
|
|
11196
|
-
case
|
|
11197
|
-
case
|
|
11198
|
-
case
|
|
11199
|
-
case
|
|
11375
|
+
case "string":
|
|
11376
|
+
case "number":
|
|
11377
|
+
case "bigint":
|
|
11378
|
+
case "boolean":
|
|
11379
|
+
case "nan":
|
|
11380
|
+
case "date":
|
|
11381
|
+
case "symbol":
|
|
11382
|
+
case "undefined":
|
|
11383
|
+
case "null":
|
|
11384
|
+
case "any":
|
|
11385
|
+
case "unknown":
|
|
11386
|
+
case "never":
|
|
11387
|
+
case "void":
|
|
11388
|
+
case "map":
|
|
11389
|
+
case "lazy":
|
|
11390
|
+
case "set":
|
|
11391
|
+
case "custom": {
|
|
11200
11392
|
return [];
|
|
11201
11393
|
}
|
|
11202
11394
|
default:
|
|
@@ -11552,7 +11744,7 @@ var ZodErrorMessages = ({ zodValidationResult, viewTab }) => {
|
|
|
11552
11744
|
}, []);
|
|
11553
11745
|
if (viewTab === "json") {
|
|
11554
11746
|
return /* @__PURE__ */ jsx102("div", {
|
|
11555
|
-
children: zodValidationResult.error.
|
|
11747
|
+
children: zodValidationResult.error.issues.map((error) => {
|
|
11556
11748
|
return /* @__PURE__ */ jsxs46("div", {
|
|
11557
11749
|
style: style7,
|
|
11558
11750
|
children: [
|
|
@@ -11572,7 +11764,7 @@ var ZodErrorMessages = ({ zodValidationResult, viewTab }) => {
|
|
|
11572
11764
|
});
|
|
11573
11765
|
}
|
|
11574
11766
|
return /* @__PURE__ */ jsx102("div", {
|
|
11575
|
-
children: zodValidationResult.error.
|
|
11767
|
+
children: zodValidationResult.error.issues.map((error) => {
|
|
11576
11768
|
return /* @__PURE__ */ jsxs46("div", {
|
|
11577
11769
|
style: style7,
|
|
11578
11770
|
children: [
|
|
@@ -11629,7 +11821,7 @@ var scrollable = {
|
|
|
11629
11821
|
var parseJSON = (str, schema) => {
|
|
11630
11822
|
try {
|
|
11631
11823
|
const value = NoReactInternals8.deserializeJSONWithSpecialTypes(str);
|
|
11632
|
-
const zodValidation = schema
|
|
11824
|
+
const zodValidation = zodSafeParse(schema, value);
|
|
11633
11825
|
return { str, value, validJSON: true, zodValidation };
|
|
11634
11826
|
} catch (e) {
|
|
11635
11827
|
return { str, validJSON: false, error: e.message };
|
|
@@ -11661,7 +11853,7 @@ var RenderModalJSONPropsEditor = ({
|
|
|
11661
11853
|
const onChange = useCallback47((e) => {
|
|
11662
11854
|
const parsed = parseJSON(e.target.value, schema);
|
|
11663
11855
|
if (parsed.validJSON) {
|
|
11664
|
-
const validationResult = schema
|
|
11856
|
+
const validationResult = zodSafeParse(schema, parsed.value);
|
|
11665
11857
|
setLocalValue({
|
|
11666
11858
|
str: e.target.value,
|
|
11667
11859
|
value: parsed.value,
|
|
@@ -12273,46 +12465,72 @@ var createZodValues = (schema, zodRuntime, zodTypes) => {
|
|
|
12273
12465
|
if (!schema) {
|
|
12274
12466
|
throw new Error("Invalid zod schema");
|
|
12275
12467
|
}
|
|
12276
|
-
const
|
|
12277
|
-
|
|
12468
|
+
const description = getZodSchemaDescription(schema);
|
|
12469
|
+
if (zodTypes) {
|
|
12470
|
+
if (description === zodTypes.ZodZypesInternals.REMOTION_COLOR_BRAND) {
|
|
12471
|
+
return "#ffffff";
|
|
12472
|
+
}
|
|
12473
|
+
if (description === zodTypes.ZodZypesInternals.REMOTION_TEXTAREA_BRAND) {
|
|
12474
|
+
return "";
|
|
12475
|
+
}
|
|
12476
|
+
if (description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND) {
|
|
12477
|
+
return [
|
|
12478
|
+
[1, 0, 0],
|
|
12479
|
+
[0, 1, 0],
|
|
12480
|
+
[0, 0, 1]
|
|
12481
|
+
];
|
|
12482
|
+
}
|
|
12483
|
+
}
|
|
12484
|
+
const typeName = getZodSchemaType(schema);
|
|
12278
12485
|
switch (typeName) {
|
|
12279
|
-
case
|
|
12486
|
+
case "string":
|
|
12280
12487
|
return "";
|
|
12281
|
-
case
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12488
|
+
case "number": {
|
|
12489
|
+
const { checks } = getZodDef(schema);
|
|
12490
|
+
if (checks) {
|
|
12491
|
+
if (isZodV3Schema(schema)) {
|
|
12492
|
+
for (const check of checks) {
|
|
12493
|
+
if (check.kind === "min")
|
|
12494
|
+
return check.value;
|
|
12495
|
+
if (check.kind === "max" && check.value < 0)
|
|
12496
|
+
return check.value;
|
|
12497
|
+
}
|
|
12498
|
+
} else {
|
|
12499
|
+
for (const check of checks) {
|
|
12500
|
+
const cd = check._zod?.def;
|
|
12501
|
+
if (cd?.check === "greater_than")
|
|
12502
|
+
return cd.value;
|
|
12503
|
+
if (cd?.check === "less_than" && cd.value < 0)
|
|
12504
|
+
return cd.value;
|
|
12505
|
+
}
|
|
12288
12506
|
}
|
|
12289
12507
|
}
|
|
12290
12508
|
return 0;
|
|
12291
12509
|
}
|
|
12292
|
-
case
|
|
12510
|
+
case "bigint":
|
|
12293
12511
|
return BigInt(0);
|
|
12294
|
-
case
|
|
12512
|
+
case "boolean":
|
|
12295
12513
|
return false;
|
|
12296
|
-
case
|
|
12514
|
+
case "nan":
|
|
12297
12515
|
return NaN;
|
|
12298
|
-
case
|
|
12516
|
+
case "date":
|
|
12299
12517
|
return new Date;
|
|
12300
|
-
case
|
|
12518
|
+
case "symbol":
|
|
12301
12519
|
return Symbol("remotion");
|
|
12302
|
-
case
|
|
12520
|
+
case "undefined":
|
|
12521
|
+
case "void":
|
|
12303
12522
|
return;
|
|
12304
|
-
case
|
|
12523
|
+
case "null":
|
|
12305
12524
|
return null;
|
|
12306
|
-
case
|
|
12525
|
+
case "any":
|
|
12526
|
+
case "custom":
|
|
12307
12527
|
throw new Error("Cannot create a value for type z.any()");
|
|
12308
|
-
case
|
|
12528
|
+
case "unknown":
|
|
12309
12529
|
throw new Error("Cannot create a value for type z.unknown()");
|
|
12310
|
-
case
|
|
12530
|
+
case "never":
|
|
12311
12531
|
throw new Error("Cannot create a value for type z.never()");
|
|
12312
|
-
case
|
|
12313
|
-
|
|
12314
|
-
case zodRuntime.ZodFirstPartyTypeKind.ZodObject: {
|
|
12315
|
-
const shape = def.shape();
|
|
12532
|
+
case "object": {
|
|
12533
|
+
const shape = getObjectShape(schema);
|
|
12316
12534
|
const keys = Object.keys(shape);
|
|
12317
12535
|
const returnValue = keys.reduce((existing, key) => {
|
|
12318
12536
|
existing[key] = createZodValues(shape[key], zodRuntime, zodTypes);
|
|
@@ -12320,40 +12538,25 @@ var createZodValues = (schema, zodRuntime, zodTypes) => {
|
|
|
12320
12538
|
}, {});
|
|
12321
12539
|
return returnValue;
|
|
12322
12540
|
}
|
|
12323
|
-
case
|
|
12324
|
-
return [
|
|
12325
|
-
createZodValues(def.type, zodRuntime, zodTypes)
|
|
12326
|
-
];
|
|
12541
|
+
case "array": {
|
|
12542
|
+
return [createZodValues(getArrayElement(schema), zodRuntime, zodTypes)];
|
|
12327
12543
|
}
|
|
12328
|
-
case
|
|
12329
|
-
const
|
|
12330
|
-
return
|
|
12544
|
+
case "union": {
|
|
12545
|
+
const firstOption = getUnionOptions(schema)[0];
|
|
12546
|
+
return firstOption ? createZodValues(firstOption, zodRuntime, zodTypes) : undefined;
|
|
12331
12547
|
}
|
|
12332
|
-
case
|
|
12333
|
-
const
|
|
12334
|
-
return createZodValues(
|
|
12548
|
+
case "discriminatedUnion": {
|
|
12549
|
+
const firstOption = getUnionOptions(schema)[0];
|
|
12550
|
+
return createZodValues(firstOption, zodRuntime, zodTypes);
|
|
12335
12551
|
}
|
|
12336
|
-
case
|
|
12337
|
-
return
|
|
12552
|
+
case "literal": {
|
|
12553
|
+
return getLiteralValue(schema);
|
|
12338
12554
|
}
|
|
12339
|
-
case
|
|
12340
|
-
|
|
12341
|
-
return "#ffffff";
|
|
12342
|
-
}
|
|
12343
|
-
if (zodTypes && schema._def.description === zodTypes.ZodZypesInternals.REMOTION_TEXTAREA_BRAND) {
|
|
12344
|
-
return "";
|
|
12345
|
-
}
|
|
12346
|
-
if (zodTypes && schema._def.description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND) {
|
|
12347
|
-
return [
|
|
12348
|
-
[1, 0, 0],
|
|
12349
|
-
[0, 1, 0],
|
|
12350
|
-
[0, 0, 1]
|
|
12351
|
-
];
|
|
12352
|
-
}
|
|
12353
|
-
return createZodValues(def.schema, zodRuntime, zodTypes);
|
|
12555
|
+
case "effects": {
|
|
12556
|
+
return createZodValues(getEffectsInner(schema), zodRuntime, zodTypes);
|
|
12354
12557
|
}
|
|
12355
|
-
case
|
|
12356
|
-
const { left: left3, right } =
|
|
12558
|
+
case "intersection": {
|
|
12559
|
+
const { left: left3, right } = getIntersectionSchemas(schema);
|
|
12357
12560
|
const leftValue = createZodValues(left3, zodRuntime, zodTypes);
|
|
12358
12561
|
if (typeof leftValue !== "object") {
|
|
12359
12562
|
throw new Error("Cannot create value for type z.intersection: Left side is not an object");
|
|
@@ -12364,73 +12567,59 @@ var createZodValues = (schema, zodRuntime, zodTypes) => {
|
|
|
12364
12567
|
}
|
|
12365
12568
|
return { ...leftValue, ...rightValue };
|
|
12366
12569
|
}
|
|
12367
|
-
case
|
|
12368
|
-
|
|
12369
|
-
return items;
|
|
12570
|
+
case "tuple": {
|
|
12571
|
+
return getTupleItems(schema).map((item2) => createZodValues(item2, zodRuntime, zodTypes));
|
|
12370
12572
|
}
|
|
12371
|
-
case
|
|
12372
|
-
const values = createZodValues(
|
|
12573
|
+
case "record": {
|
|
12574
|
+
const values = createZodValues(getRecordValueType(schema), zodRuntime, zodTypes);
|
|
12373
12575
|
return { key: values };
|
|
12374
12576
|
}
|
|
12375
|
-
case
|
|
12376
|
-
const
|
|
12377
|
-
const
|
|
12378
|
-
const key = createZodValues(defType.keyType, zodRuntime, zodTypes);
|
|
12577
|
+
case "map": {
|
|
12578
|
+
const values = createZodValues(getRecordValueType(schema), zodRuntime, zodTypes);
|
|
12579
|
+
const key = createZodValues(getRecordKeyType(schema), zodRuntime, zodTypes);
|
|
12379
12580
|
return new Map([[key, values]]);
|
|
12380
12581
|
}
|
|
12381
|
-
case
|
|
12382
|
-
const
|
|
12383
|
-
const type = defType.getter();
|
|
12582
|
+
case "lazy": {
|
|
12583
|
+
const type = getZodDef(schema).getter();
|
|
12384
12584
|
return createZodValues(type, zodRuntime, zodTypes);
|
|
12385
12585
|
}
|
|
12386
|
-
case
|
|
12387
|
-
const
|
|
12388
|
-
const values = createZodValues(defType.valueType, zodRuntime, zodTypes);
|
|
12586
|
+
case "set": {
|
|
12587
|
+
const values = createZodValues(getZodDef(schema).valueType, zodRuntime, zodTypes);
|
|
12389
12588
|
return new Set([values]);
|
|
12390
12589
|
}
|
|
12391
|
-
case
|
|
12590
|
+
case "function": {
|
|
12392
12591
|
throw new Error("Cannot create a value for type function");
|
|
12393
12592
|
}
|
|
12394
|
-
case
|
|
12395
|
-
|
|
12396
|
-
return values[0];
|
|
12593
|
+
case "enum": {
|
|
12594
|
+
return getFirstEnumValue(schema);
|
|
12397
12595
|
}
|
|
12398
|
-
case
|
|
12596
|
+
case "nativeEnum": {
|
|
12399
12597
|
return 0;
|
|
12400
12598
|
}
|
|
12401
|
-
case
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
return
|
|
12405
|
-
}
|
|
12406
|
-
case zodRuntime.ZodFirstPartyTypeKind.ZodNullable: {
|
|
12407
|
-
const defType = def;
|
|
12408
|
-
const value = createZodValues(defType.innerType, zodRuntime, zodTypes);
|
|
12409
|
-
return value;
|
|
12599
|
+
case "optional":
|
|
12600
|
+
case "nullable":
|
|
12601
|
+
case "catch": {
|
|
12602
|
+
return createZodValues(getInnerType(schema), zodRuntime, zodTypes);
|
|
12410
12603
|
}
|
|
12411
|
-
case
|
|
12412
|
-
|
|
12413
|
-
return defType.defaultValue();
|
|
12604
|
+
case "default": {
|
|
12605
|
+
return getDefaultValue(schema);
|
|
12414
12606
|
}
|
|
12415
|
-
case
|
|
12416
|
-
const
|
|
12417
|
-
const
|
|
12418
|
-
|
|
12419
|
-
}
|
|
12420
|
-
case zodRuntime.ZodFirstPartyTypeKind.ZodPromise: {
|
|
12421
|
-
const defType = def;
|
|
12422
|
-
const value = createZodValues(defType.type, zodRuntime, zodTypes);
|
|
12607
|
+
case "promise": {
|
|
12608
|
+
const def = getZodDef(schema);
|
|
12609
|
+
const inner = isZodV3Schema(schema) ? def.type : def.innerType;
|
|
12610
|
+
const value = createZodValues(inner, zodRuntime, zodTypes);
|
|
12423
12611
|
return Promise.resolve(value);
|
|
12424
12612
|
}
|
|
12425
|
-
case
|
|
12426
|
-
|
|
12427
|
-
const value = createZodValues(defType.type, zodRuntime, zodTypes);
|
|
12428
|
-
return value;
|
|
12613
|
+
case "branded": {
|
|
12614
|
+
return createZodValues(getBrandedInner(schema), zodRuntime, zodTypes);
|
|
12429
12615
|
}
|
|
12430
|
-
case
|
|
12431
|
-
|
|
12432
|
-
const
|
|
12433
|
-
|
|
12616
|
+
case "pipeline":
|
|
12617
|
+
case "pipe": {
|
|
12618
|
+
const out = getPipelineOutput(schema);
|
|
12619
|
+
if (getZodSchemaType(out) === "transform") {
|
|
12620
|
+
return createZodValues(getPipelineInput(schema), zodRuntime, zodTypes);
|
|
12621
|
+
}
|
|
12622
|
+
return createZodValues(out, zodRuntime, zodTypes);
|
|
12434
12623
|
}
|
|
12435
12624
|
default:
|
|
12436
12625
|
throw new Error("Not implemented: " + typeName);
|
|
@@ -12463,16 +12652,16 @@ var SchemaArrayItemSeparationLine = ({ onChange, index, schema, isLast, showAddB
|
|
|
12463
12652
|
if (!z) {
|
|
12464
12653
|
throw new Error("expected zod");
|
|
12465
12654
|
}
|
|
12466
|
-
const
|
|
12655
|
+
const arrayElement = getArrayElement(schema);
|
|
12467
12656
|
const onAdd = useCallback50(() => {
|
|
12468
12657
|
onChange((oldV) => {
|
|
12469
12658
|
return [
|
|
12470
12659
|
...oldV.slice(0, index + 1),
|
|
12471
|
-
createZodValues(
|
|
12660
|
+
createZodValues(arrayElement, z, zodTypes),
|
|
12472
12661
|
...oldV.slice(index + 1)
|
|
12473
12662
|
];
|
|
12474
12663
|
}, false, true);
|
|
12475
|
-
}, [
|
|
12664
|
+
}, [arrayElement, index, onChange, z, zodTypes]);
|
|
12476
12665
|
const dynamicAddButtonStyle = useMemo61(() => {
|
|
12477
12666
|
return {
|
|
12478
12667
|
display: "flex",
|
|
@@ -12603,7 +12792,7 @@ import React78, { useMemo as useMemo67, useState as useState46 } from "react";
|
|
|
12603
12792
|
import { useCallback as useCallback51, useMemo as useMemo63 } from "react";
|
|
12604
12793
|
import { jsx as jsx111 } from "react/jsx-runtime";
|
|
12605
12794
|
var ZodArrayItemEditor = ({
|
|
12606
|
-
|
|
12795
|
+
elementSchema,
|
|
12607
12796
|
onChange,
|
|
12608
12797
|
jsonPath,
|
|
12609
12798
|
index,
|
|
@@ -12641,7 +12830,7 @@ var ZodArrayItemEditor = ({
|
|
|
12641
12830
|
return /* @__PURE__ */ jsx111("div", {
|
|
12642
12831
|
children: /* @__PURE__ */ jsx111(ZodSwitch, {
|
|
12643
12832
|
jsonPath: newJsonPath,
|
|
12644
|
-
schema:
|
|
12833
|
+
schema: elementSchema,
|
|
12645
12834
|
value,
|
|
12646
12835
|
setValue,
|
|
12647
12836
|
defaultValue,
|
|
@@ -12875,7 +13064,8 @@ var stackTraceLabel = {
|
|
|
12875
13064
|
fontSize: 14
|
|
12876
13065
|
};
|
|
12877
13066
|
var ZodFieldValidation = ({ localValue, path }) => {
|
|
12878
|
-
|
|
13067
|
+
const { zodValidation } = localValue;
|
|
13068
|
+
if (zodValidation.success) {
|
|
12879
13069
|
return null;
|
|
12880
13070
|
}
|
|
12881
13071
|
return /* @__PURE__ */ jsxs54("div", {
|
|
@@ -12883,7 +13073,7 @@ var ZodFieldValidation = ({ localValue, path }) => {
|
|
|
12883
13073
|
children: [
|
|
12884
13074
|
/* @__PURE__ */ jsx114(ValidationMessage, {
|
|
12885
13075
|
align: "flex-start",
|
|
12886
|
-
message:
|
|
13076
|
+
message: zodValidation.error.format()._errors[0],
|
|
12887
13077
|
type: "error"
|
|
12888
13078
|
}),
|
|
12889
13079
|
/* @__PURE__ */ jsx114(Spacing, {
|
|
@@ -12898,7 +13088,7 @@ var ZodFieldValidation = ({ localValue, path }) => {
|
|
|
12898
13088
|
style: stackTraceLabel,
|
|
12899
13089
|
children: "Zod Validation has failed:"
|
|
12900
13090
|
}),
|
|
12901
|
-
|
|
13091
|
+
zodValidation.error.issues.map((error, index) => /* @__PURE__ */ jsxs54("div", {
|
|
12902
13092
|
style: stackTraceLabel,
|
|
12903
13093
|
children: [
|
|
12904
13094
|
"Type: ",
|
|
@@ -12950,7 +13140,7 @@ var useLocalState = ({
|
|
|
12950
13140
|
[parentRevision]: {
|
|
12951
13141
|
value: unsavedValue,
|
|
12952
13142
|
keyStabilityRevision: 0,
|
|
12953
|
-
zodValidation: schema
|
|
13143
|
+
zodValidation: zodSafeParse(schema, unsavedValue)
|
|
12954
13144
|
}
|
|
12955
13145
|
};
|
|
12956
13146
|
});
|
|
@@ -12959,7 +13149,7 @@ var useLocalState = ({
|
|
|
12959
13149
|
return {
|
|
12960
13150
|
value: unsavedValue,
|
|
12961
13151
|
keyStabilityRevision: 0,
|
|
12962
|
-
zodValidation: schema
|
|
13152
|
+
zodValidation: zodSafeParse(schema, unsavedValue)
|
|
12963
13153
|
};
|
|
12964
13154
|
}
|
|
12965
13155
|
return localValueOrNull[parentRevision];
|
|
@@ -12978,7 +13168,7 @@ var useLocalState = ({
|
|
|
12978
13168
|
return localUnsavedValue ?? {
|
|
12979
13169
|
value: savedValue,
|
|
12980
13170
|
keyStabilityRevision: 0,
|
|
12981
|
-
zodValidation: schema
|
|
13171
|
+
zodValidation: zodSafeParse(schema, savedValue)
|
|
12982
13172
|
};
|
|
12983
13173
|
}, [localUnsavedValue, savedValue, schema]);
|
|
12984
13174
|
const stateRef = useRef26(currentLocalValue);
|
|
@@ -12989,7 +13179,7 @@ var useLocalState = ({
|
|
|
12989
13179
|
if (isSame) {
|
|
12990
13180
|
return;
|
|
12991
13181
|
}
|
|
12992
|
-
const safeParse = schema
|
|
13182
|
+
const safeParse = zodSafeParse(schema, newValue);
|
|
12993
13183
|
if (safeParse.success || forceApply) {
|
|
12994
13184
|
setValue(updater, forceApply, increment);
|
|
12995
13185
|
}
|
|
@@ -13057,7 +13247,7 @@ var ZodArrayEditor = ({
|
|
|
13057
13247
|
savedValue: defaultValue
|
|
13058
13248
|
});
|
|
13059
13249
|
const [expanded, setExpanded] = useState46(true);
|
|
13060
|
-
const
|
|
13250
|
+
const arrayElement = getArrayElement(schema);
|
|
13061
13251
|
const suffix2 = useMemo67(() => {
|
|
13062
13252
|
return expanded ? " [" : " [...] ";
|
|
13063
13253
|
}, [expanded]);
|
|
@@ -13066,10 +13256,6 @@ var ZodArrayEditor = ({
|
|
|
13066
13256
|
throw new Error("expected zod");
|
|
13067
13257
|
}
|
|
13068
13258
|
const zodTypes = useZodTypesIfPossible();
|
|
13069
|
-
const typeName = def.typeName;
|
|
13070
|
-
if (typeName !== z.ZodFirstPartyTypeKind.ZodArray) {
|
|
13071
|
-
throw new Error("expected object");
|
|
13072
|
-
}
|
|
13073
13259
|
const isDefaultValue = useMemo67(() => {
|
|
13074
13260
|
return deepEqual(localValue.value, defaultValue);
|
|
13075
13261
|
}, [defaultValue, localValue]);
|
|
@@ -13108,10 +13294,10 @@ var ZodArrayEditor = ({
|
|
|
13108
13294
|
/* @__PURE__ */ jsx116(ZodArrayItemEditor, {
|
|
13109
13295
|
onChange,
|
|
13110
13296
|
value: child,
|
|
13111
|
-
|
|
13297
|
+
elementSchema: arrayElement,
|
|
13112
13298
|
index: i,
|
|
13113
13299
|
jsonPath,
|
|
13114
|
-
defaultValue: defaultValue?.[i] ?? createZodValues(
|
|
13300
|
+
defaultValue: defaultValue?.[i] ?? createZodValues(arrayElement, z, zodTypes),
|
|
13115
13301
|
onSave,
|
|
13116
13302
|
showSaveButton,
|
|
13117
13303
|
saving,
|
|
@@ -13760,7 +13946,7 @@ var ZodDefaultEditor = ({
|
|
|
13760
13946
|
saveDisabledByParent,
|
|
13761
13947
|
mayPad
|
|
13762
13948
|
}) => {
|
|
13763
|
-
const
|
|
13949
|
+
const innerType = getInnerType(schema);
|
|
13764
13950
|
return /* @__PURE__ */ jsx123(ZodSwitch, {
|
|
13765
13951
|
defaultValue,
|
|
13766
13952
|
jsonPath,
|
|
@@ -13797,8 +13983,8 @@ var ZodDiscriminatedUnionEditor = ({
|
|
|
13797
13983
|
throw new Error("expected zod");
|
|
13798
13984
|
}
|
|
13799
13985
|
const zodTypes = useZodTypesIfPossible();
|
|
13800
|
-
const
|
|
13801
|
-
const options = useMemo72(() =>
|
|
13986
|
+
const discriminator = getDiscriminator(schema);
|
|
13987
|
+
const options = useMemo72(() => getDiscriminatedOptionKeys(schema), [schema]);
|
|
13802
13988
|
const {
|
|
13803
13989
|
localValue,
|
|
13804
13990
|
onChange: setLocalValue,
|
|
@@ -13816,9 +14002,13 @@ var ZodDiscriminatedUnionEditor = ({
|
|
|
13816
14002
|
label: option,
|
|
13817
14003
|
id: option,
|
|
13818
14004
|
keyHint: null,
|
|
13819
|
-
leftItem: option === value[
|
|
14005
|
+
leftItem: option === value[discriminator] ? /* @__PURE__ */ jsx124(Checkmark, {}) : null,
|
|
13820
14006
|
onClick: () => {
|
|
13821
|
-
const
|
|
14007
|
+
const optionSchema = getDiscriminatedOption(schema, option);
|
|
14008
|
+
if (!optionSchema) {
|
|
14009
|
+
throw new Error(`No schema found for discriminator value: ${option}`);
|
|
14010
|
+
}
|
|
14011
|
+
const val = createZodValues(optionSchema, z, zodTypes);
|
|
13822
14012
|
setLocalValue(() => val, false, false);
|
|
13823
14013
|
},
|
|
13824
14014
|
quickSwitcherLabel: null,
|
|
@@ -13826,29 +14016,21 @@ var ZodDiscriminatedUnionEditor = ({
|
|
|
13826
14016
|
type: "item"
|
|
13827
14017
|
};
|
|
13828
14018
|
});
|
|
13829
|
-
}, [
|
|
13830
|
-
options,
|
|
13831
|
-
setLocalValue,
|
|
13832
|
-
typedSchema.discriminator,
|
|
13833
|
-
typedSchema.optionsMap,
|
|
13834
|
-
value,
|
|
13835
|
-
z,
|
|
13836
|
-
zodTypes
|
|
13837
|
-
]);
|
|
14019
|
+
}, [options, setLocalValue, discriminator, schema, value, z, zodTypes]);
|
|
13838
14020
|
const save = useCallback58(() => {
|
|
13839
14021
|
onSave(() => value, false, false);
|
|
13840
14022
|
}, [onSave, value]);
|
|
13841
14023
|
const discriminatedUnionReplacement = useMemo72(() => {
|
|
13842
14024
|
return {
|
|
13843
|
-
discriminator
|
|
14025
|
+
discriminator,
|
|
13844
14026
|
markup: /* @__PURE__ */ jsxs60(Fieldset, {
|
|
13845
14027
|
shouldPad: mayPad,
|
|
13846
14028
|
success: true,
|
|
13847
14029
|
children: [
|
|
13848
14030
|
/* @__PURE__ */ jsx124(SchemaLabel, {
|
|
13849
14031
|
handleClick: null,
|
|
13850
|
-
isDefaultValue: localValue.value[
|
|
13851
|
-
jsonPath: [...jsonPath,
|
|
14032
|
+
isDefaultValue: localValue.value[discriminator] === defaultValue[discriminator],
|
|
14033
|
+
jsonPath: [...jsonPath, discriminator],
|
|
13852
14034
|
onRemove,
|
|
13853
14035
|
onReset: reset,
|
|
13854
14036
|
onSave: save,
|
|
@@ -13861,7 +14043,7 @@ var ZodDiscriminatedUnionEditor = ({
|
|
|
13861
14043
|
/* @__PURE__ */ jsx124(Combobox, {
|
|
13862
14044
|
title: "Select type",
|
|
13863
14045
|
values: comboBoxValues,
|
|
13864
|
-
selectedId: value[
|
|
14046
|
+
selectedId: value[discriminator]
|
|
13865
14047
|
})
|
|
13866
14048
|
]
|
|
13867
14049
|
}, "replacement")
|
|
@@ -13879,9 +14061,13 @@ var ZodDiscriminatedUnionEditor = ({
|
|
|
13879
14061
|
saveDisabledByParent,
|
|
13880
14062
|
saving,
|
|
13881
14063
|
showSaveButton,
|
|
13882
|
-
|
|
14064
|
+
discriminator,
|
|
13883
14065
|
value
|
|
13884
14066
|
]);
|
|
14067
|
+
const currentOptionSchema = getDiscriminatedOption(schema, value[discriminator]);
|
|
14068
|
+
if (!currentOptionSchema) {
|
|
14069
|
+
throw new Error("No matching option found for discriminated union");
|
|
14070
|
+
}
|
|
13885
14071
|
return /* @__PURE__ */ jsx124(ZodObjectEditor, {
|
|
13886
14072
|
jsonPath,
|
|
13887
14073
|
mayPad,
|
|
@@ -13890,12 +14076,12 @@ var ZodDiscriminatedUnionEditor = ({
|
|
|
13890
14076
|
onSave,
|
|
13891
14077
|
saveDisabledByParent,
|
|
13892
14078
|
saving,
|
|
13893
|
-
schema:
|
|
14079
|
+
schema: currentOptionSchema,
|
|
13894
14080
|
setValue: setLocalValue,
|
|
13895
14081
|
showSaveButton,
|
|
13896
14082
|
unsavedValue: value,
|
|
13897
14083
|
discriminatedUnionReplacement
|
|
13898
|
-
}, value[
|
|
14084
|
+
}, value[discriminator]);
|
|
13899
14085
|
};
|
|
13900
14086
|
|
|
13901
14087
|
// src/components/RenderModal/SchemaEditor/ZodEffectEditor.tsx
|
|
@@ -13915,9 +14101,9 @@ var ZodEffectEditor = ({
|
|
|
13915
14101
|
saving,
|
|
13916
14102
|
mayPad
|
|
13917
14103
|
}) => {
|
|
13918
|
-
const
|
|
13919
|
-
if (
|
|
13920
|
-
throw new Error("expected
|
|
14104
|
+
const typeName = getZodSchemaType(schema);
|
|
14105
|
+
if (typeName !== "effects") {
|
|
14106
|
+
throw new Error("expected effect");
|
|
13921
14107
|
}
|
|
13922
14108
|
const { localValue, onChange } = useLocalState({
|
|
13923
14109
|
unsavedValue: value,
|
|
@@ -13925,11 +14111,7 @@ var ZodEffectEditor = ({
|
|
|
13925
14111
|
setValue: updateValue,
|
|
13926
14112
|
savedValue: defaultValue
|
|
13927
14113
|
});
|
|
13928
|
-
const
|
|
13929
|
-
const typeName = def.typeName;
|
|
13930
|
-
if (typeName !== z.ZodFirstPartyTypeKind.ZodEffects) {
|
|
13931
|
-
throw new Error("expected effect");
|
|
13932
|
-
}
|
|
14114
|
+
const innerSchema = getEffectsInner(schema);
|
|
13933
14115
|
return /* @__PURE__ */ jsxs61(Fieldset, {
|
|
13934
14116
|
shouldPad: mayPad,
|
|
13935
14117
|
success: localValue.zodValidation.success,
|
|
@@ -13940,7 +14122,7 @@ var ZodEffectEditor = ({
|
|
|
13940
14122
|
value,
|
|
13941
14123
|
setValue: onChange,
|
|
13942
14124
|
jsonPath,
|
|
13943
|
-
schema:
|
|
14125
|
+
schema: innerSchema,
|
|
13944
14126
|
defaultValue,
|
|
13945
14127
|
onSave,
|
|
13946
14128
|
showSaveButton,
|
|
@@ -13975,10 +14157,6 @@ var ZodEnumEditor = ({
|
|
|
13975
14157
|
onRemove,
|
|
13976
14158
|
saving
|
|
13977
14159
|
}) => {
|
|
13978
|
-
const z = useZodIfPossible();
|
|
13979
|
-
if (!z) {
|
|
13980
|
-
throw new Error("expected zod");
|
|
13981
|
-
}
|
|
13982
14160
|
const {
|
|
13983
14161
|
localValue,
|
|
13984
14162
|
onChange: setLocalValue,
|
|
@@ -13989,14 +14167,10 @@ var ZodEnumEditor = ({
|
|
|
13989
14167
|
unsavedValue: value,
|
|
13990
14168
|
savedValue: defaultValue
|
|
13991
14169
|
});
|
|
13992
|
-
const
|
|
13993
|
-
const typeName = def.typeName;
|
|
13994
|
-
if (typeName !== z.ZodFirstPartyTypeKind.ZodEnum) {
|
|
13995
|
-
throw new Error("expected enum");
|
|
13996
|
-
}
|
|
14170
|
+
const enumValues = getEnumValues(schema);
|
|
13997
14171
|
const isRoot = jsonPath.length === 0;
|
|
13998
14172
|
const comboBoxValues = useMemo73(() => {
|
|
13999
|
-
return
|
|
14173
|
+
return enumValues.map((option) => {
|
|
14000
14174
|
return {
|
|
14001
14175
|
value: option,
|
|
14002
14176
|
label: option,
|
|
@@ -14011,7 +14185,7 @@ var ZodEnumEditor = ({
|
|
|
14011
14185
|
type: "item"
|
|
14012
14186
|
};
|
|
14013
14187
|
});
|
|
14014
|
-
}, [
|
|
14188
|
+
}, [enumValues, setLocalValue, value]);
|
|
14015
14189
|
const save = useCallback59(() => {
|
|
14016
14190
|
onSave(() => value, false, false);
|
|
14017
14191
|
}, [onSave, value]);
|
|
@@ -14076,7 +14250,7 @@ var ZodMatrixEditor = ({
|
|
|
14076
14250
|
savedValue: defaultValue
|
|
14077
14251
|
});
|
|
14078
14252
|
const [expanded, setExpanded] = useState49(true);
|
|
14079
|
-
const
|
|
14253
|
+
const arrayElement = getArrayElement(schema);
|
|
14080
14254
|
const suffix2 = useMemo74(() => {
|
|
14081
14255
|
return expanded ? " [" : " [...] ";
|
|
14082
14256
|
}, [expanded]);
|
|
@@ -14134,10 +14308,10 @@ var ZodMatrixEditor = ({
|
|
|
14134
14308
|
children: /* @__PURE__ */ jsx127(ZodArrayItemEditor, {
|
|
14135
14309
|
onChange,
|
|
14136
14310
|
value: item2,
|
|
14137
|
-
|
|
14311
|
+
elementSchema: arrayElement,
|
|
14138
14312
|
index: actualIndex,
|
|
14139
14313
|
jsonPath,
|
|
14140
|
-
defaultValue: defaultValue?.[actualIndex] ?? createZodValues(
|
|
14314
|
+
defaultValue: defaultValue?.[actualIndex] ?? createZodValues(arrayElement, z, zodTypes),
|
|
14141
14315
|
onSave,
|
|
14142
14316
|
showSaveButton,
|
|
14143
14317
|
saving,
|
|
@@ -14337,7 +14511,7 @@ var ZodNullableEditor = ({
|
|
|
14337
14511
|
saveDisabledByParent,
|
|
14338
14512
|
mayPad
|
|
14339
14513
|
}) => {
|
|
14340
|
-
const
|
|
14514
|
+
const innerType = getInnerType(schema);
|
|
14341
14515
|
return /* @__PURE__ */ jsx130(ZodOrNullishEditor, {
|
|
14342
14516
|
defaultValue,
|
|
14343
14517
|
jsonPath,
|
|
@@ -14362,40 +14536,58 @@ var fullWidth6 = {
|
|
|
14362
14536
|
width: "100%"
|
|
14363
14537
|
};
|
|
14364
14538
|
var getMinValue = (schema) => {
|
|
14365
|
-
const
|
|
14366
|
-
if (!
|
|
14367
|
-
return -Infinity;
|
|
14368
|
-
}
|
|
14369
|
-
if (minCheck.kind !== "min") {
|
|
14370
|
-
throw new Error("Expected min check");
|
|
14371
|
-
}
|
|
14372
|
-
if (!minCheck.inclusive) {
|
|
14539
|
+
const { checks } = getZodDef(schema);
|
|
14540
|
+
if (!checks)
|
|
14373
14541
|
return -Infinity;
|
|
14542
|
+
if (isZodV3Schema(schema)) {
|
|
14543
|
+
const minCheck = checks.find((c) => c.kind === "min");
|
|
14544
|
+
if (!minCheck || !minCheck.inclusive)
|
|
14545
|
+
return -Infinity;
|
|
14546
|
+
return minCheck.value;
|
|
14547
|
+
}
|
|
14548
|
+
for (const c of checks) {
|
|
14549
|
+
const def = c._zod?.def;
|
|
14550
|
+
if (def?.check === "greater_than" && def.inclusive) {
|
|
14551
|
+
return def.value;
|
|
14552
|
+
}
|
|
14374
14553
|
}
|
|
14375
|
-
return
|
|
14554
|
+
return -Infinity;
|
|
14376
14555
|
};
|
|
14377
14556
|
var getMaxValue = (schema) => {
|
|
14378
|
-
const
|
|
14379
|
-
if (!
|
|
14380
|
-
return Infinity;
|
|
14381
|
-
}
|
|
14382
|
-
if (maxCheck.kind !== "max") {
|
|
14383
|
-
throw new Error("Expected max check");
|
|
14384
|
-
}
|
|
14385
|
-
if (!maxCheck.inclusive) {
|
|
14557
|
+
const { checks } = getZodDef(schema);
|
|
14558
|
+
if (!checks)
|
|
14386
14559
|
return Infinity;
|
|
14560
|
+
if (isZodV3Schema(schema)) {
|
|
14561
|
+
const maxCheck = checks.find((c) => c.kind === "max");
|
|
14562
|
+
if (!maxCheck || !maxCheck.inclusive)
|
|
14563
|
+
return Infinity;
|
|
14564
|
+
return maxCheck.value;
|
|
14565
|
+
}
|
|
14566
|
+
for (const c of checks) {
|
|
14567
|
+
const def = c._zod?.def;
|
|
14568
|
+
if (def?.check === "less_than" && def.inclusive) {
|
|
14569
|
+
return def.value;
|
|
14570
|
+
}
|
|
14387
14571
|
}
|
|
14388
|
-
return
|
|
14572
|
+
return Infinity;
|
|
14389
14573
|
};
|
|
14390
14574
|
var getStep = (schema) => {
|
|
14391
|
-
const
|
|
14392
|
-
if (!
|
|
14575
|
+
const { checks } = getZodDef(schema);
|
|
14576
|
+
if (!checks)
|
|
14393
14577
|
return;
|
|
14578
|
+
if (isZodV3Schema(schema)) {
|
|
14579
|
+
const multipleStep = checks.find((c) => c.kind === "multipleOf");
|
|
14580
|
+
if (!multipleStep)
|
|
14581
|
+
return;
|
|
14582
|
+
return multipleStep.value;
|
|
14394
14583
|
}
|
|
14395
|
-
|
|
14396
|
-
|
|
14584
|
+
for (const c of checks) {
|
|
14585
|
+
const def = c._zod?.def;
|
|
14586
|
+
if (def?.check === "multiple_of") {
|
|
14587
|
+
return def.value;
|
|
14588
|
+
}
|
|
14397
14589
|
}
|
|
14398
|
-
return
|
|
14590
|
+
return;
|
|
14399
14591
|
};
|
|
14400
14592
|
var ZodNumberEditor = ({
|
|
14401
14593
|
jsonPath,
|
|
@@ -14488,7 +14680,7 @@ var ZodOptionalEditor = ({
|
|
|
14488
14680
|
saveDisabledByParent,
|
|
14489
14681
|
mayPad
|
|
14490
14682
|
}) => {
|
|
14491
|
-
const
|
|
14683
|
+
const innerType = getInnerType(schema);
|
|
14492
14684
|
return /* @__PURE__ */ jsx132(ZodOrNullishEditor, {
|
|
14493
14685
|
defaultValue,
|
|
14494
14686
|
jsonPath,
|
|
@@ -14525,10 +14717,6 @@ var ZodStaticFileEditor = ({
|
|
|
14525
14717
|
saveDisabledByParent,
|
|
14526
14718
|
mayPad
|
|
14527
14719
|
}) => {
|
|
14528
|
-
const z = useZodIfPossible();
|
|
14529
|
-
if (!z) {
|
|
14530
|
-
throw new Error("expected zod");
|
|
14531
|
-
}
|
|
14532
14720
|
const {
|
|
14533
14721
|
localValue,
|
|
14534
14722
|
onChange: setLocalValue,
|
|
@@ -14539,11 +14727,6 @@ var ZodStaticFileEditor = ({
|
|
|
14539
14727
|
unsavedValue: value,
|
|
14540
14728
|
savedValue: defaultValue
|
|
14541
14729
|
});
|
|
14542
|
-
const def = schema._def;
|
|
14543
|
-
const typeName = def.typeName;
|
|
14544
|
-
if (typeName !== z.ZodFirstPartyTypeKind.ZodString) {
|
|
14545
|
-
throw new Error("expected enum");
|
|
14546
|
-
}
|
|
14547
14730
|
const isRoot = jsonPath.length === 0;
|
|
14548
14731
|
const staticFiles = useStaticFiles();
|
|
14549
14732
|
const comboBoxValues = useMemo75(() => {
|
|
@@ -14768,7 +14951,7 @@ import React92, { useMemo as useMemo77, useState as useState50 } from "react";
|
|
|
14768
14951
|
import { useCallback as useCallback66, useMemo as useMemo76 } from "react";
|
|
14769
14952
|
import { jsx as jsx136 } from "react/jsx-runtime";
|
|
14770
14953
|
var ZodTupleItemEditor = ({
|
|
14771
|
-
|
|
14954
|
+
tupleItems,
|
|
14772
14955
|
onChange,
|
|
14773
14956
|
jsonPath,
|
|
14774
14957
|
index,
|
|
@@ -14802,7 +14985,7 @@ var ZodTupleItemEditor = ({
|
|
|
14802
14985
|
return /* @__PURE__ */ jsx136("div", {
|
|
14803
14986
|
children: /* @__PURE__ */ jsx136(ZodSwitch, {
|
|
14804
14987
|
jsonPath: newJsonPath,
|
|
14805
|
-
schema:
|
|
14988
|
+
schema: tupleItems[index],
|
|
14806
14989
|
value,
|
|
14807
14990
|
setValue,
|
|
14808
14991
|
defaultValue,
|
|
@@ -14838,7 +15021,7 @@ var ZodTupleEditor = ({
|
|
|
14838
15021
|
savedValue: defaultValue
|
|
14839
15022
|
});
|
|
14840
15023
|
const [expanded, setExpanded] = useState50(true);
|
|
14841
|
-
const
|
|
15024
|
+
const tupleItems = getTupleItems(schema);
|
|
14842
15025
|
const suffix2 = useMemo77(() => {
|
|
14843
15026
|
return expanded ? " [" : " [...] ";
|
|
14844
15027
|
}, [expanded]);
|
|
@@ -14847,10 +15030,6 @@ var ZodTupleEditor = ({
|
|
|
14847
15030
|
throw new Error("expected zod");
|
|
14848
15031
|
}
|
|
14849
15032
|
const zodTypes = useZodTypesIfPossible();
|
|
14850
|
-
const typeName = def.typeName;
|
|
14851
|
-
if (typeName !== z.ZodFirstPartyTypeKind.ZodTuple) {
|
|
14852
|
-
throw new Error("expected object");
|
|
14853
|
-
}
|
|
14854
15033
|
const isDefaultValue = useMemo77(() => {
|
|
14855
15034
|
return deepEqual(localValue.value, defaultValue);
|
|
14856
15035
|
}, [defaultValue, localValue]);
|
|
@@ -14889,10 +15068,10 @@ var ZodTupleEditor = ({
|
|
|
14889
15068
|
/* @__PURE__ */ jsx137(ZodTupleItemEditor, {
|
|
14890
15069
|
onChange,
|
|
14891
15070
|
value: child,
|
|
14892
|
-
|
|
15071
|
+
tupleItems,
|
|
14893
15072
|
index: i,
|
|
14894
15073
|
jsonPath,
|
|
14895
|
-
defaultValue: defaultValue?.[i] ?? createZodValues(
|
|
15074
|
+
defaultValue: defaultValue?.[i] ?? createZodValues(tupleItems[i], z, zodTypes),
|
|
14896
15075
|
onSave,
|
|
14897
15076
|
showSaveButton,
|
|
14898
15077
|
saving,
|
|
@@ -14929,14 +15108,18 @@ var ZodTupleEditor = ({
|
|
|
14929
15108
|
|
|
14930
15109
|
// src/components/RenderModal/SchemaEditor/ZodUnionEditor.tsx
|
|
14931
15110
|
import { jsx as jsx138 } from "react/jsx-runtime";
|
|
14932
|
-
var findNull = (value
|
|
14933
|
-
const nullIndex = value.findIndex((v) =>
|
|
15111
|
+
var findNull = (value) => {
|
|
15112
|
+
const nullIndex = value.findIndex((v) => {
|
|
15113
|
+
const type = getZodSchemaType(v);
|
|
15114
|
+
return type === "null" || type === "undefined";
|
|
15115
|
+
});
|
|
14934
15116
|
if (nullIndex === -1) {
|
|
14935
15117
|
return null;
|
|
14936
15118
|
}
|
|
14937
|
-
const nullishValue = value[nullIndex]
|
|
15119
|
+
const nullishValue = getZodSchemaType(value[nullIndex]) === "null" ? null : undefined;
|
|
14938
15120
|
const otherSchema = value[nullIndex === 0 ? 1 : 0];
|
|
14939
|
-
const
|
|
15121
|
+
const otherType = getZodSchemaType(otherSchema);
|
|
15122
|
+
const otherSchemaIsAlsoNullish = otherType === "null" || otherType === "undefined";
|
|
14940
15123
|
return {
|
|
14941
15124
|
nullIndex,
|
|
14942
15125
|
nullishValue,
|
|
@@ -14957,11 +15140,7 @@ var ZodUnionEditor = ({
|
|
|
14957
15140
|
saveDisabledByParent,
|
|
14958
15141
|
mayPad
|
|
14959
15142
|
}) => {
|
|
14960
|
-
const
|
|
14961
|
-
const z = useZodIfPossible();
|
|
14962
|
-
if (!z) {
|
|
14963
|
-
throw new Error("expected zod");
|
|
14964
|
-
}
|
|
15143
|
+
const options = getUnionOptions(schema);
|
|
14965
15144
|
if (options.length > 2) {
|
|
14966
15145
|
return /* @__PURE__ */ jsx138(ZonNonEditableValue, {
|
|
14967
15146
|
jsonPath,
|
|
@@ -14980,7 +15159,7 @@ var ZodUnionEditor = ({
|
|
|
14980
15159
|
mayPad
|
|
14981
15160
|
});
|
|
14982
15161
|
}
|
|
14983
|
-
const nullResult = findNull(options
|
|
15162
|
+
const nullResult = findNull(options);
|
|
14984
15163
|
if (!nullResult) {
|
|
14985
15164
|
return /* @__PURE__ */ jsx138(ZonNonEditableValue, {
|
|
14986
15165
|
jsonPath,
|
|
@@ -15032,14 +15211,10 @@ var ZodSwitch = ({
|
|
|
15032
15211
|
saveDisabledByParent,
|
|
15033
15212
|
mayPad
|
|
15034
15213
|
}) => {
|
|
15035
|
-
const
|
|
15036
|
-
const
|
|
15037
|
-
const z = useZodIfPossible();
|
|
15038
|
-
if (!z) {
|
|
15039
|
-
throw new Error("expected zod");
|
|
15040
|
-
}
|
|
15214
|
+
const typeName = getZodSchemaType(schema);
|
|
15215
|
+
const description = getZodSchemaDescription(schema);
|
|
15041
15216
|
const zodTypes = useZodTypesIfPossible();
|
|
15042
|
-
if (typeName ===
|
|
15217
|
+
if (typeName === "object") {
|
|
15043
15218
|
return /* @__PURE__ */ jsx139(ZodObjectEditor, {
|
|
15044
15219
|
setValue,
|
|
15045
15220
|
unsavedValue: value,
|
|
@@ -15055,7 +15230,22 @@ var ZodSwitch = ({
|
|
|
15055
15230
|
discriminatedUnionReplacement: null
|
|
15056
15231
|
});
|
|
15057
15232
|
}
|
|
15058
|
-
if (typeName ===
|
|
15233
|
+
if (typeName === "string") {
|
|
15234
|
+
if (zodTypes && description === zodTypes.ZodZypesInternals.REMOTION_COLOR_BRAND) {
|
|
15235
|
+
return /* @__PURE__ */ jsx139(ZodColorEditor, {
|
|
15236
|
+
value,
|
|
15237
|
+
setValue,
|
|
15238
|
+
jsonPath,
|
|
15239
|
+
schema,
|
|
15240
|
+
onSave,
|
|
15241
|
+
defaultValue,
|
|
15242
|
+
showSaveButton,
|
|
15243
|
+
onRemove,
|
|
15244
|
+
saving,
|
|
15245
|
+
saveDisabledByParent,
|
|
15246
|
+
mayPad
|
|
15247
|
+
});
|
|
15248
|
+
}
|
|
15059
15249
|
if (value.startsWith(window.remotion_staticBase)) {
|
|
15060
15250
|
return /* @__PURE__ */ jsx139(ZodStaticFileEditor, {
|
|
15061
15251
|
setValue,
|
|
@@ -15071,7 +15261,7 @@ var ZodSwitch = ({
|
|
|
15071
15261
|
mayPad
|
|
15072
15262
|
});
|
|
15073
15263
|
}
|
|
15074
|
-
if (zodTypes &&
|
|
15264
|
+
if (zodTypes && description === zodTypes.ZodZypesInternals.REMOTION_TEXTAREA_BRAND) {
|
|
15075
15265
|
return /* @__PURE__ */ jsx139(ZodTextareaEditor, {
|
|
15076
15266
|
value,
|
|
15077
15267
|
setValue,
|
|
@@ -15100,7 +15290,7 @@ var ZodSwitch = ({
|
|
|
15100
15290
|
mayPad
|
|
15101
15291
|
});
|
|
15102
15292
|
}
|
|
15103
|
-
if (typeName ===
|
|
15293
|
+
if (typeName === "date") {
|
|
15104
15294
|
return /* @__PURE__ */ jsx139(ZodDateEditor, {
|
|
15105
15295
|
value,
|
|
15106
15296
|
setValue,
|
|
@@ -15115,7 +15305,7 @@ var ZodSwitch = ({
|
|
|
15115
15305
|
mayPad
|
|
15116
15306
|
});
|
|
15117
15307
|
}
|
|
15118
|
-
if (typeName ===
|
|
15308
|
+
if (typeName === "number") {
|
|
15119
15309
|
return /* @__PURE__ */ jsx139(ZodNumberEditor, {
|
|
15120
15310
|
value,
|
|
15121
15311
|
setValue,
|
|
@@ -15130,7 +15320,7 @@ var ZodSwitch = ({
|
|
|
15130
15320
|
mayPad
|
|
15131
15321
|
});
|
|
15132
15322
|
}
|
|
15133
|
-
if (typeName ===
|
|
15323
|
+
if (typeName === "boolean") {
|
|
15134
15324
|
return /* @__PURE__ */ jsx139(ZodBooleanEditor, {
|
|
15135
15325
|
value,
|
|
15136
15326
|
setValue,
|
|
@@ -15145,7 +15335,7 @@ var ZodSwitch = ({
|
|
|
15145
15335
|
schema
|
|
15146
15336
|
});
|
|
15147
15337
|
}
|
|
15148
|
-
if (typeName ===
|
|
15338
|
+
if (typeName === "undefined") {
|
|
15149
15339
|
return /* @__PURE__ */ jsx139(ZonNonEditableValue, {
|
|
15150
15340
|
jsonPath,
|
|
15151
15341
|
showSaveButton,
|
|
@@ -15154,7 +15344,7 @@ var ZodSwitch = ({
|
|
|
15154
15344
|
mayPad
|
|
15155
15345
|
});
|
|
15156
15346
|
}
|
|
15157
|
-
if (typeName ===
|
|
15347
|
+
if (typeName === "null") {
|
|
15158
15348
|
return /* @__PURE__ */ jsx139(ZonNonEditableValue, {
|
|
15159
15349
|
jsonPath,
|
|
15160
15350
|
showSaveButton,
|
|
@@ -15163,7 +15353,7 @@ var ZodSwitch = ({
|
|
|
15163
15353
|
mayPad
|
|
15164
15354
|
});
|
|
15165
15355
|
}
|
|
15166
|
-
if (typeName ===
|
|
15356
|
+
if (typeName === "any") {
|
|
15167
15357
|
return /* @__PURE__ */ jsx139(ZonNonEditableValue, {
|
|
15168
15358
|
jsonPath,
|
|
15169
15359
|
showSaveButton,
|
|
@@ -15172,7 +15362,7 @@ var ZodSwitch = ({
|
|
|
15172
15362
|
mayPad
|
|
15173
15363
|
});
|
|
15174
15364
|
}
|
|
15175
|
-
if (typeName ===
|
|
15365
|
+
if (typeName === "bigint") {
|
|
15176
15366
|
return /* @__PURE__ */ jsx139(ZonNonEditableValue, {
|
|
15177
15367
|
jsonPath,
|
|
15178
15368
|
showSaveButton,
|
|
@@ -15181,7 +15371,7 @@ var ZodSwitch = ({
|
|
|
15181
15371
|
mayPad
|
|
15182
15372
|
});
|
|
15183
15373
|
}
|
|
15184
|
-
if (typeName ===
|
|
15374
|
+
if (typeName === "unknown") {
|
|
15185
15375
|
return /* @__PURE__ */ jsx139(ZonNonEditableValue, {
|
|
15186
15376
|
jsonPath,
|
|
15187
15377
|
showSaveButton,
|
|
@@ -15190,7 +15380,22 @@ var ZodSwitch = ({
|
|
|
15190
15380
|
mayPad
|
|
15191
15381
|
});
|
|
15192
15382
|
}
|
|
15193
|
-
if (typeName ===
|
|
15383
|
+
if (typeName === "array") {
|
|
15384
|
+
if (zodTypes && description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND) {
|
|
15385
|
+
return /* @__PURE__ */ jsx139(ZodMatrixEditor, {
|
|
15386
|
+
setValue,
|
|
15387
|
+
value,
|
|
15388
|
+
jsonPath,
|
|
15389
|
+
schema,
|
|
15390
|
+
defaultValue,
|
|
15391
|
+
onSave,
|
|
15392
|
+
showSaveButton,
|
|
15393
|
+
onRemove,
|
|
15394
|
+
saving,
|
|
15395
|
+
saveDisabledByParent,
|
|
15396
|
+
mayPad
|
|
15397
|
+
});
|
|
15398
|
+
}
|
|
15194
15399
|
return /* @__PURE__ */ jsx139(ZodArrayEditor, {
|
|
15195
15400
|
setValue,
|
|
15196
15401
|
value,
|
|
@@ -15205,7 +15410,7 @@ var ZodSwitch = ({
|
|
|
15205
15410
|
mayPad
|
|
15206
15411
|
});
|
|
15207
15412
|
}
|
|
15208
|
-
if (typeName ===
|
|
15413
|
+
if (typeName === "enum") {
|
|
15209
15414
|
return /* @__PURE__ */ jsx139(ZodEnumEditor, {
|
|
15210
15415
|
setValue,
|
|
15211
15416
|
value,
|
|
@@ -15218,8 +15423,8 @@ var ZodSwitch = ({
|
|
|
15218
15423
|
saving
|
|
15219
15424
|
});
|
|
15220
15425
|
}
|
|
15221
|
-
if (typeName ===
|
|
15222
|
-
if (zodTypes &&
|
|
15426
|
+
if (typeName === "effects") {
|
|
15427
|
+
if (zodTypes && description === zodTypes.ZodZypesInternals.REMOTION_COLOR_BRAND) {
|
|
15223
15428
|
return /* @__PURE__ */ jsx139(ZodColorEditor, {
|
|
15224
15429
|
value,
|
|
15225
15430
|
setValue,
|
|
@@ -15234,12 +15439,12 @@ var ZodSwitch = ({
|
|
|
15234
15439
|
mayPad
|
|
15235
15440
|
});
|
|
15236
15441
|
}
|
|
15237
|
-
if (zodTypes &&
|
|
15442
|
+
if (zodTypes && description === zodTypes.ZodZypesInternals.REMOTION_MATRIX_BRAND) {
|
|
15238
15443
|
return /* @__PURE__ */ jsx139(ZodMatrixEditor, {
|
|
15239
15444
|
setValue,
|
|
15240
15445
|
value,
|
|
15241
15446
|
jsonPath,
|
|
15242
|
-
schema: schema
|
|
15447
|
+
schema: getEffectsInner(schema),
|
|
15243
15448
|
defaultValue,
|
|
15244
15449
|
onSave,
|
|
15245
15450
|
showSaveButton,
|
|
@@ -15262,7 +15467,7 @@ var ZodSwitch = ({
|
|
|
15262
15467
|
mayPad
|
|
15263
15468
|
});
|
|
15264
15469
|
}
|
|
15265
|
-
if (typeName ===
|
|
15470
|
+
if (typeName === "union") {
|
|
15266
15471
|
return /* @__PURE__ */ jsx139(ZodUnionEditor, {
|
|
15267
15472
|
schema,
|
|
15268
15473
|
showSaveButton,
|
|
@@ -15277,7 +15482,7 @@ var ZodSwitch = ({
|
|
|
15277
15482
|
mayPad
|
|
15278
15483
|
});
|
|
15279
15484
|
}
|
|
15280
|
-
if (typeName ===
|
|
15485
|
+
if (typeName === "optional") {
|
|
15281
15486
|
return /* @__PURE__ */ jsx139(ZodOptionalEditor, {
|
|
15282
15487
|
jsonPath,
|
|
15283
15488
|
showSaveButton,
|
|
@@ -15292,7 +15497,7 @@ var ZodSwitch = ({
|
|
|
15292
15497
|
mayPad
|
|
15293
15498
|
});
|
|
15294
15499
|
}
|
|
15295
|
-
if (typeName ===
|
|
15500
|
+
if (typeName === "nullable") {
|
|
15296
15501
|
return /* @__PURE__ */ jsx139(ZodNullableEditor, {
|
|
15297
15502
|
jsonPath,
|
|
15298
15503
|
showSaveButton,
|
|
@@ -15307,7 +15512,7 @@ var ZodSwitch = ({
|
|
|
15307
15512
|
mayPad
|
|
15308
15513
|
});
|
|
15309
15514
|
}
|
|
15310
|
-
if (typeName ===
|
|
15515
|
+
if (typeName === "default") {
|
|
15311
15516
|
return /* @__PURE__ */ jsx139(ZodDefaultEditor, {
|
|
15312
15517
|
jsonPath,
|
|
15313
15518
|
showSaveButton,
|
|
@@ -15322,7 +15527,7 @@ var ZodSwitch = ({
|
|
|
15322
15527
|
mayPad
|
|
15323
15528
|
});
|
|
15324
15529
|
}
|
|
15325
|
-
if (typeName ===
|
|
15530
|
+
if (typeName === "discriminatedUnion") {
|
|
15326
15531
|
return /* @__PURE__ */ jsx139(ZodDiscriminatedUnionEditor, {
|
|
15327
15532
|
defaultValue,
|
|
15328
15533
|
mayPad,
|
|
@@ -15337,7 +15542,7 @@ var ZodSwitch = ({
|
|
|
15337
15542
|
showSaveButton
|
|
15338
15543
|
});
|
|
15339
15544
|
}
|
|
15340
|
-
if (typeName ===
|
|
15545
|
+
if (typeName === "tuple") {
|
|
15341
15546
|
return /* @__PURE__ */ jsx139(ZodTupleEditor, {
|
|
15342
15547
|
setValue,
|
|
15343
15548
|
value,
|
|
@@ -15377,10 +15582,6 @@ var ZodObjectEditor = ({
|
|
|
15377
15582
|
mayPad,
|
|
15378
15583
|
discriminatedUnionReplacement
|
|
15379
15584
|
}) => {
|
|
15380
|
-
const z = useZodIfPossible();
|
|
15381
|
-
if (!z) {
|
|
15382
|
-
throw new Error("expected zod");
|
|
15383
|
-
}
|
|
15384
15585
|
const [expanded, setExpanded] = useState51(true);
|
|
15385
15586
|
const { localValue, onChange, RevisionContextProvider, reset } = useLocalState({
|
|
15386
15587
|
schema,
|
|
@@ -15388,12 +15589,11 @@ var ZodObjectEditor = ({
|
|
|
15388
15589
|
unsavedValue,
|
|
15389
15590
|
savedValue
|
|
15390
15591
|
});
|
|
15391
|
-
const
|
|
15392
|
-
|
|
15393
|
-
if (typeName !== z.ZodFirstPartyTypeKind.ZodObject) {
|
|
15592
|
+
const typeName = getZodSchemaType(schema);
|
|
15593
|
+
if (typeName !== "object") {
|
|
15394
15594
|
throw new Error("expected object");
|
|
15395
15595
|
}
|
|
15396
|
-
const shape =
|
|
15596
|
+
const shape = getObjectShape(schema);
|
|
15397
15597
|
const keys = Object.keys(shape);
|
|
15398
15598
|
const isRoot = jsonPath.length === 0;
|
|
15399
15599
|
const isDefaultValue = useMemo78(() => {
|
|
@@ -15538,13 +15738,12 @@ var SchemaEditor = ({
|
|
|
15538
15738
|
save.unregister();
|
|
15539
15739
|
};
|
|
15540
15740
|
}, [keybindings, onQuickSave, onSave]);
|
|
15541
|
-
const
|
|
15542
|
-
const typeName = def.typeName;
|
|
15741
|
+
const typeName = getZodSchemaType(schema);
|
|
15543
15742
|
const reset = useCallback67(() => {
|
|
15544
15743
|
setValue(savedDefaultProps);
|
|
15545
15744
|
}, [savedDefaultProps, setValue]);
|
|
15546
15745
|
if (!zodValidationResult.success) {
|
|
15547
|
-
const defaultPropsValid = schema
|
|
15746
|
+
const defaultPropsValid = zodSafeParse(schema, savedDefaultProps);
|
|
15548
15747
|
if (!defaultPropsValid.success) {
|
|
15549
15748
|
return /* @__PURE__ */ jsx141(InvalidDefaultProps, {
|
|
15550
15749
|
zodValidationResult
|
|
@@ -15555,7 +15754,7 @@ var SchemaEditor = ({
|
|
|
15555
15754
|
zodValidationResult
|
|
15556
15755
|
});
|
|
15557
15756
|
}
|
|
15558
|
-
if (typeName !==
|
|
15757
|
+
if (typeName !== "object") {
|
|
15559
15758
|
return /* @__PURE__ */ jsx141(TopLevelZodValue, {
|
|
15560
15759
|
typeReceived: typeName
|
|
15561
15760
|
});
|
|
@@ -15817,7 +16016,7 @@ var DataEditor = ({
|
|
|
15817
16016
|
if (schema === "no-schema") {
|
|
15818
16017
|
return "no-schema";
|
|
15819
16018
|
}
|
|
15820
|
-
return schema
|
|
16019
|
+
return zodSafeParse(schema, defaultProps);
|
|
15821
16020
|
}, [defaultProps, schema]);
|
|
15822
16021
|
const setShowWarning = useCallback69((val) => {
|
|
15823
16022
|
setShowWarningWithoutPersistance((prevVal) => {
|
|
@@ -15992,9 +16191,8 @@ var DataEditor = ({
|
|
|
15992
16191
|
if (zodValidationResult === "no-schema") {
|
|
15993
16192
|
throw new Error("expected schema");
|
|
15994
16193
|
}
|
|
15995
|
-
const
|
|
15996
|
-
|
|
15997
|
-
if (typeName === z.ZodFirstPartyTypeKind.ZodAny) {
|
|
16194
|
+
const typeName = getZodSchemaType(schema);
|
|
16195
|
+
if (typeName === "any") {
|
|
15998
16196
|
return /* @__PURE__ */ jsx143(NoSchemaDefined, {});
|
|
15999
16197
|
}
|
|
16000
16198
|
if (!unresolvedComposition.defaultProps) {
|
|
@@ -23346,7 +23544,8 @@ var CodemodFooter = ({
|
|
|
23346
23544
|
successNotification,
|
|
23347
23545
|
errorNotification,
|
|
23348
23546
|
genericSubmitLabel,
|
|
23349
|
-
submitLabel
|
|
23547
|
+
submitLabel,
|
|
23548
|
+
onSuccess
|
|
23350
23549
|
}) => {
|
|
23351
23550
|
const [submitting, setSubmitting] = useState72(false);
|
|
23352
23551
|
const { setSelectedModal } = useContext78(ModalsContext);
|
|
@@ -23375,6 +23574,7 @@ var CodemodFooter = ({
|
|
|
23375
23574
|
signal: new AbortController().signal
|
|
23376
23575
|
}).then(() => {
|
|
23377
23576
|
notification2.replaceContent(successNotification, 2000);
|
|
23577
|
+
onSuccess?.();
|
|
23378
23578
|
}).catch((err) => {
|
|
23379
23579
|
notification2.replaceContent(`${errorNotification}: ${err.message}`, 2000);
|
|
23380
23580
|
});
|
|
@@ -23382,6 +23582,7 @@ var CodemodFooter = ({
|
|
|
23382
23582
|
codemod,
|
|
23383
23583
|
errorNotification,
|
|
23384
23584
|
loadingNotification,
|
|
23585
|
+
onSuccess,
|
|
23385
23586
|
setSelectedModal,
|
|
23386
23587
|
successNotification
|
|
23387
23588
|
]);
|
|
@@ -23526,7 +23727,8 @@ var DeleteCompositionLoaded = ({ compositionId }) => {
|
|
|
23526
23727
|
genericSubmitLabel: `Delete`,
|
|
23527
23728
|
submitLabel: ({ relativeRootPath }) => `Delete from ${relativeRootPath}`,
|
|
23528
23729
|
codemod,
|
|
23529
|
-
valid: true
|
|
23730
|
+
valid: true,
|
|
23731
|
+
onSuccess: null
|
|
23530
23732
|
})
|
|
23531
23733
|
})
|
|
23532
23734
|
]
|
|
@@ -23787,6 +23989,9 @@ var DuplicateCompositionLoaded = ({ initialType }) => {
|
|
|
23787
23989
|
size4.width,
|
|
23788
23990
|
type
|
|
23789
23991
|
]);
|
|
23992
|
+
const onDuplicateSuccess = useCallback106(() => {
|
|
23993
|
+
pushUrl(`/${newId}`);
|
|
23994
|
+
}, [newId]);
|
|
23790
23995
|
const onSubmit = useCallback106((e) => {
|
|
23791
23996
|
e.preventDefault();
|
|
23792
23997
|
}, []);
|
|
@@ -23985,7 +24190,8 @@ var DuplicateCompositionLoaded = ({ initialType }) => {
|
|
|
23985
24190
|
genericSubmitLabel: "Duplicate",
|
|
23986
24191
|
submitLabel: ({ relativeRootPath }) => `Add to ${relativeRootPath}`,
|
|
23987
24192
|
codemod,
|
|
23988
|
-
valid
|
|
24193
|
+
valid,
|
|
24194
|
+
onSuccess: onDuplicateSuccess
|
|
23989
24195
|
})
|
|
23990
24196
|
})
|
|
23991
24197
|
]
|
|
@@ -24097,7 +24303,8 @@ var RenameCompositionLoaded = () => {
|
|
|
24097
24303
|
genericSubmitLabel: "Rename",
|
|
24098
24304
|
submitLabel: ({ relativeRootPath }) => `Modify ${relativeRootPath}`,
|
|
24099
24305
|
codemod,
|
|
24100
|
-
valid
|
|
24306
|
+
valid,
|
|
24307
|
+
onSuccess: null
|
|
24101
24308
|
})
|
|
24102
24309
|
})
|
|
24103
24310
|
]
|