UNPKG

@atlaskit/table-tree

Version:

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

36 lines (35 loc) • 1.37 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. */ const Chevron = ({ isExpanded, ariaControls, collapseLabel = 'Collapse', expandLabel = 'Expand', rowId, extendedLabel, onExpandToggle = __noop }) => { const getLabel = defaultLabel => extendedLabel ? `${defaultLabel} ${extendedLabel} row` : `${defaultLabel} row ${rowId}`; return /*#__PURE__*/React.createElement(ChevronContainer, null, /*#__PURE__*/React.createElement(IconButton, { appearance: "subtle", onClick: onExpandToggle, spacing: "compact", icon: iconProps => 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;