frontend/packages/components/bot-semi/README.md
A comprehensive UI component library that provides wrapped and enhanced components based on SemiDesign UI framework. This package serves as the foundation UI layer for the Coze bot studio platform, offering both direct Semi UI re-exports and custom-styled components.
useGrab for advanced UI interactionsAdd the package to your project using workspace dependencies:
{
"dependencies": {
"@coze-arch/bot-semi": "workspace:*"
}
}
Then run:
rush update
Import components individually for optimal tree-shaking:
import { UIButton, UIModal, useUIModal } from '@coze-arch/bot-semi';
import { Button, Input, Table } from '@coze-arch/bot-semi';
function MyComponent() {
const modal = useUIModal();
return (
<div>
<UIButton onClick={() => modal.show()}>
Open Modal
</UIButton>
<UIModal {...modal.props}>
Modal Content
</UIModal>
</div>
);
}
Custom-styled button component with enhanced theming:
import { UIButton } from '@coze-arch/bot-semi/Button';
<UIButton theme="solid" size="default">
Click me
</UIButton>
Enhanced modal with platform-specific styling and behavior:
import { UIModal, useUIModal } from '@coze-arch/bot-semi/Modal';
const modal = useUIModal();
<UIModal
type="info"
showScrollBar={false}
{...modal.props}
>
Content
</UIModal>
Feature-rich table component with action integration:
import { UITable, UITableAction } from '@coze-arch/bot-semi';
<UITable
columns={columns}
dataSource={data}
renderActions={(record) => (
<UITableAction
items={[
{ key: 'edit', label: 'Edit' },
{ key: 'delete', label: 'Delete' }
]}
/>
)}
/>
Enhanced input component with platform styling:
import { UIInput } from '@coze-arch/bot-semi/Input';
<UIInput
placeholder="Enter text"
size="default"
/>
Pre-configured form components:
import { UIFormInput, UIFormTextArea, UIFormSelect } from '@coze-arch/bot-semi';
<Form>
<UIFormInput field="name" label="Name" />
<UIFormTextArea field="description" label="Description" />
<UIFormSelect field="category" label="Category" options={options} />
</Form>
Platform-specific layout wrapper:
import { UILayout } from '@coze-arch/bot-semi/Layout';
<UILayout header={<Header />} footer={<Footer />}>
<Content />
</UILayout>
Enhanced tab navigation:
import { UITabBar } from '@coze-arch/bot-semi';
<UITabBar
tabs={[
{ key: 'tab1', label: 'Tab 1' },
{ key: 'tab2', label: 'Tab 2' }
]}
activeKey="tab1"
onChange={handleTabChange}
/>
Customized empty state component:
import { UIEmpty } from '@coze-arch/bot-semi/Empty';
<UIEmpty
image={UIEmpty.PRESENTED_IMAGE_SIMPLE}
description="No data available"
/>
Enhanced tag component with color variants:
import { UITag } from '@coze-arch/bot-semi/Tag';
<UITag color="blue" closable>
Sample Tag
</UITag>
Hook for drag-and-drop functionality:
import { useGrab } from '@coze-arch/bot-semi';
const targetRef = useRef(null);
const { subscribeGrab, grabbing } = useGrab({
grabTarget: targetRef,
isModifyStyle: true,
onPositionChange: ({ left, top }) => {
console.log('Position:', { left, top });
}
});
useEffect(() => {
const unsubscribe = subscribeGrab();
return unsubscribe;
}, []);
Hook for modal state management:
import { useUIModal } from '@coze-arch/bot-semi';
const modal = useUIModal();
// Show modal
modal.show();
// Hide modal
modal.hide();
// Use props in component
<UIModal {...modal.props} />
All Semi UI components are available as direct imports:
import {
Button,
Input,
Table,
Form,
DatePicker,
Select,
// ... all other Semi UI components
} from '@coze-arch/bot-semi';
src/
├── components/ # Enhanced UI components
│ ├── ui-button/ # Custom button implementation
│ ├── ui-modal/ # Custom modal implementation
│ ├── ui-table/ # Custom table implementation
│ └── ...
├── hooks/ # Custom hooks
│ └── use-grab.ts # Drag and drop hook
├── semi/ # Semi UI re-exports
│ ├── index.ts # Main re-export file
│ ├── button.ts # Button types re-export
│ └── ...
└── utils/ # Utility functions
# Type checking
rush ts-check
# Linting
rush lint
# Testing
rush test
# Test with coverage
rush test:cov
Apache-2.0 License
For more information about Semi Design components, visit the Semi Design documentation.