@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,28 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
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) { _defineProperty(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; }
|
|
6
|
+
|
|
7
|
+
/** @jsx jsx */
|
|
8
|
+
import { jsx } from '@emotion/core';
|
|
9
|
+
import { easeOut, SlideIn } from '@atlaskit/motion';
|
|
10
|
+
export var NestingMotion = function NestingMotion(props) {
|
|
11
|
+
var children = props.children,
|
|
12
|
+
enterFrom = props.enterFrom,
|
|
13
|
+
exitTo = props.exitTo,
|
|
14
|
+
testId = props.testId;
|
|
15
|
+
return jsx(SlideIn, {
|
|
16
|
+
exitTo: exitTo,
|
|
17
|
+
enterFrom: enterFrom,
|
|
18
|
+
animationTimingFunction: function animationTimingFunction(_) {
|
|
19
|
+
return easeOut;
|
|
20
|
+
}
|
|
21
|
+
}, function (innerProps, direction) {
|
|
22
|
+
return children(_objectSpread({
|
|
23
|
+
'data-enter-from': enterFrom,
|
|
24
|
+
'data-exit-to': exitTo,
|
|
25
|
+
'data-testid': testId && "".concat(testId, "-").concat(direction)
|
|
26
|
+
}, innerProps));
|
|
27
|
+
});
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (_) {}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
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) { _defineProperty(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; }
|
|
10
|
+
|
|
11
|
+
/** @jsx jsx */
|
|
12
|
+
import React, { Fragment, useCallback, useMemo, useState } from 'react';
|
|
13
|
+
import { jsx } from '@emotion/core';
|
|
14
|
+
import RightArrow from '@atlaskit/icon/glyph/arrow-right-circle';
|
|
15
|
+
import { N10 } from '@atlaskit/theme/colors';
|
|
16
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
17
|
+
import { token } from '@atlaskit/tokens';
|
|
18
|
+
import { overrideStyleFunction } from '../../common/styles';
|
|
19
|
+
import { ButtonItem, CustomItem, NavigationContent } from '../index';
|
|
20
|
+
import { ROOT_ID } from '../NestableNavigationContent';
|
|
21
|
+
import { NestedContext, useNestedContext } from '../NestableNavigationContent/context';
|
|
22
|
+
import { nestingItemStyle } from './styles';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* NestingItem will render itself differently depending in what context it is rendered in.
|
|
26
|
+
* When not open - it will render itself as an item.
|
|
27
|
+
* When open - it will render its children.
|
|
28
|
+
*/
|
|
29
|
+
var NestingItem = function NestingItem(props) {
|
|
30
|
+
var children = props.children,
|
|
31
|
+
iconAfter = props.iconAfter,
|
|
32
|
+
title = props.title,
|
|
33
|
+
onClick = props.onClick,
|
|
34
|
+
cssFn = props.cssFn,
|
|
35
|
+
isSelected = props.isSelected,
|
|
36
|
+
id = props.id,
|
|
37
|
+
component = props.component,
|
|
38
|
+
testId = props.testId,
|
|
39
|
+
rest = _objectWithoutProperties(props, ["children", "iconAfter", "title", "onClick", "cssFn", "isSelected", "id", "component", "testId"]);
|
|
40
|
+
|
|
41
|
+
var _useNestedContext = useNestedContext(),
|
|
42
|
+
currentStackId = _useNestedContext.currentStackId,
|
|
43
|
+
onNest = _useNestedContext.onNest,
|
|
44
|
+
onUnNest = _useNestedContext.onUnNest,
|
|
45
|
+
contextualBackButton = _useNestedContext.backButton,
|
|
46
|
+
stack = _useNestedContext.stack;
|
|
47
|
+
|
|
48
|
+
var mergedStyles = overrideStyleFunction(nestingItemStyle, cssFn);
|
|
49
|
+
|
|
50
|
+
var _useState = useState(false),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
isInteracted = _useState2[0],
|
|
53
|
+
setIsInteracted = _useState2[1];
|
|
54
|
+
|
|
55
|
+
var backButton = props.overrides && props.overrides.GoBackItem && props.overrides.GoBackItem.render && props.overrides.GoBackItem.render({
|
|
56
|
+
onClick: onUnNest,
|
|
57
|
+
testId: testId && "".concat(testId, "--go-back-item")
|
|
58
|
+
}) || contextualBackButton;
|
|
59
|
+
var context = useMemo(function () {
|
|
60
|
+
return {
|
|
61
|
+
stack: stack,
|
|
62
|
+
currentStackId: currentStackId,
|
|
63
|
+
onNest: onNest,
|
|
64
|
+
onUnNest: onUnNest,
|
|
65
|
+
backButton: backButton,
|
|
66
|
+
parentId: id
|
|
67
|
+
};
|
|
68
|
+
}, [onNest, onUnNest, backButton, stack, id, currentStackId]);
|
|
69
|
+
|
|
70
|
+
var isNormalClick = function isNormalClick(e) {
|
|
71
|
+
return !(e.button || e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* We want both the on nest handler and the onclick handler to be called.
|
|
75
|
+
* We create a wrapper function to call both.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
var onClickHandler = useCallback(function (e) {
|
|
80
|
+
if (isInteracted) {
|
|
81
|
+
// We return early if this has been interacted with because its assumed
|
|
82
|
+
// this will be already exiting - so we don't want to double up the click.
|
|
83
|
+
return;
|
|
84
|
+
} // Avoid a nesting transition if a modifier key is detected during click.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
if (isNormalClick(e)) {
|
|
88
|
+
setIsInteracted(true);
|
|
89
|
+
onNest(id);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
onClick && onClick(e);
|
|
93
|
+
}, [isInteracted, onClick, onNest, id]);
|
|
94
|
+
|
|
95
|
+
if (currentStackId === id) {
|
|
96
|
+
return jsx(NestedContext.Provider, {
|
|
97
|
+
value: context
|
|
98
|
+
}, stack.length >= 1 && jsx("div", {
|
|
99
|
+
css: {
|
|
100
|
+
marginLeft: gridSize(),
|
|
101
|
+
marginRight: gridSize(),
|
|
102
|
+
// This padding bottom needs to match the section margin inside @atlaskit/menu.
|
|
103
|
+
paddingTop: gridSize() * 0.75,
|
|
104
|
+
paddingBottom: gridSize() * 0.75
|
|
105
|
+
}
|
|
106
|
+
}, backButton), jsx(NavigationContent, {
|
|
107
|
+
testId: testId,
|
|
108
|
+
showTopScrollIndicator: stack.length >= 1
|
|
109
|
+
}, children));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if ([ROOT_ID].concat(_toConsumableArray(stack)).includes(id)) {
|
|
113
|
+
return children;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var componentProps = _objectSpread(_objectSpread({
|
|
117
|
+
iconAfter: jsx(Fragment, null, iconAfter ? jsx("span", {
|
|
118
|
+
"data-custom-icon": true
|
|
119
|
+
}, iconAfter) : null, jsx("span", {
|
|
120
|
+
"data-right-arrow": true
|
|
121
|
+
}, jsx(RightArrow, {
|
|
122
|
+
testId: testId && "".concat(testId, "--item--right-arrow"),
|
|
123
|
+
secondaryColor: token('color.background.default', N10),
|
|
124
|
+
label: ""
|
|
125
|
+
}))),
|
|
126
|
+
onClick: onClickHandler,
|
|
127
|
+
isSelected: isSelected || isInteracted,
|
|
128
|
+
testId: testId && "".concat(testId, "--item")
|
|
129
|
+
}, rest), {}, {
|
|
130
|
+
children: title,
|
|
131
|
+
cssFn: mergedStyles
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if (component) {
|
|
135
|
+
return jsx(CustomItem, _extends({}, componentProps, {
|
|
136
|
+
//@ts-expect-error TODO Fix legit TypeScript 3.9.6 improved inference error
|
|
137
|
+
component: component
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return jsx(ButtonItem, componentProps);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export default NestingItem;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
var _enabledCSS, _disabledCSS;
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
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) { _defineProperty(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; }
|
|
8
|
+
|
|
9
|
+
// exposed for testing purposes
|
|
10
|
+
export var enabledCSS = (_enabledCSS = {}, _defineProperty(_enabledCSS, '&:hover [data-custom-icon]', {
|
|
11
|
+
display: 'none'
|
|
12
|
+
}), _defineProperty(_enabledCSS, '&:active [data-custom-icon]', {
|
|
13
|
+
display: 'none'
|
|
14
|
+
}), _defineProperty(_enabledCSS, '&:focus [data-custom-icon]', {
|
|
15
|
+
display: 'none'
|
|
16
|
+
}), _defineProperty(_enabledCSS, '& [data-custom-icon]', {
|
|
17
|
+
display: 'inherit'
|
|
18
|
+
}), _defineProperty(_enabledCSS, '&:hover [data-right-arrow]', {
|
|
19
|
+
display: 'inherit'
|
|
20
|
+
}), _defineProperty(_enabledCSS, '&:active [data-right-arrow]', {
|
|
21
|
+
display: 'inherit'
|
|
22
|
+
}), _defineProperty(_enabledCSS, '&:focus [data-right-arrow]', {
|
|
23
|
+
display: 'inherit'
|
|
24
|
+
}), _defineProperty(_enabledCSS, '& [data-right-arrow]', {
|
|
25
|
+
display: 'none'
|
|
26
|
+
}), _enabledCSS);
|
|
27
|
+
var disabledCSS = (_disabledCSS = {}, _defineProperty(_disabledCSS, '[data-item-elem-after]', {
|
|
28
|
+
opacity: 0
|
|
29
|
+
}), _defineProperty(_disabledCSS, '& [data-right-arrow]', {
|
|
30
|
+
display: 'none'
|
|
31
|
+
}), _disabledCSS);
|
|
32
|
+
export var nestingItemStyle = function nestingItemStyle(state) {
|
|
33
|
+
return _objectSpread({}, state.isDisabled ? disabledCSS : enabledCSS);
|
|
34
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HeadingItem as MenuHeadingItem } from '@atlaskit/menu';
|
|
4
|
+
import { overrideStyleFunction, sectionHeaderStyle } from '../../common/styles';
|
|
5
|
+
import { useShouldNestedElementRender } from '../NestableNavigationContent/context';
|
|
6
|
+
|
|
7
|
+
var HeadingItem = function HeadingItem(props) {
|
|
8
|
+
var _useShouldNestedEleme = useShouldNestedElementRender(),
|
|
9
|
+
shouldRender = _useShouldNestedEleme.shouldRender;
|
|
10
|
+
|
|
11
|
+
if (!shouldRender) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var cssFn = overrideStyleFunction(sectionHeaderStyle, props.cssFn);
|
|
16
|
+
return /*#__PURE__*/React.createElement(MenuHeadingItem, _extends({}, props, {
|
|
17
|
+
cssFn: cssFn
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default HeadingItem;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { Section as MenuSection } from '@atlaskit/menu';
|
|
4
|
+
import { sectionHeaderStyle } from '../../common/styles';
|
|
5
|
+
import { useShouldNestedElementRender } from '../NestableNavigationContent/context';
|
|
6
|
+
// Type needed on props to extract types with extract react types.
|
|
7
|
+
var Section = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
8
|
+
var _useShouldNestedEleme = useShouldNestedElementRender(),
|
|
9
|
+
shouldRender = _useShouldNestedEleme.shouldRender;
|
|
10
|
+
|
|
11
|
+
if (!shouldRender) {
|
|
12
|
+
return props.children;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return /*#__PURE__*/React.createElement(MenuSection, _extends({}, props, {
|
|
16
|
+
ref: ref,
|
|
17
|
+
overrides: {
|
|
18
|
+
HeadingItem: {
|
|
19
|
+
cssFn: sectionHeaderStyle
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
24
|
+
export default Section;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { SkeletonHeadingItem as MenuSkeletonHeadingItem } from '@atlaskit/menu';
|
|
4
|
+
import { ITEM_SIDE_PADDING } from '../../common/styles';
|
|
5
|
+
import { useShouldNestedElementRender } from '../NestableNavigationContent/context';
|
|
6
|
+
|
|
7
|
+
var SkeletonHeadingItem = function SkeletonHeadingItem(props) {
|
|
8
|
+
var _useShouldNestedEleme = useShouldNestedElementRender(),
|
|
9
|
+
shouldRender = _useShouldNestedEleme.shouldRender;
|
|
10
|
+
|
|
11
|
+
if (!shouldRender) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return /*#__PURE__*/React.createElement(MenuSkeletonHeadingItem, _extends({
|
|
16
|
+
cssFn: function cssFn() {
|
|
17
|
+
return {
|
|
18
|
+
paddingLeft: ITEM_SIDE_PADDING,
|
|
19
|
+
paddingRight: ITEM_SIDE_PADDING
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}, props));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default SkeletonHeadingItem;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/core';
|
|
4
|
+
import { N10, N500 } from '@atlaskit/theme/colors';
|
|
5
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
6
|
+
import { token } from '@atlaskit/tokens';
|
|
7
|
+
var SideNavigation = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
8
|
+
var children = props.children,
|
|
9
|
+
testId = props.testId,
|
|
10
|
+
label = props.label;
|
|
11
|
+
return jsx("nav", {
|
|
12
|
+
ref: ref,
|
|
13
|
+
"data-testid": testId,
|
|
14
|
+
"aria-label": label,
|
|
15
|
+
css: {
|
|
16
|
+
width: '100%',
|
|
17
|
+
height: '100%',
|
|
18
|
+
color: token('color.text.mediumEmphasis', N500),
|
|
19
|
+
minWidth: gridSize() * 30,
|
|
20
|
+
backgroundColor: token('color.background.default', N10),
|
|
21
|
+
position: 'relative',
|
|
22
|
+
display: 'flex',
|
|
23
|
+
flexDirection: 'column',
|
|
24
|
+
overflow: 'hidden'
|
|
25
|
+
}
|
|
26
|
+
}, children);
|
|
27
|
+
});
|
|
28
|
+
export default SideNavigation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as SideNavigation } from './SideNavigation';
|
|
2
|
+
export { Section, HeadingItem, SkeletonHeadingItem } from './Section';
|
|
3
|
+
export { default as NestingItem } from './NestingItem';
|
|
4
|
+
export { default as NavigationContent } from './NavigationContent';
|
|
5
|
+
export { ButtonItem, GoBackItem, LinkItem, CustomItem, SkeletonItem } from './Item';
|
|
6
|
+
export { default as Footer } from './Footer';
|
|
7
|
+
export { default as Header } from './Header';
|
|
8
|
+
export { default as NavigationHeader } from './NavigationHeader';
|
|
9
|
+
export { default as NavigationFooter } from './NavigationFooter';
|
|
10
|
+
export { default as LoadingItems } from './LoadingItems';
|
|
11
|
+
export { default as NestableNavigationContent } from './NestableNavigationContent';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { SideNavigation, Header, NavigationHeader, NavigationContent, Section, HeadingItem, SkeletonHeadingItem, NestableNavigationContent, NestingItem, ButtonItem, LinkItem, GoBackItem, CustomItem, SkeletonItem, Footer, NavigationFooter, LoadingItems } from './components';
|
|
2
|
+
export { useShouldNestedElementRender } from './components/NestableNavigationContent/context';
|
|
3
|
+
export { VAR_SCROLL_INDICATOR_COLOR, VAR_SEPARATOR_COLOR } from './common/constants';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSFn, StatelessCSSFn } from '@atlaskit/menu';
|
|
2
|
+
export declare const ITEM_SIDE_PADDING: number;
|
|
3
|
+
/**
|
|
4
|
+
* Allows chaining of style functions on top of base style functions
|
|
5
|
+
* @param baseStyle the base custom cssFn
|
|
6
|
+
* @param newStyle a new cssFn to be applied after the base style
|
|
7
|
+
*/
|
|
8
|
+
export declare const overrideStyleFunction: <TState>(baseStyle: CSSFn<TState>, newStyle?: CSSFn<TState> | undefined) => CSSFn<TState>;
|
|
9
|
+
export declare const baseSideNavItemStyle: CSSFn;
|
|
10
|
+
export declare const sectionHeaderStyle: StatelessCSSFn;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CSSFn, CustomItemComponentProps } from '@atlaskit/menu';
|
|
3
|
+
export interface HeaderProps {
|
|
4
|
+
/**
|
|
5
|
+
* A function that can be used to override the styles of the component.
|
|
6
|
+
* It receives the current styles and state and expects a styles object.
|
|
7
|
+
*/
|
|
8
|
+
cssFn?: CSSFn;
|
|
9
|
+
/**
|
|
10
|
+
* Element to render before the item text.
|
|
11
|
+
* Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
|
|
12
|
+
*/
|
|
13
|
+
iconBefore?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Event that is triggered when the element is clicked.
|
|
16
|
+
*/
|
|
17
|
+
onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Description of the item.
|
|
20
|
+
* This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
|
|
21
|
+
*/
|
|
22
|
+
description?: string | JSX.Element;
|
|
23
|
+
/**
|
|
24
|
+
* Primary content for the item.
|
|
25
|
+
*/
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* A `testId` prop is provided for specified elements,
|
|
29
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
30
|
+
* serving as a hook for automated tests.
|
|
31
|
+
*/
|
|
32
|
+
testId?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Custom component to render as an item.
|
|
35
|
+
* This can be both a functional component or a class component.
|
|
36
|
+
* **Will return `null` if no component is defined.**
|
|
37
|
+
|
|
38
|
+
* **NOTE:** Make sure the reference for this component does not change between renders else undefined behavior may happen.
|
|
39
|
+
*/
|
|
40
|
+
component?: React.ComponentType<CustomItemComponentProps>;
|
|
41
|
+
}
|
|
42
|
+
declare const Header: React.ForwardRefExoticComponent<HeaderProps & React.RefAttributes<HTMLElement>>;
|
|
43
|
+
export default Header;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ButtonItemProps } from '@atlaskit/menu';
|
|
3
|
+
export type { ButtonItemProps } from '@atlaskit/menu';
|
|
4
|
+
declare const ButtonItem: React.ForwardRefExoticComponent<ButtonItemProps & React.RefAttributes<HTMLElement>>;
|
|
5
|
+
export default ButtonItem;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CustomItemComponentProps, CustomItemProps } from '@atlaskit/menu';
|
|
2
|
+
export type { CustomItemComponentProps, CustomItemProps } from '@atlaskit/menu';
|
|
3
|
+
interface CustomItemType {
|
|
4
|
+
<TComponentProps extends {}>(props: CustomItemProps<TComponentProps> & {
|
|
5
|
+
ref?: any;
|
|
6
|
+
} & Omit<TComponentProps, keyof CustomItemComponentProps>): JSX.Element | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Used to support any custom items needed by products alongside the Header and Footer patterns.
|
|
10
|
+
* Specific implementation of headers and footers are provided in the examples folder.
|
|
11
|
+
*/
|
|
12
|
+
declare const CustomItem: CustomItemType;
|
|
13
|
+
export default CustomItem;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ButtonItemProps } from '@atlaskit/menu';
|
|
3
|
+
export type { ButtonItemProps as GoBackItemProps } from '@atlaskit/menu';
|
|
4
|
+
declare const GoBackItem: React.ForwardRefExoticComponent<ButtonItemProps & React.RefAttributes<HTMLElement>>;
|
|
5
|
+
export default GoBackItem;
|