legacyUtil.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. var __rest = this && this.__rest || function (s, e) {
  3. var t = {};
  4. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  5. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  6. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  7. }
  8. return t;
  9. };
  10. import { warning } from '../../vc-util/warning';
  11. export const INTERNAL_COL_DEFINE = 'RC_TABLE_INTERNAL_COL_DEFINE';
  12. export function getExpandableProps(props) {
  13. const {
  14. expandable
  15. } = props,
  16. legacyExpandableConfig = __rest(props, ["expandable"]);
  17. let config;
  18. if (props.expandable !== undefined) {
  19. config = _extends(_extends({}, legacyExpandableConfig), expandable);
  20. } else {
  21. if (process.env.NODE_ENV !== 'production' && ['indentSize', 'expandedRowKeys', 'defaultExpandedRowKeys', 'defaultExpandAllRows', 'expandedRowRender', 'expandRowByClick', 'expandIcon', 'onExpand', 'onExpandedRowsChange', 'expandedRowClassName', 'expandIconColumnIndex', 'showExpandColumn'].some(prop => prop in props)) {
  22. warning(false, 'expanded related props have been moved into `expandable`.');
  23. }
  24. config = legacyExpandableConfig;
  25. }
  26. if (config.showExpandColumn === false) {
  27. config.expandIconColumnIndex = -1;
  28. }
  29. return config;
  30. }
  31. /**
  32. * Returns only data- and aria- key/value pairs
  33. * @param {object} props
  34. */
  35. export function getDataAndAriaProps(props) {
  36. /* eslint-disable no-param-reassign */
  37. return Object.keys(props).reduce((memo, key) => {
  38. if (key.startsWith('data-') || key.startsWith('aria-')) {
  39. memo[key] = props[key];
  40. }
  41. return memo;
  42. }, {});
  43. /* eslint-enable */
  44. }