@atlaskit/page-layout
Version:
A collection of components which let you compose an application's page layout.
43 lines (42 loc) • 2.19 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import { useContext, useEffect } from 'react';
import { SidebarResizeContext } from './sidebar-resize-context';
/**
* _**WARNING:**_ This hook is intended as a temporary solution and
* is likely to be removed in a future version of page-layout.
*
* ---
*
* This hook will prevent the left sidebar from automatically collapsing
* when it is in a flyout state.
*
* The intended use case for this hook is to allow popup menus in the
* left sidebar to be usable while it is in a flyout state.
*
* ## Usage
* The intended usage is to use this hook within the popup component
* you are rendering. This way the left sidebar will be locked for
* as long as the popup is open.
*
* @deprecated `@atlaskit/page-layout` is deprecated. Use `@atlaskit/navigation-system` instead.
*/
export var useLeftSidebarFlyoutLock = function useLeftSidebarFlyoutLock() {
var _useContext = useContext(SidebarResizeContext),
setLeftSidebarState = _useContext.setLeftSidebarState;
useEffect(function () {
setLeftSidebarState(function (current) {
return _objectSpread(_objectSpread({}, current), {}, {
flyoutLockCount: current.flyoutLockCount + 1
});
});
return function () {
setLeftSidebarState(function (current) {
return _objectSpread(_objectSpread({}, current), {}, {
flyoutLockCount: current.flyoutLockCount - 1
});
});
};
}, [setLeftSidebarState]);
};