fix: make name required on field types (#337)
* fix: make name required on field types * fix: improve typescript types
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import React, { Suspense, lazy } from 'react';
|
||||
import Loading from '../../../elements/Loading';
|
||||
import { Props } from './types';
|
||||
|
||||
const Code = lazy(() => import('./Code'));
|
||||
|
||||
const CodeField: React.FC = (props) => (
|
||||
const CodeField: React.FC<Props> = (props) => (
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Code {...props} />
|
||||
</Suspense>
|
||||
|
||||
@@ -8,7 +8,7 @@ const withCondition = <P extends Record<string, unknown>>(Field: React.Component
|
||||
admin: {
|
||||
condition,
|
||||
} = {},
|
||||
} = props as FieldBase;
|
||||
} = props as Partial<FieldBase>;
|
||||
|
||||
if (condition) {
|
||||
return <WithCondition {...props} />;
|
||||
@@ -24,7 +24,7 @@ const withCondition = <P extends Record<string, unknown>>(Field: React.Component
|
||||
admin: {
|
||||
condition,
|
||||
} = {},
|
||||
} = props as FieldBase & {
|
||||
} = props as Partial<FieldBase> & {
|
||||
path?: string
|
||||
};
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ describe('Cell Types', () => {
|
||||
describe('Select', () => {
|
||||
const fieldWithOptionsObject: SelectField = {
|
||||
type: 'select',
|
||||
name: 'selectObject',
|
||||
options: [{
|
||||
value: 'one',
|
||||
label: 'One',
|
||||
@@ -129,6 +130,7 @@ describe('Cell Types', () => {
|
||||
};
|
||||
const fieldWithStringsOptions: SelectField = {
|
||||
type: 'select',
|
||||
name: 'selectString',
|
||||
options: ['blue', 'green', 'yellow'],
|
||||
};
|
||||
it('renders options objects', () => {
|
||||
|
||||
Reference in New Issue
Block a user