@atlaskit/side-navigation 1.3.0 → 1.4.0
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.
- package/CHANGELOG.md +12 -0
- package/codemods/helpers/generic.tsx +10 -12
- package/dist/cjs/components/LoadingItems/index.js +13 -9
- package/dist/cjs/components/NavigationFooter/index.js +5 -5
- package/dist/cjs/components/NavigationHeader/index.js +8 -7
- package/dist/cjs/components/NestableNavigationContent/index.js +25 -15
- package/dist/cjs/components/NestingItem/index.js +19 -10
- package/dist/cjs/components/SideNavigation/index.js +13 -12
- package/dist/cjs/components/utils/hooks.js +48 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/LoadingItems/index.js +14 -10
- package/dist/es2019/components/NavigationFooter/index.js +6 -6
- package/dist/es2019/components/NavigationHeader/index.js +9 -8
- package/dist/es2019/components/NestableNavigationContent/index.js +24 -16
- package/dist/es2019/components/NestingItem/index.js +19 -12
- package/dist/es2019/components/SideNavigation/index.js +14 -13
- package/dist/es2019/components/utils/hooks.js +34 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/LoadingItems/index.js +14 -10
- package/dist/esm/components/NavigationFooter/index.js +6 -6
- package/dist/esm/components/NavigationHeader/index.js +9 -8
- package/dist/esm/components/NestableNavigationContent/index.js +25 -16
- package/dist/esm/components/NestingItem/index.js +19 -12
- package/dist/esm/components/SideNavigation/index.js +14 -13
- package/dist/esm/components/utils/hooks.js +34 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/components/NestableNavigationContent/context.d.ts +2 -1
- package/dist/types/components/NestableNavigationContent/index.d.ts +5 -0
- package/dist/types/components/utils/hooks.d.ts +5 -0
- package/package.json +6 -12
- package/report.api.md +92 -375
- package/dist/types-ts4.0/common/constants.d.ts +0 -2
- package/dist/types-ts4.0/common/styles.d.ts +0 -12
- package/dist/types-ts4.0/components/Footer/index.d.ts +0 -11
- package/dist/types-ts4.0/components/Header/index.d.ts +0 -50
- package/dist/types-ts4.0/components/Item/button-item.d.ts +0 -14
- package/dist/types-ts4.0/components/Item/custom-item.d.ts +0 -14
- package/dist/types-ts4.0/components/Item/go-back-item.d.ts +0 -14
- package/dist/types-ts4.0/components/Item/index.d.ts +0 -10
- package/dist/types-ts4.0/components/Item/link-item.d.ts +0 -16
- package/dist/types-ts4.0/components/Item/skeleton-item.d.ts +0 -13
- package/dist/types-ts4.0/components/LoadingItems/index.d.ts +0 -35
- package/dist/types-ts4.0/components/NavigationContent/index.d.ts +0 -25
- package/dist/types-ts4.0/components/NavigationContent/styles.d.ts +0 -91
- package/dist/types-ts4.0/components/NavigationFooter/index.d.ts +0 -16
- package/dist/types-ts4.0/components/NavigationHeader/index.d.ts +0 -16
- package/dist/types-ts4.0/components/NestableNavigationContent/context.d.ts +0 -23
- package/dist/types-ts4.0/components/NestableNavigationContent/index.d.ts +0 -69
- package/dist/types-ts4.0/components/NestableNavigationContent/nesting-motion.d.ts +0 -22
- package/dist/types-ts4.0/components/NestingItem/hack-for-ert.d.ts +0 -2
- package/dist/types-ts4.0/components/NestingItem/index.d.ts +0 -91
- package/dist/types-ts4.0/components/NestingItem/styles.d.ts +0 -28
- package/dist/types-ts4.0/components/Section/heading-item.d.ts +0 -11
- package/dist/types-ts4.0/components/Section/index.d.ts +0 -6
- package/dist/types-ts4.0/components/Section/section.d.ts +0 -34
- package/dist/types-ts4.0/components/Section/skeleton-heading-item.d.ts +0 -12
- package/dist/types-ts4.0/components/SideNavigation/index.d.ts +0 -32
- package/dist/types-ts4.0/components/index.d.ts +0 -22
- package/dist/types-ts4.0/index.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/side-navigation
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`5c065ba2010`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5c065ba2010) - Improve state management to allow detection of invalid stack state. Add prop `onUnknownNest` to allow handling of invalid stack state.
|
|
8
|
+
|
|
9
|
+
## 1.3.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`5f36f2ce46d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5f36f2ce46d) - Adds a defensive `css()` function wrapping to many of the style calls in the side-navigation package. This is expected to help fix an issue with certain styles in side navigation not appearing if consumed when different versions of `@emotion` are present on the page.
|
|
14
|
+
|
|
3
15
|
## 1.3.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -562,19 +562,17 @@ export function changeImportFor({
|
|
|
562
562
|
.filter((path) => path.node.source.value === oldPackagePath)
|
|
563
563
|
.find(j.ImportSpecifier)
|
|
564
564
|
.nodes()
|
|
565
|
-
.map(
|
|
566
|
-
(specifier
|
|
567
|
-
if (specifier.imported.name !== currentName) {
|
|
568
|
-
return null;
|
|
569
|
-
}
|
|
570
|
-
// If aliased: return the alias
|
|
571
|
-
if (specifier.local && specifier.local.name !== currentName) {
|
|
572
|
-
return specifier.local.name;
|
|
573
|
-
}
|
|
574
|
-
|
|
565
|
+
.map((specifier): Nullable<string> => {
|
|
566
|
+
if (specifier.imported.name !== currentName) {
|
|
575
567
|
return null;
|
|
576
|
-
}
|
|
577
|
-
|
|
568
|
+
}
|
|
569
|
+
// If aliased: return the alias
|
|
570
|
+
if (specifier.local && specifier.local.name !== currentName) {
|
|
571
|
+
return specifier.local.name;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return null;
|
|
575
|
+
})
|
|
578
576
|
.filter(Boolean)[0] || null;
|
|
579
577
|
|
|
580
578
|
base
|
|
@@ -16,12 +16,23 @@ var _motion = require("@atlaskit/motion");
|
|
|
16
16
|
var _context = require("../NestableNavigationContent/context");
|
|
17
17
|
|
|
18
18
|
/** @jsx jsx */
|
|
19
|
-
|
|
19
|
+
var baseMotionStyles = (0, _react.css)({
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
zIndex: 1,
|
|
22
|
+
top: 0,
|
|
23
|
+
right: 0,
|
|
24
|
+
left: 0
|
|
25
|
+
});
|
|
26
|
+
var enteringStyles = (0, _react.css)({
|
|
27
|
+
position: 'static',
|
|
28
|
+
zIndex: 2
|
|
29
|
+
});
|
|
20
30
|
/**
|
|
21
31
|
* __Loading items__
|
|
22
32
|
*
|
|
23
33
|
* Loading items conditionally render based on the useShouldNestedElementRender() hook.
|
|
24
34
|
*/
|
|
35
|
+
|
|
25
36
|
var LoadingItems = function LoadingItems(_ref) {
|
|
26
37
|
var children = _ref.children,
|
|
27
38
|
isLoading = _ref.isLoading,
|
|
@@ -41,14 +52,7 @@ var LoadingItems = function LoadingItems(_ref) {
|
|
|
41
52
|
}, function (motion, state) {
|
|
42
53
|
return (0, _react.jsx)("span", (0, _extends2.default)({}, motion, {
|
|
43
54
|
"data-testid": testId && "".concat(testId, "--").concat(state),
|
|
44
|
-
css:
|
|
45
|
-
// Used to have the exiting section appear above the entering one.
|
|
46
|
-
position: state === 'entering' ? undefined : 'absolute',
|
|
47
|
-
zIndex: state === 'entering' ? 2 : 1,
|
|
48
|
-
top: 0,
|
|
49
|
-
left: 0,
|
|
50
|
-
right: 0
|
|
51
|
-
}
|
|
55
|
+
css: [baseMotionStyles, state === 'entering' && enteringStyles]
|
|
52
56
|
}), isLoading ? fallback : children);
|
|
53
57
|
}));
|
|
54
58
|
};
|
|
@@ -10,11 +10,11 @@ var _react = require("@emotion/react");
|
|
|
10
10
|
var _constants = require("@atlaskit/theme/constants");
|
|
11
11
|
|
|
12
12
|
/** @jsx jsx */
|
|
13
|
-
var
|
|
14
|
-
position: 'relative',
|
|
13
|
+
var footerStyles = (0, _react.css)({
|
|
15
14
|
padding: (0, _constants.gridSize)(),
|
|
16
|
-
paddingBottom: (0, _constants.gridSize)() * 1.75
|
|
17
|
-
|
|
15
|
+
paddingBottom: (0, _constants.gridSize)() * 1.75,
|
|
16
|
+
position: 'relative'
|
|
17
|
+
});
|
|
18
18
|
/**
|
|
19
19
|
* __Navigation footer__
|
|
20
20
|
*
|
|
@@ -27,7 +27,7 @@ var footerCSS = {
|
|
|
27
27
|
var NavigationFooter = function NavigationFooter(_ref) {
|
|
28
28
|
var children = _ref.children;
|
|
29
29
|
return (0, _react.jsx)("div", {
|
|
30
|
-
css:
|
|
30
|
+
css: footerStyles
|
|
31
31
|
}, children);
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -10,7 +10,12 @@ var _react = require("@emotion/react");
|
|
|
10
10
|
var _constants = require("@atlaskit/theme/constants");
|
|
11
11
|
|
|
12
12
|
/** @jsx jsx */
|
|
13
|
-
|
|
13
|
+
var navigationHeaderStyles = (0, _react.css)({
|
|
14
|
+
paddingTop: (0, _constants.gridSize)() * 3,
|
|
15
|
+
paddingRight: (0, _constants.gridSize)(),
|
|
16
|
+
paddingBottom: (0, _constants.gridSize)(),
|
|
17
|
+
paddingLeft: (0, _constants.gridSize)()
|
|
18
|
+
});
|
|
14
19
|
/**
|
|
15
20
|
* __Navigation header__
|
|
16
21
|
*
|
|
@@ -19,16 +24,12 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
19
24
|
* - [Examples](https://atlassian.design/components/side-navigation/examples#header-and-footer)
|
|
20
25
|
* - [Code](https://atlassian.design/components/side-navigation/code)
|
|
21
26
|
*/
|
|
27
|
+
|
|
22
28
|
var NavigationHeader = function NavigationHeader(props) {
|
|
23
29
|
var children = props.children;
|
|
24
30
|
return (0, _react.jsx)("div", {
|
|
25
31
|
"data-navheader": true,
|
|
26
|
-
css:
|
|
27
|
-
paddingTop: (0, _constants.gridSize)() * 3,
|
|
28
|
-
paddingBottom: (0, _constants.gridSize)(),
|
|
29
|
-
paddingLeft: (0, _constants.gridSize)(),
|
|
30
|
-
paddingRight: (0, _constants.gridSize)()
|
|
31
|
-
}
|
|
32
|
+
css: navigationHeaderStyles
|
|
32
33
|
}, children);
|
|
33
34
|
};
|
|
34
35
|
|
|
@@ -21,6 +21,8 @@ var _Item = require("../Item");
|
|
|
21
21
|
|
|
22
22
|
var _NestingItem = _interopRequireDefault(require("../NestingItem"));
|
|
23
23
|
|
|
24
|
+
var _hooks = require("../utils/hooks");
|
|
25
|
+
|
|
24
26
|
var _context = require("./context");
|
|
25
27
|
|
|
26
28
|
var _nestingMotion = require("./nesting-motion");
|
|
@@ -29,7 +31,18 @@ var _nestingMotion = require("./nesting-motion");
|
|
|
29
31
|
// Named so ERT doesn't pick up the override name as a type.
|
|
30
32
|
var ROOT_ID = 'ATLASKIT_NESTED_ROOT';
|
|
31
33
|
exports.ROOT_ID = ROOT_ID;
|
|
32
|
-
|
|
34
|
+
var nestableNavigationContentStyles = (0, _react2.css)({
|
|
35
|
+
height: '100%',
|
|
36
|
+
position: 'relative',
|
|
37
|
+
outline: 'none'
|
|
38
|
+
});
|
|
39
|
+
var nestingRootStyles = (0, _react2.css)({
|
|
40
|
+
display: 'flex',
|
|
41
|
+
width: '100%',
|
|
42
|
+
height: '100%',
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
flexDirection: 'column'
|
|
45
|
+
});
|
|
33
46
|
/**
|
|
34
47
|
* __Nestable navigation content__
|
|
35
48
|
*
|
|
@@ -38,6 +51,7 @@ exports.ROOT_ID = ROOT_ID;
|
|
|
38
51
|
* - [Examples](https://atlassian.design/components/side-navigation/examples#nested-navigation)
|
|
39
52
|
* - [Code](https://atlassian.design/components/side-navigation/code)
|
|
40
53
|
*/
|
|
54
|
+
|
|
41
55
|
var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
42
56
|
var containerRef = (0, _react.useRef)(null);
|
|
43
57
|
var children = props.children,
|
|
@@ -45,6 +59,7 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
45
59
|
overrides = props.overrides,
|
|
46
60
|
initialStack = props.initialStack,
|
|
47
61
|
onChange = props.onChange,
|
|
62
|
+
onUnknownNest = props.onUnknownNest,
|
|
48
63
|
stack = props.stack;
|
|
49
64
|
|
|
50
65
|
var _useState = (0, _react.useState)(stack || initialStack || []),
|
|
@@ -64,6 +79,10 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
64
79
|
var renderGoBackItem = overrides && overrides.GoBackItem && overrides.GoBackItem.render ? overrides.GoBackItem.render : function (props) {
|
|
65
80
|
return (0, _react2.jsx)(_Item.GoBackItem, props, "Go back");
|
|
66
81
|
};
|
|
82
|
+
|
|
83
|
+
var _useChildIds = (0, _hooks.useChildIds)(currentStackId, committedStack, onUnknownNest),
|
|
84
|
+
childIdsRef = _useChildIds.childIdsRef;
|
|
85
|
+
|
|
67
86
|
var onNestHandler = (0, _react.useCallback)(function (layerId) {
|
|
68
87
|
onChange && onChange(committedStack.concat(layerId));
|
|
69
88
|
|
|
@@ -137,9 +156,10 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
137
156
|
stack: committedStack,
|
|
138
157
|
onNest: onNestHandler,
|
|
139
158
|
onUnNest: onUnNestHandler,
|
|
140
|
-
parentId: ROOT_ID
|
|
159
|
+
parentId: ROOT_ID,
|
|
160
|
+
childIds: childIdsRef
|
|
141
161
|
};
|
|
142
|
-
}, [
|
|
162
|
+
}, [currentStackId, backButton, committedStack, onNestHandler, onUnNestHandler, childIdsRef]);
|
|
143
163
|
|
|
144
164
|
var manageFocus = function manageFocus(event) {
|
|
145
165
|
var triggeredByKeyboard = event.nativeEvent.detail === 0;
|
|
@@ -151,11 +171,7 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
151
171
|
|
|
152
172
|
return (0, _react2.jsx)("div", {
|
|
153
173
|
"data-testid": testId,
|
|
154
|
-
css:
|
|
155
|
-
position: 'relative',
|
|
156
|
-
height: '100%',
|
|
157
|
-
outline: 'none'
|
|
158
|
-
},
|
|
174
|
+
css: nestableNavigationContentStyles,
|
|
159
175
|
ref: containerRef,
|
|
160
176
|
tabIndex: -1,
|
|
161
177
|
onClick: manageFocus
|
|
@@ -168,13 +184,7 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
168
184
|
testId: testId && "".concat(testId, "-anim")
|
|
169
185
|
}, function (motion) {
|
|
170
186
|
return (0, _react2.jsx)("div", (0, _extends2.default)({
|
|
171
|
-
css:
|
|
172
|
-
position: 'absolute',
|
|
173
|
-
width: '100%',
|
|
174
|
-
height: '100%',
|
|
175
|
-
display: 'flex',
|
|
176
|
-
flexDirection: 'column'
|
|
177
|
-
}
|
|
187
|
+
css: nestingRootStyles
|
|
178
188
|
}, motion), (0, _react2.jsx)(_context.NestedContext.Provider, {
|
|
179
189
|
// This provider is inside the NestingMotion to ensure it keeps a stale
|
|
180
190
|
// reference to the previous value.
|
|
@@ -37,6 +37,8 @@ var _NestableNavigationContent = require("../NestableNavigationContent");
|
|
|
37
37
|
|
|
38
38
|
var _context = require("../NestableNavigationContent/context");
|
|
39
39
|
|
|
40
|
+
var _hooks = require("../utils/hooks");
|
|
41
|
+
|
|
40
42
|
var _styles2 = require("./styles");
|
|
41
43
|
|
|
42
44
|
var _excluded = ["children", "iconAfter", "title", "onClick", "cssFn", "isSelected", "id", "component", "testId"];
|
|
@@ -49,11 +51,19 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
49
51
|
|
|
50
52
|
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) { (0, _defineProperty2.default)(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; }
|
|
51
53
|
|
|
54
|
+
var nestingItemStyles = (0, _react2.css)({
|
|
55
|
+
marginRight: (0, _constants.gridSize)(),
|
|
56
|
+
marginLeft: (0, _constants.gridSize)(),
|
|
57
|
+
// This padding bottom needs to match the section margin inside @atlaskit/menu.
|
|
58
|
+
paddingTop: (0, _constants.gridSize)() * 0.75,
|
|
59
|
+
paddingBottom: (0, _constants.gridSize)() * 0.75
|
|
60
|
+
});
|
|
52
61
|
/**
|
|
53
62
|
* NestingItem will render itself differently depending in what context it is rendered in.
|
|
54
63
|
* When not open - it will render itself as an item.
|
|
55
64
|
* When open - it will render its children.
|
|
56
65
|
*/
|
|
66
|
+
|
|
57
67
|
var NestingItem = function NestingItem(props) {
|
|
58
68
|
var children = props.children,
|
|
59
69
|
iconAfter = props.iconAfter,
|
|
@@ -71,7 +81,8 @@ var NestingItem = function NestingItem(props) {
|
|
|
71
81
|
onNest = _useNestedContext.onNest,
|
|
72
82
|
onUnNest = _useNestedContext.onUnNest,
|
|
73
83
|
contextualBackButton = _useNestedContext.backButton,
|
|
74
|
-
stack = _useNestedContext.stack
|
|
84
|
+
stack = _useNestedContext.stack,
|
|
85
|
+
childIds = _useNestedContext.childIds;
|
|
75
86
|
|
|
76
87
|
var mergedStyles = (0, _styles.overrideStyleFunction)(_styles2.nestingItemStyle, cssFn);
|
|
77
88
|
|
|
@@ -91,9 +102,13 @@ var NestingItem = function NestingItem(props) {
|
|
|
91
102
|
onNest: onNest,
|
|
92
103
|
onUnNest: onUnNest,
|
|
93
104
|
backButton: backButton,
|
|
94
|
-
parentId: id
|
|
105
|
+
parentId: id,
|
|
106
|
+
childIds: childIds
|
|
95
107
|
};
|
|
96
|
-
},
|
|
108
|
+
}, // childIds shouldn't change as it's a ref
|
|
109
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
110
|
+
[onNest, onUnNest, backButton, stack, id, currentStackId]);
|
|
111
|
+
(0, _hooks.useChildIdsEffect)(childIds, id);
|
|
97
112
|
|
|
98
113
|
var isNormalClick = function isNormalClick(e) {
|
|
99
114
|
return !(e.button || e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
@@ -124,13 +139,7 @@ var NestingItem = function NestingItem(props) {
|
|
|
124
139
|
return (0, _react2.jsx)(_context.NestedContext.Provider, {
|
|
125
140
|
value: context
|
|
126
141
|
}, stack.length >= 1 && (0, _react2.jsx)("div", {
|
|
127
|
-
css:
|
|
128
|
-
marginLeft: (0, _constants.gridSize)(),
|
|
129
|
-
marginRight: (0, _constants.gridSize)(),
|
|
130
|
-
// This padding bottom needs to match the section margin inside @atlaskit/menu.
|
|
131
|
-
paddingTop: (0, _constants.gridSize)() * 0.75,
|
|
132
|
-
paddingBottom: (0, _constants.gridSize)() * 0.75
|
|
133
|
-
}
|
|
142
|
+
css: nestingItemStyles
|
|
134
143
|
}, backButton), (0, _react2.jsx)(_index.NavigationContent, {
|
|
135
144
|
testId: testId,
|
|
136
145
|
showTopScrollIndicator: stack.length >= 1
|
|
@@ -14,7 +14,17 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
14
14
|
var _constants = require("@atlaskit/theme/constants");
|
|
15
15
|
|
|
16
16
|
/** @jsx jsx */
|
|
17
|
-
|
|
17
|
+
var sideNavStyles = (0, _react2.css)({
|
|
18
|
+
display: 'flex',
|
|
19
|
+
width: '100%',
|
|
20
|
+
minWidth: (0, _constants.gridSize)() * 30,
|
|
21
|
+
height: '100%',
|
|
22
|
+
position: 'relative',
|
|
23
|
+
flexDirection: 'column',
|
|
24
|
+
backgroundColor: "var(--ds-surface, ".concat(_colors.N10, ")"),
|
|
25
|
+
color: "var(--ds-text-subtle, ".concat(_colors.N500, ")"),
|
|
26
|
+
overflow: 'hidden'
|
|
27
|
+
});
|
|
18
28
|
/**
|
|
19
29
|
* __Side navigation__
|
|
20
30
|
*
|
|
@@ -24,6 +34,7 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
24
34
|
* - [Code](https://atlassian.design/components/side-navigation/code)
|
|
25
35
|
* - [Usage](https://atlassian.design/components/side-navigation/usage)
|
|
26
36
|
*/
|
|
37
|
+
|
|
27
38
|
var SideNavigation = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
28
39
|
var children = props.children,
|
|
29
40
|
testId = props.testId,
|
|
@@ -32,17 +43,7 @@ var SideNavigation = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
32
43
|
ref: ref,
|
|
33
44
|
"data-testid": testId,
|
|
34
45
|
"aria-label": label,
|
|
35
|
-
css:
|
|
36
|
-
width: '100%',
|
|
37
|
-
height: '100%',
|
|
38
|
-
color: "var(--ds-text-subtle, ".concat(_colors.N500, ")"),
|
|
39
|
-
minWidth: (0, _constants.gridSize)() * 30,
|
|
40
|
-
backgroundColor: "var(--ds-surface, ".concat(_colors.N10, ")"),
|
|
41
|
-
position: 'relative',
|
|
42
|
-
display: 'flex',
|
|
43
|
-
flexDirection: 'column',
|
|
44
|
-
overflow: 'hidden'
|
|
45
|
-
}
|
|
46
|
+
css: sideNavStyles
|
|
46
47
|
}, children);
|
|
47
48
|
});
|
|
48
49
|
var _default = SideNavigation;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useChildIdsEffect = exports.useChildIds = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _NestableNavigationContent = require("../NestableNavigationContent");
|
|
11
|
+
|
|
12
|
+
var useChildIds = function useChildIds(currentStackId, committedStack, onUnknownNest) {
|
|
13
|
+
var childIdsRef = (0, _react.useRef)(new Set());
|
|
14
|
+
(0, _react.useEffect)(function () {
|
|
15
|
+
// we are holding navigation item IDs in childIdsRef
|
|
16
|
+
// check if the current displayed nav item (currentStackId) is in childIdsRef. if it's not, this means it's undefined
|
|
17
|
+
if (currentStackId === _NestableNavigationContent.ROOT_ID || !childIdsRef.current.size || childIdsRef.current.has(currentStackId) || !onUnknownNest) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
onUnknownNest(committedStack || [currentStackId]);
|
|
22
|
+
}, [currentStackId, committedStack, onUnknownNest]);
|
|
23
|
+
return {
|
|
24
|
+
childIdsRef: childIdsRef
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.useChildIds = useChildIds;
|
|
29
|
+
|
|
30
|
+
var useChildIdsEffect = function useChildIdsEffect(childIds, id) {
|
|
31
|
+
(0, _react.useEffect)(function () {
|
|
32
|
+
if (!childIds || !childIds.current) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!childIds.current.has(id)) {
|
|
37
|
+
childIds.current.add(id);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return function () {
|
|
41
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
+
childIds.current.delete(id);
|
|
43
|
+
}; // childIds shouldn't change as it's a ref
|
|
44
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
+
}, [id]);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.useChildIdsEffect = useChildIdsEffect;
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { jsx } from '@emotion/react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
5
|
import { ExitingPersistence, FadeIn, mediumDurationMs } from '@atlaskit/motion';
|
|
6
6
|
import { useShouldNestedElementRender } from '../NestableNavigationContent/context';
|
|
7
|
-
|
|
7
|
+
const baseMotionStyles = css({
|
|
8
|
+
position: 'absolute',
|
|
9
|
+
zIndex: 1,
|
|
10
|
+
top: 0,
|
|
11
|
+
right: 0,
|
|
12
|
+
left: 0
|
|
13
|
+
});
|
|
14
|
+
const enteringStyles = css({
|
|
15
|
+
position: 'static',
|
|
16
|
+
zIndex: 2
|
|
17
|
+
});
|
|
8
18
|
/**
|
|
9
19
|
* __Loading items__
|
|
10
20
|
*
|
|
11
21
|
* Loading items conditionally render based on the useShouldNestedElementRender() hook.
|
|
12
22
|
*/
|
|
23
|
+
|
|
13
24
|
const LoadingItems = ({
|
|
14
25
|
children,
|
|
15
26
|
isLoading,
|
|
@@ -29,14 +40,7 @@ const LoadingItems = ({
|
|
|
29
40
|
duration: mediumDurationMs
|
|
30
41
|
}, (motion, state) => jsx("span", _extends({}, motion, {
|
|
31
42
|
"data-testid": testId && `${testId}--${state}`,
|
|
32
|
-
css:
|
|
33
|
-
// Used to have the exiting section appear above the entering one.
|
|
34
|
-
position: state === 'entering' ? undefined : 'absolute',
|
|
35
|
-
zIndex: state === 'entering' ? 2 : 1,
|
|
36
|
-
top: 0,
|
|
37
|
-
left: 0,
|
|
38
|
-
right: 0
|
|
39
|
-
}
|
|
43
|
+
css: [baseMotionStyles, state === 'entering' && enteringStyles]
|
|
40
44
|
}), isLoading ? fallback : children)));
|
|
41
45
|
};
|
|
42
46
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
3
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
4
|
-
const
|
|
5
|
-
position: 'relative',
|
|
4
|
+
const footerStyles = css({
|
|
6
5
|
padding: gridSize(),
|
|
7
|
-
paddingBottom: gridSize() * 1.75
|
|
8
|
-
|
|
6
|
+
paddingBottom: gridSize() * 1.75,
|
|
7
|
+
position: 'relative'
|
|
8
|
+
});
|
|
9
9
|
/**
|
|
10
10
|
* __Navigation footer__
|
|
11
11
|
*
|
|
@@ -19,7 +19,7 @@ const NavigationFooter = ({
|
|
|
19
19
|
children
|
|
20
20
|
}) => {
|
|
21
21
|
return jsx("div", {
|
|
22
|
-
css:
|
|
22
|
+
css: footerStyles
|
|
23
23
|
}, children);
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
3
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
4
|
-
|
|
4
|
+
const navigationHeaderStyles = css({
|
|
5
|
+
paddingTop: gridSize() * 3,
|
|
6
|
+
paddingRight: gridSize(),
|
|
7
|
+
paddingBottom: gridSize(),
|
|
8
|
+
paddingLeft: gridSize()
|
|
9
|
+
});
|
|
5
10
|
/**
|
|
6
11
|
* __Navigation header__
|
|
7
12
|
*
|
|
@@ -10,18 +15,14 @@ import { gridSize } from '@atlaskit/theme/constants';
|
|
|
10
15
|
* - [Examples](https://atlassian.design/components/side-navigation/examples#header-and-footer)
|
|
11
16
|
* - [Code](https://atlassian.design/components/side-navigation/code)
|
|
12
17
|
*/
|
|
18
|
+
|
|
13
19
|
const NavigationHeader = props => {
|
|
14
20
|
const {
|
|
15
21
|
children
|
|
16
22
|
} = props;
|
|
17
23
|
return jsx("div", {
|
|
18
24
|
"data-navheader": true,
|
|
19
|
-
css:
|
|
20
|
-
paddingTop: gridSize() * 3,
|
|
21
|
-
paddingBottom: gridSize(),
|
|
22
|
-
paddingLeft: gridSize(),
|
|
23
|
-
paddingRight: gridSize()
|
|
24
|
-
}
|
|
25
|
+
css: navigationHeaderStyles
|
|
25
26
|
}, children);
|
|
26
27
|
};
|
|
27
28
|
|
|
@@ -2,15 +2,27 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
-
import { jsx } from '@emotion/react';
|
|
5
|
+
import { css, jsx } from '@emotion/react';
|
|
6
6
|
import { ExitingPersistence } from '@atlaskit/motion';
|
|
7
7
|
import { GoBackItem as GoBackButton } from '../Item';
|
|
8
8
|
import { default as NestingItem } from '../NestingItem';
|
|
9
|
+
import { useChildIds } from '../utils/hooks';
|
|
9
10
|
import { NestedContext } from './context';
|
|
10
11
|
import { NestingMotion } from './nesting-motion'; // Named so ERT doesn't pick up the override name as a type.
|
|
11
12
|
|
|
12
13
|
export const ROOT_ID = 'ATLASKIT_NESTED_ROOT';
|
|
13
|
-
|
|
14
|
+
const nestableNavigationContentStyles = css({
|
|
15
|
+
height: '100%',
|
|
16
|
+
position: 'relative',
|
|
17
|
+
outline: 'none'
|
|
18
|
+
});
|
|
19
|
+
const nestingRootStyles = css({
|
|
20
|
+
display: 'flex',
|
|
21
|
+
width: '100%',
|
|
22
|
+
height: '100%',
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
flexDirection: 'column'
|
|
25
|
+
});
|
|
14
26
|
/**
|
|
15
27
|
* __Nestable navigation content__
|
|
16
28
|
*
|
|
@@ -19,6 +31,7 @@ export const ROOT_ID = 'ATLASKIT_NESTED_ROOT';
|
|
|
19
31
|
* - [Examples](https://atlassian.design/components/side-navigation/examples#nested-navigation)
|
|
20
32
|
* - [Code](https://atlassian.design/components/side-navigation/code)
|
|
21
33
|
*/
|
|
34
|
+
|
|
22
35
|
const NestableNavigationContent = props => {
|
|
23
36
|
const containerRef = useRef(null);
|
|
24
37
|
const {
|
|
@@ -27,6 +40,7 @@ const NestableNavigationContent = props => {
|
|
|
27
40
|
overrides,
|
|
28
41
|
initialStack,
|
|
29
42
|
onChange,
|
|
43
|
+
onUnknownNest,
|
|
30
44
|
stack
|
|
31
45
|
} = props;
|
|
32
46
|
const [committedStack, setCommittedStack] = useState(stack || initialStack || []);
|
|
@@ -35,6 +49,9 @@ const NestableNavigationContent = props => {
|
|
|
35
49
|
const [transition, setTransition] = useState('nesting');
|
|
36
50
|
const backTestId = testId && `${testId}--go-back-item`;
|
|
37
51
|
const renderGoBackItem = overrides && overrides.GoBackItem && overrides.GoBackItem.render ? overrides.GoBackItem.render : props => jsx(GoBackButton, props, "Go back");
|
|
52
|
+
const {
|
|
53
|
+
childIdsRef
|
|
54
|
+
} = useChildIds(currentStackId, committedStack, onUnknownNest);
|
|
38
55
|
const onNestHandler = useCallback(layerId => {
|
|
39
56
|
onChange && onChange(committedStack.concat(layerId));
|
|
40
57
|
|
|
@@ -107,8 +124,9 @@ const NestableNavigationContent = props => {
|
|
|
107
124
|
stack: committedStack,
|
|
108
125
|
onNest: onNestHandler,
|
|
109
126
|
onUnNest: onUnNestHandler,
|
|
110
|
-
parentId: ROOT_ID
|
|
111
|
-
|
|
127
|
+
parentId: ROOT_ID,
|
|
128
|
+
childIds: childIdsRef
|
|
129
|
+
}), [currentStackId, backButton, committedStack, onNestHandler, onUnNestHandler, childIdsRef]);
|
|
112
130
|
|
|
113
131
|
const manageFocus = event => {
|
|
114
132
|
const triggeredByKeyboard = event.nativeEvent.detail === 0;
|
|
@@ -120,11 +138,7 @@ const NestableNavigationContent = props => {
|
|
|
120
138
|
|
|
121
139
|
return jsx("div", {
|
|
122
140
|
"data-testid": testId,
|
|
123
|
-
css:
|
|
124
|
-
position: 'relative',
|
|
125
|
-
height: '100%',
|
|
126
|
-
outline: 'none'
|
|
127
|
-
},
|
|
141
|
+
css: nestableNavigationContentStyles,
|
|
128
142
|
ref: containerRef,
|
|
129
143
|
tabIndex: -1,
|
|
130
144
|
onClick: manageFocus
|
|
@@ -136,13 +150,7 @@ const NestableNavigationContent = props => {
|
|
|
136
150
|
exitTo: transition === 'nesting' ? 'left' : 'right',
|
|
137
151
|
testId: testId && `${testId}-anim`
|
|
138
152
|
}, motion => jsx("div", _extends({
|
|
139
|
-
css:
|
|
140
|
-
position: 'absolute',
|
|
141
|
-
width: '100%',
|
|
142
|
-
height: '100%',
|
|
143
|
-
display: 'flex',
|
|
144
|
-
flexDirection: 'column'
|
|
145
|
-
}
|
|
153
|
+
css: nestingRootStyles
|
|
146
154
|
}, motion), jsx(NestedContext.Provider, {
|
|
147
155
|
// This provider is inside the NestingMotion to ensure it keeps a stale
|
|
148
156
|
// reference to the previous value.
|