Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): Action onClick add event param #874

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/ui/src/Action/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface BaseProps extends ButtonProps {
visible?: boolean;
/** 固定展示、不会被折叠 */
fixed?: boolean;
onClick?: () => Promise<void> | void;
onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void> | void;
children?: React.ReactElement | string;
enableLoading?: boolean;
tooltip?: string;
Expand All @@ -26,8 +26,8 @@ export class ActionButton extends React.PureComponent<BaseProps> {
<Tooltip placement="top" title={tooltip}>
<Button
loading={enableLoading && (loading || this.state.loading)}
onClick={_ => {
const handle = onClick?.();
onClick={e => {
const handle = onClick?.(e);

if (enableLoading && (handle as Promise<void>)?.then) {
this.setState({ loading: true });
Expand Down Expand Up @@ -68,8 +68,8 @@ export class ActionLink extends React.PureComponent<BaseProps> {
<Typography.Link
style={{ padding: 0, ...style }}
disabled={loading || disabled || this.state.disabled}
onClick={_ => {
const handle = onClick?.();
onClick={e => {
const handle = onClick?.(e);

if (enableLoading && (handle as Promise<void>)?.then) {
this.setState({ loading: true, disabled: true });
Expand Down
42 changes: 21 additions & 21 deletions packages/ui/src/Action/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ nav:

### Action.Link

| 参数 | 说明 | 类型 | 默认值 |
| :-------- | :----------------- | :----------------------------- | :----- |
| visible | 是否可见 | boolean | true |
| loading | 设置加载状态 | boolean | false |
| tooltip | 设置提示文案 | string | - |
| disabled | 是否禁用 | boolean | false |
| fixed | 固定展示、不被折叠 | boolean | false |
| onClick | 点击链接的回调 | async () => void \| () => void | - |
| className | 设置 link 的样式名 | string | - |
| 参数 | 说明 | 类型 | 默认值 |
| :-- | :-- | :-- | :-- |
| visible | 是否可见 | boolean | true |
| loading | 设置加载状态 | boolean | false |
| tooltip | 设置提示文案 | string | - |
| disabled | 是否禁用 | boolean | false |
| fixed | 固定展示、不被折叠 | boolean | false |
| onClick | 点击链接的回调 | async (event: React.MouseEvent<HTMLElement, MouseEvent>) => void \| (event: React.MouseEvent<HTMLElement, MouseEvent>) => void | - |
| className | 设置 link 的样式名 | string | - |

### Action.Button

| 参数 | 说明 | 类型 | 默认值 |
| :-------- | :----------------- | :----------------------------- | :------ |
| visible | 是否可见 | boolean | true |
| type | 设置按钮类型 | primary \| default | default |
| size | 设置按钮大小 | large \| middle \| small | middle |
| danger | 设置危险按钮 | boolean | false |
| disabled | 是否禁用 | boolean | false |
| loading | 设置加载状态 | boolean | false |
| tooltip | 设置提示文案 | string | - |
| fixed | 固定展示、不被折叠 | boolean | false |
| onClick | 点击链接的回调 | async () => void \| () => void | - |
| className | 设置按钮的样式名 | string | - |
| 参数 | 说明 | 类型 | 默认值 |
| :-- | :-- | :-- | :-- |
| visible | 是否可见 | boolean | true |
| type | 设置按钮类型 | primary \| default | default |
| size | 设置按钮大小 | large \| middle \| small | middle |
| danger | 设置危险按钮 | boolean | false |
| disabled | 是否禁用 | boolean | false |
| loading | 设置加载状态 | boolean | false |
| tooltip | 设置提示文案 | string | - |
| fixed | 固定展示、不被折叠 | boolean | false |
| onClick | 点击链接的回调 | async (event: React.MouseEvent<HTMLElement, MouseEvent>) => void \| (event: React.MouseEvent<HTMLElement, MouseEvent>) => void | - |
| className | 设置按钮的样式名 | string | - |
Loading