Skip to content

Commit

Permalink
fix: rollup warning (#46024)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ authored and nnmax committed Nov 22, 2023
1 parent 08a85d2 commit c079f68
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 10 deletions.
21 changes: 14 additions & 7 deletions components/card/Card.tsx
@@ -1,7 +1,8 @@
import * as React from 'react';
import classNames from 'classnames';
import type { Tab } from 'rc-tabs/lib/interface';
import omit from 'rc-util/lib/omit';
import * as React from 'react';

import { ConfigContext } from '../config-provider';
import useSize from '../config-provider/hooks/useSize';
import Skeleton from '../skeleton';
Expand Down Expand Up @@ -47,12 +48,18 @@ export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 't
}

function getAction(actions: React.ReactNode[]): React.ReactNode[] {
return actions.map<React.ReactNode>((action, index) => (
// eslint-disable-next-line react/no-array-index-key
<li style={{ width: `${100 / actions.length}%` }} key={`action-${index}`}>
<span>{action}</span>
</li>
));
return actions.map<React.ReactNode>((action, index) => {
// Move this out since eslint not allow index key
// And eslint-disable makes conflict with rollup
// ref https://github.com/ant-design/ant-design/issues/46022
const key = `action-${index}`;

return (
<li style={{ width: `${100 / actions.length}%` }} key={key}>
<span>{action}</span>
</li>
);
});
}

const Card = React.forwardRef<HTMLDivElement, CardProps>((props, ref) => {
Expand Down
1 change: 1 addition & 0 deletions components/checkbox/Checkbox.tsx
Expand Up @@ -35,6 +35,7 @@ export interface AbstractCheckboxProps<T> {
autoFocus?: boolean;
type?: string;
skipGroup?: boolean;
required?: boolean;
}

export interface CheckboxChangeEventTarget extends CheckboxProps {
Expand Down
2 changes: 2 additions & 0 deletions components/checkbox/Group.tsx
Expand Up @@ -18,6 +18,7 @@ export interface CheckboxOptionType {
title?: string;
id?: string;
onChange?: (e: CheckboxChangeEvent) => void;
required?: boolean;
}

export interface AbstractCheckboxGroupProps {
Expand Down Expand Up @@ -126,6 +127,7 @@ const InternalGroup: React.ForwardRefRenderFunction<HTMLDivElement, CheckboxGrou
style={option.style}
title={option.title}
id={option.id}
required={option.required}
>
{option.label}
</Checkbox>
Expand Down
2 changes: 2 additions & 0 deletions components/checkbox/index.en-US.md
Expand Up @@ -41,6 +41,7 @@ Common props ref:[Common props](/docs/react/common-props)
| disabled | If disable checkbox | boolean | false | |
| indeterminate | The indeterminate checked state of checkbox | boolean | false | |
| onChange | The callback function that is triggered when the state changes | (e: CheckboxChangeEvent) => void | - | |
| required | If set to `true`, a non-null value must be specified when submitting the form. the browser's native form validation will be triggered. | boolean | - | |

#### Checkbox Group

Expand All @@ -60,6 +61,7 @@ interface Option {
label: string;
value: string;
disabled?: boolean;
required?: boolean;
}
```

Expand Down
2 changes: 2 additions & 0 deletions components/checkbox/index.zh-CN.md
Expand Up @@ -42,6 +42,7 @@ demo:
| disabled | 失效状态 | boolean | false | |
| indeterminate | 设置 indeterminate 状态,只负责样式控制 | boolean | false | |
| onChange | 变化时的回调函数 | (e: CheckboxChangeEvent) => void | - | |
| required | 如果设置为 `true`,则提交表单时必须指定一个非空值。这将会触发浏览器原生表单验证功能 | boolean | - | |

#### Checkbox Group

Expand All @@ -61,6 +62,7 @@ interface Option {
label: string;
value: string;
disabled?: boolean;
required?: boolean;
}
```

Expand Down
1 change: 1 addition & 0 deletions components/radio/group.tsx
Expand Up @@ -80,6 +80,7 @@ const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>((props, ref
title={option.title}
style={option.style}
id={option.id}
required={option.required}
>
{option.label}
</Radio>
Expand Down
5 changes: 3 additions & 2 deletions components/radio/index.en-US.md
Expand Up @@ -39,12 +39,13 @@ Common props ref:[Common props](/docs/react/common-props)
### Radio/Radio.Button

| Property | Description | Type | Default |
| --- | --- | --- | --- |
| --- | --- | --- | --- | --- |
| autoFocus | Whether get focus when component mounted | boolean | false |
| checked | Specifies whether the radio is selected | boolean | false |
| defaultChecked | Specifies the initial state: whether or not the radio is selected | boolean | false |
| disabled | Disable radio | boolean | false |
| value | According to value for comparison, to determine whether the selected | any | - |
| required | If set to `true`, a non-null value must be specified when submitting the form. the browser's native form validation will be triggered. | boolean | - | |

### RadioGroup

Expand All @@ -56,7 +57,7 @@ Radio group can wrap a group of `Radio`。
| defaultValue | Default selected value | any | - | |
| disabled | Disable all radio buttons | boolean | false | |
| name | The `name` property of all `input[type="radio"]` children | string | - | |
| options | Set children optional | string\[] \| number\[] \| Array&lt;{ label: ReactNode; value: string; disabled?: boolean; }> | - | |
| options | Set children optional | string\[] \| number\[] \| Array&lt;{ label: ReactNode; value: string; disabled?: boolean; required?: boolean; }> | - | |
| optionType | Set Radio optionType | `default` \| `button` | `default` | 4.4.0 |
| size | The size of radio button style | `large` \| `middle` \| `small` | - | |
| value | Used for setting the currently selected value | any | - | |
Expand Down
3 changes: 2 additions & 1 deletion components/radio/index.zh-CN.md
Expand Up @@ -47,6 +47,7 @@ demo:
| defaultChecked | 初始是否选中 | boolean | false |
| disabled | 禁用 Radio | boolean | false |
| value | 根据 value 进行比较,判断是否选中 | any | - |
| required | 如果设置为 `true`,则提交表单时必须指定一个非空值。这将会触发浏览器原生表单验证功能 | boolean | - | |

### Radio.Group

Expand All @@ -59,7 +60,7 @@ demo:
| defaultValue | 默认选中的值 | any | - | | |
| disabled | 禁选所有子单选器 | boolean | false | | |
| name | RadioGroup 下所有 `input[type="radio"]``name` 属性 | string | - | | |
| options | 以配置形式设置子元素 | string\[] \| number\[] \| Array&lt;{ label: ReactNode; value: string; disabled?: boolean; }> | - | | |
| options | 以配置形式设置子元素 | string\[] \| number\[] \| Array&lt;{ label: ReactNode; value: string; disabled?: boolean; required?: boolean; }> | - | | |
| optionType | 用于设置 Radio `options` 类型 | `default` \| `button` | `default` | 4.4.0 | |
| size | 大小,只对按钮样式生效 | `large` \| `middle` \| `small` | - | | |
| value | 用于设置当前选中的值 | any | - | | |
Expand Down

0 comments on commit c079f68

Please sign in to comment.