Files
chainlit--chainlit/cypress/e2e/custom_element/public/elements/Counter.jsx
T
wehub-resource-sync b7f52be4c9
CI / Run CI (push) Has been cancelled
CI / check-backend (push) Has been cancelled
CI / check-frontend (push) Has been cancelled
CI / tests (push) Has been cancelled
CI / e2e-tests (push) Has been cancelled
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:48:47 +08:00

35 lines
915 B
React

import { X } from 'lucide-react';
import { Button } from '@/components/ui/button';
export default function Counter() {
return (
<div id="custom-counter" className="mt-4 flex flex-col gap-2">
<div>Count: {props.count}</div>
{props.loading ? 'Loading...' : null}
<Button
id="increment"
onClick={() =>
updateElement(Object.assign(props, { count: props.count + 1 }))
}
>
{' '}
Increment
</Button>
<Button
id="action"
onClick={async () => {
await updateElement(Object.assign(props, { loading: true }));
await callAction({ name: 'test', payload: {} });
await updateElement(Object.assign(props, { loading: false }));
}}
>
Run test action
</Button>
<Button id="remove" onClick={deleteElement}>
<X /> Remove
</Button>
</div>
);
}