UNPKG

@txdfe/at

Version:

一个设计体系组件库

719 lines (716 loc) 29.8 kB
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 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 _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /* eslint-disable react/no-multi-comp */ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import shallowElementEquals from 'shallow-element-equals'; import Loading from '../loading'; import zhCN from '../locale/zh-cn'; import { log, obj } from '../util'; import BodyComponent from './base/body'; import HeaderComponent from './base/header'; import WrapperComponent from './base/wrapper'; import RowComponent from './base/row'; import CellComponent from './base/cell'; import FilterComponent from './base/filter'; import SortComponent from './base/sort'; import Column from './column'; import ColumnGroup from './column-group'; import guid from '../util/guid'; import AutoWidth from './base/auto-width'; var Children = React.Children; var noop = function noop() {}; var ColGroup = /*#__PURE__*/function (_React$Component) { function ColGroup() { _classCallCheck(this, ColGroup); return _callSuper(this, ColGroup, arguments); } _inherits(ColGroup, _React$Component); return _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.createElement("col", { style: style, key: index }); }); return /*#__PURE__*/React.createElement("colgroup", { key: "table-colgroup" }, cols); } }]); }(React.Component); /** Table */ var Table = /*#__PURE__*/function (_React$Component2) { function Table(props, context) { var _this; _classCallCheck(this, Table); _this = _callSuper(this, Table, [props, context]); _defineProperty(_this, "state", { sort: _this.props.sort || {} }); _defineProperty(_this, "renderColGroup", function (flatChildren) { return /*#__PURE__*/React.createElement(ColGroup, { flatChildren: flatChildren, table: _this }); }); _defineProperty(_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(_this, "onFilter", function (filterParams) { _this.props.onFilter(filterParams); }); _defineProperty(_this, "onResizeChange", function (dataIndex, value) { _this.props.onResizeChange(dataIndex, value); }); _defineProperty(_this, "getWrapperRef", function (wrapper) { if (!wrapper) { return _this.wrapper; } _this.wrapper = wrapper; }); _defineProperty(_this, "getAffixRef", function (affixRef) { if (!affixRef) { return _this.affixRef; } _this.affixRef = affixRef; }); _defineProperty(_this, "getHeaderCellRef", function (i, j, cell) { var cellRef = "header_cell_".concat(i, "_").concat(j); if (!cell) { return _this[cellRef]; } _this[cellRef] = cell; }); _defineProperty(_this, "getRowRef", function (i, row) { var rowRef = "row_".concat(i); if (!row) { return _this[rowRef]; } _this[rowRef] = row; }); _defineProperty(_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, _this); getTableInstanceForVirtual && getTableInstanceForVirtual(props.lockType, _this); _this.notRenderCellIndex = []; _this.refColGroup = null; _this.AutoWidth = new AutoWidth({ padding: 15, table: _this }); return _this; } _inherits(Table, _React$Component2); return _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 = shallowElementEquals(nextProps, this.props) && obj.shallowEqual(nextState, this.state) && 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'))) { 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 _getChildren2 = function getChildren(propsChildren, level) { groupChildren[level] = groupChildren[level] || []; propsChildren.forEach(function (child) { if (child.children) { hasGroupHeader = true; _getChildren2(child.children, level + 1); } else { child.columnId = guid('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; }; _getChildren2(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 ? HeaderComponent : _components$Header, _components$Wrapper = components.Wrapper, Wrapper = _components$Wrapper === void 0 ? WrapperComponent : _components$Wrapper, _components$Body = components.Body, Body = _components$Body === void 0 ? BodyComponent : _components$Body; var colGroup = this.renderColGroup(flatChildren); return /*#__PURE__*/React.createElement(Wrapper, { colGroup: colGroup, ref: this.getWrapperRef, prefix: prefix }, hasHeader ? /*#__PURE__*/React.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.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() { 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 : _this$props3$loadingC, others = _objectWithoutProperties(_this$props3, _excluded); var cls = classnames(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefix, "table"), true), 'only-bottom-border', !hasBorder), 'no-header', !hasHeader), "zebra", isZebra), className, className)); if (rtl) { others.dir = 'rtl'; } var content = /*#__PURE__*/React.createElement("div", _extends({ className: cls }, others), table); if (loading) { var loadingClassName = "".concat(prefix, "table-loading"); return /*#__PURE__*/React.createElement(LoadingComponent, { className: loadingClassName }, content); } return content; } }]); }(React.Component); _defineProperty(Table, "displayName", 'Table'); _defineProperty(Table, "Column", Column); _defineProperty(Table, "ColumnGroup", ColumnGroup); _defineProperty(Table, "Header", HeaderComponent); _defineProperty(Table, "Body", BodyComponent); _defineProperty(Table, "Wrapper", WrapperComponent); _defineProperty(Table, "Row", RowComponent); _defineProperty(Table, "Cell", CellComponent); _defineProperty(Table, "Filter", FilterComponent); _defineProperty(Table, "Sort", SortComponent); _defineProperty(Table, "propTypes", { /** * 样式类名的品牌前缀 */ prefix: PropTypes.string, pure: PropTypes.bool, rtl: PropTypes.bool, /** * 自定义类名 */ className: PropTypes.string, /** * 自定义内联样式 */ style: PropTypes.object, /** * 表格展示的数据源 */ dataSource: PropTypes.array, entireDataSource: PropTypes.array, /** * 点击表格每一行触发的事件 * @param {Object} record 该行所对应的数据 * @param {Number} index 该行所对应的序列 * @param {Event} e DOM事件对象 */ onRowClick: PropTypes.func, /** * 悬浮在表格每一行的时候触发的事件 * @param {Object} record 该行所对应的数据 * @param {Number} index 该行所对应的序列 * @param {Event} e DOM事件对象 */ onRowMouseEnter: PropTypes.func, /** * 离开表格每一行的时候触发的事件 * @param {Object} record 该行所对应的数据 * @param {Number} index 该行所对应的序列 * @param {Event} e DOM事件对象 */ onRowMouseLeave: PropTypes.func, /** * 点击列排序触发的事件 * @param {String} dataIndex 指定的排序的字段 * @param {String} order 排序对应的顺序, 有`desc`和`asc`两种 */ onSort: PropTypes.func, /** * 点击过滤确认按钮触发的事件 * @param {Object} filterParams 过滤的字段信息 */ onFilter: PropTypes.func, /** * 重设列尺寸的时候触发的事件 * @param {String} dataIndex 指定重设的字段 * @param {Number} value 列宽变动的数值 */ onResizeChange: PropTypes.func, /** * 设置每一行的属性,如果返回值和其他针对行操作的属性冲突则无效。 * @param {Object} record 该行所对应的数据 * @param {Number} index 该行所对应的序列 * @returns {Object} 需要设置的行属性 */ rowProps: PropTypes.func, /** * 设置单元格的属性,通过该属性可以进行合并单元格 * @param {Number} rowIndex 该行所对应的序列 * @param {Number} colIndex 该列所对应的序列 * @param {String} dataIndex 该列所对应的字段名称 * @param {Object} record 该行对应的记录 * @returns {Object} 返回td元素的所支持的属性对象 */ cellProps: PropTypes.func, /** * 表格是否具有边框 */ hasBorder: PropTypes.bool, /** * 表格是否具有头部 */ hasHeader: PropTypes.bool, /** * 表格是否是斑马线 */ isZebra: PropTypes.bool, /** * 表格是否在加载中 */ loading: PropTypes.bool, /** * 自定义 Loading 组件 * 请务必传递 props, 使用方式: loadingComponent={props => <Loading {...props}/>} * @param {Object} props 当前点击行的key */ loadingComponent: PropTypes.func, /** * 当前过滤的的keys,使用此属性可以控制表格的头部的过滤选项中哪个菜单被选中,格式为 {dataIndex: {selectedKeys:[]}} * 示例: * 假设要控制dataIndex为id的列的过滤菜单中key为one的菜单项选中 * `<Table filterParams={{id: {selectedKeys: ['one']}}}/>` */ filterParams: PropTypes.object, /** * 当前排序的字段,使用此属性可以控制表格的字段的排序,格式为{dataIndex: 'asc'} */ sort: PropTypes.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.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.object, components: PropTypes.object, columns: PropTypes.array, /** * 设置数据为空的时候的表格内容展现 */ emptyContent: PropTypes.node, /** * dataSource当中数据的主键,如果给定的数据源中的属性不包含该主键,会造成选择状态全部选中 */ primaryKey: PropTypes.string, lockType: PropTypes.oneOf(['left', 'right']), wrapperContent: PropTypes.any, refs: PropTypes.object, /** * 额外渲染行的渲染函数 * @param {Object} record 该行所对应的数据 * @param {Number} index 该行所对应的序列 * @returns {Element} 渲染内容 */ expandedRowRender: PropTypes.func, /** * 额外渲染行的缩进 */ expandedRowIndent: PropTypes.array, /** * 默认情况下展开的渲染行或者Tree, 传入此属性为受控状态 */ openRowKeys: PropTypes.array, /** * 是否显示点击展开额外渲染行的+号按钮 */ hasExpandedRowCtrl: PropTypes.bool, /** * 设置额外渲染行的属性 */ getExpandedColProps: PropTypes.func, /** * 在额外渲染行或者Tree展开或者收起的时候触发的事件 * @param {Array} openRowKeys 展开的渲染行的key * @param {String} currentRowKey 当前点击的渲染行的key * @param {Boolean} expanded 当前点击是展开还是收起 * @param {Object} currentRecord 当前点击额外渲染行的记录 */ onRowOpen: PropTypes.func, /** * 点击额外渲染行触发的事件 * @param {Object} record 该行所对应的数据 * @param {Number} index 该行所对应的序列 * @param {Event} e DOM事件对象 */ onExpandedRowClick: PropTypes.func, /** * 表头是否固定,该属性配合maxBodyHeight使用,当内容区域的高度超过maxBodyHeight的时候,在内容区域会出现滚动条 */ fixedHeader: PropTypes.bool, /** * 最大内容区域的高度,在`fixedHeader`为`true`的时候,超过这个高度会出现滚动条 */ maxBodyHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.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.object, /** * 表头是否是sticky */ stickyHeader: PropTypes.bool, /** * 距离窗口顶部达到指定偏移量后触发 */ offsetTop: PropTypes.number, /** * affix组件的的属性 */ affixProps: PropTypes.object, /** * 在tree模式下的缩进尺寸, 仅在isTree为true时候有效 */ indent: PropTypes.number, /** * 开启Table的tree模式, 接收的数据格式中包含children则渲染成tree table */ isTree: PropTypes.bool, /** * 是否开启虚拟滚动 */ useVirtual: PropTypes.bool, /** * 设置行高 */ rowHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.func]), /** * 在内容区域滚动的时候触发的函数 */ onBodyScroll: PropTypes.func, /** * 开启时,getExpandedColProps() / rowProps() / expandedRowRender() 的第二个参数 index (该行所对应的序列) 将按照01,2,3,4...的顺序返回,否则返回真实index(0,2,4,6... / 1,3,5,7...) */ expandedIndexSimulate: PropTypes.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.Table }); _defineProperty(Table, "childContextTypes", { notRenderCellIndex: PropTypes.array, lockType: PropTypes.oneOf(['left', 'right']) }); _defineProperty(Table, "contextTypes", { getTableInstance: PropTypes.func, getTableInstanceForVirtual: PropTypes.func }); export { Table as default };