@atlaskit/menu 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/button-item/package.json +2 -2
- package/custom-item/package.json +2 -2
- 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 +9 -1
- package/dist/types/internal/components/skeleton-shimmer.d.ts +1 -1
- package/dist/types/types.d.ts +3 -3
- 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/heading-item/package.json +2 -2
- package/link-item/package.json +2 -2
- package/menu-group/package.json +2 -2
- package/package.json +18 -3
- package/popup-menu-group/package.json +2 -2
- package/section/package.json +2 -2
- package/skeleton-heading-item/package.json +2 -2
- package/skeleton-item/package.json +2 -2
- package/types/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/menu
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`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.
|
|
8
|
+
|
|
9
|
+
## 1.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
|
|
14
|
+
|
|
3
15
|
## 1.6.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/button-item/package.json
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"types": "../dist/types/entry-points/menu-item/button-item.d.ts",
|
|
8
8
|
"typesVersions": {
|
|
9
|
-
">=4.
|
|
9
|
+
">=4.5 <4.9": {
|
|
10
10
|
"*": [
|
|
11
|
-
"../dist/types-ts4.
|
|
11
|
+
"../dist/types-ts4.5/entry-points/menu-item/button-item.d.ts"
|
|
12
12
|
]
|
|
13
13
|
}
|
|
14
14
|
}
|
package/custom-item/package.json
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"types": "../dist/types/entry-points/menu-item/custom-item.d.ts",
|
|
8
8
|
"typesVersions": {
|
|
9
|
-
">=4.
|
|
9
|
+
">=4.5 <4.9": {
|
|
10
10
|
"*": [
|
|
11
|
-
"../dist/types-ts4.
|
|
11
|
+
"../dist/types-ts4.5/entry-points/menu-item/custom-item.d.ts"
|
|
12
12
|
]
|
|
13
13
|
}
|
|
14
14
|
}
|
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';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
2
|
+
export type SpacingMode = 'compact' | 'cozy';
|
|
3
3
|
/**
|
|
4
4
|
* __Spacing context__
|
|
5
5
|
*
|
|
@@ -8,3 +8,11 @@ export declare 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">;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface TitleOverrides {
|
|
|
20
20
|
export interface Overrides {
|
|
21
21
|
Title?: TitleOverrides;
|
|
22
22
|
}
|
|
23
|
-
export
|
|
23
|
+
export type Dimension = string | number;
|
|
24
24
|
export interface MenuGroupSizing {
|
|
25
25
|
/**
|
|
26
26
|
* Useful to constrain the menu group minimum height to a specific value.
|
|
@@ -367,7 +367,7 @@ export interface SkeletonHeadingItemProps {
|
|
|
367
367
|
*/
|
|
368
368
|
cssFn?: StatelessCSSFn;
|
|
369
369
|
}
|
|
370
|
-
export
|
|
370
|
+
export type ItemState = {
|
|
371
371
|
isSelected: boolean;
|
|
372
372
|
isDisabled: boolean;
|
|
373
373
|
};
|
|
@@ -385,4 +385,4 @@ export interface CSSFn<TState = ItemState extends void ? void : ItemState> {
|
|
|
385
385
|
/**
|
|
386
386
|
* @deprecated This type is deprecated and will be removed in a future release. See DSP-2676 for more information.
|
|
387
387
|
*/
|
|
388
|
-
export
|
|
388
|
+
export type StatelessCSSFn = CSSFn<void>;
|
|
@@ -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;
|