UNPKG

@wordpress/components

Version:
75 lines (64 loc) 2.26 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.NavigatorToParentButton = void 0; var _element = require("@wordpress/element"); var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _context = require("../../ui/context"); var _view = require("../../view"); var _hook = require("../navigator-back-button/hook"); /** * External dependencies */ /** * Internal dependencies */ function UnconnectedNavigatorToParentButton(props, forwardedRef) { const navigatorToParentButtonProps = (0, _hook.useNavigatorBackButton)({ ...props, goToParent: true }); return (0, _element.createElement)(_view.View, (0, _extends2.default)({ ref: forwardedRef }, navigatorToParentButtonProps)); } /* * The `NavigatorToParentButton` component can be used to navigate to a screen and * should be used in combination with the `NavigatorProvider`, the * `NavigatorScreen` and the `NavigatorButton` components (or the `useNavigator` * hook). * * @example * ```jsx * import { * __experimentalNavigatorProvider as NavigatorProvider, * __experimentalNavigatorScreen as NavigatorScreen, * __experimentalNavigatorButton as NavigatorButton, * __experimentalNavigatorToParentButton as NavigatorToParentButton, * } from '@wordpress/components'; * * const MyNavigation = () => ( * <NavigatorProvider initialPath="/"> * <NavigatorScreen path="/"> * <p>This is the home screen.</p> * <NavigatorButton path="/child"> * Navigate to child screen. * </NavigatorButton> * </NavigatorScreen> * * <NavigatorScreen path="/child"> * <p>This is the child screen.</p> * <NavigatorToParentButton> * Go to parent * </NavigatorToParentButton> * </NavigatorScreen> * </NavigatorProvider> * ); * ``` */ const NavigatorToParentButton = (0, _context.contextConnect)(UnconnectedNavigatorToParentButton, 'NavigatorToParentButton'); exports.NavigatorToParentButton = NavigatorToParentButton; var _default = NavigatorToParentButton; exports.default = _default; //# sourceMappingURL=component.js.map