mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 13:08:41 +08:00
Align table checkbox (#5183)
* Align table checkbox * Don't select Item * I18n selection text * Update snapshot
This commit is contained in:
parent
bae042b29f
commit
c037abab6a
@ -17,6 +17,8 @@ export default {
|
|||||||
filterConfirm: 'OK',
|
filterConfirm: 'OK',
|
||||||
filterReset: 'Reset',
|
filterReset: 'Reset',
|
||||||
emptyText: 'No Data',
|
emptyText: 'No Data',
|
||||||
|
selectAll: 'Select All',
|
||||||
|
selectInvert: 'Select Invert',
|
||||||
},
|
},
|
||||||
Modal: {
|
Modal: {
|
||||||
okText: 'OK',
|
okText: 'OK',
|
||||||
|
@ -13,6 +13,7 @@ export interface SelectionDecorator {
|
|||||||
|
|
||||||
export interface SelectionCheckboxAllProps {
|
export interface SelectionCheckboxAllProps {
|
||||||
store: Store;
|
store: Store;
|
||||||
|
locale: any;
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
getCheckboxPropsByItem: (item, index) => any;
|
getCheckboxPropsByItem: (item, index) => any;
|
||||||
getRecordKey: (record, index?) => string;
|
getRecordKey: (record, index?) => string;
|
||||||
@ -22,22 +23,23 @@ export interface SelectionCheckboxAllProps {
|
|||||||
selections: SelectionDecorator[];
|
selections: SelectionDecorator[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultSelections: SelectionDecorator[] = [{
|
|
||||||
key: 'all',
|
|
||||||
text: '全选',
|
|
||||||
onSelect: () => {},
|
|
||||||
}, {
|
|
||||||
key: 'invert',
|
|
||||||
text: '反选',
|
|
||||||
onSelect: () => {},
|
|
||||||
}];
|
|
||||||
|
|
||||||
export default class SelectionCheckboxAll extends React.Component<SelectionCheckboxAllProps, any> {
|
export default class SelectionCheckboxAll extends React.Component<SelectionCheckboxAllProps, any> {
|
||||||
unsubscribe: () => void;
|
unsubscribe: () => void;
|
||||||
|
defaultSelections: SelectionDecorator[];
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
this.defaultSelections = [{
|
||||||
|
key: 'all',
|
||||||
|
text: props.locale.selectAll,
|
||||||
|
onSelect: () => {},
|
||||||
|
}, {
|
||||||
|
key: 'invert',
|
||||||
|
text: props.locale.selectInvert,
|
||||||
|
onSelect: () => {},
|
||||||
|
}];
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
checked: this.getCheckState(props),
|
checked: this.getCheckState(props),
|
||||||
indeterminate: this.getIndeterminateState(props),
|
indeterminate: this.getIndeterminateState(props),
|
||||||
@ -154,11 +156,12 @@ export default class SelectionCheckboxAll extends React.Component<SelectionCheck
|
|||||||
|
|
||||||
let selectionPrefixCls = `${prefixCls}-selection`;
|
let selectionPrefixCls = `${prefixCls}-selection`;
|
||||||
|
|
||||||
let selections = defaultSelections.concat(this.props.selections || []);
|
let selections = this.defaultSelections.concat(this.props.selections || []);
|
||||||
|
|
||||||
let menu = (
|
let menu = (
|
||||||
<Menu
|
<Menu
|
||||||
className={`${selectionPrefixCls}-menu`}
|
className={`${selectionPrefixCls}-menu`}
|
||||||
|
selectedKeys={[]}
|
||||||
>
|
>
|
||||||
{this.renderMenus(selections)}
|
{this.renderMenus(selections)}
|
||||||
</Menu>
|
</Menu>
|
||||||
@ -167,6 +170,7 @@ export default class SelectionCheckboxAll extends React.Component<SelectionCheck
|
|||||||
return (
|
return (
|
||||||
<div className={selectionPrefixCls}>
|
<div className={selectionPrefixCls}>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
className={`${selectionPrefixCls}-select-all`}
|
||||||
checked={checked}
|
checked={checked}
|
||||||
indeterminate={indeterminate}
|
indeterminate={indeterminate}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
@ -30,6 +30,8 @@ const defaultLocale = {
|
|||||||
filterConfirm: '确定',
|
filterConfirm: '确定',
|
||||||
filterReset: '重置',
|
filterReset: '重置',
|
||||||
emptyText: <span><Icon type="frown-o" />暂无数据</span>,
|
emptyText: <span><Icon type="frown-o" />暂无数据</span>,
|
||||||
|
selectAll: '全选',
|
||||||
|
selectInvert: '反选',
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultPagination = {
|
const defaultPagination = {
|
||||||
@ -627,6 +629,7 @@ export default class Table<T> extends React.Component<TableProps<T>, any> {
|
|||||||
selectionColumn.title = (
|
selectionColumn.title = (
|
||||||
<SelectionCheckboxAll
|
<SelectionCheckboxAll
|
||||||
store={this.store}
|
store={this.store}
|
||||||
|
locale={this.getLocale()}
|
||||||
data={data}
|
data={data}
|
||||||
getCheckboxPropsByItem={this.getCheckboxPropsByItem}
|
getCheckboxPropsByItem={this.getCheckboxPropsByItem}
|
||||||
getRecordKey={this.getRecordKey}
|
getRecordKey={this.getRecordKey}
|
||||||
|
@ -1135,7 +1135,7 @@ exports[`test renders ./components/table/demo/dynamic-settings.md correctly 1`]
|
|||||||
<div
|
<div
|
||||||
class="ant-table-selection">
|
class="ant-table-selection">
|
||||||
<label
|
<label
|
||||||
class="ant-checkbox-wrapper">
|
class="ant-table-selection-select-all ant-checkbox-wrapper">
|
||||||
<span
|
<span
|
||||||
class="ant-checkbox">
|
class="ant-checkbox">
|
||||||
<input
|
<input
|
||||||
@ -2335,7 +2335,7 @@ exports[`test renders ./components/table/demo/expand-children.md correctly 1`] =
|
|||||||
<div
|
<div
|
||||||
class="ant-table-selection">
|
class="ant-table-selection">
|
||||||
<label
|
<label
|
||||||
class="ant-checkbox-wrapper">
|
class="ant-table-selection-select-all ant-checkbox-wrapper">
|
||||||
<span
|
<span
|
||||||
class="ant-checkbox">
|
class="ant-checkbox">
|
||||||
<input
|
<input
|
||||||
@ -6987,7 +6987,7 @@ exports[`test renders ./components/table/demo/row-selection.md correctly 1`] = `
|
|||||||
<div
|
<div
|
||||||
class="ant-table-selection">
|
class="ant-table-selection">
|
||||||
<label
|
<label
|
||||||
class="ant-checkbox-wrapper">
|
class="ant-table-selection-select-all ant-checkbox-wrapper">
|
||||||
<span
|
<span
|
||||||
class="ant-checkbox">
|
class="ant-checkbox">
|
||||||
<input
|
<input
|
||||||
@ -7253,7 +7253,7 @@ exports[`test renders ./components/table/demo/row-selection-and-operation.md cor
|
|||||||
<div
|
<div
|
||||||
class="ant-table-selection">
|
class="ant-table-selection">
|
||||||
<label
|
<label
|
||||||
class="ant-checkbox-wrapper">
|
class="ant-table-selection-select-all ant-checkbox-wrapper">
|
||||||
<span
|
<span
|
||||||
class="ant-checkbox">
|
class="ant-checkbox">
|
||||||
<input
|
<input
|
||||||
@ -7725,7 +7725,7 @@ exports[`test renders ./components/table/demo/row-selection-custom.md correctly
|
|||||||
<div
|
<div
|
||||||
class="ant-table-selection">
|
class="ant-table-selection">
|
||||||
<label
|
<label
|
||||||
class="ant-checkbox-wrapper">
|
class="ant-table-selection-select-all ant-checkbox-wrapper">
|
||||||
<span
|
<span
|
||||||
class="ant-checkbox">
|
class="ant-checkbox">
|
||||||
<input
|
<input
|
||||||
|
@ -53,7 +53,7 @@ class App extends React.Component {
|
|||||||
onChange: this.onSelectChange,
|
onChange: this.onSelectChange,
|
||||||
selections: [{
|
selections: [{
|
||||||
key: 'odd',
|
key: 'odd',
|
||||||
text: '奇数项',
|
text: 'Select Odd Row',
|
||||||
onSelect: (changableRowKeys) => {
|
onSelect: (changableRowKeys) => {
|
||||||
let newSelectedRowKeys = [];
|
let newSelectedRowKeys = [];
|
||||||
newSelectedRowKeys = changableRowKeys.filter((key, index) => {
|
newSelectedRowKeys = changableRowKeys.filter((key, index) => {
|
||||||
@ -66,7 +66,7 @@ class App extends React.Component {
|
|||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
key: 'even',
|
key: 'even',
|
||||||
text: '偶数项',
|
text: 'Select Even Row',
|
||||||
onSelect: (changableRowKeys) => {
|
onSelect: (changableRowKeys) => {
|
||||||
let newSelectedRowKeys = [];
|
let newSelectedRowKeys = [];
|
||||||
newSelectedRowKeys = changableRowKeys.filter((key, index) => {
|
newSelectedRowKeys = changableRowKeys.filter((key, index) => {
|
||||||
|
@ -138,12 +138,17 @@
|
|||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-thead > tr > th.@{table-prefix-cls}-selection-column {
|
||||||
|
padding-left: 16px;
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
&-thead > tr > th.@{table-prefix-cls}-selection-column,
|
&-thead > tr > th.@{table-prefix-cls}-selection-column,
|
||||||
&-tbody > tr > td.@{table-prefix-cls}-selection-column,
|
&-tbody > tr > td.@{table-prefix-cls}-selection-column,
|
||||||
&-expand-icon-th,
|
&-expand-icon-th,
|
||||||
&-row-expand-icon-cell {
|
&-row-expand-icon-cell {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 48px;
|
width: 62px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-header {
|
&-header {
|
||||||
@ -432,7 +437,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-selection {
|
&-selection {
|
||||||
width: 40px;
|
&-select-all {
|
||||||
|
margin-right: 4px !important;
|
||||||
|
}
|
||||||
|
|
||||||
.@{iconfont-css-prefix}-down {
|
.@{iconfont-css-prefix}-down {
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
@ -456,8 +463,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-down {
|
&-down {
|
||||||
|
cursor: pointer;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user