further types to admin
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export type Props = {
|
||||
label?: string
|
||||
label?: string | JSX.Element
|
||||
required?: boolean
|
||||
htmlFor?: string
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ export type Context = {
|
||||
export type Props = {
|
||||
className?: string
|
||||
operation?: Operation
|
||||
readOnly: boolean
|
||||
permissions: {
|
||||
readOnly?: boolean
|
||||
permissions?: {
|
||||
[field: string]: FieldPermissions
|
||||
}
|
||||
filter?: (field: Field) => boolean
|
||||
|
||||
@@ -32,7 +32,7 @@ const Text: React.FC<Props> = (props) => {
|
||||
return validationResult;
|
||||
}, [validate, maxLength, minLength, required]);
|
||||
|
||||
const fieldType = useFieldType({
|
||||
const fieldType = useFieldType<string>({
|
||||
path,
|
||||
validate: memoizedValidate,
|
||||
enableDebouncedValue: true,
|
||||
@@ -70,7 +70,7 @@ const Text: React.FC<Props> = (props) => {
|
||||
required={required}
|
||||
/>
|
||||
<input
|
||||
value={value as string || ''}
|
||||
value={value || ''}
|
||||
onChange={setValue}
|
||||
disabled={readOnly}
|
||||
placeholder={placeholder}
|
||||
|
||||
@@ -66,7 +66,6 @@ const AddUploadModal: React.FC<Props> = (props) => {
|
||||
</header>
|
||||
<Upload
|
||||
{...collection.upload}
|
||||
fieldTypes={fieldTypes}
|
||||
/>
|
||||
<NegativeFieldGutterProvider allow>
|
||||
<RenderFields
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Options, FieldType } from './types';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
const useFieldType = (options: Options): FieldType => {
|
||||
const useFieldType = <T extends unknown>(options: Options): FieldType<T> => {
|
||||
const {
|
||||
path,
|
||||
validate,
|
||||
|
||||
@@ -9,8 +9,8 @@ export type Options = {
|
||||
stringify?: boolean
|
||||
}
|
||||
|
||||
export type FieldType = {
|
||||
value: unknown
|
||||
export type FieldType<T> = {
|
||||
value: T
|
||||
errorMessage?: string
|
||||
showError: boolean
|
||||
formSubmitted: boolean
|
||||
|
||||
Reference in New Issue
Block a user