1
1
import { Plus } from '@gravity-ui/icons' ;
2
2
import { Button , Card , Icon } from '@gravity-ui/uikit' ;
3
- import React , { useCallback } from 'react' ;
3
+ import * as React from 'react' ;
4
4
5
5
import { ArrayObjectInput , ArrayTextInput , DynamicFormValue } from '../../../../../common/types' ;
6
6
import { removeFromArray , swapArrayItems } from '../../../../utils' ;
@@ -27,15 +27,15 @@ interface ArrayFieldProps {
27
27
const ArrayDynamicField = ( { title, values, onUpdate, className, blockConfig} : ArrayFieldProps ) => {
28
28
const haveItems = values && Array . isArray ( values ) && values . length ;
29
29
30
- const onAddItem = useCallback ( ( ) => {
30
+ const onAddItem = React . useCallback ( ( ) => {
31
31
if ( blockConfig . arrayType === 'text' ) {
32
32
onUpdate ( '' , haveItems ? [ ...values , '' ] : [ '' ] ) ;
33
33
} else if ( blockConfig . arrayType === 'object' ) {
34
34
onUpdate ( '' , haveItems ? [ ...values , { } ] : [ { } ] ) ;
35
35
}
36
36
} , [ blockConfig . arrayType , haveItems , onUpdate , values ] ) ;
37
37
38
- const onDeleteItem = useCallback (
38
+ const onDeleteItem = React . useCallback (
39
39
( index : number ) => {
40
40
if ( Array . isArray ( values ) ) {
41
41
const newArray = removeFromArray ( values , index ) ;
@@ -45,7 +45,7 @@ const ArrayDynamicField = ({title, values, onUpdate, className, blockConfig}: Ar
45
45
[ onUpdate , values ] ,
46
46
) ;
47
47
48
- const onReorderItem = useCallback (
48
+ const onReorderItem = React . useCallback (
49
49
( index : number , placement : 'up' | 'down' ) => {
50
50
if ( Array . isArray ( values ) ) {
51
51
const newArray = swapArrayItems (
@@ -59,7 +59,7 @@ const ArrayDynamicField = ({title, values, onUpdate, className, blockConfig}: Ar
59
59
[ onUpdate , values ] ,
60
60
) ;
61
61
62
- const renderInput = useCallback (
62
+ const renderInput = React . useCallback (
63
63
( value : DynamicFormValue , index : number ) => {
64
64
const arrayItemButton = (
65
65
< ItemButton
@@ -113,7 +113,7 @@ const ArrayDynamicField = ({title, values, onUpdate, className, blockConfig}: Ar
113
113
[ blockConfig , haveItems , onDeleteItem , onReorderItem , onUpdate , values ] ,
114
114
) ;
115
115
116
- const renderInputs = useCallback ( ( ) => {
116
+ const renderInputs = React . useCallback ( ( ) => {
117
117
if ( haveItems ) {
118
118
const renderItems = values
119
119
. map ( renderInput )
0 commit comments