2022-11-08 10:17:56 +08:00
|
|
|
import React from 'react';
|
|
|
|
import {Button, InputTable, Form, Controller, InputBox} from 'amis-ui';
|
|
|
|
|
|
|
|
export default function ButtonExamples() {
|
|
|
|
const handleSubmit = React.useCallback((data: any) => {
|
|
|
|
console.log('submit', data);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="wrapper">
|
2022-11-09 17:58:43 +08:00
|
|
|
<Form defaultValue={{items: [{a: 1, b: 2}]}} onSubmit={handleSubmit}>
|
2022-11-08 10:17:56 +08:00
|
|
|
{({control, onSubmit}) => {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<InputTable
|
|
|
|
name="items"
|
|
|
|
control={control}
|
|
|
|
minLength={2}
|
|
|
|
maxLength={5}
|
|
|
|
columns={[
|
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
tdRender: ({control}) => {
|
|
|
|
return (
|
|
|
|
<Controller
|
|
|
|
name="key"
|
|
|
|
control={control}
|
|
|
|
isRequired
|
|
|
|
render={({field, fieldState}) => (
|
|
|
|
<InputBox
|
|
|
|
{...field}
|
|
|
|
placeholder="Key"
|
|
|
|
hasError={!!fieldState.error}
|
|
|
|
disabled={false}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
<Button onClick={onSubmit}>Submit</Button>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
</Form>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|