@atlaskit/side-navigation 1.5.1 → 1.5.3
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/dist/cjs/common/styles.js +7 -19
- package/dist/cjs/components/Footer/index.js +11 -19
- package/dist/cjs/components/Header/index.js +15 -33
- package/dist/cjs/components/Item/button-item.js +6 -20
- package/dist/cjs/components/Item/custom-item.js +8 -21
- package/dist/cjs/components/Item/go-back-item.js +13 -28
- package/dist/cjs/components/Item/index.js +0 -6
- package/dist/cjs/components/Item/link-item.js +6 -20
- package/dist/cjs/components/Item/skeleton-item.js +8 -20
- package/dist/cjs/components/LoadingItems/index.js +8 -16
- package/dist/cjs/components/NavigationContent/index.js +3 -15
- package/dist/cjs/components/NavigationContent/styles.js +9 -24
- package/dist/cjs/components/NavigationFooter/index.js +1 -6
- package/dist/cjs/components/NavigationHeader/index.js +1 -6
- package/dist/cjs/components/NestableNavigationContent/context.js +1 -13
- package/dist/cjs/components/NestableNavigationContent/index.js +30 -51
- package/dist/cjs/components/NestableNavigationContent/nesting-motion.js +3 -11
- package/dist/cjs/components/NestingItem/hack-for-ert.js +0 -1
- package/dist/cjs/components/NestingItem/index.js +23 -59
- package/dist/cjs/components/NestingItem/styles.js +0 -8
- package/dist/cjs/components/Section/heading-item.js +3 -12
- package/dist/cjs/components/Section/index.js +0 -4
- package/dist/cjs/components/Section/section.js +3 -15
- package/dist/cjs/components/Section/skeleton-heading-item.js +5 -17
- package/dist/cjs/components/SideNavigation/index.js +6 -8
- package/dist/cjs/components/index.js +0 -12
- package/dist/cjs/components/utils/hooks.js +2 -10
- package/dist/cjs/index.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/common/styles.js +7 -6
- package/dist/es2019/components/Footer/index.js +7 -8
- package/dist/es2019/components/Header/index.js +5 -6
- package/dist/es2019/components/Item/button-item.js +4 -6
- package/dist/es2019/components/Item/custom-item.js +7 -8
- package/dist/es2019/components/Item/go-back-item.js +2 -3
- package/dist/es2019/components/Item/link-item.js +4 -6
- package/dist/es2019/components/Item/skeleton-item.js +9 -11
- package/dist/es2019/components/LoadingItems/index.js +3 -6
- package/dist/es2019/components/NavigationContent/index.js +0 -4
- package/dist/es2019/components/NavigationContent/styles.js +9 -10
- package/dist/es2019/components/NavigationFooter/index.js +2 -3
- package/dist/es2019/components/NavigationHeader/index.js +1 -3
- package/dist/es2019/components/NestableNavigationContent/context.js +1 -8
- package/dist/es2019/components/NestableNavigationContent/index.js +17 -22
- package/dist/es2019/components/NestableNavigationContent/nesting-motion.js +1 -1
- package/dist/es2019/components/NestingItem/index.js +5 -15
- package/dist/es2019/components/NestingItem/styles.js +2 -1
- package/dist/es2019/components/Section/heading-item.js +2 -5
- package/dist/es2019/components/Section/section.js +2 -4
- package/dist/es2019/components/Section/skeleton-heading-item.js +6 -8
- package/dist/es2019/components/SideNavigation/index.js +3 -2
- package/dist/es2019/components/utils/hooks.js +2 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/common/styles.js +7 -10
- package/dist/esm/components/Footer/index.js +11 -12
- package/dist/esm/components/Header/index.js +16 -20
- package/dist/esm/components/Item/button-item.js +6 -9
- package/dist/esm/components/Item/custom-item.js +9 -11
- package/dist/esm/components/Item/go-back-item.js +13 -16
- package/dist/esm/components/Item/link-item.js +6 -9
- package/dist/esm/components/Item/skeleton-item.js +8 -14
- package/dist/esm/components/LoadingItems/index.js +7 -11
- package/dist/esm/components/NavigationContent/index.js +3 -9
- package/dist/esm/components/NavigationContent/styles.js +9 -13
- package/dist/esm/components/NavigationFooter/index.js +2 -3
- package/dist/esm/components/NavigationHeader/index.js +1 -3
- package/dist/esm/components/NestableNavigationContent/context.js +1 -8
- package/dist/esm/components/NestableNavigationContent/index.js +30 -41
- package/dist/esm/components/NestableNavigationContent/nesting-motion.js +4 -7
- package/dist/esm/components/NestingItem/index.js +23 -39
- package/dist/esm/components/NestingItem/styles.js +0 -4
- package/dist/esm/components/Section/heading-item.js +3 -6
- package/dist/esm/components/Section/section.js +3 -5
- package/dist/esm/components/Section/skeleton-heading-item.js +5 -11
- package/dist/esm/components/SideNavigation/index.js +5 -4
- package/dist/esm/components/utils/hooks.js +2 -4
- package/dist/esm/version.json +1 -1
- package/dist/types/components/NavigationContent/styles.d.ts +4 -4
- package/package.json +2 -2
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _react = require("@emotion/react");
|
|
13
|
-
|
|
14
10
|
var _motion = require("@atlaskit/motion");
|
|
15
|
-
|
|
16
11
|
var _context = require("../NestableNavigationContent/context");
|
|
17
|
-
|
|
18
12
|
/** @jsx jsx */
|
|
13
|
+
|
|
19
14
|
var baseMotionStyles = (0, _react.css)({
|
|
20
15
|
position: 'absolute',
|
|
21
16
|
zIndex: 1,
|
|
@@ -27,30 +22,28 @@ var enteringStyles = (0, _react.css)({
|
|
|
27
22
|
position: 'static',
|
|
28
23
|
zIndex: 2
|
|
29
24
|
});
|
|
25
|
+
|
|
30
26
|
/**
|
|
31
27
|
* __Loading items__
|
|
32
28
|
*
|
|
33
29
|
* Loading items conditionally render based on the useShouldNestedElementRender() hook.
|
|
34
30
|
*/
|
|
35
|
-
|
|
36
31
|
var LoadingItems = function LoadingItems(_ref) {
|
|
37
32
|
var children = _ref.children,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
isLoading = _ref.isLoading,
|
|
34
|
+
fallback = _ref.fallback,
|
|
35
|
+
testId = _ref.testId;
|
|
42
36
|
var _useShouldNestedEleme = (0, _context.useShouldNestedElementRender)(),
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
shouldRender = _useShouldNestedEleme.shouldRender;
|
|
45
38
|
if (!shouldRender) {
|
|
46
39
|
return children;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
41
|
return (0, _react.jsx)(_motion.ExitingPersistence, null, (0, _react.jsx)(_motion.FadeIn, {
|
|
50
42
|
key: "loading-section-".concat(isLoading),
|
|
51
43
|
duration: _motion.mediumDurationMs
|
|
52
44
|
}, function (motion, state) {
|
|
53
|
-
return (
|
|
45
|
+
return (
|
|
46
|
+
// eslint-disable-next-line @repo/internal/react/use-primitives
|
|
54
47
|
(0, _react.jsx)("span", (0, _extends2.default)({}, motion, {
|
|
55
48
|
"data-testid": testId && "".concat(testId, "--").concat(state),
|
|
56
49
|
css: [baseMotionStyles, state === 'entering' && enteringStyles]
|
|
@@ -58,6 +51,5 @@ var LoadingItems = function LoadingItems(_ref) {
|
|
|
58
51
|
);
|
|
59
52
|
}));
|
|
60
53
|
};
|
|
61
|
-
|
|
62
54
|
var _default = LoadingItems;
|
|
63
55
|
exports.default = _default;
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("react");
|
|
11
|
-
|
|
12
9
|
var _react2 = require("@emotion/react");
|
|
13
|
-
|
|
14
10
|
var _useScrollbarWidth = _interopRequireDefault(require("@atlaskit/ds-lib/use-scrollbar-width"));
|
|
15
|
-
|
|
16
11
|
var _context = require("../NestableNavigationContent/context");
|
|
17
|
-
|
|
18
12
|
var _styles = require("./styles");
|
|
19
|
-
|
|
20
13
|
/* eslint-disable @repo/internal/react/use-primitives */
|
|
21
|
-
|
|
22
14
|
/** @jsx jsx */
|
|
23
15
|
|
|
24
16
|
/**
|
|
@@ -31,18 +23,14 @@ var _styles = require("./styles");
|
|
|
31
23
|
*/
|
|
32
24
|
var NavigationContent = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
33
25
|
var showTopScrollIndicator = props.showTopScrollIndicator,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
children = props.children,
|
|
27
|
+
testId = props.testId;
|
|
37
28
|
var _useShouldNestedEleme = (0, _context.useShouldNestedElementRender)(),
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
shouldRender = _useShouldNestedEleme.shouldRender;
|
|
40
30
|
var scrollbar = (0, _useScrollbarWidth.default)();
|
|
41
|
-
|
|
42
31
|
if (!shouldRender) {
|
|
43
32
|
return children;
|
|
44
33
|
}
|
|
45
|
-
|
|
46
34
|
var typedRef = ref;
|
|
47
35
|
return (0, _react2.jsx)("div", {
|
|
48
36
|
ref: typedRef,
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.outerContainerCSS = exports.innerContainerCSS = exports.containerCSS = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _colors = require("@atlaskit/theme/colors");
|
|
13
|
-
|
|
14
10
|
var _constants = require("@atlaskit/theme/constants");
|
|
15
|
-
|
|
16
11
|
var _typography = require("@atlaskit/theme/typography");
|
|
17
|
-
|
|
18
12
|
var _constants2 = require("../../common/constants");
|
|
19
|
-
|
|
20
13
|
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; }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
var scrollIndicatorMaskZIndex = 2;
|
|
25
16
|
var scrollIndicatorZIndex = 1;
|
|
26
17
|
var scrollIndicatorHeight = 2;
|
|
@@ -28,14 +19,13 @@ var scrollIndicatorBorderRadius = 1;
|
|
|
28
19
|
var containerPadding = (0, _constants.gridSize)();
|
|
29
20
|
var itemHeadingContentHeight = _typography.headingSizes.h100.lineHeight;
|
|
30
21
|
var skeletonHeadingHeight = containerPadding;
|
|
31
|
-
var skeletonHeadingMarginOffset = 3;
|
|
22
|
+
var skeletonHeadingMarginOffset = 3;
|
|
23
|
+
// Skeleton content is slightly shorter than the real content.
|
|
32
24
|
// Because of that we slightly increase the top margin to offset this so the
|
|
33
25
|
// containing size both real and skeleton always equal approx 30px.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
var skeletonHeadingTopMargin = containerPadding * 2.5 + (itemHeadingContentHeight - skeletonHeadingHeight) - skeletonHeadingMarginOffset;
|
|
27
|
+
// We want to move the entire body up by 3px without affecting the height of the skeleton container.
|
|
37
28
|
var skeletonHeadingBottomMargin = containerPadding * 0.75 + skeletonHeadingMarginOffset;
|
|
38
|
-
|
|
39
29
|
/**
|
|
40
30
|
* This outer container css contains the "real" scroll indicators which are
|
|
41
31
|
* always rendered to the screen.
|
|
@@ -75,15 +65,13 @@ var outerContainerCSS = function outerContainerCSS(opts) {
|
|
|
75
65
|
}
|
|
76
66
|
};
|
|
77
67
|
};
|
|
68
|
+
|
|
78
69
|
/**
|
|
79
70
|
* This inner container css contains the "mask" logic for the scroll indicators.
|
|
80
71
|
* Essentially they cover (mask) the "real" scroll indicators when the user is scrolled
|
|
81
72
|
* to the top or bottom of the container.
|
|
82
73
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
74
|
exports.outerContainerCSS = outerContainerCSS;
|
|
86
|
-
|
|
87
75
|
var innerContainerCSS = function innerContainerCSS(opts) {
|
|
88
76
|
return _objectSpread(_objectSpread({
|
|
89
77
|
display: 'flex',
|
|
@@ -121,22 +109,20 @@ var innerContainerCSS = function innerContainerCSS(opts) {
|
|
|
121
109
|
}
|
|
122
110
|
});
|
|
123
111
|
};
|
|
124
|
-
|
|
125
112
|
exports.innerContainerCSS = innerContainerCSS;
|
|
126
|
-
|
|
127
113
|
var containerCSS = function containerCSS(opts) {
|
|
128
114
|
return {
|
|
129
115
|
// When the scroll indicator is always shown we need to add some padding
|
|
130
116
|
// so the spacing between matches what it would be if the indicator was a "block" element.
|
|
131
117
|
// We use margin here so any child absolutely positioned elements are positioned correctly.
|
|
132
118
|
marginTop: opts.showTopScrollIndicator ? scrollIndicatorHeight : 0,
|
|
133
|
-
marginLeft: "var(--ds-
|
|
134
|
-
marginRight: "var(--ds-
|
|
119
|
+
marginLeft: "var(--ds-space-100, 8px)",
|
|
120
|
+
marginRight: "var(--ds-space-100, 8px)",
|
|
135
121
|
// Enables child absolutely positioned elements to be positioned relative to this element.
|
|
136
122
|
position: 'relative',
|
|
137
123
|
'& [data-ds--menu--heading-item]': {
|
|
138
|
-
marginBottom: "var(--ds-
|
|
139
|
-
marginTop: "var(--ds-
|
|
124
|
+
marginBottom: "var(--ds-space-075, 6px)",
|
|
125
|
+
marginTop: "var(--ds-space-200, 20px)"
|
|
140
126
|
},
|
|
141
127
|
'& [data-ds--menu--skeleton-heading-item]': {
|
|
142
128
|
marginTop: skeletonHeadingTopMargin,
|
|
@@ -144,5 +130,4 @@ var containerCSS = function containerCSS(opts) {
|
|
|
144
130
|
}
|
|
145
131
|
};
|
|
146
132
|
};
|
|
147
|
-
|
|
148
133
|
exports.containerCSS = containerCSS;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("@emotion/react");
|
|
11
|
-
|
|
12
9
|
var _box = _interopRequireDefault(require("@atlaskit/ds-explorations/box"));
|
|
13
|
-
|
|
14
10
|
/** @jsx jsx */
|
|
15
11
|
|
|
16
12
|
/**
|
|
@@ -28,10 +24,9 @@ var NavigationFooter = function NavigationFooter(_ref) {
|
|
|
28
24
|
position: "relative",
|
|
29
25
|
padding: "space.100",
|
|
30
26
|
UNSAFE_style: {
|
|
31
|
-
paddingBottom: "var(--ds-
|
|
27
|
+
paddingBottom: "var(--ds-space-200, 14px)"
|
|
32
28
|
}
|
|
33
29
|
}, children);
|
|
34
30
|
};
|
|
35
|
-
|
|
36
31
|
var _default = NavigationFooter;
|
|
37
32
|
exports.default = _default;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("@emotion/react");
|
|
11
|
-
|
|
12
9
|
var _box = _interopRequireDefault(require("@atlaskit/ds-explorations/box"));
|
|
13
|
-
|
|
14
10
|
/** @jsx jsx */
|
|
15
11
|
|
|
16
12
|
/**
|
|
@@ -28,10 +24,9 @@ var NavigationHeader = function NavigationHeader(props) {
|
|
|
28
24
|
"data-navheader": true,
|
|
29
25
|
padding: "space.100",
|
|
30
26
|
UNSAFE_style: {
|
|
31
|
-
paddingTop: "var(--ds-
|
|
27
|
+
paddingTop: "var(--ds-space-300, 24px)"
|
|
32
28
|
}
|
|
33
29
|
}, children);
|
|
34
30
|
};
|
|
35
|
-
|
|
36
31
|
var _default = NavigationHeader;
|
|
37
32
|
exports.default = _default;
|
|
@@ -4,51 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useShouldNestedElementRender = exports.useNestedContext = exports.NestedContext = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* @internal
|
|
12
10
|
*/
|
|
13
11
|
var NestedContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
14
12
|
exports.NestedContext = NestedContext;
|
|
15
|
-
|
|
16
13
|
var useNestedContext = function useNestedContext() {
|
|
17
14
|
var context = (0, _react.useContext)(NestedContext);
|
|
18
|
-
|
|
19
15
|
if (!context) {
|
|
20
16
|
var error = '';
|
|
21
|
-
|
|
22
17
|
if (process.env.NODE_ENV === 'development') {
|
|
23
18
|
error = "\nTo use a <NestingItem /> it needs to be a descendant of <NestableNavigationContent>.\nYou probably need to replace your <NavigationContent> with <NestableNavigationContent>.\n\nimport { NestableNavigationContent } from '@atlaskit/side-navigation';\n ";
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
throw new Error(error);
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
return context;
|
|
30
23
|
};
|
|
24
|
+
|
|
31
25
|
/**
|
|
32
26
|
* Used by children of the NestableNavigationContent component to see if they should render or not.
|
|
33
27
|
* If `shouldRender` returns `true` - return your nodes.
|
|
34
28
|
* If it returns `false` - either return `null` or `children` if you have children.
|
|
35
29
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
30
|
exports.useNestedContext = useNestedContext;
|
|
39
|
-
|
|
40
31
|
var useShouldNestedElementRender = function useShouldNestedElementRender() {
|
|
41
32
|
var context = (0, _react.useContext)(NestedContext);
|
|
42
|
-
|
|
43
33
|
if (!context) {
|
|
44
34
|
return {
|
|
45
35
|
shouldRender: true
|
|
46
36
|
};
|
|
47
37
|
}
|
|
48
|
-
|
|
49
38
|
return {
|
|
50
39
|
shouldRender: context.currentStackId === context.parentId
|
|
51
40
|
};
|
|
52
41
|
};
|
|
53
|
-
|
|
54
42
|
exports.useShouldNestedElementRender = useShouldNestedElementRender;
|
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.ROOT_ID = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
10
|
var _react = require("react");
|
|
15
|
-
|
|
16
11
|
var _react2 = require("@emotion/react");
|
|
17
|
-
|
|
18
12
|
var _motion = require("@atlaskit/motion");
|
|
19
|
-
|
|
20
13
|
var _Item = require("../Item");
|
|
21
|
-
|
|
22
14
|
var _NestingItem = _interopRequireDefault(require("../NestingItem"));
|
|
23
|
-
|
|
24
15
|
var _hooks = require("../utils/hooks");
|
|
25
|
-
|
|
26
16
|
var _context = require("./context");
|
|
27
|
-
|
|
28
17
|
var _nestingMotion = require("./nesting-motion");
|
|
29
|
-
|
|
30
18
|
/** @jsx jsx */
|
|
19
|
+
|
|
31
20
|
// Named so ERT doesn't pick up the override name as a type.
|
|
21
|
+
|
|
32
22
|
var ROOT_ID = 'ATLASKIT_NESTED_ROOT';
|
|
33
23
|
exports.ROOT_ID = ROOT_ID;
|
|
34
24
|
var nestableNavigationContentStyles = (0, _react2.css)({
|
|
@@ -43,6 +33,7 @@ var nestingRootStyles = (0, _react2.css)({
|
|
|
43
33
|
position: 'absolute',
|
|
44
34
|
flexDirection: 'column'
|
|
45
35
|
});
|
|
36
|
+
|
|
46
37
|
/**
|
|
47
38
|
* __Nestable navigation content__
|
|
48
39
|
*
|
|
@@ -51,49 +42,41 @@ var nestingRootStyles = (0, _react2.css)({
|
|
|
51
42
|
* - [Examples](https://atlassian.design/components/side-navigation/examples#nested-navigation)
|
|
52
43
|
* - [Code](https://atlassian.design/components/side-navigation/code)
|
|
53
44
|
*/
|
|
54
|
-
|
|
55
45
|
var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
56
46
|
var containerRef = (0, _react.useRef)(null);
|
|
57
47
|
var children = props.children,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
testId = props.testId,
|
|
49
|
+
overrides = props.overrides,
|
|
50
|
+
initialStack = props.initialStack,
|
|
51
|
+
onChange = props.onChange,
|
|
52
|
+
onUnknownNest = props.onUnknownNest,
|
|
53
|
+
stack = props.stack;
|
|
65
54
|
var _useState = (0, _react.useState)(stack || initialStack || []),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
56
|
+
committedStack = _useState2[0],
|
|
57
|
+
setCommittedStack = _useState2[1];
|
|
70
58
|
var controlledStack = stack || undefined;
|
|
71
59
|
var currentStackId = committedStack[committedStack.length - 1] || ROOT_ID;
|
|
72
|
-
|
|
73
60
|
var _useState3 = (0, _react.useState)('nesting'),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
62
|
+
transition = _useState4[0],
|
|
63
|
+
setTransition = _useState4[1];
|
|
78
64
|
var backTestId = testId && "".concat(testId, "--go-back-item");
|
|
79
65
|
var renderGoBackItem = overrides && overrides.GoBackItem && overrides.GoBackItem.render ? overrides.GoBackItem.render : function (props) {
|
|
80
66
|
return (0, _react2.jsx)(_Item.GoBackItem, props, "Go back");
|
|
81
67
|
};
|
|
82
|
-
|
|
83
68
|
var _useChildIds = (0, _hooks.useChildIds)(currentStackId, committedStack, onUnknownNest),
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
childIdsRef = _useChildIds.childIdsRef;
|
|
86
70
|
var onNestHandler = (0, _react.useCallback)(function (layerId) {
|
|
87
71
|
onChange && onChange(committedStack.concat(layerId));
|
|
88
|
-
|
|
89
72
|
if (controlledStack) {
|
|
90
73
|
// We are in controlled mode - ignore the steps.
|
|
91
74
|
return;
|
|
92
|
-
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// We need to split the state update into to parts.
|
|
93
78
|
// First: Updating the direction of the motions.
|
|
94
79
|
// Second: Actually updating the stack (which will cause elements to enter & leave).
|
|
95
|
-
|
|
96
|
-
|
|
97
80
|
setTransition('nesting');
|
|
98
81
|
requestAnimationFrame(function () {
|
|
99
82
|
setCommittedStack(function (prev) {
|
|
@@ -104,15 +87,14 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
104
87
|
}, [controlledStack, onChange, committedStack]);
|
|
105
88
|
var onUnNestHandler = (0, _react.useCallback)(function () {
|
|
106
89
|
onChange && onChange(committedStack.slice(0, committedStack.length - 1));
|
|
107
|
-
|
|
108
90
|
if (controlledStack) {
|
|
109
91
|
// We are in controlled mode - ignore the steps.
|
|
110
92
|
return;
|
|
111
|
-
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// We need to split the state update into to parts.
|
|
112
96
|
// First: Updating the direction of the motions.
|
|
113
97
|
// Second: Actually updating the stack (which will cause elements to enter & leave).
|
|
114
|
-
|
|
115
|
-
|
|
116
98
|
setTransition('unnesting');
|
|
117
99
|
requestAnimationFrame(function () {
|
|
118
100
|
setCommittedStack(function (prev) {
|
|
@@ -126,13 +108,12 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
126
108
|
// We aren't in controlled mode - bail out.
|
|
127
109
|
return;
|
|
128
110
|
}
|
|
129
|
-
|
|
130
111
|
if (JSON.stringify(committedStack) === JSON.stringify(controlledStack)) {
|
|
131
112
|
// stacks are equal - do nothing!
|
|
132
113
|
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
114
|
+
}
|
|
135
115
|
|
|
116
|
+
// Controlled prop updated, let's figure out if we're nesting or unnesting.
|
|
136
117
|
if (controlledStack.length < committedStack.length) {
|
|
137
118
|
// We are unnesting (removing from the stack)
|
|
138
119
|
setTransition('unnesting');
|
|
@@ -140,7 +121,6 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
140
121
|
// We are nesting (adding to the stack)
|
|
141
122
|
setTransition('nesting');
|
|
142
123
|
}
|
|
143
|
-
|
|
144
124
|
requestAnimationFrame(function () {
|
|
145
125
|
setCommittedStack(controlledStack);
|
|
146
126
|
});
|
|
@@ -160,23 +140,22 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
160
140
|
childIds: childIdsRef
|
|
161
141
|
};
|
|
162
142
|
}, [currentStackId, backButton, committedStack, onNestHandler, onUnNestHandler, childIdsRef]);
|
|
163
|
-
|
|
164
143
|
var manageFocus = function manageFocus(event) {
|
|
165
144
|
var triggeredByKeyboard = event.nativeEvent.detail === 0;
|
|
166
|
-
|
|
167
145
|
if (triggeredByKeyboard) {
|
|
168
146
|
containerRef.current && containerRef.current.focus();
|
|
169
147
|
}
|
|
170
148
|
};
|
|
171
|
-
|
|
172
|
-
|
|
149
|
+
return (
|
|
150
|
+
// eslint-disable-next-line @repo/internal/react/use-primitives
|
|
173
151
|
(0, _react2.jsx)("div", {
|
|
174
152
|
"data-testid": testId,
|
|
175
153
|
css: nestableNavigationContentStyles,
|
|
176
154
|
ref: containerRef,
|
|
177
155
|
tabIndex: -1,
|
|
178
156
|
onClick: manageFocus
|
|
179
|
-
}, (0, _react2.jsx)(_motion.ExitingPersistence, null, (0, _react2.jsx)(_nestingMotion.NestingMotion
|
|
157
|
+
}, (0, _react2.jsx)(_motion.ExitingPersistence, null, (0, _react2.jsx)(_nestingMotion.NestingMotion
|
|
158
|
+
// Key is needed to have a unique react instance per stack name.
|
|
180
159
|
// This enables us to easily animate it in & out with exiting persistence.
|
|
181
160
|
, {
|
|
182
161
|
key: currentStackId,
|
|
@@ -184,7 +163,8 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
184
163
|
exitTo: transition === 'nesting' ? 'left' : 'right',
|
|
185
164
|
testId: testId && "".concat(testId, "-anim")
|
|
186
165
|
}, function (motion) {
|
|
187
|
-
return (
|
|
166
|
+
return (
|
|
167
|
+
// eslint-disable-next-line @repo/internal/react/use-primitives
|
|
188
168
|
(0, _react2.jsx)("div", (0, _extends2.default)({
|
|
189
169
|
css: nestingRootStyles
|
|
190
170
|
}, motion), (0, _react2.jsx)(_context.NestedContext.Provider, {
|
|
@@ -199,6 +179,5 @@ var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
|
199
179
|
})))
|
|
200
180
|
);
|
|
201
181
|
};
|
|
202
|
-
|
|
203
182
|
var _default = NestableNavigationContent;
|
|
204
183
|
exports.default = _default;
|
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.NestingMotion = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _react = require("@emotion/react");
|
|
13
|
-
|
|
14
10
|
var _motion = require("@atlaskit/motion");
|
|
15
|
-
|
|
16
11
|
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; }
|
|
17
|
-
|
|
18
12
|
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; }
|
|
19
|
-
|
|
20
13
|
/**
|
|
21
14
|
* @internal
|
|
22
15
|
*/
|
|
23
16
|
var NestingMotion = function NestingMotion(props) {
|
|
24
17
|
var children = props.children,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
enterFrom = props.enterFrom,
|
|
19
|
+
exitTo = props.exitTo,
|
|
20
|
+
testId = props.testId;
|
|
28
21
|
return (0, _react.jsx)(_motion.SlideIn, {
|
|
29
22
|
exitTo: exitTo,
|
|
30
23
|
enterFrom: enterFrom,
|
|
@@ -39,5 +32,4 @@ var NestingMotion = function NestingMotion(props) {
|
|
|
39
32
|
}, innerProps));
|
|
40
33
|
});
|
|
41
34
|
};
|
|
42
|
-
|
|
43
35
|
exports.NestingMotion = NestingMotion;
|