@atlaskit/page-layout 1.3.7 → 1.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/common/constants.js +8 -4
  3. package/dist/cjs/common/hooks/index.js +0 -3
  4. package/dist/cjs/common/hooks/use-is-sidebar-collapsing.js +3 -12
  5. package/dist/cjs/common/hooks/use-is-sidebar-dragging.js +3 -12
  6. package/dist/cjs/common/safe-local-storage.js +2 -13
  7. package/dist/cjs/common/utils.js +0 -35
  8. package/dist/cjs/components/index.js +0 -13
  9. package/dist/cjs/components/resize-control/grab-area.js +8 -17
  10. package/dist/cjs/components/resize-control/index.js +33 -84
  11. package/dist/cjs/components/resize-control/resize-button.js +9 -24
  12. package/dist/cjs/components/resize-control/shadow.js +3 -7
  13. package/dist/cjs/components/skip-links/index.js +0 -2
  14. package/dist/cjs/components/skip-links/skip-link-components.js +18 -48
  15. package/dist/cjs/components/skip-links/use-custom-skip-link.js +3 -8
  16. package/dist/cjs/components/slots/banner-slot.js +10 -21
  17. package/dist/cjs/components/slots/content.js +3 -6
  18. package/dist/cjs/components/slots/internal/left-sidebar-inner.js +9 -14
  19. package/dist/cjs/components/slots/internal/left-sidebar-outer.js +10 -22
  20. package/dist/cjs/components/slots/internal/resizable-children-wrapper.js +10 -15
  21. package/dist/cjs/components/slots/internal/slot-focus-ring.js +5 -8
  22. package/dist/cjs/components/slots/left-panel.js +9 -20
  23. package/dist/cjs/components/slots/left-sidebar-without-resize.js +6 -18
  24. package/dist/cjs/components/slots/left-sidebar.js +39 -75
  25. package/dist/cjs/components/slots/main.js +9 -23
  26. package/dist/cjs/components/slots/page-layout.js +7 -16
  27. package/dist/cjs/components/slots/right-panel.js +9 -20
  28. package/dist/cjs/components/slots/right-sidebar.js +9 -21
  29. package/dist/cjs/components/slots/slot-dimensions.js +1 -5
  30. package/dist/cjs/components/slots/top-navigation.js +10 -21
  31. package/dist/cjs/controllers/index.js +0 -6
  32. package/dist/cjs/controllers/sidebar-resize-context.js +6 -21
  33. package/dist/cjs/controllers/sidebar-resize-controller.js +34 -50
  34. package/dist/cjs/controllers/skip-link-context.js +2 -12
  35. package/dist/cjs/controllers/skip-link-controller.js +6 -22
  36. package/dist/cjs/controllers/use-page-layout-grid.js +6 -12
  37. package/dist/cjs/controllers/use-update-css-vars.js +0 -3
  38. package/dist/cjs/index.js +0 -3
  39. package/dist/cjs/version.json +1 -1
  40. package/dist/es2019/common/constants.js +8 -4
  41. package/dist/es2019/common/hooks/use-is-sidebar-collapsing.js +0 -4
  42. package/dist/es2019/common/hooks/use-is-sidebar-dragging.js +0 -4
  43. package/dist/es2019/common/safe-local-storage.js +2 -12
  44. package/dist/es2019/common/utils.js +4 -20
  45. package/dist/es2019/components/resize-control/grab-area.js +7 -8
  46. package/dist/es2019/components/resize-control/index.js +26 -43
  47. package/dist/es2019/components/resize-control/resize-button.js +7 -11
  48. package/dist/es2019/components/resize-control/shadow.js +3 -3
  49. package/dist/es2019/components/skip-links/skip-link-components.js +16 -31
  50. package/dist/es2019/components/slots/banner-slot.js +1 -3
  51. package/dist/es2019/components/slots/content.js +2 -2
  52. package/dist/es2019/components/slots/internal/left-sidebar-inner.js +5 -5
  53. package/dist/es2019/components/slots/internal/left-sidebar-outer.js +1 -4
  54. package/dist/es2019/components/slots/internal/resizable-children-wrapper.js +4 -4
  55. package/dist/es2019/components/slots/internal/slot-focus-ring.js +3 -3
  56. package/dist/es2019/components/slots/left-panel.js +1 -3
  57. package/dist/es2019/components/slots/left-sidebar-without-resize.js +1 -2
  58. package/dist/es2019/components/slots/left-sidebar.js +25 -40
  59. package/dist/es2019/components/slots/main.js +4 -5
  60. package/dist/es2019/components/slots/page-layout.js +1 -3
  61. package/dist/es2019/components/slots/right-panel.js +1 -3
  62. package/dist/es2019/components/slots/right-sidebar.js +3 -5
  63. package/dist/es2019/components/slots/top-navigation.js +1 -3
  64. package/dist/es2019/controllers/sidebar-resize-context.js +7 -5
  65. package/dist/es2019/controllers/sidebar-resize-controller.js +14 -16
  66. package/dist/es2019/controllers/skip-link-context.js +0 -1
  67. package/dist/es2019/controllers/skip-link-controller.js +3 -7
  68. package/dist/es2019/controllers/use-page-layout-grid.js +4 -5
  69. package/dist/es2019/controllers/use-update-css-vars.js +0 -2
  70. package/dist/es2019/version.json +1 -1
  71. package/dist/esm/common/constants.js +8 -4
  72. package/dist/esm/common/hooks/use-is-sidebar-collapsing.js +3 -8
  73. package/dist/esm/common/hooks/use-is-sidebar-dragging.js +3 -8
  74. package/dist/esm/common/safe-local-storage.js +2 -12
  75. package/dist/esm/common/utils.js +0 -22
  76. package/dist/esm/components/resize-control/grab-area.js +9 -14
  77. package/dist/esm/components/resize-control/index.js +33 -72
  78. package/dist/esm/components/resize-control/resize-button.js +10 -15
  79. package/dist/esm/components/resize-control/shadow.js +3 -3
  80. package/dist/esm/components/skip-links/skip-link-components.js +19 -39
  81. package/dist/esm/components/skip-links/use-custom-skip-link.js +2 -4
  82. package/dist/esm/components/slots/banner-slot.js +9 -11
  83. package/dist/esm/components/slots/content.js +3 -3
  84. package/dist/esm/components/slots/internal/left-sidebar-inner.js +9 -9
  85. package/dist/esm/components/slots/internal/left-sidebar-outer.js +9 -12
  86. package/dist/esm/components/slots/internal/resizable-children-wrapper.js +10 -10
  87. package/dist/esm/components/slots/internal/slot-focus-ring.js +5 -5
  88. package/dist/esm/components/slots/left-panel.js +8 -10
  89. package/dist/esm/components/slots/left-sidebar-without-resize.js +7 -9
  90. package/dist/esm/components/slots/left-sidebar.js +40 -65
  91. package/dist/esm/components/slots/main.js +10 -13
  92. package/dist/esm/components/slots/page-layout.js +6 -10
  93. package/dist/esm/components/slots/right-panel.js +8 -10
  94. package/dist/esm/components/slots/right-sidebar.js +10 -12
  95. package/dist/esm/components/slots/slot-dimensions.js +1 -1
  96. package/dist/esm/components/slots/top-navigation.js +9 -11
  97. package/dist/esm/controllers/sidebar-resize-context.js +6 -11
  98. package/dist/esm/controllers/sidebar-resize-controller.js +34 -38
  99. package/dist/esm/controllers/skip-link-context.js +2 -4
  100. package/dist/esm/controllers/skip-link-controller.js +6 -12
  101. package/dist/esm/controllers/use-page-layout-grid.js +6 -8
  102. package/dist/esm/controllers/use-update-css-vars.js +0 -2
  103. package/dist/esm/version.json +1 -1
  104. package/package.json +2 -2
@@ -4,13 +4,12 @@ import { isReducedMotion } from '@atlaskit/motion';
4
4
  import { COLLAPSED_LEFT_SIDEBAR_WIDTH, DEFAULT_LEFT_SIDEBAR_WIDTH, GRAB_AREA_SELECTOR, IS_SIDEBAR_COLLAPSING } from '../common/constants';
5
5
  import { getPageLayoutSlotCSSSelector } from '../common/utils';
6
6
  import { SidebarResizeContext } from './sidebar-resize-context';
7
-
8
7
  const handleDataAttributesAndCb = (callback = noop, isLeftSidebarCollapsed, leftSidebarState) => {
9
8
  document.documentElement.removeAttribute(IS_SIDEBAR_COLLAPSING);
10
9
  callback(leftSidebarState);
11
- }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
12
-
10
+ };
13
11
 
12
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
14
13
  export const SidebarResizeController = ({
15
14
  children,
16
15
  onLeftSidebarExpand: onExpand,
@@ -33,16 +32,16 @@ export const SidebarResizeController = ({
33
32
  if (event.propertyName === 'width' && event.target && event.target.matches(leftSidebarSelector)) {
34
33
  const $leftSidebarResizeController = document.querySelector(`[${GRAB_AREA_SELECTOR}]`);
35
34
  const isCollapsed = !!$leftSidebarResizeController && $leftSidebarResizeController.hasAttribute('disabled');
36
- handleDataAttributesAndCb(isCollapsed ? onCollapse : onExpand, isCollapsed, leftSidebarState); // Make sure multiple event handlers do not get attached
37
- // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
35
+ handleDataAttributesAndCb(isCollapsed ? onCollapse : onExpand, isCollapsed, leftSidebarState);
38
36
 
37
+ // Make sure multiple event handlers do not get attached
38
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
39
39
  document.querySelector(leftSidebarSelector).removeEventListener('transitionend', transitionEventHandler);
40
- } // eslint-disable-next-line react-hooks/exhaustive-deps
41
-
40
+ }
41
+ // eslint-disable-next-line react-hooks/exhaustive-deps
42
42
  }, []);
43
43
  useEffect(() => {
44
44
  const $leftSidebar = document.querySelector(leftSidebarSelector);
45
-
46
45
  if ($leftSidebar && !isReducedMotion()) {
47
46
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
48
47
  $leftSidebar.addEventListener('transitionend', transitionEventHandler);
@@ -55,11 +54,9 @@ export const SidebarResizeController = ({
55
54
  flyoutLockCount,
56
55
  isFixed
57
56
  } = leftSidebarState;
58
-
59
57
  if (isResizing) {
60
58
  return;
61
59
  }
62
-
63
60
  const width = Math.max(lastLeftSidebarWidth, DEFAULT_LEFT_SIDEBAR_WIDTH);
64
61
  const updatedLeftSidebarState = {
65
62
  isLeftSidebarCollapsed: false,
@@ -70,8 +67,9 @@ export const SidebarResizeController = ({
70
67
  flyoutLockCount,
71
68
  isFixed
72
69
  };
73
- setLeftSidebarState(updatedLeftSidebarState); // onTransitionEnd isn't triggered when a user prefers reduced motion
70
+ setLeftSidebarState(updatedLeftSidebarState);
74
71
 
72
+ // onTransitionEnd isn't triggered when a user prefers reduced motion
75
73
  if (isReducedMotion()) {
76
74
  handleDataAttributesAndCb(onExpand, false, updatedLeftSidebarState);
77
75
  }
@@ -84,13 +82,12 @@ export const SidebarResizeController = ({
84
82
  isFixed,
85
83
  isLeftSidebarCollapsed
86
84
  } = leftSidebarState;
87
-
88
85
  if (isResizing || isLeftSidebarCollapsed) {
89
86
  return;
90
- } // data-attribute is used as a CSS selector to sync the hiding/showing
91
- // of the nav contents with expand/collapse animation
92
-
87
+ }
93
88
 
89
+ // data-attribute is used as a CSS selector to sync the hiding/showing
90
+ // of the nav contents with expand/collapse animation
94
91
  document.documentElement.setAttribute(IS_SIDEBAR_COLLAPSING, 'true');
95
92
  const updatedLeftSidebarState = {
96
93
  isLeftSidebarCollapsed: true,
@@ -101,8 +98,9 @@ export const SidebarResizeController = ({
101
98
  flyoutLockCount,
102
99
  isFixed
103
100
  };
104
- setLeftSidebarState(updatedLeftSidebarState); // onTransitionEnd isn't triggered when a user prefers reduced motion
101
+ setLeftSidebarState(updatedLeftSidebarState);
105
102
 
103
+ // onTransitionEnd isn't triggered when a user prefers reduced motion
106
104
  if (collapseWithoutTransition || isReducedMotion()) {
107
105
  handleDataAttributesAndCb(onCollapse, true, updatedLeftSidebarState);
108
106
  }
@@ -19,7 +19,6 @@ export const useSkipLink = (id, skipLinkTitle) => {
19
19
  skipLinkTitle
20
20
  });
21
21
  }
22
-
23
22
  return () => {
24
23
  unregisterSkipLink(id);
25
24
  };
@@ -1,22 +1,20 @@
1
1
  import React, { useRef, useState } from 'react';
2
2
  import { PAGE_LAYOUT_SLOT_SELECTOR } from '../common/constants';
3
3
  import { SkipLinksContext } from './skip-link-context';
4
-
5
4
  const byDOMOrder = (a, b) => {
6
5
  var _a$listIndex, _b$listIndex;
7
-
8
6
  const elems = Array.from(document.querySelectorAll(`[${PAGE_LAYOUT_SLOT_SELECTOR}]`));
9
7
  const elemA = document.getElementById(a.id);
10
8
  const elemB = document.getElementById(b.id);
11
9
  const indexA = (_a$listIndex = a.listIndex) !== null && _a$listIndex !== void 0 ? _a$listIndex : elems.indexOf(elemA);
12
10
  const indexB = (_b$listIndex = b.listIndex) !== null && _b$listIndex !== void 0 ? _b$listIndex : elems.indexOf(elemB);
11
+
13
12
  /**
14
13
  * If they are tied it is because one (or both) is
15
14
  * a custom skiplink with a set index.
16
15
  *
17
16
  * Give the custom skiplink priority.
18
17
  */
19
-
20
18
  if (indexA === indexB) {
21
19
  if (a.listIndex !== undefined) {
22
20
  return -1;
@@ -24,11 +22,10 @@ const byDOMOrder = (a, b) => {
24
22
  return 1;
25
23
  }
26
24
  }
27
-
28
25
  return indexA - indexB;
29
- }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
30
-
26
+ };
31
27
 
28
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
32
29
  export const SkipLinksController = ({
33
30
  children
34
31
  }) => {
@@ -41,7 +38,6 @@ export const SkipLinksController = ({
41
38
  }) => id === skipLinkData.id)) {
42
39
  return oldLinks;
43
40
  }
44
-
45
41
  return [...oldLinks, skipLinkData].sort(byDOMOrder);
46
42
  });
47
43
  });
@@ -1,21 +1,20 @@
1
1
  import { mergeGridStateIntoStorage, removeFromGridStateInStorage } from '../common/utils';
2
-
3
2
  const publishGridState = gridState => {
4
3
  Object.entries(gridState).forEach(([slotName, value]) => {
5
4
  if (!value) {
6
5
  document.documentElement.style.removeProperty(`--${slotName}`);
7
6
  removeFromGridStateInStorage('gridState', slotName);
8
7
  return;
9
- } //Update the css variable
8
+ }
10
9
 
10
+ //Update the css variable
11
+ document.documentElement.style.setProperty(`--${slotName}`, `${value}px`);
11
12
 
12
- document.documentElement.style.setProperty(`--${slotName}`, `${value}px`); // also update state in local storage so that
13
+ // also update state in local storage so that
13
14
  // it persists across page refresh, across tabs etc
14
-
15
15
  mergeGridStateIntoStorage('gridState', {
16
16
  [slotName]: value
17
17
  });
18
18
  });
19
19
  };
20
-
21
20
  export default publishGridState;
@@ -1,5 +1,4 @@
1
1
  import { useEffect } from 'react';
2
-
3
2
  function useUpdateCssVar(cssVar, value) {
4
3
  useEffect(() => {
5
4
  document.documentElement.style.setProperty(`--${cssVar}`, `${value}px`);
@@ -8,5 +7,4 @@ function useUpdateCssVar(cssVar, value) {
8
7
  };
9
8
  }, [cssVar, value]);
10
9
  }
11
-
12
10
  export default useUpdateCssVar;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/page-layout",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "sideEffects": false
5
5
  }
@@ -6,8 +6,9 @@ export var VAR_RIGHT_PANEL_WIDTH = 'rightPanelWidth';
6
6
  export var VAR_TOP_NAVIGATION_HEIGHT = 'topNavigationHeight';
7
7
  export var VAR_BANNER_HEIGHT = 'bannerHeight';
8
8
  export var VAR_LEFT_SIDEBAR_FLYOUT = 'leftSidebarFlyoutWidth';
9
- export var DIMENSIONS = [VAR_LEFT_PANEL_WIDTH, VAR_RIGHT_PANEL_WIDTH, VAR_BANNER_HEIGHT, VAR_TOP_NAVIGATION_HEIGHT, VAR_LEFT_SIDEBAR_WIDTH, VAR_RIGHT_SIDEBAR_WIDTH]; // Grid area names
9
+ export var DIMENSIONS = [VAR_LEFT_PANEL_WIDTH, VAR_RIGHT_PANEL_WIDTH, VAR_BANNER_HEIGHT, VAR_TOP_NAVIGATION_HEIGHT, VAR_LEFT_SIDEBAR_WIDTH, VAR_RIGHT_SIDEBAR_WIDTH];
10
10
 
11
+ // Grid area names
11
12
  export var LEFT_PANEL = 'left-panel';
12
13
  export var RIGHT_PANEL = 'right-panel';
13
14
  export var BANNER = 'banner';
@@ -15,15 +16,17 @@ export var TOP_NAVIGATION = 'top-navigation';
15
16
  export var CONTENT = 'content';
16
17
  export var MAIN = 'main';
17
18
  export var LEFT_SIDEBAR = 'left-sidebar';
18
- export var RIGHT_SIDEBAR = 'right-sidebar'; // Default slot dimension values
19
+ export var RIGHT_SIDEBAR = 'right-sidebar';
19
20
 
21
+ // Default slot dimension values
20
22
  export var DEFAULT_BANNER_HEIGHT = 56;
21
23
  export var DEFAULT_TOP_NAVIGATION_HEIGHT = 56;
22
24
  export var DEFAULT_LEFT_SIDEBAR_WIDTH = 240;
23
25
  export var DEFAULT_RIGHT_SIDEBAR_WIDTH = 280;
24
26
  export var DEFAULT_RIGHT_PANEL_WIDTH = 368;
25
- export var DEFAULT_LEFT_PANEL_WIDTH = 368; // Other constants
27
+ export var DEFAULT_LEFT_PANEL_WIDTH = 368;
26
28
 
29
+ // Other constants
27
30
  export var COLLAPSED_LEFT_SIDEBAR_WIDTH = 20;
28
31
  export var MIN_LEFT_SIDEBAR_WIDTH = 80;
29
32
  export var DEFAULT_LEFT_SIDEBAR_FLYOUT_WIDTH = 240;
@@ -31,8 +34,9 @@ export var MIN_LEFT_SIDEBAR_DRAG_THRESHOLD = 200;
31
34
  export var TRANSITION_DURATION = 300;
32
35
  export var FLYOUT_DELAY = 200;
33
36
  export var LEFT_SIDEBAR_EXPANDED_WIDTH = 'expandedLeftSidebarWidth';
34
- export var PAGE_LAYOUT_LS_KEY = 'DS_PAGE_LAYOUT_UI_STATE'; // Data attributes
37
+ export var PAGE_LAYOUT_LS_KEY = 'DS_PAGE_LAYOUT_UI_STATE';
35
38
 
39
+ // Data attributes
36
40
  export var IS_SIDEBAR_DRAGGING = 'data-is-sidebar-dragging';
37
41
  export var IS_SIDEBAR_COLLAPSING = 'data-is-sidebar-collapsing';
38
42
  export var IS_FLYOUT_OPEN = 'data-is-flyout-open';
@@ -1,22 +1,18 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { IS_SIDEBAR_COLLAPSING } from '../constants';
4
-
5
4
  var getIsCollapsing = function getIsCollapsing() {
6
5
  // SSR bail-out because document is undefined on the server
7
6
  if (typeof document === 'undefined') {
8
7
  return false;
9
8
  }
10
-
11
9
  return document.documentElement.getAttribute(IS_SIDEBAR_COLLAPSING) === 'true';
12
10
  };
13
-
14
11
  var useIsSidebarCollapsing = function useIsSidebarCollapsing() {
15
12
  var _useState = useState(getIsCollapsing),
16
- _useState2 = _slicedToArray(_useState, 2),
17
- isCollapsing = _useState2[0],
18
- setIsCollapsing = _useState2[1];
19
-
13
+ _useState2 = _slicedToArray(_useState, 2),
14
+ isCollapsing = _useState2[0],
15
+ setIsCollapsing = _useState2[1];
20
16
  useEffect(function () {
21
17
  var observer = new MutationObserver(function () {
22
18
  setIsCollapsing(getIsCollapsing);
@@ -30,5 +26,4 @@ var useIsSidebarCollapsing = function useIsSidebarCollapsing() {
30
26
  }, []);
31
27
  return isCollapsing;
32
28
  };
33
-
34
29
  export default useIsSidebarCollapsing;
@@ -1,22 +1,18 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { IS_SIDEBAR_DRAGGING } from '../constants';
4
-
5
4
  var getIsDragging = function getIsDragging() {
6
5
  // SSR bail-out because document is undefined on the server
7
6
  if (typeof document === 'undefined') {
8
7
  return false;
9
8
  }
10
-
11
9
  return document.documentElement.getAttribute(IS_SIDEBAR_DRAGGING) === 'true';
12
10
  };
13
-
14
11
  var useIsSidebarDragging = function useIsSidebarDragging() {
15
12
  var _useState = useState(getIsDragging),
16
- _useState2 = _slicedToArray(_useState, 2),
17
- isDragging = _useState2[0],
18
- setIsDragging = _useState2[1];
19
-
13
+ _useState2 = _slicedToArray(_useState, 2),
14
+ isDragging = _useState2[0],
15
+ setIsDragging = _useState2[1];
20
16
  useEffect(function () {
21
17
  var observer = new MutationObserver(function () {
22
18
  setIsDragging(getIsDragging);
@@ -30,5 +26,4 @@ var useIsSidebarDragging = function useIsSidebarDragging() {
30
26
  }, []);
31
27
  return isDragging;
32
28
  };
33
-
34
29
  export default useIsSidebarDragging;
@@ -13,13 +13,12 @@ var isLocalStorageSupported = function isLocalStorageSupported() {
13
13
  return false;
14
14
  }
15
15
  };
16
-
17
16
  var safeLocalStorage = function safeLocalStorage() {
18
17
  if (isLocalStorageSupported()) {
19
18
  return localStorage;
20
- } // Returning a mock object here in the case that this is run in SSR mode
21
-
19
+ }
22
20
 
21
+ // Returning a mock object here in the case that this is run in SSR mode
23
22
  if (typeof window === 'undefined') {
24
23
  return {
25
24
  getItem: function getItem(_key) {
@@ -37,24 +36,19 @@ var safeLocalStorage = function safeLocalStorage() {
37
36
  key: function key(_index) {
38
37
  return null;
39
38
  },
40
-
41
39
  get length() {
42
40
  return 0;
43
41
  }
44
-
45
42
  };
46
43
  }
47
-
48
44
  if (window.__localStorageFallback && Object.keys(window.__localStorageFallback).length !== 0) {
49
45
  return window.__localStorageFallback;
50
46
  }
51
-
52
47
  var storageAPI = {
53
48
  getItem: function getItem(key) {
54
49
  if (window.__localStorageFallback.hasOwnProperty(key)) {
55
50
  return window.__localStorageFallback[key];
56
51
  }
57
-
58
52
  return null;
59
53
  },
60
54
  setItem: function setItem(key, value) {
@@ -70,18 +64,14 @@ var safeLocalStorage = function safeLocalStorage() {
70
64
  }
71
65
  }
72
66
  },
73
-
74
67
  get length() {
75
68
  if (!window.__localStorageFallback) {
76
69
  return 0;
77
70
  }
78
-
79
71
  return Object.keys(window.__localStorageFallback).length;
80
72
  }
81
-
82
73
  };
83
74
  window.__localStorageFallback = Object.create(storageAPI);
84
75
  return window.__localStorageFallback;
85
76
  };
86
-
87
77
  export default safeLocalStorage;
@@ -1,85 +1,63 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
-
4
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
-
6
4
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
-
8
5
  import { DEFAULT_LEFT_SIDEBAR_WIDTH, DIMENSIONS, LEFT_PANEL_WIDTH, PAGE_LAYOUT_LS_KEY, PAGE_LAYOUT_SLOT_SELECTOR } from './constants';
9
6
  import safeLocalStorage from './safe-local-storage';
10
7
  var emptyGridState = DIMENSIONS.reduce(function (acc, currentValue) {
11
8
  return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, currentValue, 0));
12
9
  }, {});
13
-
14
10
  var mergeGridStateIntoStorage = function mergeGridStateIntoStorage(key, value) {
15
11
  var storageValue = JSON.parse(safeLocalStorage().getItem(PAGE_LAYOUT_LS_KEY) || '{}');
16
-
17
12
  if (value !== null && _typeof(value) === 'object') {
18
13
  storageValue[key] = _objectSpread(_objectSpread({}, storageValue[key]), value);
19
14
  } else {
20
15
  storageValue[key] = value;
21
16
  }
22
-
23
17
  safeLocalStorage().setItem(PAGE_LAYOUT_LS_KEY, JSON.stringify(storageValue));
24
18
  };
25
-
26
19
  var getGridStateFromStorage = function getGridStateFromStorage(key) {
27
20
  var storageValue = JSON.parse(safeLocalStorage().getItem(PAGE_LAYOUT_LS_KEY) || '{}');
28
21
  return storageValue[key];
29
22
  };
30
-
31
23
  var removeFromGridStateInStorage = function removeFromGridStateInStorage(key, secondKey) {
32
24
  var storageValue = JSON.parse(safeLocalStorage().getItem(PAGE_LAYOUT_LS_KEY) || '{}');
33
-
34
25
  if (secondKey && storageValue[key]) {
35
26
  delete storageValue[key][secondKey];
36
27
  } else {
37
28
  delete storageValue[key];
38
29
  }
39
-
40
30
  safeLocalStorage().setItem(PAGE_LAYOUT_LS_KEY, JSON.stringify(storageValue));
41
31
  };
42
-
43
32
  var resolveDimension = function resolveDimension(key) {
44
33
  var dimension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
45
34
  var shouldPersist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
46
-
47
35
  if (shouldPersist) {
48
36
  var cachedGridState = getGridStateFromStorage('gridState');
49
37
  return cachedGridState && Object.keys(cachedGridState).length > 0 && cachedGridState[key] ? cachedGridState[key] : dimension;
50
38
  }
51
-
52
39
  return dimension;
53
40
  };
54
-
55
41
  var getLeftPanelWidth = function getLeftPanelWidth() {
56
42
  if (typeof window === 'undefined') {
57
43
  return 0;
58
44
  }
59
-
60
45
  return parseInt(window.getComputedStyle(document.documentElement).getPropertyValue("--".concat(LEFT_PANEL_WIDTH)), 10) || 0;
61
46
  };
62
-
63
47
  var getLeftSidebarPercentage = function getLeftSidebarPercentage(currentWidth, maxWidth) {
64
48
  var total = (currentWidth - DEFAULT_LEFT_SIDEBAR_WIDTH) / (maxWidth - DEFAULT_LEFT_SIDEBAR_WIDTH);
65
-
66
49
  if (total < 0) {
67
50
  return 0;
68
51
  }
69
-
70
52
  if (total > 1) {
71
53
  return 100;
72
54
  }
73
-
74
55
  return Math.floor(total * 100);
75
56
  };
76
-
77
57
  var getPageLayoutSlotSelector = function getPageLayoutSlotSelector(slotName) {
78
58
  return _defineProperty({}, PAGE_LAYOUT_SLOT_SELECTOR, slotName);
79
59
  };
80
-
81
60
  var getPageLayoutSlotCSSSelector = function getPageLayoutSlotCSSSelector(slotName) {
82
61
  return "[".concat(PAGE_LAYOUT_SLOT_SELECTOR, "='").concat(slotName, "']");
83
62
  };
84
-
85
63
  export { emptyGridState, mergeGridStateIntoStorage, getGridStateFromStorage, removeFromGridStateInStorage, resolveDimension, getLeftPanelWidth, getLeftSidebarPercentage, getPageLayoutSlotSelector, getPageLayoutSlotCSSSelector };
@@ -2,12 +2,11 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  var _excluded = ["testId", "isLeftSidebarCollapsed"];
5
-
6
5
  /** @jsx jsx */
6
+
7
7
  import { css, jsx } from '@emotion/react';
8
8
  import { B100, B200 } from '@atlaskit/theme/colors';
9
9
  import { GRAB_AREA_LINE_SELECTOR, GRAB_AREA_SELECTOR } from '../../common/constants';
10
-
11
10
  /**
12
11
  * Determines the color of the grab line.
13
12
  *
@@ -45,26 +44,22 @@ var lineStyles = css({
45
44
  backgroundColor: "var(".concat(varLineColor, ")"),
46
45
  transition: 'background-color 200ms'
47
46
  });
48
-
49
47
  var grabAreaLineSelector = _defineProperty({}, GRAB_AREA_LINE_SELECTOR, true);
50
-
51
- var grabAreaSelector = _defineProperty({}, GRAB_AREA_SELECTOR, true); // TODO: Consider allowing this to be controlled using arrow keys
52
-
53
-
48
+ var grabAreaSelector = _defineProperty({}, GRAB_AREA_SELECTOR, true);
49
+ // TODO: Consider allowing this to be controlled using arrow keys
54
50
  var GrabArea = function GrabArea(_ref) {
55
51
  var testId = _ref.testId,
56
- isLeftSidebarCollapsed = _ref.isLeftSidebarCollapsed,
57
- rest = _objectWithoutProperties(_ref, _excluded);
58
-
52
+ isLeftSidebarCollapsed = _ref.isLeftSidebarCollapsed,
53
+ rest = _objectWithoutProperties(_ref, _excluded);
59
54
  return jsx("button", _extends({}, grabAreaSelector, {
60
55
  "data-testid": testId,
61
56
  type: "button",
62
- css: [grabAreaStyles, isLeftSidebarCollapsed && grabAreaCollapsedStyles] // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
63
-
57
+ css: [grabAreaStyles, isLeftSidebarCollapsed && grabAreaCollapsedStyles]
58
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
64
59
  }, rest), jsx("span", _extends({
65
60
  css: lineStyles
66
61
  }, grabAreaLineSelector)));
67
- }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
68
-
62
+ };
69
63
 
64
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
70
65
  export default GrabArea;