@atlaskit/side-navigation 1.1.2
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 +517 -0
- package/LICENSE +13 -0
- package/README.md +16 -0
- package/build/tsconfig.json +17 -0
- package/codemods/0.8.0-change-css-fn-prop.ts +184 -0
- package/codemods/__tests__/0.8.0-change-css-fn-prop.ts +360 -0
- package/codemods/helpers/generic.ts +674 -0
- package/dist/cjs/common/constants.js +10 -0
- package/dist/cjs/common/styles.js +104 -0
- package/dist/cjs/components/Footer/index.js +67 -0
- package/dist/cjs/components/Header/index.js +73 -0
- package/dist/cjs/components/Item/button-item.js +47 -0
- package/dist/cjs/components/Item/custom-item.js +52 -0
- package/dist/cjs/components/Item/go-back-item.js +65 -0
- package/dist/cjs/components/Item/index.js +47 -0
- package/dist/cjs/components/Item/link-item.js +47 -0
- package/dist/cjs/components/Item/skeleton-item.js +43 -0
- package/dist/cjs/components/LoadingItems/index.js +51 -0
- package/dist/cjs/components/NavigationContent/index.js +52 -0
- package/dist/cjs/components/NavigationContent/styles.js +152 -0
- package/dist/cjs/components/NavigationFooter/index.js +27 -0
- package/dist/cjs/components/NavigationHeader/index.js +27 -0
- package/dist/cjs/components/NestableNavigationContent/context.js +51 -0
- package/dist/cjs/components/NestableNavigationContent/index.js +182 -0
- package/dist/cjs/components/NestableNavigationContent/nesting-motion.js +40 -0
- package/dist/cjs/components/NestingItem/hack-for-ert.js +8 -0
- package/dist/cjs/components/NestingItem/index.js +173 -0
- package/dist/cjs/components/NestingItem/styles.js +47 -0
- package/dist/cjs/components/Section/heading-item.js +35 -0
- package/dist/cjs/components/Section/index.js +31 -0
- package/dist/cjs/components/Section/section.js +45 -0
- package/dist/cjs/components/Section/skeleton-heading-item.js +39 -0
- package/dist/cjs/components/SideNavigation/index.js +41 -0
- package/dist/cjs/components/index.js +131 -0
- package/dist/cjs/index.js +131 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/common/constants.js +2 -0
- package/dist/es2019/common/styles.js +78 -0
- package/dist/es2019/components/Footer/index.js +52 -0
- package/dist/es2019/components/Header/index.js +46 -0
- package/dist/es2019/components/Item/button-item.js +25 -0
- package/dist/es2019/components/Item/custom-item.js +31 -0
- package/dist/es2019/components/Item/go-back-item.js +34 -0
- package/dist/es2019/components/Item/index.js +5 -0
- package/dist/es2019/components/Item/link-item.js +25 -0
- package/dist/es2019/components/Item/skeleton-item.js +28 -0
- package/dist/es2019/components/LoadingItems/index.js +38 -0
- package/dist/es2019/components/NavigationContent/index.js +38 -0
- package/dist/es2019/components/NavigationContent/styles.js +120 -0
- package/dist/es2019/components/NavigationFooter/index.js +18 -0
- package/dist/es2019/components/NavigationHeader/index.js +20 -0
- package/dist/es2019/components/NestableNavigationContent/context.js +41 -0
- package/dist/es2019/components/NestableNavigationContent/index.js +148 -0
- package/dist/es2019/components/NestableNavigationContent/nesting-motion.js +21 -0
- package/dist/es2019/components/NestingItem/hack-for-ert.js +1 -0
- package/dist/es2019/components/NestingItem/index.js +128 -0
- package/dist/es2019/components/NestingItem/styles.js +39 -0
- package/dist/es2019/components/Section/heading-item.js +22 -0
- package/dist/es2019/components/Section/index.js +3 -0
- package/dist/es2019/components/Section/section.js +25 -0
- package/dist/es2019/components/Section/skeleton-heading-item.js +24 -0
- package/dist/es2019/components/SideNavigation/index.js +30 -0
- package/dist/es2019/components/index.js +11 -0
- package/dist/es2019/index.js +3 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/common/constants.js +2 -0
- package/dist/esm/common/styles.js +82 -0
- package/dist/esm/components/Footer/index.js +51 -0
- package/dist/esm/components/Header/index.js +50 -0
- package/dist/esm/components/Item/button-item.js +25 -0
- package/dist/esm/components/Item/custom-item.js +31 -0
- package/dist/esm/components/Item/go-back-item.js +41 -0
- package/dist/esm/components/Item/index.js +5 -0
- package/dist/esm/components/Item/link-item.js +25 -0
- package/dist/esm/components/Item/skeleton-item.js +29 -0
- package/dist/esm/components/LoadingItems/index.js +39 -0
- package/dist/esm/components/NavigationContent/index.js +37 -0
- package/dist/esm/components/NavigationContent/styles.js +130 -0
- package/dist/esm/components/NavigationFooter/index.js +17 -0
- package/dist/esm/components/NavigationHeader/index.js +18 -0
- package/dist/esm/components/NestableNavigationContent/context.js +36 -0
- package/dist/esm/components/NestableNavigationContent/index.js +163 -0
- package/dist/esm/components/NestableNavigationContent/nesting-motion.js +28 -0
- package/dist/esm/components/NestingItem/hack-for-ert.js +1 -0
- package/dist/esm/components/NestingItem/index.js +144 -0
- package/dist/esm/components/NestingItem/styles.js +34 -0
- package/dist/esm/components/Section/heading-item.js +21 -0
- package/dist/esm/components/Section/index.js +3 -0
- package/dist/esm/components/Section/section.js +24 -0
- package/dist/esm/components/Section/skeleton-heading-item.js +25 -0
- package/dist/esm/components/SideNavigation/index.js +28 -0
- package/dist/esm/components/index.js +11 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/common/constants.d.ts +2 -0
- package/dist/types/common/styles.d.ts +10 -0
- package/dist/types/components/Footer/index.d.ts +4 -0
- package/dist/types/components/Header/index.d.ts +43 -0
- package/dist/types/components/Item/button-item.d.ts +5 -0
- package/dist/types/components/Item/custom-item.d.ts +13 -0
- package/dist/types/components/Item/go-back-item.d.ts +5 -0
- package/dist/types/components/Item/index.d.ts +10 -0
- package/dist/types/components/Item/link-item.d.ts +5 -0
- package/dist/types/components/Item/skeleton-item.d.ts +4 -0
- package/dist/types/components/LoadingItems/index.d.ts +30 -0
- package/dist/types/components/NavigationContent/index.d.ts +17 -0
- package/dist/types/components/NavigationContent/styles.d.ts +91 -0
- package/dist/types/components/NavigationFooter/index.d.ts +7 -0
- package/dist/types/components/NavigationHeader/index.d.ts +5 -0
- package/dist/types/components/NestableNavigationContent/context.d.ts +20 -0
- package/dist/types/components/NestableNavigationContent/index.d.ts +58 -0
- package/dist/types/components/NestableNavigationContent/nesting-motion.d.ts +18 -0
- package/dist/types/components/NestingItem/hack-for-ert.d.ts +2 -0
- package/dist/types/components/NestingItem/index.d.ts +91 -0
- package/dist/types/components/NestingItem/styles.d.ts +28 -0
- package/dist/types/components/Section/heading-item.d.ts +4 -0
- package/dist/types/components/Section/index.d.ts +6 -0
- package/dist/types/components/Section/section.d.ts +25 -0
- package/dist/types/components/Section/skeleton-heading-item.d.ts +4 -0
- package/dist/types/components/SideNavigation/index.d.ts +23 -0
- package/dist/types/components/index.d.ts +22 -0
- package/dist/types/index.d.ts +4 -0
- package/docs/00-intro.tsx +70 -0
- package/docs/01-side-navigation.tsx +33 -0
- package/docs/02-navigation-header.tsx +39 -0
- package/docs/03-navigation-content.tsx +40 -0
- package/docs/04-nestable-navigation-content.tsx +95 -0
- package/docs/05-navigation-footer.tsx +38 -0
- package/docs/99-loading-states.tsx +95 -0
- package/docs/button-item.tsx +38 -0
- package/docs/custom-item.tsx +45 -0
- package/docs/go-back-item.tsx +31 -0
- package/docs/heading-item.tsx +30 -0
- package/docs/link-item.tsx +39 -0
- package/docs/nesting-item.tsx +52 -0
- package/docs/section.tsx +40 -0
- package/docs/skeleton-heading-item.tsx +30 -0
- package/docs/skeleton-item.tsx +30 -0
- package/package.json +71 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.ROOT_ID = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = require("react");
|
|
15
|
+
|
|
16
|
+
var _core = require("@emotion/core");
|
|
17
|
+
|
|
18
|
+
var _motion = require("@atlaskit/motion");
|
|
19
|
+
|
|
20
|
+
var _Item = require("../Item");
|
|
21
|
+
|
|
22
|
+
var _NestingItem = _interopRequireDefault(require("../NestingItem"));
|
|
23
|
+
|
|
24
|
+
var _context = require("./context");
|
|
25
|
+
|
|
26
|
+
var _nestingMotion = require("./nesting-motion");
|
|
27
|
+
|
|
28
|
+
/** @jsx jsx */
|
|
29
|
+
// Named so ERT doesn't pick up the override name as a type.
|
|
30
|
+
var ROOT_ID = 'ATLASKIT_NESTED_ROOT';
|
|
31
|
+
exports.ROOT_ID = ROOT_ID;
|
|
32
|
+
|
|
33
|
+
var NestableNavigationContent = function NestableNavigationContent(props) {
|
|
34
|
+
var containerRef = (0, _react.useRef)(null);
|
|
35
|
+
var children = props.children,
|
|
36
|
+
testId = props.testId,
|
|
37
|
+
overrides = props.overrides,
|
|
38
|
+
initialStack = props.initialStack,
|
|
39
|
+
onChange = props.onChange,
|
|
40
|
+
stack = props.stack;
|
|
41
|
+
|
|
42
|
+
var _useState = (0, _react.useState)(stack || initialStack || []),
|
|
43
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
44
|
+
committedStack = _useState2[0],
|
|
45
|
+
setCommittedStack = _useState2[1];
|
|
46
|
+
|
|
47
|
+
var controlledStack = stack || undefined;
|
|
48
|
+
var currentStackId = committedStack[committedStack.length - 1] || ROOT_ID;
|
|
49
|
+
|
|
50
|
+
var _useState3 = (0, _react.useState)('nesting'),
|
|
51
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
52
|
+
transition = _useState4[0],
|
|
53
|
+
setTransition = _useState4[1];
|
|
54
|
+
|
|
55
|
+
var backTestId = testId && "".concat(testId, "--go-back-item");
|
|
56
|
+
var renderGoBackItem = overrides && overrides.GoBackItem && overrides.GoBackItem.render ? overrides.GoBackItem.render : function (props) {
|
|
57
|
+
return (0, _core.jsx)(_Item.GoBackItem, props, "Go back");
|
|
58
|
+
};
|
|
59
|
+
var onNestHandler = (0, _react.useCallback)(function (layerId) {
|
|
60
|
+
onChange && onChange(committedStack.concat(layerId));
|
|
61
|
+
|
|
62
|
+
if (controlledStack) {
|
|
63
|
+
// We are in controlled mode - ignore the steps.
|
|
64
|
+
return;
|
|
65
|
+
} // We need to split the state update into to parts.
|
|
66
|
+
// First: Updating the direction of the motions.
|
|
67
|
+
// Second: Actually updating the stack (which will cause elements to enter & leave).
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
setTransition('nesting');
|
|
71
|
+
requestAnimationFrame(function () {
|
|
72
|
+
setCommittedStack(function (prev) {
|
|
73
|
+
var newStack = prev.concat(layerId);
|
|
74
|
+
return newStack;
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}, [controlledStack, onChange, committedStack]);
|
|
78
|
+
var onUnNestHandler = (0, _react.useCallback)(function () {
|
|
79
|
+
onChange && onChange(committedStack.slice(0, committedStack.length - 1));
|
|
80
|
+
|
|
81
|
+
if (controlledStack) {
|
|
82
|
+
// We are in controlled mode - ignore the steps.
|
|
83
|
+
return;
|
|
84
|
+
} // We need to split the state update into to parts.
|
|
85
|
+
// First: Updating the direction of the motions.
|
|
86
|
+
// Second: Actually updating the stack (which will cause elements to enter & leave).
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
setTransition('unnesting');
|
|
90
|
+
requestAnimationFrame(function () {
|
|
91
|
+
setCommittedStack(function (prev) {
|
|
92
|
+
var newStack = prev.slice(0, prev.length - 1);
|
|
93
|
+
return newStack;
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}, [controlledStack, onChange, committedStack]);
|
|
97
|
+
(0, _react.useEffect)(function () {
|
|
98
|
+
if (!controlledStack) {
|
|
99
|
+
// We aren't in controlled mode - bail out.
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (JSON.stringify(committedStack) === JSON.stringify(controlledStack)) {
|
|
104
|
+
// stacks are equal - do nothing!
|
|
105
|
+
return;
|
|
106
|
+
} // Controlled prop updated, let's figure out if we're nesting or unnesting.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if (controlledStack.length < committedStack.length) {
|
|
110
|
+
// We are unnesting (removing from the stack)
|
|
111
|
+
setTransition('unnesting');
|
|
112
|
+
} else {
|
|
113
|
+
// We are nesting (adding to the stack)
|
|
114
|
+
setTransition('nesting');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
requestAnimationFrame(function () {
|
|
118
|
+
setCommittedStack(controlledStack);
|
|
119
|
+
});
|
|
120
|
+
}, [committedStack, controlledStack]);
|
|
121
|
+
var backButton = renderGoBackItem({
|
|
122
|
+
onClick: onUnNestHandler,
|
|
123
|
+
testId: backTestId
|
|
124
|
+
});
|
|
125
|
+
var context = (0, _react.useMemo)(function () {
|
|
126
|
+
return {
|
|
127
|
+
currentStackId: currentStackId,
|
|
128
|
+
backButton: backButton,
|
|
129
|
+
stack: committedStack,
|
|
130
|
+
onNest: onNestHandler,
|
|
131
|
+
onUnNest: onUnNestHandler,
|
|
132
|
+
parentId: ROOT_ID
|
|
133
|
+
};
|
|
134
|
+
}, [onNestHandler, onUnNestHandler, backButton, committedStack, currentStackId]);
|
|
135
|
+
|
|
136
|
+
var manageFocus = function manageFocus(event) {
|
|
137
|
+
var triggeredByKeyboard = event.nativeEvent.detail === 0;
|
|
138
|
+
|
|
139
|
+
if (triggeredByKeyboard) {
|
|
140
|
+
containerRef.current && containerRef.current.focus();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return (0, _core.jsx)("div", {
|
|
145
|
+
"data-testid": testId,
|
|
146
|
+
css: {
|
|
147
|
+
position: 'relative',
|
|
148
|
+
height: '100%',
|
|
149
|
+
outline: 'none'
|
|
150
|
+
},
|
|
151
|
+
ref: containerRef,
|
|
152
|
+
tabIndex: -1,
|
|
153
|
+
onClick: manageFocus
|
|
154
|
+
}, (0, _core.jsx)(_motion.ExitingPersistence, null, (0, _core.jsx)(_nestingMotion.NestingMotion // Key is needed to have a unique react instance per stack name.
|
|
155
|
+
// This enables us to easily animate it in & out with exiting persistence.
|
|
156
|
+
, {
|
|
157
|
+
key: currentStackId,
|
|
158
|
+
enterFrom: transition === 'nesting' ? 'right' : 'left',
|
|
159
|
+
exitTo: transition === 'nesting' ? 'left' : 'right',
|
|
160
|
+
testId: testId && "".concat(testId, "-anim")
|
|
161
|
+
}, function (motion) {
|
|
162
|
+
return (0, _core.jsx)("div", (0, _extends2.default)({
|
|
163
|
+
css: {
|
|
164
|
+
position: 'absolute',
|
|
165
|
+
width: '100%',
|
|
166
|
+
height: '100%',
|
|
167
|
+
display: 'flex',
|
|
168
|
+
flexDirection: 'column'
|
|
169
|
+
}
|
|
170
|
+
}, motion), (0, _core.jsx)(_context.NestedContext.Provider, {
|
|
171
|
+
// This provider is inside the NestingMotion to ensure it keeps a stale
|
|
172
|
+
// reference to the previous value.
|
|
173
|
+
value: context
|
|
174
|
+
}, (0, _core.jsx)(_NestingItem.default, {
|
|
175
|
+
title: "",
|
|
176
|
+
id: ROOT_ID
|
|
177
|
+
}, children)));
|
|
178
|
+
})));
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
var _default = NestableNavigationContent;
|
|
182
|
+
exports.default = _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.NestingMotion = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _core = require("@emotion/core");
|
|
13
|
+
|
|
14
|
+
var _motion = require("@atlaskit/motion");
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
+
|
|
20
|
+
var NestingMotion = function NestingMotion(props) {
|
|
21
|
+
var children = props.children,
|
|
22
|
+
enterFrom = props.enterFrom,
|
|
23
|
+
exitTo = props.exitTo,
|
|
24
|
+
testId = props.testId;
|
|
25
|
+
return (0, _core.jsx)(_motion.SlideIn, {
|
|
26
|
+
exitTo: exitTo,
|
|
27
|
+
enterFrom: enterFrom,
|
|
28
|
+
animationTimingFunction: function animationTimingFunction(_) {
|
|
29
|
+
return _motion.easeOut;
|
|
30
|
+
}
|
|
31
|
+
}, function (innerProps, direction) {
|
|
32
|
+
return children(_objectSpread({
|
|
33
|
+
'data-enter-from': enterFrom,
|
|
34
|
+
'data-exit-to': exitTo,
|
|
35
|
+
'data-testid': testId && "".concat(testId, "-").concat(direction)
|
|
36
|
+
}, innerProps));
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.NestingMotion = NestingMotion;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
+
|
|
18
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
|
+
|
|
20
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
21
|
+
|
|
22
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
23
|
+
|
|
24
|
+
var _core = require("@emotion/core");
|
|
25
|
+
|
|
26
|
+
var _arrowRightCircle = _interopRequireDefault(require("@atlaskit/icon/glyph/arrow-right-circle"));
|
|
27
|
+
|
|
28
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
29
|
+
|
|
30
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
31
|
+
|
|
32
|
+
var _tokens = require("@atlaskit/tokens");
|
|
33
|
+
|
|
34
|
+
var _styles = require("../../common/styles");
|
|
35
|
+
|
|
36
|
+
var _index = require("../index");
|
|
37
|
+
|
|
38
|
+
var _NestableNavigationContent = require("../NestableNavigationContent");
|
|
39
|
+
|
|
40
|
+
var _context = require("../NestableNavigationContent/context");
|
|
41
|
+
|
|
42
|
+
var _styles2 = require("./styles");
|
|
43
|
+
|
|
44
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
|
+
|
|
46
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
47
|
+
|
|
48
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
49
|
+
|
|
50
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* NestingItem will render itself differently depending in what context it is rendered in.
|
|
54
|
+
* When not open - it will render itself as an item.
|
|
55
|
+
* When open - it will render its children.
|
|
56
|
+
*/
|
|
57
|
+
var NestingItem = function NestingItem(props) {
|
|
58
|
+
var children = props.children,
|
|
59
|
+
iconAfter = props.iconAfter,
|
|
60
|
+
title = props.title,
|
|
61
|
+
onClick = props.onClick,
|
|
62
|
+
cssFn = props.cssFn,
|
|
63
|
+
isSelected = props.isSelected,
|
|
64
|
+
id = props.id,
|
|
65
|
+
component = props.component,
|
|
66
|
+
testId = props.testId,
|
|
67
|
+
rest = (0, _objectWithoutProperties2.default)(props, ["children", "iconAfter", "title", "onClick", "cssFn", "isSelected", "id", "component", "testId"]);
|
|
68
|
+
|
|
69
|
+
var _useNestedContext = (0, _context.useNestedContext)(),
|
|
70
|
+
currentStackId = _useNestedContext.currentStackId,
|
|
71
|
+
onNest = _useNestedContext.onNest,
|
|
72
|
+
onUnNest = _useNestedContext.onUnNest,
|
|
73
|
+
contextualBackButton = _useNestedContext.backButton,
|
|
74
|
+
stack = _useNestedContext.stack;
|
|
75
|
+
|
|
76
|
+
var mergedStyles = (0, _styles.overrideStyleFunction)(_styles2.nestingItemStyle, cssFn);
|
|
77
|
+
|
|
78
|
+
var _useState = (0, _react.useState)(false),
|
|
79
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
80
|
+
isInteracted = _useState2[0],
|
|
81
|
+
setIsInteracted = _useState2[1];
|
|
82
|
+
|
|
83
|
+
var backButton = props.overrides && props.overrides.GoBackItem && props.overrides.GoBackItem.render && props.overrides.GoBackItem.render({
|
|
84
|
+
onClick: onUnNest,
|
|
85
|
+
testId: testId && "".concat(testId, "--go-back-item")
|
|
86
|
+
}) || contextualBackButton;
|
|
87
|
+
var context = (0, _react.useMemo)(function () {
|
|
88
|
+
return {
|
|
89
|
+
stack: stack,
|
|
90
|
+
currentStackId: currentStackId,
|
|
91
|
+
onNest: onNest,
|
|
92
|
+
onUnNest: onUnNest,
|
|
93
|
+
backButton: backButton,
|
|
94
|
+
parentId: id
|
|
95
|
+
};
|
|
96
|
+
}, [onNest, onUnNest, backButton, stack, id, currentStackId]);
|
|
97
|
+
|
|
98
|
+
var isNormalClick = function isNormalClick(e) {
|
|
99
|
+
return !(e.button || e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* We want both the on nest handler and the onclick handler to be called.
|
|
103
|
+
* We create a wrapper function to call both.
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
var onClickHandler = (0, _react.useCallback)(function (e) {
|
|
108
|
+
if (isInteracted) {
|
|
109
|
+
// We return early if this has been interacted with because its assumed
|
|
110
|
+
// this will be already exiting - so we don't want to double up the click.
|
|
111
|
+
return;
|
|
112
|
+
} // Avoid a nesting transition if a modifier key is detected during click.
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if (isNormalClick(e)) {
|
|
116
|
+
setIsInteracted(true);
|
|
117
|
+
onNest(id);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
onClick && onClick(e);
|
|
121
|
+
}, [isInteracted, onClick, onNest, id]);
|
|
122
|
+
|
|
123
|
+
if (currentStackId === id) {
|
|
124
|
+
return (0, _core.jsx)(_context.NestedContext.Provider, {
|
|
125
|
+
value: context
|
|
126
|
+
}, stack.length >= 1 && (0, _core.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
|
+
}
|
|
134
|
+
}, backButton), (0, _core.jsx)(_index.NavigationContent, {
|
|
135
|
+
testId: testId,
|
|
136
|
+
showTopScrollIndicator: stack.length >= 1
|
|
137
|
+
}, children));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if ([_NestableNavigationContent.ROOT_ID].concat((0, _toConsumableArray2.default)(stack)).includes(id)) {
|
|
141
|
+
return children;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
var componentProps = _objectSpread(_objectSpread({
|
|
145
|
+
iconAfter: (0, _core.jsx)(_react.Fragment, null, iconAfter ? (0, _core.jsx)("span", {
|
|
146
|
+
"data-custom-icon": true
|
|
147
|
+
}, iconAfter) : null, (0, _core.jsx)("span", {
|
|
148
|
+
"data-right-arrow": true
|
|
149
|
+
}, (0, _core.jsx)(_arrowRightCircle.default, {
|
|
150
|
+
testId: testId && "".concat(testId, "--item--right-arrow"),
|
|
151
|
+
secondaryColor: (0, _tokens.token)('color.background.default', _colors.N10),
|
|
152
|
+
label: ""
|
|
153
|
+
}))),
|
|
154
|
+
onClick: onClickHandler,
|
|
155
|
+
isSelected: isSelected || isInteracted,
|
|
156
|
+
testId: testId && "".concat(testId, "--item")
|
|
157
|
+
}, rest), {}, {
|
|
158
|
+
children: title,
|
|
159
|
+
cssFn: mergedStyles
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
if (component) {
|
|
163
|
+
return (0, _core.jsx)(_index.CustomItem, (0, _extends2.default)({}, componentProps, {
|
|
164
|
+
//@ts-expect-error TODO Fix legit TypeScript 3.9.6 improved inference error
|
|
165
|
+
component: component
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return (0, _core.jsx)(_index.ButtonItem, componentProps);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
var _default = NestingItem;
|
|
173
|
+
exports.default = _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.nestingItemStyle = exports.enabledCSS = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _enabledCSS, _disabledCSS;
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
+
|
|
18
|
+
// exposed for testing purposes
|
|
19
|
+
var enabledCSS = (_enabledCSS = {}, (0, _defineProperty2.default)(_enabledCSS, '&:hover [data-custom-icon]', {
|
|
20
|
+
display: 'none'
|
|
21
|
+
}), (0, _defineProperty2.default)(_enabledCSS, '&:active [data-custom-icon]', {
|
|
22
|
+
display: 'none'
|
|
23
|
+
}), (0, _defineProperty2.default)(_enabledCSS, '&:focus [data-custom-icon]', {
|
|
24
|
+
display: 'none'
|
|
25
|
+
}), (0, _defineProperty2.default)(_enabledCSS, '& [data-custom-icon]', {
|
|
26
|
+
display: 'inherit'
|
|
27
|
+
}), (0, _defineProperty2.default)(_enabledCSS, '&:hover [data-right-arrow]', {
|
|
28
|
+
display: 'inherit'
|
|
29
|
+
}), (0, _defineProperty2.default)(_enabledCSS, '&:active [data-right-arrow]', {
|
|
30
|
+
display: 'inherit'
|
|
31
|
+
}), (0, _defineProperty2.default)(_enabledCSS, '&:focus [data-right-arrow]', {
|
|
32
|
+
display: 'inherit'
|
|
33
|
+
}), (0, _defineProperty2.default)(_enabledCSS, '& [data-right-arrow]', {
|
|
34
|
+
display: 'none'
|
|
35
|
+
}), _enabledCSS);
|
|
36
|
+
exports.enabledCSS = enabledCSS;
|
|
37
|
+
var disabledCSS = (_disabledCSS = {}, (0, _defineProperty2.default)(_disabledCSS, '[data-item-elem-after]', {
|
|
38
|
+
opacity: 0
|
|
39
|
+
}), (0, _defineProperty2.default)(_disabledCSS, '& [data-right-arrow]', {
|
|
40
|
+
display: 'none'
|
|
41
|
+
}), _disabledCSS);
|
|
42
|
+
|
|
43
|
+
var nestingItemStyle = function nestingItemStyle(state) {
|
|
44
|
+
return _objectSpread({}, state.isDisabled ? disabledCSS : enabledCSS);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.nestingItemStyle = nestingItemStyle;
|