Skip to content

Commit

Permalink
Merge pull request #874 from wzc520pyfm/feat/support-e-for-action
Browse files Browse the repository at this point in the history
feat(ui): Action onClick add event param
  • Loading branch information
dengfuping authored Dec 14, 2024
2 parents f3bc49c + 0f1a4ee commit 05934b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
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 | - |

0 comments on commit 05934b8

Please sign in to comment.