legacyUtil.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
  3. var _excluded = ["expandable"];
  4. import { warning } from '../../vc-util/warning';
  5. export var INTERNAL_COL_DEFINE = 'RC_TABLE_INTERNAL_COL_DEFINE';
  6. export function getExpandableProps(props) {
  7. var expandable = props.expandable,
  8. legacyExpandableConfig = _objectWithoutProperties(props, _excluded);
  9. var config;
  10. if (props.expandable !== undefined) {
  11. config = _objectSpread(_objectSpread({}, legacyExpandableConfig), expandable);
  12. } else {
  13. if (process.env.NODE_ENV !== 'production' && ['indentSize', 'expandedRowKeys', 'defaultExpandedRowKeys', 'defaultExpandAllRows', 'expandedRowRender', 'expandRowByClick', 'expandIcon', 'onExpand', 'onExpandedRowsChange', 'expandedRowClassName', 'expandIconColumnIndex', 'showExpandColumn'].some(function (prop) {
  14. return prop in props;
  15. })) {
  16. warning(false, 'expanded related props have been moved into `expandable`.');
  17. }
  18. config = legacyExpandableConfig;
  19. }
  20. if (config.showExpandColumn === false) {
  21. config.expandIconColumnIndex = -1;
  22. }
  23. return config;
  24. }
  25. /**
  26. * Returns only data- and aria- key/value pairs
  27. * @param {object} props
  28. */
  29. export function getDataAndAriaProps(props) {
  30. /* eslint-disable no-param-reassign */
  31. return Object.keys(props).reduce(function (memo, key) {
  32. if (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-') {
  33. memo[key] = props[key];
  34. }
  35. return memo;
  36. }, {});
  37. /* eslint-enable */
  38. }