chore: auto merge branchs (#29932)

chore: master merge feature
This commit is contained in:
github-actions[bot] 2021-03-29 03:48:56 +00:00 committed by GitHub
commit ad2a496c23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 254 additions and 59 deletions

View File

@ -24435,7 +24435,7 @@ exports[`ConfigProvider components Tabs configProvider 1`] = `
exports[`ConfigProvider components Tabs configProvider componentSize large 1`] = `
<div
class="config-tabs config-tabs-top"
class="config-tabs config-tabs-top config-tabs-large"
>
<div
class="config-tabs-nav"
@ -24520,7 +24520,7 @@ exports[`ConfigProvider components Tabs configProvider componentSize large 1`] =
exports[`ConfigProvider components Tabs configProvider componentSize middle 1`] = `
<div
class="config-tabs config-tabs-top"
class="config-tabs config-tabs-top config-tabs-middle"
>
<div
class="config-tabs-nav"

View File

@ -25,8 +25,11 @@ import {
Divider,
Table,
Card,
Tabs,
} from 'antd';
const { TabPane } = Tabs;
const FormSizeDemo = () => {
const [componentSize, setComponentSize] = useState('small');
return (
@ -46,6 +49,19 @@ const FormSizeDemo = () => {
<div className="example">
<Input />
</div>
<div className="example">
<Tabs defaultActiveKey="1">
<TabPane tab="Tab 1" key="1">
Content of Tab Pane 1
</TabPane>
<TabPane tab="Tab 2" key="2">
Content of Tab Pane 2
</TabPane>
<TabPane tab="Tab 3" key="3">
Content of Tab Pane 3
</TabPane>
</Tabs>
</div>
<div className="example">
<Input.Search allowClear />
</div>

View File

@ -6,7 +6,14 @@ import { PickerLocale } from '../generatePicker';
const locale: PickerLocale = {
lang: {
placeholder: 'Välj datum',
yearPlaceholder: 'Välj år',
quarterPlaceholder: 'Välj kvartal',
monthPlaceholder: 'Välj månad',
weekPlaceholder: 'Välj vecka',
rangePlaceholder: ['Startdatum', 'Slutdatum'],
rangeYearPlaceholder: ['Startår', 'Slutår'],
rangeMonthPlaceholder: ['Startmånad', 'Slutmånad'],
rangeWeekPlaceholder: ['Startvecka', 'Slutvecka'],
...CalendarLocale,
},
timePickerLocale: {

View File

@ -261535,7 +261535,7 @@ exports[`Locale Provider should display the text as sv 1`] = `
<span
class="ant-transfer-list-header-selected"
>
0 element
0 objekt
</span>
<span
class="ant-transfer-list-header-title"
@ -261549,7 +261549,7 @@ exports[`Locale Provider should display the text as sv 1`] = `
>
<input
class="ant-input ant-transfer-list-search"
placeholder="Sök"
placeholder="Sök här"
type="text"
value=""
/>
@ -261623,7 +261623,7 @@ exports[`Locale Provider should display the text as sv 1`] = `
<div
class="ant-empty-description"
>
Ingen information
Ingen data
</div>
</div>
</div>
@ -261727,7 +261727,7 @@ exports[`Locale Provider should display the text as sv 1`] = `
<span
class="ant-transfer-list-header-selected"
>
0 element
0 objekt
</span>
<span
class="ant-transfer-list-header-title"
@ -261741,7 +261741,7 @@ exports[`Locale Provider should display the text as sv 1`] = `
>
<input
class="ant-input ant-transfer-list-search"
placeholder="Sök"
placeholder="Sök här"
type="text"
value=""
/>
@ -261815,7 +261815,7 @@ exports[`Locale Provider should display the text as sv 1`] = `
<div
class="ant-empty-description"
>
Ingen information
Ingen data
</div>
</div>
</div>
@ -262891,7 +262891,7 @@ exports[`Locale Provider should display the text as sv 1`] = `
<div
class="ant-empty-description"
>
Ingen information
Ingen data
</div>
</div>
</td>

View File

@ -1,9 +1,12 @@
/* eslint-disable no-template-curly-in-string */
import Pagination from 'rc-pagination/lib/locale/fr_FR';
import DatePicker from '../date-picker/locale/fr_FR';
import TimePicker from '../time-picker/locale/fr_FR';
import Calendar from '../calendar/locale/fr_FR';
import { Locale } from '../locale-provider';
const typeTemplate = "La valeur du champ ${label} n'est pas valide pour le type ${type}";
const localeValues: Locale = {
locale: 'fr',
Pagination,
@ -57,6 +60,56 @@ const localeValues: Locale = {
PageHeader: {
back: 'Retour',
},
Form: {
optional: '(optionnel)',
defaultValidateMessages: {
default: 'Erreur de validation pour le champ ${label}',
required: 'Le champ ${label} est obligatoire',
enum: 'La valeur du champ ${label} doit être parmi [${enum}]',
whitespace: 'La valeur du champ ${label} ne peut pas être vide',
date: {
format: "La valeur du champ ${label} n'est pas au format date",
parse: 'La valeur du champ ${label} ne peut pas être convertie vers une date',
invalid: "La valeur du champ ${label} n'est pas une date valide",
},
types: {
string: typeTemplate,
method: typeTemplate,
array: typeTemplate,
object: typeTemplate,
number: typeTemplate,
date: typeTemplate,
boolean: typeTemplate,
integer: typeTemplate,
float: typeTemplate,
regexp: typeTemplate,
email: typeTemplate,
url: typeTemplate,
hex: typeTemplate,
},
string: {
len: 'La taille du champ ${label} doit être de ${len} caractères',
min: 'La taille du champ ${label} doit être au minimum de ${min} caractères',
max: 'La taille du champ ${label} doit être au maximum de ${max} caractères',
range: 'La taille du champ ${label} doit être entre ${min} et ${max} caractères',
},
number: {
len: 'La valeur du champ ${label} doit être égale à ${len}',
min: 'La valeur du champ ${label} doit être plus grande que ${min}',
max: 'La valeur du champ ${label} doit être plus petit que ${max}',
range: 'La valeur du champ ${label} doit être entre ${min} et ${max}',
},
array: {
len: 'La taille du tableau ${label} doit être de ${len}',
min: 'La taille du tableau ${label} doit être au minimum de ${min}',
max: 'La taille du tableau ${label} doit être au maximum de ${max}',
range: 'La taille du tableau ${label} doit être entre ${min}-${max}',
},
pattern: {
mismatch: 'La valeur du champ ${label} ne correspond pas au modèle ${pattern}',
},
},
},
};
export default localeValues;

View File

@ -1,19 +1,37 @@
/* eslint-disable no-template-curly-in-string */
import Pagination from 'rc-pagination/lib/locale/sv_SE';
import DatePicker from '../date-picker/locale/sv_SE';
import TimePicker from '../time-picker/locale/sv_SE';
import Calendar from '../calendar/locale/sv_SE';
import { Locale } from '../locale-provider';
const typeTemplate = '${label} är inte en giltig ${type}';
const localeValues: Locale = {
locale: 'sv',
Pagination,
DatePicker,
TimePicker,
Calendar,
global: {
placeholder: 'Vänligen välj',
},
Table: {
filterTitle: 'Filtermeny',
filterConfirm: 'OK',
filterReset: 'Rensa',
filterReset: 'Återställ',
filterEmptyText: 'Inga filter',
emptyText: 'Ingen data',
selectAll: 'Markera nuvarande sida',
selectInvert: 'Invertera nuvarande sida',
selectNone: 'Avmarkera all data',
selectionAll: 'Markera all data',
sortTitle: 'Sortera',
expand: 'Expandera rad',
collapse: 'Komprimera rad',
triggerDesc: 'Klicka för att sortera i fallande ordning',
triggerAsc: 'Klicka för att sortera i stigande ordning',
cancelSort: 'Klicka för att avbryta sortering',
},
Modal: {
okText: 'OK',
@ -25,25 +43,91 @@ const localeValues: Locale = {
cancelText: 'Avbryt',
},
Transfer: {
searchPlaceholder: 'Sök',
itemUnit: 'element',
itemsUnit: 'element',
},
Empty: {
description: 'Ingen information',
},
Text: {
edit: 'editera',
copy: 'kopiera',
copied: 'kopierad',
expand: 'expandera',
titles: ['', ''],
searchPlaceholder: 'Sök här',
itemUnit: 'objekt',
itemsUnit: 'objekt',
remove: 'Ta bort',
selectCurrent: 'Markera nuvarande sida',
removeCurrent: 'Ta bort nuvarande sida',
selectAll: 'Markera all data',
removeAll: 'Ta bort all data',
selectInvert: 'Invertera nuvarande sida',
},
Upload: {
uploading: 'Uppladdning...',
uploading: 'Laddar upp...',
removeFile: 'Ta bort fil',
uploadError: 'Uppladdningsfel',
previewFile: 'Förhandsgranska filen',
downloadFile: 'Nedladdning fil',
previewFile: 'Förhandsgranska fil',
downloadFile: 'Ladda ned fil',
},
Empty: {
description: 'Ingen data',
},
Icon: {
icon: 'ikon',
},
Text: {
edit: 'Redigera',
copy: 'Kopiera',
copied: 'Kopierad',
expand: 'Expandera',
},
PageHeader: {
back: 'Tillbaka',
},
Form: {
optional: '(valfritt)',
defaultValidateMessages: {
default: 'Fältvalideringsfel för ${label}',
required: 'Vänligen fyll i ${label}',
enum: '${label} måste vara en av [${enum}]',
whitespace: '${label} kan inte vara ett tomt tecken',
date: {
format: '${label} datumformatet är ogiltigt',
parse: '${label} kan inte konverteras till ett datum',
invalid: '${label} är ett ogiltigt datum',
},
types: {
string: typeTemplate,
method: typeTemplate,
array: typeTemplate,
object: typeTemplate,
number: typeTemplate,
date: typeTemplate,
boolean: typeTemplate,
integer: typeTemplate,
float: typeTemplate,
regexp: typeTemplate,
email: typeTemplate,
url: typeTemplate,
hex: typeTemplate,
},
string: {
len: '${label} måste vara ${len} tecken',
min: '${label} måste vara minst ${min} tecken',
max: '${label} måste vara högst ${max} tecken',
range: '${label} måste vara mellan ${min}-${max} tecken',
},
number: {
len: '${label} måste vara lika med ${len}',
min: '${label} måste vara minst ${min}',
max: '${label} måste vara högst ${max}',
range: '${label} måste vara mellan ${min}-${max}',
},
array: {
len: 'Måste vara ${len} ${label}',
min: 'Minst ${min} ${label}',
max: 'Högst ${max} ${label}',
range: 'Antal ${label} måste vara mellan ${min}-${max}',
},
pattern: {
mismatch: '${label} stämmer inte överens med mönstret ${pattern}',
},
},
},
Image: {
preview: 'Förhandsgranska',
},
};

View File

@ -66,6 +66,22 @@ describe('Table.rowSelection', () => {
.filter(key => key !== null);
}
it('select default row', () => {
const wrapper = mount(createTable({ rowSelection: { defaultSelectedRowKeys: [0] } }));
const checkboxes = wrapper.find('input');
expect(getSelections(wrapper)).toEqual([0]);
checkboxes.at(1).simulate('change', { target: { checked: false } });
expect(getSelections(wrapper)).toEqual([]);
checkboxes.at(0).simulate('change', { target: { checked: true } });
expect(getSelections(wrapper)).toEqual([0, 1, 2, 3]);
checkboxes.at(0).simulate('change', { target: { checked: false } });
expect(getSelections(wrapper)).toEqual([]);
});
it('select by checkbox', () => {
const wrapper = mount(createTable());
const checkboxes = wrapper.find('input');

View File

@ -79,6 +79,7 @@ export default function useSelection<RecordType>(
const {
preserveSelectedRowKeys,
selectedRowKeys,
defaultSelectedRowKeys,
getCheckboxProps,
onChange: onSelectionChange,
onSelect,
@ -112,9 +113,12 @@ export default function useSelection<RecordType>(
const preserveRecordsRef = React.useRef(new Map<Key, RecordType>());
// ========================= Keys =========================
const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(selectedRowKeys || [], {
value: selectedRowKeys,
});
const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(
selectedRowKeys || defaultSelectedRowKeys || [],
{
value: selectedRowKeys,
},
);
const { keyEntities } = useMemo(
() =>

View File

@ -155,9 +155,9 @@ const columns = [
### ColumnGroup
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| title | 列头显示文字 | ReactNode | - |
| 参数 | 说明 | 类型 | 默认值 |
| ----- | ------------ | --------- | ------ |
| title | 列头显示文字 | ReactNode | - |
### pagination
@ -205,6 +205,7 @@ const columns = [
| preserveSelectedRowKeys | 当数据被删除时仍然保留选项的 `key` | boolean | - | 4.4.0 |
| renderCell | 渲染勾选框,用法与 Column 的 `render` 相同 | function(checked, record, index, originNode) {} | - | 4.1.0 |
| selectedRowKeys | 指定选中项的 key 数组,需要和 onChange 进行配合 | string\[] \| number\[] | \[] | |
| defaultSelectedRowKeys | 默认选中项的 key 数组 | string\[] \| number\[] | \[] | |
| selections | 自定义选择项 [配置项](#selection), 设为 `true` 时使用默认选择项 | object\[] \| boolean | true | |
| type | 多选/单选 | `checkbox` \| `radio` | `checkbox` | |
| onChange | 选中项发生变化时的回调 | function(selectedRowKeys, selectedRows) | - | |
@ -223,11 +224,11 @@ const columns = [
### selection
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| key | React 需要的 key建议设置 | string | - |
| text | 选择项显示的文字 | ReactNode | - |
| onSelect | 选择项点击回调 | function(changeableRowKeys) | - |
| 参数 | 说明 | 类型 | 默认值 |
| -------- | -------------------------- | --------------------------- | ------ |
| key | React 需要的 key建议设置 | string | - |
| text | 选择项显示的文字 | ReactNode | - |
| onSelect | 选择项点击回调 | function(changeableRowKeys) | - |
## 在 TypeScript 中使用

View File

@ -143,6 +143,7 @@ export interface TableRowSelection<T> {
preserveSelectedRowKeys?: boolean;
type?: RowSelectionType;
selectedRowKeys?: Key[];
defaultSelectedRowKeys?: Key[];
onChange?: (selectedRowKeys: Key[], selectedRows: T[]) => void;
getCheckboxProps?: (record: T) => Partial<Omit<CheckboxProps, 'checked' | 'defaultChecked'>>;
onSelect?: SelectionSelectFn<T>;

View File

@ -8,7 +8,7 @@ import CloseOutlined from '@ant-design/icons/CloseOutlined';
import devWarning from '../_util/devWarning';
import { ConfigContext } from '../config-provider';
import { SizeType } from '../config-provider/SizeContext';
import SizeContext, { SizeType } from '../config-provider/SizeContext';
export type TabsType = 'line' | 'card' | 'editable-card';
export type TabsPosition = 'top' | 'right' | 'bottom' | 'left';
@ -24,11 +24,17 @@ export interface TabsProps extends Omit<RcTabsProps, 'editable'> {
onEdit?: (e: React.MouseEvent | React.KeyboardEvent | string, action: 'add' | 'remove') => void;
}
function Tabs({ type, className, size, onEdit, hideAdd, centered, addIcon, ...props }: TabsProps) {
const {
prefixCls: customizePrefixCls,
moreIcon = <EllipsisOutlined />,
} = props;
function Tabs({
type,
className,
size: propSize,
onEdit,
hideAdd,
centered,
addIcon,
...props
}: TabsProps) {
const { prefixCls: customizePrefixCls, moreIcon = <EllipsisOutlined /> } = props;
const { getPrefixCls, direction } = React.useContext(ConfigContext);
const prefixCls = getPrefixCls('tabs', customizePrefixCls);
@ -52,23 +58,30 @@ function Tabs({ type, className, size, onEdit, hideAdd, centered, addIcon, ...pr
);
return (
<RcTabs
direction={direction}
moreTransitionName={`${rootPrefixCls}-slide-up`}
{...props}
className={classNames(
{
[`${prefixCls}-${size}`]: size,
[`${prefixCls}-card`]: ['card', 'editable-card'].includes(type as string),
[`${prefixCls}-editable-card`]: type === 'editable-card',
[`${prefixCls}-centered`]: centered,
},
className,
)}
editable={editable}
moreIcon={moreIcon}
prefixCls={prefixCls}
/>
<SizeContext.Consumer>
{contextSize => {
const size = propSize !== undefined ? propSize : contextSize;
return (
<RcTabs
direction={direction}
moreTransitionName={`${rootPrefixCls}-slide-up`}
{...props}
className={classNames(
{
[`${prefixCls}-${size}`]: size,
[`${prefixCls}-card`]: ['card', 'editable-card'].includes(type as string),
[`${prefixCls}-editable-card`]: type === 'editable-card',
[`${prefixCls}-centered`]: centered,
},
className,
)}
editable={editable}
moreIcon={moreIcon}
prefixCls={prefixCls}
/>
);
}}
</SizeContext.Consumer>
);
}