UNPKG

@atlaskit/side-navigation

Version:

A highly composable side navigation component that supports nested views.

50 lines (49 loc) • 1.94 kB
import _extends from "@babel/runtime/helpers/extends"; import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["className", "iconBefore", "onClick", "isSelected"]; import React, { forwardRef, useCallback, useState } from 'react'; import ArrowLeftIcon from '@atlaskit/icon/core/arrow-left'; import { ButtonItem } from './button-item'; /** * __Go back item__ * * A go back item is used to provide a customized "go back" button in nested * navigations. * * - [Examples](https://atlassian.design/components/side-navigation/examples#go-back-item) * - [Code](https://atlassian.design/components/side-navigation/code) * * @deprecated `@atlaskit/side-navigation` is deprecated. Use `@atlaskit/navigation-system` instead. */ export var GoBackItem = /*#__PURE__*/forwardRef(function (_ref, ref) { var className = _ref.className, _ref$iconBefore = _ref.iconBefore, iconBefore = _ref$iconBefore === void 0 ? /*#__PURE__*/React.createElement(ArrowLeftIcon, { color: "currentColor", label: "" }) : _ref$iconBefore, onClick = _ref.onClick, isSelected = _ref.isSelected, rest = _objectWithoutProperties(_ref, _excluded); var _useState = useState(false), _useState2 = _slicedToArray(_useState, 2), isInteracted = _useState2[0], setIsInteracted = _useState2[1]; var onClickHandler = useCallback(function (e) { if (isInteracted) { return; } setIsInteracted(true); onClick && onClick(e); }, [onClick, isInteracted]); return /*#__PURE__*/React.createElement(ButtonItem, _extends({ isSelected: isSelected // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-classname-prop , className: className, iconBefore: iconBefore, onClick: onClickHandler, ref: ref }, rest)); });