vendor: amis 6.13.0 base (fork root)

This commit is contained in:
2026-06-16 22:14:57 +08:00
commit 8c8e4247a9
3840 changed files with 2467374 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
import React from 'react';
import {Button, ConfirmBox, Controller, Form, InputBox} from 'amis-ui';
export default function ButtonExamples() {
const [isShow, setIsShow] = React.useState(false);
const handleClick = React.useCallback(() => {
setIsShow(!isShow);
}, [isShow]);
const handleCancel = React.useCallback(() => {
setIsShow(false);
}, []);
// const beforeConfirm = React.useCallback(async () => {
// return false;
// }, []);
const handleConfirm = React.useCallback((data: any) => {
console.log('confirmed', data);
setIsShow(false);
}, []);
async function handleValidate() {
return new Promise<void>((resolve, reject) => {
// setTimeout(() => reject('error message'), 200);
setTimeout(() => resolve(), 200);
});
}
return (
<div className="wrapper">
<Button onClick={handleClick}>Open</Button>
<ConfirmBox
type="drawer"
size="md"
position="bottom"
onConfirm={handleConfirm}
show={isShow}
onCancel={handleCancel}
>
{({bodyRef}) => (
<Form ref={bodyRef} onValidate={handleValidate}>
{({control}) => (
<>
<Controller
mode="horizontal"
label="A"
name="a"
control={control}
rules={{maxLength: 20}}
isRequired
render={({field, fieldState}) => (
<InputBox
{...field}
hasError={!!fieldState.error}
disabled={false}
/>
)}
/>
<Controller
mode="horizontal"
label="B"
name="b"
control={control}
rules={{maxLength: 20}}
isRequired
render={({field, fieldState}) => (
<InputBox
{...field}
hasError={!!fieldState.error}
disabled={false}
/>
)}
/>
</>
)}
</Form>
)}
</ConfirmBox>
</div>
);
}