@atlaskit/menu 1.6.1 → 1.7.1
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/index.js +6 -0
- package/dist/cjs/internal/components/menu-context.js +12 -2
- package/dist/cjs/internal/components/menu-item-primitive.js +29 -1
- package/dist/cjs/menu-section/menu-group.js +3 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/internal/components/menu-context.js +10 -1
- package/dist/es2019/internal/components/menu-item-primitive.js +30 -2
- package/dist/es2019/menu-section/menu-group.js +4 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/components/menu-context.js +10 -1
- package/dist/esm/internal/components/menu-item-primitive.js +30 -2
- package/dist/esm/menu-section/menu-group.js +4 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/components/menu-context.d.ts +8 -0
- package/dist/types-ts4.5/entry-points/menu-item/button-item.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/menu-item/custom-item.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/menu-item/heading-item.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/menu-item/link-item.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/menu-item/skeleton-heading-item.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/menu-item/skeleton-item.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/menu-section/menu-group.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/menu-section/popup-menu-group.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/menu-section/section.d.ts +1 -0
- package/dist/types-ts4.5/index.d.ts +11 -0
- package/dist/types-ts4.5/internal/components/menu-context.d.ts +18 -0
- package/dist/types-ts4.5/internal/components/menu-item-primitive.d.ts +18 -0
- package/dist/types-ts4.5/internal/components/skeleton-shimmer.d.ts +24 -0
- package/dist/types-ts4.5/menu-item/button-item.d.ts +12 -0
- package/dist/types-ts4.5/menu-item/custom-item.d.ts +18 -0
- package/dist/types-ts4.5/menu-item/heading-item.d.ts +13 -0
- package/dist/types-ts4.5/menu-item/link-item.d.ts +12 -0
- package/dist/types-ts4.5/menu-item/skeleton-heading-item.d.ts +12 -0
- package/dist/types-ts4.5/menu-item/skeleton-item.d.ts +12 -0
- package/dist/types-ts4.5/menu-section/menu-group.d.ts +13 -0
- package/dist/types-ts4.5/menu-section/popup-menu-group.d.ts +8 -0
- package/dist/types-ts4.5/menu-section/section.d.ts +12 -0
- package/dist/types-ts4.5/types.d.ts +388 -0
- package/package.json +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/menu
|
|
2
2
|
|
|
3
|
+
## 1.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
|
|
8
|
+
|
|
9
|
+
## 1.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`d518f0e34b9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d518f0e34b9) - [ux] We are testing a selected indicator change to menu, dropdown-menu, and side-navigation packages behind an internal feature flag. If successful this will be released in a later minor release.
|
|
14
|
+
|
|
3
15
|
## 1.6.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -40,6 +40,12 @@ Object.defineProperty(exports, "PopupMenuGroup", {
|
|
|
40
40
|
return _popupMenuGroup.default;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
+
Object.defineProperty(exports, "SELECTION_STYLE_CONTEXT_DO_NOT_USE", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _menuContext.SELECTION_STYLE_CONTEXT_DO_NOT_USE;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
43
49
|
Object.defineProperty(exports, "Section", {
|
|
44
50
|
enumerable: true,
|
|
45
51
|
get: function get() {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SpacingContext = void 0;
|
|
6
|
+
exports.SpacingContext = exports.SELECTION_STYLE_CONTEXT_DO_NOT_USE = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
/**
|
|
9
9
|
* __Spacing context__
|
|
@@ -13,4 +13,14 @@ var _react = require("react");
|
|
|
13
13
|
* @internal Do not use directly.
|
|
14
14
|
*/
|
|
15
15
|
var SpacingContext = /*#__PURE__*/(0, _react.createContext)('cozy');
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* __Selection context__
|
|
19
|
+
*
|
|
20
|
+
* The selection context is used to set what selection mode the menu items display as.
|
|
21
|
+
*
|
|
22
|
+
* @internal Do not use directly.
|
|
23
|
+
*/
|
|
24
|
+
exports.SpacingContext = SpacingContext;
|
|
25
|
+
var SELECTION_STYLE_CONTEXT_DO_NOT_USE = /*#__PURE__*/(0, _react.createContext)('border');
|
|
26
|
+
exports.SELECTION_STYLE_CONTEXT_DO_NOT_USE = SELECTION_STYLE_CONTEXT_DO_NOT_USE;
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _react2 = require("@emotion/react");
|
|
10
10
|
var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _inline = _interopRequireDefault(require("@atlaskit/primitives/inline"));
|
|
12
13
|
var _colors = require("@atlaskit/theme/colors");
|
|
13
14
|
var _menuContext = require("./menu-context");
|
|
@@ -53,6 +54,9 @@ var descriptionStyles = (0, _react2.css)({
|
|
|
53
54
|
var disabledDescriptionStyles = (0, _react2.css)({
|
|
54
55
|
color: "var(--ds-text-disabled, ".concat(_colors.N200, ")")
|
|
55
56
|
});
|
|
57
|
+
var positionRelativeStyles = (0, _react2.css)({
|
|
58
|
+
position: 'relative'
|
|
59
|
+
});
|
|
56
60
|
var primitiveStyles = (0, _react2.css)({
|
|
57
61
|
display: 'flex',
|
|
58
62
|
boxSizing: 'border-box',
|
|
@@ -112,6 +116,29 @@ var disabledStyles = (0, _react2.css)({
|
|
|
112
116
|
color: "var(--ds-text-disabled, ".concat(_colors.N200, ")")
|
|
113
117
|
}
|
|
114
118
|
});
|
|
119
|
+
var selectedBorderStyles = (0, _react2.css)({
|
|
120
|
+
'&::before': {
|
|
121
|
+
width: 2,
|
|
122
|
+
position: 'absolute',
|
|
123
|
+
top: 0,
|
|
124
|
+
bottom: 0,
|
|
125
|
+
left: 0,
|
|
126
|
+
background: "var(--ds-border-selected, transparent)",
|
|
127
|
+
content: '""'
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
var selectedNotchStyles = (0, _react2.css)({
|
|
131
|
+
'&::before': {
|
|
132
|
+
width: 4,
|
|
133
|
+
position: 'absolute',
|
|
134
|
+
top: "var(--ds-space-150, 12px)",
|
|
135
|
+
bottom: "var(--ds-space-150, 12px)",
|
|
136
|
+
left: 0,
|
|
137
|
+
background: "var(--ds-border-selected, transparent)",
|
|
138
|
+
borderRadius: '0 4px 4px 0',
|
|
139
|
+
content: '""'
|
|
140
|
+
}
|
|
141
|
+
});
|
|
115
142
|
var selectedStyles = (0, _react2.css)({
|
|
116
143
|
backgroundColor: "var(--ds-background-selected, ".concat(_colors.N20, ")"),
|
|
117
144
|
// Fallback set as babel plugin inserts one otherwise
|
|
@@ -164,6 +191,7 @@ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
|
|
|
164
191
|
_ref$isSelected = _ref.isSelected,
|
|
165
192
|
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
|
|
166
193
|
var spacing = (0, _react.useContext)(_menuContext.SpacingContext);
|
|
194
|
+
var selectionStyle = (0, _react.useContext)(_menuContext.SELECTION_STYLE_CONTEXT_DO_NOT_USE);
|
|
167
195
|
var renderTitle = overrides && overrides.Title && overrides.Title.render || defaultRender;
|
|
168
196
|
return (0, _react2.jsx)(_react2.ClassNames, null, function (_ref2) {
|
|
169
197
|
var cn = _ref2.css,
|
|
@@ -171,7 +199,7 @@ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
|
|
|
171
199
|
return (0, _react2.jsx)(_focusRing.default, {
|
|
172
200
|
isInset: true
|
|
173
201
|
}, children({
|
|
174
|
-
className: cx([cn([primitiveStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && selectedStyles, isDisabled ? disabledStyles : interactiveStyles]), className]),
|
|
202
|
+
className: cx([cn([(0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.menu-selected-state-change_0see9') && positionRelativeStyles, primitiveStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && [selectedStyles, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.menu-selected-state-change_0see9') && (selectionStyle === 'border' ? selectedBorderStyles : selectedNotchStyles)], isDisabled ? disabledStyles : interactiveStyles]), className]),
|
|
175
203
|
children: (0, _react2.jsx)(_inline.default, {
|
|
176
204
|
as: "span",
|
|
177
205
|
spread: "space-between",
|
|
@@ -32,6 +32,8 @@ var MenuGroup = function MenuGroup(_ref) {
|
|
|
32
32
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
33
33
|
return (0, _react.jsx)(_menuContext.SpacingContext.Provider, {
|
|
34
34
|
value: spacing
|
|
35
|
+
}, (0, _react.jsx)(_menuContext.SELECTION_STYLE_CONTEXT_DO_NOT_USE.Provider, {
|
|
36
|
+
value: "border"
|
|
35
37
|
}, (0, _react.jsx)(_dsExplorations.UNSAFE_Box, (0, _extends2.default)({
|
|
36
38
|
UNSAFE_style: {
|
|
37
39
|
minWidth: minWidth,
|
|
@@ -46,7 +48,7 @@ var MenuGroup = function MenuGroup(_ref) {
|
|
|
46
48
|
role: role,
|
|
47
49
|
position: "static"
|
|
48
50
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
49
|
-
}, rest)));
|
|
51
|
+
}, rest))));
|
|
50
52
|
};
|
|
51
53
|
var _default = MenuGroup;
|
|
52
54
|
exports.default = _default;
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { default as ButtonItem } from './menu-item/button-item';
|
|
|
2
2
|
export { default as LinkItem } from './menu-item/link-item';
|
|
3
3
|
export { default as CustomItem } from './menu-item/custom-item';
|
|
4
4
|
export { default as SkeletonItem } from './menu-item/skeleton-item';
|
|
5
|
-
export { SpacingContext } from './internal/components/menu-context';
|
|
5
|
+
export { SpacingContext, SELECTION_STYLE_CONTEXT_DO_NOT_USE } from './internal/components/menu-context';
|
|
6
6
|
export { default as HeadingItem } from './menu-item/heading-item';
|
|
7
7
|
export { default as SkeletonHeadingItem } from './menu-item/skeleton-heading-item';
|
|
8
8
|
export { default as Section } from './menu-section/section';
|
|
@@ -6,4 +6,13 @@ import { createContext } from 'react';
|
|
|
6
6
|
*
|
|
7
7
|
* @internal Do not use directly.
|
|
8
8
|
*/
|
|
9
|
-
export const SpacingContext = /*#__PURE__*/createContext('cozy');
|
|
9
|
+
export const SpacingContext = /*#__PURE__*/createContext('cozy');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* __Selection context__
|
|
13
|
+
*
|
|
14
|
+
* The selection context is used to set what selection mode the menu items display as.
|
|
15
|
+
*
|
|
16
|
+
* @internal Do not use directly.
|
|
17
|
+
*/
|
|
18
|
+
export const SELECTION_STYLE_CONTEXT_DO_NOT_USE = /*#__PURE__*/createContext('border');
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { ClassNames, css, jsx } from '@emotion/react';
|
|
4
4
|
import FocusRing from '@atlaskit/focus-ring';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import Inline from '@atlaskit/primitives/inline';
|
|
6
7
|
import { N20, N200, N30 } from '@atlaskit/theme/colors';
|
|
7
|
-
import { SpacingContext } from './menu-context';
|
|
8
|
+
import { SELECTION_STYLE_CONTEXT_DO_NOT_USE, SpacingContext } from './menu-context';
|
|
8
9
|
const defaultRender = (Component, props) =>
|
|
9
10
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
10
11
|
jsx(Component, props);
|
|
@@ -42,6 +43,9 @@ const descriptionStyles = css({
|
|
|
42
43
|
const disabledDescriptionStyles = css({
|
|
43
44
|
color: `var(--ds-text-disabled, ${N200})`
|
|
44
45
|
});
|
|
46
|
+
const positionRelativeStyles = css({
|
|
47
|
+
position: 'relative'
|
|
48
|
+
});
|
|
45
49
|
const primitiveStyles = css({
|
|
46
50
|
display: 'flex',
|
|
47
51
|
boxSizing: 'border-box',
|
|
@@ -101,6 +105,29 @@ const disabledStyles = css({
|
|
|
101
105
|
color: `var(--ds-text-disabled, ${N200})`
|
|
102
106
|
}
|
|
103
107
|
});
|
|
108
|
+
const selectedBorderStyles = css({
|
|
109
|
+
'&::before': {
|
|
110
|
+
width: 2,
|
|
111
|
+
position: 'absolute',
|
|
112
|
+
top: 0,
|
|
113
|
+
bottom: 0,
|
|
114
|
+
left: 0,
|
|
115
|
+
background: "var(--ds-border-selected, transparent)",
|
|
116
|
+
content: '""'
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
const selectedNotchStyles = css({
|
|
120
|
+
'&::before': {
|
|
121
|
+
width: 4,
|
|
122
|
+
position: 'absolute',
|
|
123
|
+
top: "var(--ds-space-150, 12px)",
|
|
124
|
+
bottom: "var(--ds-space-150, 12px)",
|
|
125
|
+
left: 0,
|
|
126
|
+
background: "var(--ds-border-selected, transparent)",
|
|
127
|
+
borderRadius: '0 4px 4px 0',
|
|
128
|
+
content: '""'
|
|
129
|
+
}
|
|
130
|
+
});
|
|
104
131
|
const selectedStyles = css({
|
|
105
132
|
backgroundColor: `var(--ds-background-selected, ${N20})`,
|
|
106
133
|
// Fallback set as babel plugin inserts one otherwise
|
|
@@ -150,6 +177,7 @@ const MenuItemPrimitive = ({
|
|
|
150
177
|
isSelected = false
|
|
151
178
|
}) => {
|
|
152
179
|
const spacing = useContext(SpacingContext);
|
|
180
|
+
const selectionStyle = useContext(SELECTION_STYLE_CONTEXT_DO_NOT_USE);
|
|
153
181
|
const renderTitle = overrides && overrides.Title && overrides.Title.render || defaultRender;
|
|
154
182
|
return jsx(ClassNames, null, ({
|
|
155
183
|
css: cn,
|
|
@@ -158,7 +186,7 @@ const MenuItemPrimitive = ({
|
|
|
158
186
|
return jsx(FocusRing, {
|
|
159
187
|
isInset: true
|
|
160
188
|
}, children({
|
|
161
|
-
className: cx([cn([primitiveStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && selectedStyles, isDisabled ? disabledStyles : interactiveStyles]), className]),
|
|
189
|
+
className: cx([cn([getBooleanFF('platform.design-system-team.menu-selected-state-change_0see9') && positionRelativeStyles, primitiveStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && [selectedStyles, getBooleanFF('platform.design-system-team.menu-selected-state-change_0see9') && (selectionStyle === 'border' ? selectedBorderStyles : selectedNotchStyles)], isDisabled ? disabledStyles : interactiveStyles]), className]),
|
|
162
190
|
children: jsx(Inline, {
|
|
163
191
|
as: "span",
|
|
164
192
|
spread: "space-between",
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
|
|
5
|
-
import { SpacingContext } from '../internal/components/menu-context';
|
|
5
|
+
import { SELECTION_STYLE_CONTEXT_DO_NOT_USE, SpacingContext } from '../internal/components/menu-context';
|
|
6
6
|
/**
|
|
7
7
|
* __Menu group__
|
|
8
8
|
*
|
|
@@ -22,6 +22,8 @@ const MenuGroup = ({
|
|
|
22
22
|
...rest
|
|
23
23
|
}) => jsx(SpacingContext.Provider, {
|
|
24
24
|
value: spacing
|
|
25
|
+
}, jsx(SELECTION_STYLE_CONTEXT_DO_NOT_USE.Provider, {
|
|
26
|
+
value: "border"
|
|
25
27
|
}, jsx(Box, _extends({
|
|
26
28
|
UNSAFE_style: {
|
|
27
29
|
minWidth,
|
|
@@ -36,5 +38,5 @@ const MenuGroup = ({
|
|
|
36
38
|
role: role,
|
|
37
39
|
position: "static"
|
|
38
40
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
39
|
-
}, rest)));
|
|
41
|
+
}, rest))));
|
|
40
42
|
export default MenuGroup;
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { default as ButtonItem } from './menu-item/button-item';
|
|
|
2
2
|
export { default as LinkItem } from './menu-item/link-item';
|
|
3
3
|
export { default as CustomItem } from './menu-item/custom-item';
|
|
4
4
|
export { default as SkeletonItem } from './menu-item/skeleton-item';
|
|
5
|
-
export { SpacingContext } from './internal/components/menu-context';
|
|
5
|
+
export { SpacingContext, SELECTION_STYLE_CONTEXT_DO_NOT_USE } from './internal/components/menu-context';
|
|
6
6
|
export { default as HeadingItem } from './menu-item/heading-item';
|
|
7
7
|
export { default as SkeletonHeadingItem } from './menu-item/skeleton-heading-item';
|
|
8
8
|
export { default as Section } from './menu-section/section';
|
|
@@ -6,4 +6,13 @@ import { createContext } from 'react';
|
|
|
6
6
|
*
|
|
7
7
|
* @internal Do not use directly.
|
|
8
8
|
*/
|
|
9
|
-
export var SpacingContext = /*#__PURE__*/createContext('cozy');
|
|
9
|
+
export var SpacingContext = /*#__PURE__*/createContext('cozy');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* __Selection context__
|
|
13
|
+
*
|
|
14
|
+
* The selection context is used to set what selection mode the menu items display as.
|
|
15
|
+
*
|
|
16
|
+
* @internal Do not use directly.
|
|
17
|
+
*/
|
|
18
|
+
export var SELECTION_STYLE_CONTEXT_DO_NOT_USE = /*#__PURE__*/createContext('border');
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { ClassNames, css, jsx } from '@emotion/react';
|
|
4
4
|
import FocusRing from '@atlaskit/focus-ring';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import Inline from '@atlaskit/primitives/inline';
|
|
6
7
|
import { N20, N200, N30 } from '@atlaskit/theme/colors';
|
|
7
|
-
import { SpacingContext } from './menu-context';
|
|
8
|
+
import { SELECTION_STYLE_CONTEXT_DO_NOT_USE, SpacingContext } from './menu-context';
|
|
8
9
|
var defaultRender = function defaultRender(Component, props) {
|
|
9
10
|
return (
|
|
10
11
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
@@ -45,6 +46,9 @@ var descriptionStyles = css({
|
|
|
45
46
|
var disabledDescriptionStyles = css({
|
|
46
47
|
color: "var(--ds-text-disabled, ".concat(N200, ")")
|
|
47
48
|
});
|
|
49
|
+
var positionRelativeStyles = css({
|
|
50
|
+
position: 'relative'
|
|
51
|
+
});
|
|
48
52
|
var primitiveStyles = css({
|
|
49
53
|
display: 'flex',
|
|
50
54
|
boxSizing: 'border-box',
|
|
@@ -104,6 +108,29 @@ var disabledStyles = css({
|
|
|
104
108
|
color: "var(--ds-text-disabled, ".concat(N200, ")")
|
|
105
109
|
}
|
|
106
110
|
});
|
|
111
|
+
var selectedBorderStyles = css({
|
|
112
|
+
'&::before': {
|
|
113
|
+
width: 2,
|
|
114
|
+
position: 'absolute',
|
|
115
|
+
top: 0,
|
|
116
|
+
bottom: 0,
|
|
117
|
+
left: 0,
|
|
118
|
+
background: "var(--ds-border-selected, transparent)",
|
|
119
|
+
content: '""'
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
var selectedNotchStyles = css({
|
|
123
|
+
'&::before': {
|
|
124
|
+
width: 4,
|
|
125
|
+
position: 'absolute',
|
|
126
|
+
top: "var(--ds-space-150, 12px)",
|
|
127
|
+
bottom: "var(--ds-space-150, 12px)",
|
|
128
|
+
left: 0,
|
|
129
|
+
background: "var(--ds-border-selected, transparent)",
|
|
130
|
+
borderRadius: '0 4px 4px 0',
|
|
131
|
+
content: '""'
|
|
132
|
+
}
|
|
133
|
+
});
|
|
107
134
|
var selectedStyles = css({
|
|
108
135
|
backgroundColor: "var(--ds-background-selected, ".concat(N20, ")"),
|
|
109
136
|
// Fallback set as babel plugin inserts one otherwise
|
|
@@ -156,6 +183,7 @@ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
|
|
|
156
183
|
_ref$isSelected = _ref.isSelected,
|
|
157
184
|
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
|
|
158
185
|
var spacing = useContext(SpacingContext);
|
|
186
|
+
var selectionStyle = useContext(SELECTION_STYLE_CONTEXT_DO_NOT_USE);
|
|
159
187
|
var renderTitle = overrides && overrides.Title && overrides.Title.render || defaultRender;
|
|
160
188
|
return jsx(ClassNames, null, function (_ref2) {
|
|
161
189
|
var cn = _ref2.css,
|
|
@@ -163,7 +191,7 @@ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
|
|
|
163
191
|
return jsx(FocusRing, {
|
|
164
192
|
isInset: true
|
|
165
193
|
}, children({
|
|
166
|
-
className: cx([cn([primitiveStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && selectedStyles, isDisabled ? disabledStyles : interactiveStyles]), className]),
|
|
194
|
+
className: cx([cn([getBooleanFF('platform.design-system-team.menu-selected-state-change_0see9') && positionRelativeStyles, primitiveStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && [selectedStyles, getBooleanFF('platform.design-system-team.menu-selected-state-change_0see9') && (selectionStyle === 'border' ? selectedBorderStyles : selectedNotchStyles)], isDisabled ? disabledStyles : interactiveStyles]), className]),
|
|
167
195
|
children: jsx(Inline, {
|
|
168
196
|
as: "span",
|
|
169
197
|
spread: "space-between",
|
|
@@ -4,7 +4,7 @@ var _excluded = ["maxWidth", "minWidth", "minHeight", "maxHeight", "testId", "ro
|
|
|
4
4
|
/** @jsx jsx */
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
|
|
7
|
-
import { SpacingContext } from '../internal/components/menu-context';
|
|
7
|
+
import { SELECTION_STYLE_CONTEXT_DO_NOT_USE, SpacingContext } from '../internal/components/menu-context';
|
|
8
8
|
/**
|
|
9
9
|
* __Menu group__
|
|
10
10
|
*
|
|
@@ -25,6 +25,8 @@ var MenuGroup = function MenuGroup(_ref) {
|
|
|
25
25
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
26
26
|
return jsx(SpacingContext.Provider, {
|
|
27
27
|
value: spacing
|
|
28
|
+
}, jsx(SELECTION_STYLE_CONTEXT_DO_NOT_USE.Provider, {
|
|
29
|
+
value: "border"
|
|
28
30
|
}, jsx(Box, _extends({
|
|
29
31
|
UNSAFE_style: {
|
|
30
32
|
minWidth: minWidth,
|
|
@@ -39,6 +41,6 @@ var MenuGroup = function MenuGroup(_ref) {
|
|
|
39
41
|
role: role,
|
|
40
42
|
position: "static"
|
|
41
43
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
42
|
-
}, rest)));
|
|
44
|
+
}, rest))));
|
|
43
45
|
};
|
|
44
46
|
export default MenuGroup;
|
package/dist/esm/version.json
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { default as ButtonItem } from './menu-item/button-item';
|
|
|
2
2
|
export { default as LinkItem } from './menu-item/link-item';
|
|
3
3
|
export { default as CustomItem } from './menu-item/custom-item';
|
|
4
4
|
export { default as SkeletonItem } from './menu-item/skeleton-item';
|
|
5
|
-
export { SpacingContext } from './internal/components/menu-context';
|
|
5
|
+
export { SpacingContext, SELECTION_STYLE_CONTEXT_DO_NOT_USE, } from './internal/components/menu-context';
|
|
6
6
|
export { default as HeadingItem } from './menu-item/heading-item';
|
|
7
7
|
export { default as SkeletonHeadingItem } from './menu-item/skeleton-heading-item';
|
|
8
8
|
export { default as Section } from './menu-section/section';
|
|
@@ -8,3 +8,11 @@ export type SpacingMode = 'compact' | 'cozy';
|
|
|
8
8
|
* @internal Do not use directly.
|
|
9
9
|
*/
|
|
10
10
|
export declare const SpacingContext: import("react").Context<SpacingMode>;
|
|
11
|
+
/**
|
|
12
|
+
* __Selection context__
|
|
13
|
+
*
|
|
14
|
+
* The selection context is used to set what selection mode the menu items display as.
|
|
15
|
+
*
|
|
16
|
+
* @internal Do not use directly.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SELECTION_STYLE_CONTEXT_DO_NOT_USE: import("react").Context<"notch" | "border">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../menu-item/button-item';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../menu-item/custom-item';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../menu-item/heading-item';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../menu-item/link-item';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../menu-item/skeleton-heading-item';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../menu-item/skeleton-item';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../menu-section/menu-group';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../menu-section/popup-menu-group';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../menu-section/section';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as ButtonItem } from './menu-item/button-item';
|
|
2
|
+
export { default as LinkItem } from './menu-item/link-item';
|
|
3
|
+
export { default as CustomItem } from './menu-item/custom-item';
|
|
4
|
+
export { default as SkeletonItem } from './menu-item/skeleton-item';
|
|
5
|
+
export { SpacingContext, SELECTION_STYLE_CONTEXT_DO_NOT_USE, } from './internal/components/menu-context';
|
|
6
|
+
export { default as HeadingItem } from './menu-item/heading-item';
|
|
7
|
+
export { default as SkeletonHeadingItem } from './menu-item/skeleton-heading-item';
|
|
8
|
+
export { default as Section } from './menu-section/section';
|
|
9
|
+
export { default as MenuGroup } from './menu-section/menu-group';
|
|
10
|
+
export { default as PopupMenuGroup } from './menu-section/popup-menu-group';
|
|
11
|
+
export type { ButtonItemProps, CSSFn, StatelessCSSFn, CustomItemComponentProps, CustomItemProps, HeadingItemProps, ItemState, LinkItemProps, MenuGroupProps, SectionProps, SkeletonHeadingItemProps, SkeletonItemProps, Dimension, MenuItemProps as BaseItemProps, Overrides, MenuGroupSizing, RenderFunction, SectionProps as SectionBaseProps, TitleOverrides, } from './types';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type SpacingMode = 'compact' | 'cozy';
|
|
3
|
+
/**
|
|
4
|
+
* __Spacing context__
|
|
5
|
+
*
|
|
6
|
+
* The spacing context is used to provide spacing values to menu item primitives.
|
|
7
|
+
*
|
|
8
|
+
* @internal Do not use directly.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SpacingContext: import("react").Context<SpacingMode>;
|
|
11
|
+
/**
|
|
12
|
+
* __Selection context__
|
|
13
|
+
*
|
|
14
|
+
* The selection context is used to set what selection mode the menu items display as.
|
|
15
|
+
*
|
|
16
|
+
* @internal Do not use directly.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SELECTION_STYLE_CONTEXT_DO_NOT_USE: import("react").Context<"notch" | "border">;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import type { MenuItemPrimitiveProps } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* __Menu item primitive__
|
|
5
|
+
*
|
|
6
|
+
* Menu item primitive contains all the styles for menu items,
|
|
7
|
+
* including support for selected, disabled, and interaction states.
|
|
8
|
+
*
|
|
9
|
+
* Using children as function prop you wire up this to your own host element.
|
|
10
|
+
*
|
|
11
|
+
* ```jsx
|
|
12
|
+
* <MenuItemPrimitive>
|
|
13
|
+
* {({ children, ...props }) => <button {...props}>{children}</button>}
|
|
14
|
+
* </MenuItemPrimitive>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare const MenuItemPrimitive: ({ children, title, description, iconAfter, iconBefore, overrides, className, shouldTitleWrap, shouldDescriptionWrap, isDisabled, isSelected, }: MenuItemPrimitiveProps) => jsx.JSX.Element;
|
|
18
|
+
export default MenuItemPrimitive;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
type SkeletonShimmerProps = {
|
|
5
|
+
children: ({ className }: {
|
|
6
|
+
className?: string;
|
|
7
|
+
}) => ReactNode;
|
|
8
|
+
isShimmering?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* __Skeleton shimmer__
|
|
12
|
+
*
|
|
13
|
+
* A skeleton shimmer is the animation shown on loading skeletons for
|
|
14
|
+
* perceived performance and user satisfaction.
|
|
15
|
+
*
|
|
16
|
+
* This component provides a `className` through render props. This value will
|
|
17
|
+
* have type:
|
|
18
|
+
* + `string`, when `isShimmering={true}`.
|
|
19
|
+
* + `undefined`, when `isShimmering={false}`.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
declare const SkeletonShimmer: ({ children, isShimmering, }: SkeletonShimmerProps) => jsx.JSX.Element;
|
|
24
|
+
export default SkeletonShimmer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ButtonItemProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* __Button item__
|
|
5
|
+
*
|
|
6
|
+
* A button item is used to populate a menu with items that are buttons.
|
|
7
|
+
*
|
|
8
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/button-item)
|
|
9
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
10
|
+
*/
|
|
11
|
+
declare const ButtonItem: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<ButtonItemProps & import("react").RefAttributes<HTMLElement>>>;
|
|
12
|
+
export default ButtonItem;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import type { CustomItemComponentProps, CustomItemProps } from '../types';
|
|
4
|
+
interface CustomItemTypeGenericHackProps {
|
|
5
|
+
<TComponentProps>(props: CustomItemProps<TComponentProps> & {
|
|
6
|
+
ref?: any;
|
|
7
|
+
} & Omit<TComponentProps, keyof CustomItemComponentProps>): JSX.Element | null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* __Custom item__
|
|
11
|
+
*
|
|
12
|
+
* A custom item is used to populate a menu with items that can be any element.
|
|
13
|
+
*
|
|
14
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/custom-item)
|
|
15
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
16
|
+
*/
|
|
17
|
+
declare const CustomItem: CustomItemTypeGenericHackProps;
|
|
18
|
+
export default CustomItem;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import type { HeadingItemProps } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* __Heading item__
|
|
6
|
+
*
|
|
7
|
+
* A heading item is used to describe sibling menu items.
|
|
8
|
+
*
|
|
9
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/heading-item)
|
|
10
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
11
|
+
*/
|
|
12
|
+
declare const HeadingItem: import("react").MemoExoticComponent<({ children, testId, id, cssFn, ...rest }: HeadingItemProps) => jsx.JSX.Element>;
|
|
13
|
+
export default HeadingItem;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { LinkItemProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* __Link item__
|
|
5
|
+
*
|
|
6
|
+
* A link item is used to populate a menu with items that are links.
|
|
7
|
+
*
|
|
8
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/link-item)
|
|
9
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
10
|
+
*/
|
|
11
|
+
declare const LinkItem: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<LinkItemProps & import("react").RefAttributes<HTMLElement>>>;
|
|
12
|
+
export default LinkItem;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import type { SkeletonHeadingItemProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* __Skeleton heading item__
|
|
5
|
+
*
|
|
6
|
+
* A skeleton heading item is used in place of a heading item when its contents it not ready.
|
|
7
|
+
*
|
|
8
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/skeleton-heading-item)
|
|
9
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
10
|
+
*/
|
|
11
|
+
declare const SkeletonHeadingItem: ({ isShimmering, testId, width, cssFn, }: SkeletonHeadingItemProps) => jsx.JSX.Element;
|
|
12
|
+
export default SkeletonHeadingItem;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import type { SkeletonItemProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* __Skeleton item__
|
|
5
|
+
*
|
|
6
|
+
* A skeleton item is used in place of an item when its contents it not ready.
|
|
7
|
+
*
|
|
8
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/skeleton-item)
|
|
9
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
10
|
+
*/
|
|
11
|
+
declare const SkeletonItem: ({ hasAvatar, hasIcon, isShimmering, testId, width, cssFn, }: SkeletonItemProps) => jsx.JSX.Element;
|
|
12
|
+
export default SkeletonItem;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import type { MenuGroupProps } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* __Menu group__
|
|
6
|
+
*
|
|
7
|
+
* A menu group includes all the actions or items in a menu.
|
|
8
|
+
*
|
|
9
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/menu-group)
|
|
10
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
11
|
+
*/
|
|
12
|
+
declare const MenuGroup: ({ maxWidth, minWidth, minHeight, maxHeight, testId, role, spacing, ...rest }: MenuGroupProps) => jsx.JSX.Element;
|
|
13
|
+
export default MenuGroup;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import type { MenuGroupProps } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated
|
|
6
|
+
*/
|
|
7
|
+
declare const PopupMenuGroup: ({ maxWidth, minWidth, ...rest }: MenuGroupProps) => jsx.JSX.Element;
|
|
8
|
+
export default PopupMenuGroup;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SectionProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* __Section__
|
|
5
|
+
*
|
|
6
|
+
* A section includes related actions or items in a menu.
|
|
7
|
+
*
|
|
8
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/section)
|
|
9
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
10
|
+
*/
|
|
11
|
+
declare const Section: import("react").ForwardRefExoticComponent<SectionProps & import("react").RefAttributes<HTMLElement>>;
|
|
12
|
+
export default Section;
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { ComponentType, ReactNode, Ref } from 'react';
|
|
2
|
+
import { CSSObject } from '@emotion/react';
|
|
3
|
+
import type { SpacingMode } from './internal/components/menu-context';
|
|
4
|
+
export interface RenderFunction<TProps = {}> {
|
|
5
|
+
(Component: ComponentType | string, props: TProps): React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated This type is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
9
|
+
*/
|
|
10
|
+
export interface TitleOverrides {
|
|
11
|
+
render?: RenderFunction<{
|
|
12
|
+
className?: string;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
'data-item-title': boolean;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated This type is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
19
|
+
*/
|
|
20
|
+
export interface Overrides {
|
|
21
|
+
Title?: TitleOverrides;
|
|
22
|
+
}
|
|
23
|
+
export type Dimension = string | number;
|
|
24
|
+
export interface MenuGroupSizing {
|
|
25
|
+
/**
|
|
26
|
+
* Useful to constrain the menu group minimum height to a specific value.
|
|
27
|
+
*/
|
|
28
|
+
minHeight?: Dimension;
|
|
29
|
+
/**
|
|
30
|
+
* Useful to constrain the menu groups height to a specific value.
|
|
31
|
+
* Needs to be set when wanting to have scrollable sections.
|
|
32
|
+
*/
|
|
33
|
+
maxHeight?: Dimension;
|
|
34
|
+
/**
|
|
35
|
+
* Useful to constrain the menu group minimum width to a specific value.
|
|
36
|
+
*/
|
|
37
|
+
minWidth?: Dimension;
|
|
38
|
+
/**
|
|
39
|
+
* Useful to constrain the menu group width to a specific value.
|
|
40
|
+
*/
|
|
41
|
+
maxWidth?: Dimension;
|
|
42
|
+
}
|
|
43
|
+
export interface MenuGroupProps extends MenuGroupSizing {
|
|
44
|
+
/**
|
|
45
|
+
* Children of the menu group,
|
|
46
|
+
* should generally be `Section` components.
|
|
47
|
+
*/
|
|
48
|
+
children: React.ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Configure the density of the MenuGroup content.
|
|
51
|
+
*/
|
|
52
|
+
spacing?: SpacingMode;
|
|
53
|
+
/**
|
|
54
|
+
* Used to override the accessibility role for the element.
|
|
55
|
+
*/
|
|
56
|
+
role?: string;
|
|
57
|
+
/**
|
|
58
|
+
* A `testId` prop is provided for specified elements,
|
|
59
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
60
|
+
* serving as a hook for automated tests.
|
|
61
|
+
*/
|
|
62
|
+
testId?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Handler called when clicking on this element,
|
|
65
|
+
* or any children elements.
|
|
66
|
+
* Useful when needing to stop propagation of child events.
|
|
67
|
+
*/
|
|
68
|
+
onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
69
|
+
}
|
|
70
|
+
export interface SectionProps {
|
|
71
|
+
/**
|
|
72
|
+
* Unique identifier for the element.
|
|
73
|
+
*/
|
|
74
|
+
id?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Enables scrolling within the section.
|
|
77
|
+
* Make sure to set `maxHeight` on the parent `MenuGroup` component else it will not work.
|
|
78
|
+
*/
|
|
79
|
+
isScrollable?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Will render a border at the top of the section.
|
|
82
|
+
*/
|
|
83
|
+
hasSeparator?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Children of the section,
|
|
86
|
+
* should generally be `Item` or `Heading` components,
|
|
87
|
+
* but can also be [`EmptyState`](https://atlaskit.atlassian.com/packages/design-system/empty-state)s when wanting to render errors.
|
|
88
|
+
*/
|
|
89
|
+
children: React.ReactNode;
|
|
90
|
+
/**
|
|
91
|
+
* A `testId` prop is provided for specified elements,
|
|
92
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
93
|
+
* serving as a hook for automated tests.
|
|
94
|
+
*/
|
|
95
|
+
testId?: string;
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated This API is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
98
|
+
*/
|
|
99
|
+
overrides?: {
|
|
100
|
+
HeadingItem?: {
|
|
101
|
+
/**
|
|
102
|
+
* A function that overrides the styles of the component.
|
|
103
|
+
* It receives the current styles and state and expects a styles object.
|
|
104
|
+
*/
|
|
105
|
+
cssFn?: StatelessCSSFn;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* The text passed into the internal HeadingItem. If a title is not provided,
|
|
110
|
+
* the HeadingItem will not be rendered, and this component acts as a regular Section
|
|
111
|
+
*/
|
|
112
|
+
title?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface MenuItemPrimitiveProps {
|
|
115
|
+
children: (props: {
|
|
116
|
+
className: string;
|
|
117
|
+
children: React.ReactNode;
|
|
118
|
+
}) => JSX.Element;
|
|
119
|
+
title: React.ReactNode | undefined;
|
|
120
|
+
description: React.ReactNode | undefined;
|
|
121
|
+
iconAfter: React.ReactNode | undefined;
|
|
122
|
+
iconBefore: React.ReactNode | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated This API is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
125
|
+
*/
|
|
126
|
+
overrides: Overrides | undefined;
|
|
127
|
+
shouldTitleWrap: boolean | undefined;
|
|
128
|
+
shouldDescriptionWrap: boolean | undefined;
|
|
129
|
+
isDisabled: boolean | undefined;
|
|
130
|
+
isSelected: boolean | undefined;
|
|
131
|
+
className?: string;
|
|
132
|
+
}
|
|
133
|
+
export interface MenuItemProps {
|
|
134
|
+
/**
|
|
135
|
+
A function that overrides the styles of the component.
|
|
136
|
+
It receives the current styles and state and expects a styles object.
|
|
137
|
+
|
|
138
|
+
@deprecated This API is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
139
|
+
*/
|
|
140
|
+
cssFn?: CSSFn;
|
|
141
|
+
/**
|
|
142
|
+
* Element to render before the item text.
|
|
143
|
+
* Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
|
|
144
|
+
*/
|
|
145
|
+
iconBefore?: React.ReactNode;
|
|
146
|
+
/**
|
|
147
|
+
* Element to render after the item text.
|
|
148
|
+
* Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
|
|
149
|
+
*/
|
|
150
|
+
iconAfter?: React.ReactNode;
|
|
151
|
+
/**
|
|
152
|
+
* Event that is triggered when the element is clicked.
|
|
153
|
+
*/
|
|
154
|
+
onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;
|
|
155
|
+
/**
|
|
156
|
+
* Event that is triggered when the element has been pressed.
|
|
157
|
+
*/
|
|
158
|
+
onMouseDown?: React.MouseEventHandler;
|
|
159
|
+
/**
|
|
160
|
+
* Description of the item.
|
|
161
|
+
* This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
|
|
162
|
+
*/
|
|
163
|
+
description?: string | JSX.Element;
|
|
164
|
+
/**
|
|
165
|
+
* Makes the element appear disabled as well as removing interactivity.
|
|
166
|
+
*/
|
|
167
|
+
isDisabled?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Makes the element appear selected.
|
|
170
|
+
*/
|
|
171
|
+
isSelected?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Primary content for the item.
|
|
174
|
+
*/
|
|
175
|
+
children?: React.ReactNode;
|
|
176
|
+
/**
|
|
177
|
+
* A `testId` prop is provided for specified elements,
|
|
178
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
179
|
+
* serving as a hook for automated tests.
|
|
180
|
+
*/
|
|
181
|
+
testId?: string;
|
|
182
|
+
/**
|
|
183
|
+
Custom overrides for the composed components.
|
|
184
|
+
|
|
185
|
+
@deprecated This API is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
186
|
+
*/
|
|
187
|
+
overrides?: Overrides;
|
|
188
|
+
/**
|
|
189
|
+
* When `true` the title of the item will wrap multiple lines if it's long enough.
|
|
190
|
+
*/
|
|
191
|
+
shouldTitleWrap?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* When `true` the description of the item will wrap multiple lines if it's long enough.
|
|
194
|
+
*/
|
|
195
|
+
shouldDescriptionWrap?: boolean;
|
|
196
|
+
}
|
|
197
|
+
export interface ButtonItemProps extends MenuItemProps {
|
|
198
|
+
/**
|
|
199
|
+
* Unique identifier for the element.
|
|
200
|
+
*/
|
|
201
|
+
id?: string;
|
|
202
|
+
/**
|
|
203
|
+
* Used to override the accessibility role for the element.
|
|
204
|
+
*/
|
|
205
|
+
role?: string;
|
|
206
|
+
}
|
|
207
|
+
export interface LinkItemProps extends MenuItemProps {
|
|
208
|
+
/**
|
|
209
|
+
* Link to another page.
|
|
210
|
+
*/
|
|
211
|
+
href?: string;
|
|
212
|
+
/**
|
|
213
|
+
* Where to display the linked URL,
|
|
214
|
+
* see [anchor information](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) on mdn for more information.
|
|
215
|
+
*/
|
|
216
|
+
target?: string;
|
|
217
|
+
/**
|
|
218
|
+
* The relationship of the linked URL as space-separated link types.
|
|
219
|
+
* Generally you'll want to set this to "noopener noreferrer" when `target` is "_blank".
|
|
220
|
+
*/
|
|
221
|
+
rel?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Used to override the accessibility role for the element.
|
|
224
|
+
*/
|
|
225
|
+
role?: string;
|
|
226
|
+
}
|
|
227
|
+
export interface CustomItemComponentProps {
|
|
228
|
+
/**
|
|
229
|
+
* The children of the item.
|
|
230
|
+
*/
|
|
231
|
+
children: React.ReactNode;
|
|
232
|
+
/**
|
|
233
|
+
* Class to apply to the root container of the custom component,
|
|
234
|
+
* ensure this has been applied so the consistent item styling is applied.
|
|
235
|
+
*/
|
|
236
|
+
className: string;
|
|
237
|
+
/**
|
|
238
|
+
* Test id that is passed through to the custom component.
|
|
239
|
+
*/
|
|
240
|
+
'data-testid'?: string;
|
|
241
|
+
/**
|
|
242
|
+
* Event handler that is passed through to the custom component.
|
|
243
|
+
*/
|
|
244
|
+
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
245
|
+
/**
|
|
246
|
+
* Event handler that is passed through to the custom component.
|
|
247
|
+
*/
|
|
248
|
+
onMouseDown?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
249
|
+
/**
|
|
250
|
+
* Event handler that is passed through to the custom component.
|
|
251
|
+
* Used to disable the element from being draggable.
|
|
252
|
+
*/
|
|
253
|
+
onDragStart?: (event: React.DragEvent) => void;
|
|
254
|
+
/**
|
|
255
|
+
* Turns off the element being draggable.
|
|
256
|
+
*/
|
|
257
|
+
draggable: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* React ref for the raw DOM element,
|
|
260
|
+
* make sure to place this on the outer most DOM element.
|
|
261
|
+
*/
|
|
262
|
+
ref?: Ref<any>;
|
|
263
|
+
/**
|
|
264
|
+
* Makes the element appear disabled as well as removing interactivity.
|
|
265
|
+
*/
|
|
266
|
+
tabIndex?: number;
|
|
267
|
+
/**
|
|
268
|
+
* Disabled attribute.
|
|
269
|
+
*/
|
|
270
|
+
disabled?: boolean;
|
|
271
|
+
}
|
|
272
|
+
export interface CustomItemProps<TCustomComponentProps = CustomItemComponentProps> extends MenuItemProps {
|
|
273
|
+
/**
|
|
274
|
+
Custom component to render as an item. This can be both a functional component or a class component.
|
|
275
|
+
|
|
276
|
+
__Will return `null` if no component is defined.__
|
|
277
|
+
|
|
278
|
+
Props passed to `CustomItem` will be passed down to this component. If the props for `component` have TypeScript types,
|
|
279
|
+
CustomItem will extend them, providing type safety for your custom item.
|
|
280
|
+
|
|
281
|
+
e.g. `<CustomItem to="/link" component={RouterLink} />`
|
|
282
|
+
|
|
283
|
+
__NOTE:__ Make sure the reference for this component does not change between renders else undefined behavior may happen.
|
|
284
|
+
*/
|
|
285
|
+
component?: React.ComponentType<TCustomComponentProps>;
|
|
286
|
+
}
|
|
287
|
+
export interface SkeletonItemProps {
|
|
288
|
+
/**
|
|
289
|
+
* Renders a skeleton circle in the `iconBefore` location.
|
|
290
|
+
* Takes priority over `hasIcon.
|
|
291
|
+
*/
|
|
292
|
+
hasAvatar?: boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Renders a skeleton square in the `iconBefore` location.
|
|
295
|
+
*/
|
|
296
|
+
hasIcon?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
*
|
|
299
|
+
* Width of the skeleton item.
|
|
300
|
+
* Generally you don't need to specify this as it has a staggered width based on `:nth-child` by default.
|
|
301
|
+
*/
|
|
302
|
+
width?: Dimension;
|
|
303
|
+
/**
|
|
304
|
+
* A `testId` prop is provided for specified elements,
|
|
305
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
306
|
+
* serving as a hook for automated tests.
|
|
307
|
+
*/
|
|
308
|
+
testId?: string;
|
|
309
|
+
/**
|
|
310
|
+
* Causes to the skeleton to have a slight horizontal shimmer.
|
|
311
|
+
* Only use this when you want to bring more attention to the loading content.
|
|
312
|
+
*/
|
|
313
|
+
isShimmering?: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* A function that overrides the styles of this component.
|
|
316
|
+
* It receives the current styles and returns a customized styles object.
|
|
317
|
+
*/
|
|
318
|
+
cssFn?: StatelessCSSFn;
|
|
319
|
+
}
|
|
320
|
+
export interface HeadingItemProps {
|
|
321
|
+
/**
|
|
322
|
+
A function that overrides the styles.
|
|
323
|
+
It receives the current styles and returns a customized styles object.
|
|
324
|
+
|
|
325
|
+
@deprecated This API is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
326
|
+
*/
|
|
327
|
+
cssFn?: StatelessCSSFn;
|
|
328
|
+
/**
|
|
329
|
+
* The text of the heading.
|
|
330
|
+
*/
|
|
331
|
+
children: React.ReactNode;
|
|
332
|
+
/**
|
|
333
|
+
* A unique identifier that can be referenced in the `labelledby` prop of a
|
|
334
|
+
* section to allow screen readers to announce the name of groups.
|
|
335
|
+
*/
|
|
336
|
+
id?: string;
|
|
337
|
+
/**
|
|
338
|
+
* A `testId` prop is provided for specified elements,
|
|
339
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
340
|
+
* serving as a hook for automated tests.
|
|
341
|
+
*/
|
|
342
|
+
testId?: string;
|
|
343
|
+
}
|
|
344
|
+
export interface SkeletonHeadingItemProps {
|
|
345
|
+
/**
|
|
346
|
+
*
|
|
347
|
+
* Width of the skeleton heading item.
|
|
348
|
+
* Generally you don't need to specify this as it has a staggered width based on `:nth-child` by default.
|
|
349
|
+
*/
|
|
350
|
+
width?: Dimension;
|
|
351
|
+
/**
|
|
352
|
+
* A `testId` prop is provided for specified elements,
|
|
353
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
354
|
+
* serving as a hook for automated tests.
|
|
355
|
+
*/
|
|
356
|
+
testId?: string;
|
|
357
|
+
/**
|
|
358
|
+
* Causes to the skeleton to have a slight horizontal shimmer.
|
|
359
|
+
* Only use this when you want to bring more attention to the loading content.
|
|
360
|
+
*/
|
|
361
|
+
isShimmering?: boolean;
|
|
362
|
+
/**
|
|
363
|
+
A function that overrides the styles of this component.
|
|
364
|
+
It receives the current styles and returns a customized styles object.
|
|
365
|
+
|
|
366
|
+
@deprecated This API is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
367
|
+
*/
|
|
368
|
+
cssFn?: StatelessCSSFn;
|
|
369
|
+
}
|
|
370
|
+
export type ItemState = {
|
|
371
|
+
isSelected: boolean;
|
|
372
|
+
isDisabled: boolean;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
A function that overrides the styles of
|
|
376
|
+
menu components. It receives the current state
|
|
377
|
+
and should return a CSSObject.
|
|
378
|
+
|
|
379
|
+
@see @atlaskit/menu/docs/85-overriding-item-styles
|
|
380
|
+
@deprecated This type is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
381
|
+
*/
|
|
382
|
+
export interface CSSFn<TState = ItemState extends void ? void : ItemState> {
|
|
383
|
+
(currentState: TState): CSSObject | CSSObject[];
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* @deprecated This type is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
387
|
+
*/
|
|
388
|
+
export type StatelessCSSFn = CSSFn<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/menu",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "A collection of composable menu components that can be used anywhere.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@atlaskit/ds-explorations": "^2.1.0",
|
|
48
48
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
49
49
|
"@atlaskit/focus-ring": "^1.3.0",
|
|
50
|
+
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
50
51
|
"@atlaskit/primitives": "^0.9.0",
|
|
51
52
|
"@atlaskit/theme": "^12.5.0",
|
|
52
53
|
"@atlaskit/tokens": "^1.4.0",
|
|
@@ -68,6 +69,7 @@
|
|
|
68
69
|
"@atlaskit/visual-regression": "*",
|
|
69
70
|
"@atlaskit/webdriver-runner": "*",
|
|
70
71
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
72
|
+
"@atlassian/feature-flags-test-utils": "*",
|
|
71
73
|
"@emotion/jest": "^11.8.0",
|
|
72
74
|
"@testing-library/dom": "^8.17.1",
|
|
73
75
|
"@testing-library/react": "^12.1.5",
|
|
@@ -105,6 +107,11 @@
|
|
|
105
107
|
"deprecation": "no-deprecated-imports"
|
|
106
108
|
}
|
|
107
109
|
},
|
|
110
|
+
"platform-feature-flags": {
|
|
111
|
+
"platform.design-system-team.menu-selected-state-change_0see9": {
|
|
112
|
+
"type": "boolean"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
108
115
|
"homepage": "https://atlassian.design/components/menu/",
|
|
109
116
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
110
117
|
}
|