UNPKG

2.56 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4var _typeof = require("@babel/runtime/helpers/typeof");
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.findAllChildrenKeys = findAllChildrenKeys;
9exports.renderExpandIcon = renderExpandIcon;
10var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11var React = _interopRequireWildcard(require("react"));
12var _classnames = _interopRequireDefault(require("classnames"));
13function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15function renderExpandIcon(_ref) {
16 var _classNames;
17 var prefixCls = _ref.prefixCls,
18 record = _ref.record,
19 onExpand = _ref.onExpand,
20 expanded = _ref.expanded,
21 expandable = _ref.expandable;
22 var expandClassName = "".concat(prefixCls, "-row-expand-icon");
23 if (!expandable) {
24 return /*#__PURE__*/React.createElement("span", {
25 className: (0, _classnames.default)(expandClassName, "".concat(prefixCls, "-row-spaced"))
26 });
27 }
28 var onClick = function onClick(event) {
29 onExpand(record, event);
30 event.stopPropagation();
31 };
32 return /*#__PURE__*/React.createElement("span", {
33 className: (0, _classnames.default)(expandClassName, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-row-expanded"), expanded), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-row-collapsed"), !expanded), _classNames)),
34 onClick: onClick
35 });
36}
37function findAllChildrenKeys(data, getRowKey, childrenColumnName) {
38 var keys = [];
39 function dig(list) {
40 (list || []).forEach(function (item, index) {
41 keys.push(getRowKey(item, index));
42 dig(item[childrenColumnName]);
43 });
44 }
45 dig(data);
46 return keys;
47}
\No newline at end of file