Skip to content

🎥 Make videos programmatically with React

Merge branch 'main' into collapse-and-expand

Jonny Burger265b61f55348
diff --cc packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx
index a33cc013dd,2f26fdffbf..e4cb7862da
--- a/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx
+++ b/packages/cli/src/editor/components/RenderModal/SchemaEditor/ZodArrayEditor.tsx
@@@ -1,14 -1,6 +1,6 @@@
- import React, {useCallback, useMemo, useState} from 'react';
-import React, {useMemo} from 'react';
++import React, {useMemo, useState} from 'react';
import type {z} from 'zod';
- import {Plus} from '../../../icons/plus';
- import {
- useZodIfPossible,
- useZodTypesIfPossible,
- } from '../../get-zod-if-possible';
- import type {RenderInlineAction} from '../../InlineAction';
- import {InlineAction} from '../../InlineAction';
- import {fieldsetLabel} from '../layout';
- import {createZodValues} from './create-zod-values';
+ import {useZodIfPossible} from '../../get-zod-if-possible';
import {deepEqual} from './deep-equal';
import {Fieldset} from './Fieldset';
import {useLocalState} from './local-state';
@@@ -85,79 -60,52 +65,64 @@@ export const ZodArrayEditor: React.FC<
return deepEqual(localValue.value, defaultValue);
}, [defaultValue, localValue]);
- const renderAddButton: RenderInlineAction = useCallback((color) => {
- return <Plus color={color} style={{height: 12}} />;
- }, []);
-
return (
<Fieldset shouldPad={mayPad} success={localValue.zodValidation.success}>
- <SchemaLabel
- onReset={reset}
- isDefaultValue={isDefaultValue}
- jsonPath={jsonPath}
- onRemove={onRemove}
- suffix={' ['}
- onSave={() => {
- onSave(() => localValue.value, false, false);
+ <div
+ style={{
+ display: 'flex',
+ flexDirection: 'row',
}}
- saveDisabledByParent={saveDisabledByParent}
- saving={saving}
- showSaveButton={showSaveButton}
- valid={localValue.zodValidation.success}
- />
- <RevisionContextProvider>
- <SchemaVerticalGuide isRoot={false}>
- {localValue.value.map((child, i) => {
- return (
- // eslint-disable-next-line react/no-array-index-key
- <React.Fragment key={`${i}${localValue.keyStabilityRevision}`}>
- <ZodArrayItemEditor
- onChange={onChange}
- value={child}
- def={def}
- index={i}
- jsonPath={jsonPath}
- defaultValue={defaultValue[i] ?? child}
- onSave={onSave}
- showSaveButton={showSaveButton}
- saving={saving}
- saveDisabledByParent={saveDisabledByParent}
- mayPad={mayPad}
- />
- <SchemaArrayItemSeparationLine
- schema={schema}
- index={i}
- onChange={onChange}
- isLast={i === localValue.value.length - 1}
- />
- </React.Fragment>
- );
- })}
- </SchemaVerticalGuide>
- </RevisionContextProvider>
+ >
+ <SchemaLabel
+ onReset={reset}
+ isDefaultValue={isDefaultValue}
+ jsonPath={jsonPath}
+ onRemove={onRemove}
+ suffix={suffix}
+ onSave={() => {
+ onSave(() => localValue.value, false, false);
+ }}
+ saveDisabledByParent={saveDisabledByParent}
+ saving={saving}
+ showSaveButton={showSaveButton}
+ valid={localValue.zodValidation.success}
+ handleClick={() => setExpanded(!expanded)}
+ />
+ </div>
+
+ {expanded ? (
+ <RevisionContextProvider>
+ <SchemaVerticalGuide isRoot={false}>
+ {localValue.value.map((child, i) => {
+ return (
+ // eslint-disable-next-line react/no-array-index-key
+ <React.Fragment key={`${i}${localValue.keyStabilityRevision}`}>
+ <ZodArrayItemEditor
+ onChange={onChange}
+ value={child}
+ def={def}
+ index={i}
+ jsonPath={jsonPath}
+ defaultValue={defaultValue[i] ?? child}
+ onSave={onSave}
+ showSaveButton={showSaveButton}
+ saving={saving}
+ saveDisabledByParent={saveDisabledByParent}
+ mayPad={mayPad}
+ />
- {i === localValue.value.length - 1 ? null : (
- <SchemaSeparationLine />
- )}
++ <SchemaArrayItemSeparationLine
++ schema={schema}
++ index={i}
++ onChange={onChange}
++ isLast={i === localValue.value.length - 1}
++ />
+ </React.Fragment>
+ );
+ })}
+ </SchemaVerticalGuide>
+ </RevisionContextProvider>
+ ) : null}
+
- <div
- style={{
- ...fieldsetLabel,
- alignItems: 'center',
- display: 'flex',
- }}
- >
- {expanded ? (
- <>
- {']'}
- <InlineAction onClick={onAdd} renderAction={renderAddButton} />
- </>
- ) : null}
- </div>
<ZodFieldValidation path={jsonPath} localValue={localValue} />
</Fieldset>
);