@txdfe/at
Version:
一个设计体系组件库
882 lines (722 loc) • 33 kB
JavaScript
"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames2 = _interopRequireDefault(require("classnames"));
var _shallowElementEquals = _interopRequireDefault(require("shallow-element-equals"));
var _loading = _interopRequireDefault(require("../loading"));
var _zhCn = _interopRequireDefault(require("../locale/zh-cn"));
var _util = require("../util");
var _body = _interopRequireDefault(require("./base/body"));
var _header = _interopRequireDefault(require("./base/header"));
var _wrapper = _interopRequireDefault(require("./base/wrapper"));
var _row = _interopRequireDefault(require("./base/row"));
var _cell = _interopRequireDefault(require("./base/cell"));
var _filter = _interopRequireDefault(require("./base/filter"));
var _sort = _interopRequireDefault(require("./base/sort"));
var _column = _interopRequireDefault(require("./column"));
var _columnGroup = _interopRequireDefault(require("./column-group"));
var _guid = _interopRequireDefault(require("../util/guid"));
var _autoWidth = _interopRequireDefault(require("./base/auto-width"));
var _excluded = ["className", "hasBorder", "isZebra", "loading", "hasHeader", "prefix", "dataSource", "entireDataSource", "onSort", "onResizeChange", "onRowClick", "onRowMouseEnter", "onRowMouseLeave", "onFilter", "rowProps", "cellProps", "primaryKey", "components", "wrapperContent", "lockType", "locale", "expandedIndexSimulate", "refs", "pure", "rtl", "emptyContent", "filterParams", "columns", "sortIcons", "loadingComponent"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var Children = _react["default"].Children;
var noop = function noop() {};
var ColGroup = /*#__PURE__*/function (_React$Component) {
_inherits(ColGroup, _React$Component);
var _super = _createSuper(ColGroup);
function ColGroup() {
_classCallCheck(this, ColGroup);
return _super.apply(this, arguments);
}
_createClass(ColGroup, [{
key: "componentDidMount",
value: function componentDidMount() {
var table = this.props.table;
table.AutoWidth.bindColGroup(this);
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
var table = this.props.table;
table.AutoWidth.bindColGroup(this);
}
}, {
key: "render",
value: function render() {
var _this$props = this.props,
flatChildren = _this$props.flatChildren,
table = _this$props.table;
var cols = flatChildren.map(function (col, index) {
var width = col.width,
columnId = col.columnId;
var style = {};
var w = width;
if (width === 'auto' && table.AutoWidth.enable) {
w = table.AutoWidth.getBestWidth(columnId);
}
if (w) {
style = {
width: w
};
}
return /*#__PURE__*/_react["default"].createElement("col", {
style: style,
key: index
});
});
return /*#__PURE__*/_react["default"].createElement("colgroup", {
key: "table-colgroup"
}, cols);
}
}]);
return ColGroup;
}(_react["default"].Component);
/** Table */
var Table = /*#__PURE__*/function (_React$Component2) {
_inherits(Table, _React$Component2);
var _super2 = _createSuper(Table);
function Table(props, context) {
var _this;
_classCallCheck(this, Table);
_this = _super2.call(this, props, context);
_defineProperty(_assertThisInitialized(_this), "state", {
sort: _this.props.sort || {}
});
_defineProperty(_assertThisInitialized(_this), "renderColGroup", function (flatChildren) {
return /*#__PURE__*/_react["default"].createElement(ColGroup, {
flatChildren: flatChildren,
table: _assertThisInitialized(_this)
});
});
_defineProperty(_assertThisInitialized(_this), "onSort", function (dataIndex, order, sort) {
if (typeof _this.props.sort === 'undefined') {
_this.setState({
sort: sort
}, function () {
_this.props.onSort(dataIndex, order, sort);
});
} else {
_this.props.onSort(dataIndex, order, sort);
}
});
_defineProperty(_assertThisInitialized(_this), "onFilter", function (filterParams) {
_this.props.onFilter(filterParams);
});
_defineProperty(_assertThisInitialized(_this), "onResizeChange", function (dataIndex, value) {
_this.props.onResizeChange(dataIndex, value);
});
_defineProperty(_assertThisInitialized(_this), "getWrapperRef", function (wrapper) {
if (!wrapper) {
return _this.wrapper;
}
_this.wrapper = wrapper;
});
_defineProperty(_assertThisInitialized(_this), "getAffixRef", function (affixRef) {
if (!affixRef) {
return _this.affixRef;
}
_this.affixRef = affixRef;
});
_defineProperty(_assertThisInitialized(_this), "getHeaderCellRef", function (i, j, cell) {
var cellRef = "header_cell_".concat(i, "_").concat(j);
if (!cell) {
return _this[cellRef];
}
_this[cellRef] = cell;
});
_defineProperty(_assertThisInitialized(_this), "getRowRef", function (i, row) {
var rowRef = "row_".concat(i);
if (!row) {
return _this[rowRef];
}
_this[rowRef] = row;
});
_defineProperty(_assertThisInitialized(_this), "getCellRef", function (i, j, cell) {
var cellRef = "cell_".concat(i, "_").concat(j);
if (!cell) {
return _this[cellRef];
}
_this[cellRef] = cell;
});
var _this$context = _this.context,
getTableInstance = _this$context.getTableInstance,
getTableInstanceForVirtual = _this$context.getTableInstanceForVirtual;
getTableInstance && getTableInstance(props.lockType, _assertThisInitialized(_this));
getTableInstanceForVirtual && getTableInstanceForVirtual(props.lockType, _assertThisInitialized(_this));
_this.notRenderCellIndex = [];
_this.refColGroup = null;
_this.AutoWidth = new _autoWidth["default"]({
padding: 15,
table: _assertThisInitialized(_this)
});
return _this;
}
_createClass(Table, [{
key: "getChildContext",
value: function getChildContext() {
return {
notRenderCellIndex: this.notRenderCellIndex,
lockType: this.props.lockType
};
}
}, {
key: "UNSAFE_componentWillReceiveProps",
value: function UNSAFE_componentWillReceiveProps(nextProps) {
if (typeof this.props.sort !== 'undefined') {
this.setState({
sort: nextProps.sort
});
}
}
}, {
key: "shouldComponentUpdate",
value: function shouldComponentUpdate(nextProps, nextState, nextContext) {
if (nextProps.pure) {
var isEqual = (0, _shallowElementEquals["default"])(nextProps, this.props) && _util.obj.shallowEqual(nextState, this.state) && _util.obj.shallowEqual(nextContext, this.context);
return !isEqual;
}
return true;
}
}, {
key: "UNSAFE_componentWillUpdate",
value: function UNSAFE_componentWillUpdate() {
this.notRenderCellIndex = [];
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
if (this.AutoWidth && this.AutoWidth.enable) {
this.AutoWidth.calcAndUpdate();
}
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
if (this.AutoWidth && this.AutoWidth.enable) {
this.AutoWidth.calcAndUpdate();
}
}
}, {
key: "normalizeChildrenState",
value: function normalizeChildrenState(props) {
var columns = props.columns;
if (props.children) {
columns = this.normalizeChildren(props);
}
return this.fetchInfoFromBinaryChildren(columns);
} // 将React结构化数据提取props转换成数组
}, {
key: "normalizeChildren",
value: function normalizeChildren(props) {
var columns = props.columns;
var getChildren = function getChildren(children) {
var ret = [];
Children.forEach(children, function (child) {
if (child) {
var _props = _objectSpread({}, child.props);
if (!(child && typeof child.type === 'function' && (child.type._typeMark === 'column' || child.type._typeMark === 'columnGroup'))) {
_util.log.warning('Use <Table.Column/>, <Table.ColumnGroup/> as child.');
}
ret.push(_props);
if (child.props.children) {
_props.children = getChildren(child.props.children);
}
}
});
return ret;
};
if (props.children) {
columns = getChildren(props.children);
}
return columns;
}
}, {
key: "fetchInfoFromBinaryChildren",
value: function fetchInfoFromBinaryChildren(children) {
var _this2 = this;
var hasGroupHeader = false;
var flatChildren = [];
var groupChildren = [];
var getChildren = function getChildren(propsChildren, level) {
groupChildren[level] = groupChildren[level] || [];
propsChildren.forEach(function (child) {
if (child.children) {
hasGroupHeader = true;
getChildren(child.children, level + 1);
} else {
child.columnId = (0, _guid["default"])('cloumn-');
if (_this2.AutoWidth.enable) {
_this2.AutoWidth.analyzeColDefine(child);
}
flatChildren.push(child);
}
groupChildren[level].push(child);
});
};
var getColSpan = function getColSpan(children, colSpan) {
colSpan = colSpan || 0;
children.forEach(function (child) {
if (child.children) {
colSpan = getColSpan(child.children, colSpan);
} else {
colSpan += 1;
}
});
return colSpan;
};
getChildren(children, 0);
groupChildren.forEach(function (groupChild, i) {
groupChild.forEach(function (child, j) {
var colSpan;
var children = child.children;
if (children) {
colSpan = getColSpan(children);
child.colSpan = colSpan;
groupChildren[i][j] = child;
}
});
});
return {
flatChildren: flatChildren,
groupChildren: groupChildren,
hasGroupHeader: hasGroupHeader
};
}
}, {
key: "renderTable",
value: // 通过头部和扁平的结构渲染表格
function renderTable(groupChildren, flatChildren) {
if (flatChildren.length || !flatChildren.length && !this.props.lockType) {
var _this$props2 = this.props,
hasHeader = _this$props2.hasHeader,
components = _this$props2.components,
prefix = _this$props2.prefix,
wrapperContent = _this$props2.wrapperContent,
filterParams = _this$props2.filterParams,
locale = _this$props2.locale,
dataSource = _this$props2.dataSource,
emptyContent = _this$props2.emptyContent,
loading = _this$props2.loading,
primaryKey = _this$props2.primaryKey,
cellProps = _this$props2.cellProps,
rowProps = _this$props2.rowProps,
onRowClick = _this$props2.onRowClick,
onRowMouseEnter = _this$props2.onRowMouseEnter,
onRowMouseLeave = _this$props2.onRowMouseLeave,
expandedIndexSimulate = _this$props2.expandedIndexSimulate,
pure = _this$props2.pure,
rtl = _this$props2.rtl,
sortIcons = _this$props2.sortIcons;
var sort = this.state.sort;
var _components$Header = components.Header,
Header = _components$Header === void 0 ? _header["default"] : _components$Header,
_components$Wrapper = components.Wrapper,
Wrapper = _components$Wrapper === void 0 ? _wrapper["default"] : _components$Wrapper,
_components$Body = components.Body,
Body = _components$Body === void 0 ? _body["default"] : _components$Body;
var colGroup = this.renderColGroup(flatChildren);
return /*#__PURE__*/_react["default"].createElement(Wrapper, {
colGroup: colGroup,
ref: this.getWrapperRef,
prefix: prefix
}, hasHeader ? /*#__PURE__*/_react["default"].createElement(Header, {
prefix: prefix,
rtl: rtl,
pure: pure,
affixRef: this.getAffixRef,
colGroup: colGroup,
className: "".concat(prefix, "table-header"),
filterParams: filterParams,
columns: groupChildren,
locale: locale,
headerCellRef: this.getHeaderCellRef,
components: components,
onFilter: this.onFilter,
sort: sort,
onResizeChange: this.onResizeChange,
onSort: this.onSort,
sortIcons: sortIcons,
table: this
}) : null, /*#__PURE__*/_react["default"].createElement(Body, {
prefix: prefix,
rtl: rtl,
pure: pure,
colGroup: colGroup,
className: "".concat(prefix, "table-body"),
components: components,
loading: loading,
emptyContent: emptyContent,
getCellProps: cellProps,
primaryKey: primaryKey,
getRowProps: rowProps,
columns: flatChildren,
rowRef: this.getRowRef,
cellRef: this.getCellRef,
onRowClick: onRowClick,
expandedIndexSimulate: expandedIndexSimulate,
onRowMouseEnter: onRowMouseEnter,
onRowMouseLeave: onRowMouseLeave,
dataSource: dataSource,
locale: locale,
table: this
}), wrapperContent);
} else {
return null;
}
}
}, {
key: "render",
value: function render() {
var _classnames;
if (this.AutoWidth && this.AutoWidth.enable) {
this.AutoWidth.init();
}
var ret = this.normalizeChildrenState(this.props);
this.groupChildren = ret.groupChildren;
this.flatChildren = ret.flatChildren;
/* eslint-disable no-unused-vars, prefer-const */
var table = this.renderTable(ret.groupChildren, ret.flatChildren);
var _this$props3 = this.props,
className = _this$props3.className,
hasBorder = _this$props3.hasBorder,
isZebra = _this$props3.isZebra,
loading = _this$props3.loading,
hasHeader = _this$props3.hasHeader,
prefix = _this$props3.prefix,
dataSource = _this$props3.dataSource,
entireDataSource = _this$props3.entireDataSource,
onSort = _this$props3.onSort,
onResizeChange = _this$props3.onResizeChange,
onRowClick = _this$props3.onRowClick,
onRowMouseEnter = _this$props3.onRowMouseEnter,
onRowMouseLeave = _this$props3.onRowMouseLeave,
onFilter = _this$props3.onFilter,
rowProps = _this$props3.rowProps,
cellProps = _this$props3.cellProps,
primaryKey = _this$props3.primaryKey,
components = _this$props3.components,
wrapperContent = _this$props3.wrapperContent,
lockType = _this$props3.lockType,
locale = _this$props3.locale,
expandedIndexSimulate = _this$props3.expandedIndexSimulate,
refs = _this$props3.refs,
pure = _this$props3.pure,
rtl = _this$props3.rtl,
emptyContent = _this$props3.emptyContent,
filterParams = _this$props3.filterParams,
columns = _this$props3.columns,
sortIcons = _this$props3.sortIcons,
_this$props3$loadingC = _this$props3.loadingComponent,
LoadingComponent = _this$props3$loadingC === void 0 ? _loading["default"] : _this$props3$loadingC,
others = _objectWithoutProperties(_this$props3, _excluded);
var cls = (0, _classnames2["default"])((_classnames = {}, _defineProperty(_classnames, "".concat(prefix, "table"), true), _defineProperty(_classnames, 'only-bottom-border', !hasBorder), _defineProperty(_classnames, 'no-header', !hasHeader), _defineProperty(_classnames, "zebra", isZebra), _defineProperty(_classnames, className, className), _classnames));
if (rtl) {
others.dir = 'rtl';
}
var content = /*#__PURE__*/_react["default"].createElement("div", _extends({
className: cls
}, others), table);
if (loading) {
var loadingClassName = "".concat(prefix, "table-loading");
return /*#__PURE__*/_react["default"].createElement(LoadingComponent, {
className: loadingClassName
}, content);
}
return content;
}
}]);
return Table;
}(_react["default"].Component);
exports["default"] = Table;
_defineProperty(Table, "displayName", 'Table');
_defineProperty(Table, "Column", _column["default"]);
_defineProperty(Table, "ColumnGroup", _columnGroup["default"]);
_defineProperty(Table, "Header", _header["default"]);
_defineProperty(Table, "Body", _body["default"]);
_defineProperty(Table, "Wrapper", _wrapper["default"]);
_defineProperty(Table, "Row", _row["default"]);
_defineProperty(Table, "Cell", _cell["default"]);
_defineProperty(Table, "Filter", _filter["default"]);
_defineProperty(Table, "Sort", _sort["default"]);
_defineProperty(Table, "propTypes", {
/**
* 样式类名的品牌前缀
*/
prefix: _propTypes["default"].string,
pure: _propTypes["default"].bool,
rtl: _propTypes["default"].bool,
/**
* 自定义类名
*/
className: _propTypes["default"].string,
/**
* 自定义内联样式
*/
style: _propTypes["default"].object,
/**
* 表格展示的数据源
*/
dataSource: _propTypes["default"].array,
entireDataSource: _propTypes["default"].array,
/**
* 点击表格每一行触发的事件
* @param {Object} record 该行所对应的数据
* @param {Number} index 该行所对应的序列
* @param {Event} e DOM事件对象
*/
onRowClick: _propTypes["default"].func,
/**
* 悬浮在表格每一行的时候触发的事件
* @param {Object} record 该行所对应的数据
* @param {Number} index 该行所对应的序列
* @param {Event} e DOM事件对象
*/
onRowMouseEnter: _propTypes["default"].func,
/**
* 离开表格每一行的时候触发的事件
* @param {Object} record 该行所对应的数据
* @param {Number} index 该行所对应的序列
* @param {Event} e DOM事件对象
*/
onRowMouseLeave: _propTypes["default"].func,
/**
* 点击列排序触发的事件
* @param {String} dataIndex 指定的排序的字段
* @param {String} order 排序对应的顺序, 有`desc`和`asc`两种
*/
onSort: _propTypes["default"].func,
/**
* 点击过滤确认按钮触发的事件
* @param {Object} filterParams 过滤的字段信息
*/
onFilter: _propTypes["default"].func,
/**
* 重设列尺寸的时候触发的事件
* @param {String} dataIndex 指定重设的字段
* @param {Number} value 列宽变动的数值
*/
onResizeChange: _propTypes["default"].func,
/**
* 设置每一行的属性,如果返回值和其他针对行操作的属性冲突则无效。
* @param {Object} record 该行所对应的数据
* @param {Number} index 该行所对应的序列
* @returns {Object} 需要设置的行属性
*/
rowProps: _propTypes["default"].func,
/**
* 设置单元格的属性,通过该属性可以进行合并单元格
* @param {Number} rowIndex 该行所对应的序列
* @param {Number} colIndex 该列所对应的序列
* @param {String} dataIndex 该列所对应的字段名称
* @param {Object} record 该行对应的记录
* @returns {Object} 返回td元素的所支持的属性对象
*/
cellProps: _propTypes["default"].func,
/**
* 表格是否具有边框
*/
hasBorder: _propTypes["default"].bool,
/**
* 表格是否具有头部
*/
hasHeader: _propTypes["default"].bool,
/**
* 表格是否是斑马线
*/
isZebra: _propTypes["default"].bool,
/**
* 表格是否在加载中
*/
loading: _propTypes["default"].bool,
/**
* 自定义 Loading 组件
* 请务必传递 props, 使用方式: loadingComponent={props => <Loading {...props}/>}
* @param {Object} props 当前点击行的key
*/
loadingComponent: _propTypes["default"].func,
/**
* 当前过滤的的keys,使用此属性可以控制表格的头部的过滤选项中哪个菜单被选中,格式为 {dataIndex: {selectedKeys:[]}}
* 示例:
* 假设要控制dataIndex为id的列的过滤菜单中key为one的菜单项选中
* `<Table filterParams={{id: {selectedKeys: ['one']}}}/>`
*/
filterParams: _propTypes["default"].object,
/**
* 当前排序的字段,使用此属性可以控制表格的字段的排序,格式为{dataIndex: 'asc'}
*/
sort: _propTypes["default"].object,
/**
* 自定义排序按钮,例如上下排布的: `{desc: <Icon style={{top: '6px', left: '4px'}} type={'chevron-down'} size="small" />, asc: <Icon style={{top: '-6px', left: '4px'}} type={'chevron-up'} size="small" />}`
*/
sortIcons: _propTypes["default"].object,
/**
* 自定义国际化文案对象
* @property {String} ok 过滤器中确认按钮文案
* @property {String} reset 过滤器中重置按钮文案
* @property {String} empty 没有数据情况下 table内的文案
* @property {String} asc 排序升序状态下的文案
* @property {String} desc 排序将序状态下的文案
* @property {String} expanded 可折叠行,展开状态下的文案
* @property {String} folded 可折叠行,折叠状态下的文案
* @property {String} filter 过滤器文案
* @property {String} selectAll header里全选的按钮文案
*/
locale: _propTypes["default"].object,
components: _propTypes["default"].object,
columns: _propTypes["default"].array,
/**
* 设置数据为空的时候的表格内容展现
*/
emptyContent: _propTypes["default"].node,
/**
* dataSource当中数据的主键,如果给定的数据源中的属性不包含该主键,会造成选择状态全部选中
*/
primaryKey: _propTypes["default"].string,
lockType: _propTypes["default"].oneOf(['left', 'right']),
wrapperContent: _propTypes["default"].any,
refs: _propTypes["default"].object,
/**
* 额外渲染行的渲染函数
* @param {Object} record 该行所对应的数据
* @param {Number} index 该行所对应的序列
* @returns {Element} 渲染内容
*/
expandedRowRender: _propTypes["default"].func,
/**
* 额外渲染行的缩进
*/
expandedRowIndent: _propTypes["default"].array,
/**
* 默认情况下展开的渲染行或者Tree, 传入此属性为受控状态
*/
openRowKeys: _propTypes["default"].array,
/**
* 是否显示点击展开额外渲染行的+号按钮
*/
hasExpandedRowCtrl: _propTypes["default"].bool,
/**
* 设置额外渲染行的属性
*/
getExpandedColProps: _propTypes["default"].func,
/**
* 在额外渲染行或者Tree展开或者收起的时候触发的事件
* @param {Array} openRowKeys 展开的渲染行的key
* @param {String} currentRowKey 当前点击的渲染行的key
* @param {Boolean} expanded 当前点击是展开还是收起
* @param {Object} currentRecord 当前点击额外渲染行的记录
*/
onRowOpen: _propTypes["default"].func,
/**
* 点击额外渲染行触发的事件
* @param {Object} record 该行所对应的数据
* @param {Number} index 该行所对应的序列
* @param {Event} e DOM事件对象
*/
onExpandedRowClick: _propTypes["default"].func,
/**
* 表头是否固定,该属性配合maxBodyHeight使用,当内容区域的高度超过maxBodyHeight的时候,在内容区域会出现滚动条
*/
fixedHeader: _propTypes["default"].bool,
/**
* 最大内容区域的高度,在`fixedHeader`为`true`的时候,超过这个高度会出现滚动条
*/
maxBodyHeight: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].string]),
/**
* 是否启用选择模式
* @property {Function} getProps `Function(record, index)=>Object` 获取selection的默认属性
* @property {Function} onChange `Function(selectedRowKeys:Array, records:Array)` 选择改变的时候触发的事件,**注意:** 其中records只会包含当前dataSource的数据,很可能会小于selectedRowKeys的长度。
* @property {Function} onSelect `Function(selected:Boolean, record:Object, records:Array)` 用户手动选择/取消选择某行的回调
* @property {Function} onSelectAll `Function(selected:Boolean, records:Array)` 用户手动选择/取消选择所有行的回调
* @property {Array} selectedRowKeys 设置了此属性,将rowSelection变为受控状态,接收值为该行数据的primaryKey的值
* @property {String} mode 选择selection的模式, 可选值为`single`, `multiple`,默认为`multiple`
* @property {Function} columnProps `Function()=>Object` 选择列 的props,例如锁列、对齐等,可使用`Table.Column` 的所有参数
* @property {Function} titleProps `Function()=>Object` 选择列 表头的props,仅在 `multiple` 模式下生效
* @property {Function} titleAddons `Function()=>Node` 选择列 表头添加的元素,在`single` `multiple` 下都生效
*/
rowSelection: _propTypes["default"].object,
/**
* 表头是否是sticky
*/
stickyHeader: _propTypes["default"].bool,
/**
* 距离窗口顶部达到指定偏移量后触发
*/
offsetTop: _propTypes["default"].number,
/**
* affix组件的的属性
*/
affixProps: _propTypes["default"].object,
/**
* 在tree模式下的缩进尺寸, 仅在isTree为true时候有效
*/
indent: _propTypes["default"].number,
/**
* 开启Table的tree模式, 接收的数据格式中包含children则渲染成tree table
*/
isTree: _propTypes["default"].bool,
/**
* 是否开启虚拟滚动
*/
useVirtual: _propTypes["default"].bool,
/**
* 设置行高
*/
rowHeight: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].func]),
/**
* 在内容区域滚动的时候触发的函数
*/
onBodyScroll: _propTypes["default"].func,
/**
* 开启时,getExpandedColProps() / rowProps() / expandedRowRender() 的第二个参数 index (该行所对应的序列) 将按照01,2,3,4...的顺序返回,否则返回真实index(0,2,4,6... / 1,3,5,7...)
*/
expandedIndexSimulate: _propTypes["default"].bool
});
_defineProperty(Table, "defaultProps", {
dataSource: [],
onRowClick: noop,
onRowMouseEnter: noop,
onRowMouseLeave: noop,
onSort: noop,
onFilter: noop,
onResizeChange: noop,
rowProps: noop,
cellProps: noop,
prefix: 'next-',
hasBorder: true,
hasHeader: true,
isZebra: false,
loading: false,
expandedIndexSimulate: false,
primaryKey: 'id',
components: {},
locale: _zhCn["default"].Table
});
_defineProperty(Table, "childContextTypes", {
notRenderCellIndex: _propTypes["default"].array,
lockType: _propTypes["default"].oneOf(['left', 'right'])
});
_defineProperty(Table, "contextTypes", {
getTableInstance: _propTypes["default"].func,
getTableInstanceForVirtual: _propTypes["default"].func
});