Skip to content

Commit

Permalink
feat(form): add custom array functions to GridArrayInput
Browse files Browse the repository at this point in the history
  • Loading branch information
hermanwikner committed Oct 26, 2022
1 parent 9c3c46a commit 16d44ba
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {Card, Stack, Text} from '@sanity/ui'
import React, {useCallback} from 'react'
import {Item, List} from '../../common/list'
import {ArrayOfObjectsInputProps, ObjectItem, ObjectItemProps} from '../../../../types'
import {DefaultArrayInputFunctions} from '../../common/ArrayFunctions'
import {ArrayOfObjectsItem} from '../../../../members'
import {createProtoArrayValue} from '../createProtoArrayValue'
import {UploadTargetCard} from '../../common/UploadTargetCard'
import {DefaultArrayFunctions} from '../DefaultArrayFunctions'
import {GridItem} from './GridItem'
import {ErrorItem} from './ErrorItem'

Expand All @@ -27,6 +27,7 @@ export function GridArrayInput<Item extends ObjectItem>(props: ArrayOfObjectsInp
renderPreview,
renderField,
renderInput,
arrayFunctions: ArrayFunctions = DefaultArrayFunctions,
} = props

const handlePrepend = useCallback(
Expand Down Expand Up @@ -99,14 +100,14 @@ export function GridArrayInput<Item extends ObjectItem>(props: ArrayOfObjectsInp
</Stack>
</UploadTargetCard>

<DefaultArrayInputFunctions
type={schemaType}
value={value}
readOnly={readOnly}
<ArrayFunctions
onChange={onChange}
onItemAppend={handleAppend}
onItemPrepend={handlePrepend}
onValueCreate={createProtoArrayValue}
onChange={onChange}
readOnly={readOnly}
schemaType={schemaType}
value={value}
/>
</Stack>
)
Expand Down

0 comments on commit 16d44ba

Please sign in to comment.