UNPKG

@atlaskit/table-tree

Version:

A table tree is an expandable table for showing nested hierarchies of information.

42 lines (41 loc) • 1.87 kB
import _extends from "@babel/runtime/helpers/extends"; /* eslint-disable @repo/internal/react/consistent-props-definitions */ import React from 'react'; import IconButton from '@atlaskit/button/icon/button'; import __noop from '@atlaskit/ds-lib/noop'; import ChevronDownIcon from '@atlaskit/icon/core/chevron-down'; import ChevronRightIcon from '@atlaskit/icon/core/chevron-right'; import { ChevronContainer } from './chevron-container'; /** * Internal chevron component. */ var Chevron = function Chevron(_ref) { var isExpanded = _ref.isExpanded, ariaControls = _ref.ariaControls, _ref$collapseLabel = _ref.collapseLabel, collapseLabel = _ref$collapseLabel === void 0 ? 'Collapse' : _ref$collapseLabel, _ref$expandLabel = _ref.expandLabel, expandLabel = _ref$expandLabel === void 0 ? 'Expand' : _ref$expandLabel, rowId = _ref.rowId, extendedLabel = _ref.extendedLabel, _ref$onExpandToggle = _ref.onExpandToggle, onExpandToggle = _ref$onExpandToggle === void 0 ? __noop : _ref$onExpandToggle; var getLabel = function getLabel(defaultLabel) { return extendedLabel ? "".concat(defaultLabel, " ").concat(extendedLabel, " row") : "".concat(defaultLabel, " row ").concat(rowId); }; return /*#__PURE__*/React.createElement(ChevronContainer, null, /*#__PURE__*/React.createElement(IconButton, { appearance: "subtle", onClick: onExpandToggle, spacing: "compact", icon: function icon(iconProps) { return isExpanded ? /*#__PURE__*/React.createElement(ChevronDownIcon, _extends({}, iconProps, { size: "small" })) : /*#__PURE__*/React.createElement(ChevronRightIcon, _extends({}, iconProps, { size: "small" })); }, "aria-controls": isExpanded ? ariaControls : undefined, label: isExpanded ? getLabel(collapseLabel) : getLabel(expandLabel) })); }; export default Chevron;