@atlaskit/menu 1.1.3 → 1.2.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 +53 -0
- package/dist/cjs/internal/components/menu-item-primitive.js +200 -0
- package/dist/cjs/menu-item/button-item.js +31 -25
- package/dist/cjs/menu-item/custom-item.js +31 -32
- package/dist/cjs/menu-item/heading-item.js +25 -7
- package/dist/cjs/menu-item/link-item.js +50 -45
- package/dist/cjs/menu-item/skeleton-heading-item.js +42 -14
- package/dist/cjs/menu-item/skeleton-item.js +93 -13
- package/dist/cjs/menu-section/menu-group.js +11 -8
- package/dist/cjs/menu-section/section.js +83 -29
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/internal/components/menu-item-primitive.js +180 -0
- package/dist/es2019/menu-item/button-item.js +28 -21
- package/dist/es2019/menu-item/custom-item.js +32 -24
- package/dist/es2019/menu-item/heading-item.js +22 -6
- package/dist/es2019/menu-item/link-item.js +31 -26
- package/dist/es2019/menu-item/skeleton-heading-item.js +37 -11
- package/dist/es2019/menu-item/skeleton-item.js +89 -11
- package/dist/es2019/menu-section/menu-group.js +12 -8
- package/dist/es2019/menu-section/section.js +83 -31
- package/dist/es2019/version.json +1 -1
- package/dist/esm/internal/components/menu-item-primitive.js +184 -0
- package/dist/esm/menu-item/button-item.js +30 -24
- package/dist/esm/menu-item/custom-item.js +32 -26
- package/dist/esm/menu-item/heading-item.js +22 -8
- package/dist/esm/menu-item/link-item.js +49 -45
- package/dist/esm/menu-item/skeleton-heading-item.js +38 -14
- package/dist/esm/menu-item/skeleton-item.js +89 -13
- package/dist/esm/menu-section/menu-group.js +12 -8
- package/dist/esm/menu-section/section.js +82 -32
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/components/menu-item-primitive.d.ts +17 -0
- package/dist/types/menu-item/button-item.d.ts +1 -1
- package/dist/types/menu-item/custom-item.d.ts +2 -1
- package/dist/types/menu-item/skeleton-heading-item.d.ts +1 -2
- package/dist/types/menu-item/skeleton-item.d.ts +1 -2
- package/dist/types/types.d.ts +27 -7
- package/package.json +4 -2
- package/dist/cjs/internal/components/base-item.js +0 -65
- package/dist/cjs/internal/styles/menu-item/base-item.js +0 -152
- package/dist/cjs/internal/styles/menu-item/button-item.js +0 -28
- package/dist/cjs/internal/styles/menu-item/custom-item.js +0 -24
- package/dist/cjs/internal/styles/menu-item/heading-item.js +0 -28
- package/dist/cjs/internal/styles/menu-item/link-item.js +0 -22
- package/dist/cjs/internal/styles/menu-item/skeleton-heading-item.js +0 -50
- package/dist/cjs/internal/styles/menu-item/skeleton-item.js +0 -98
- package/dist/cjs/internal/styles/menu-section/menu-group.js +0 -24
- package/dist/cjs/internal/styles/menu-section/section.js +0 -83
- package/dist/es2019/internal/components/base-item.js +0 -51
- package/dist/es2019/internal/styles/menu-item/base-item.js +0 -122
- package/dist/es2019/internal/styles/menu-item/button-item.js +0 -9
- package/dist/es2019/internal/styles/menu-item/custom-item.js +0 -5
- package/dist/es2019/internal/styles/menu-item/heading-item.js +0 -16
- package/dist/es2019/internal/styles/menu-item/link-item.js +0 -3
- package/dist/es2019/internal/styles/menu-item/skeleton-heading-item.js +0 -25
- package/dist/es2019/internal/styles/menu-item/skeleton-item.js +0 -75
- package/dist/es2019/internal/styles/menu-section/menu-group.js +0 -14
- package/dist/es2019/internal/styles/menu-section/section.js +0 -62
- package/dist/esm/internal/components/base-item.js +0 -55
- package/dist/esm/internal/styles/menu-item/base-item.js +0 -124
- package/dist/esm/internal/styles/menu-item/button-item.js +0 -16
- package/dist/esm/internal/styles/menu-item/custom-item.js +0 -12
- package/dist/esm/internal/styles/menu-item/heading-item.js +0 -16
- package/dist/esm/internal/styles/menu-item/link-item.js +0 -10
- package/dist/esm/internal/styles/menu-item/skeleton-heading-item.js +0 -33
- package/dist/esm/internal/styles/menu-item/skeleton-item.js +0 -81
- package/dist/esm/internal/styles/menu-section/menu-group.js +0 -15
- package/dist/esm/internal/styles/menu-section/section.js +0 -67
- package/dist/types/internal/components/base-item.d.ts +0 -9
- package/dist/types/internal/styles/menu-item/base-item.d.ts +0 -23
- package/dist/types/internal/styles/menu-item/button-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/custom-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/heading-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/link-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/skeleton-heading-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/skeleton-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-section/menu-group.d.ts +0 -3
- package/dist/types/internal/styles/menu-section/section.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @atlaskit/menu
|
|
2
2
|
|
|
3
|
+
## 1.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2eeb5c46710`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2eeb5c46710) - Menu items can take `data-testid` directly again however we recommend to still use the officially supported `testId` prop instead. The `data-testid` prop was unintentionally removed in a previous version however will be removed as a breaking change in a later major version and remains not officially typed.
|
|
8
|
+
|
|
9
|
+
## 1.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`2b2290121eb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2b2290121eb) - Raised the minimum version carat range of focus ring to latest.
|
|
14
|
+
|
|
15
|
+
## 1.2.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [`213bfd77e61`](https://bitbucket.org/atlassian/atlassian-frontend/commits/213bfd77e61) - The DOM structure of menu item components has been flattened.
|
|
20
|
+
If you used CSS hacks (via className or cssFn) that targetted specific DOM nodes you may be broken.
|
|
21
|
+
|
|
22
|
+
Previously the structure looked like:
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
<button>
|
|
26
|
+
<div> // <-- this intermediate div has been removed
|
|
27
|
+
<span>
|
|
28
|
+
<span />
|
|
29
|
+
</span>
|
|
30
|
+
</div>
|
|
31
|
+
</button>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Now it looks like:
|
|
35
|
+
|
|
36
|
+
```jsx
|
|
37
|
+
<button>
|
|
38
|
+
<span>
|
|
39
|
+
<span />
|
|
40
|
+
</span>
|
|
41
|
+
</button>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- [`63888b03b49`](https://bitbucket.org/atlassian/atlassian-frontend/commits/63888b03b49) - Internal refactor to align style declarations to common techstack.
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies
|
|
49
|
+
|
|
50
|
+
## 1.1.4
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- [`34282240102`](https://bitbucket.org/atlassian/atlassian-frontend/commits/34282240102) - Adds explicit type to button usages components.
|
|
55
|
+
|
|
3
56
|
## 1.1.3
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
|
|
12
|
+
var _core = require("@emotion/core");
|
|
13
|
+
|
|
14
|
+
var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
|
|
15
|
+
|
|
16
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
17
|
+
|
|
18
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
19
|
+
|
|
20
|
+
var _typography = require("@atlaskit/theme/typography");
|
|
21
|
+
|
|
22
|
+
var _tokens = require("@atlaskit/tokens");
|
|
23
|
+
|
|
24
|
+
/** @jsx jsx */
|
|
25
|
+
var defaultRender = function defaultRender(Component, props) {
|
|
26
|
+
return (0, _core.jsx)(Component, props);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var gridSize = (0, _constants.gridSize)();
|
|
30
|
+
var fontSize = (0, _constants.fontSize)();
|
|
31
|
+
var itemTopBottomPadding = gridSize;
|
|
32
|
+
var itemSidePadding = gridSize * 2.5;
|
|
33
|
+
var itemElemSpacing = gridSize * 1.5;
|
|
34
|
+
var itemDescriptionSpacing = gridSize * 0.375;
|
|
35
|
+
var itemMinHeight = gridSize * 5;
|
|
36
|
+
var beforeElementStyles = (0, _core.css)({
|
|
37
|
+
display: 'flex',
|
|
38
|
+
marginRight: itemElemSpacing,
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
flexShrink: 0
|
|
41
|
+
});
|
|
42
|
+
var afterElementStyles = (0, _core.css)({
|
|
43
|
+
display: 'flex',
|
|
44
|
+
marginLeft: itemElemSpacing,
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
flexShrink: 0
|
|
47
|
+
});
|
|
48
|
+
var contentStyles = (0, _core.css)({
|
|
49
|
+
display: 'flex',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
flexDirection: 'column',
|
|
52
|
+
flexGrow: 1,
|
|
53
|
+
// Fix - avoid clipped text descenders when using standard 16px line-height
|
|
54
|
+
lineHeight: 1.22,
|
|
55
|
+
outline: 'none',
|
|
56
|
+
overflow: 'hidden',
|
|
57
|
+
textAlign: 'left'
|
|
58
|
+
});
|
|
59
|
+
var truncateStyles = (0, _core.css)({
|
|
60
|
+
display: 'block',
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
textOverflow: 'ellipsis',
|
|
63
|
+
whiteSpace: 'nowrap'
|
|
64
|
+
});
|
|
65
|
+
var wordBreakStyles = (0, _core.css)({
|
|
66
|
+
wordBreak: 'break-word'
|
|
67
|
+
});
|
|
68
|
+
var descriptionStyles = (0, _core.css)({
|
|
69
|
+
marginTop: itemDescriptionSpacing,
|
|
70
|
+
color: (0, _tokens.token)('color.text.lowEmphasis', _colors.N200),
|
|
71
|
+
fontSize: _typography.headingSizes.h200.size
|
|
72
|
+
});
|
|
73
|
+
var primitiveStyles = (0, _core.css)({
|
|
74
|
+
display: 'flex',
|
|
75
|
+
boxSizing: 'border-box',
|
|
76
|
+
width: '100%',
|
|
77
|
+
minHeight: itemMinHeight,
|
|
78
|
+
margin: 0,
|
|
79
|
+
padding: "".concat(itemTopBottomPadding, "px ").concat(itemSidePadding, "px"),
|
|
80
|
+
alignItems: 'center',
|
|
81
|
+
border: 0,
|
|
82
|
+
fontSize: fontSize,
|
|
83
|
+
outline: 0,
|
|
84
|
+
textDecoration: 'none',
|
|
85
|
+
userSelect: 'none',
|
|
86
|
+
'::-moz-focus-inner': {
|
|
87
|
+
border: 0
|
|
88
|
+
},
|
|
89
|
+
':hover': {
|
|
90
|
+
textDecoration: 'none'
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
var interactiveStyles = (0, _core.css)({
|
|
94
|
+
cursor: 'pointer'
|
|
95
|
+
});
|
|
96
|
+
var unselectedStyles = (0, _core.css)({
|
|
97
|
+
backgroundColor: 'transparent',
|
|
98
|
+
color: 'currentColor',
|
|
99
|
+
':visited': {
|
|
100
|
+
color: 'currentColor'
|
|
101
|
+
},
|
|
102
|
+
':hover': {
|
|
103
|
+
backgroundColor: (0, _tokens.token)('color.background.transparentNeutral.hover', _colors.N20),
|
|
104
|
+
color: 'currentColor'
|
|
105
|
+
},
|
|
106
|
+
':active': {
|
|
107
|
+
backgroundColor: (0, _tokens.token)('color.background.transparentNeutral.pressed', _colors.N30),
|
|
108
|
+
boxShadow: 'none',
|
|
109
|
+
color: 'currentColor'
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
var disabledStyles = (0, _core.css)({
|
|
113
|
+
cursor: 'not-allowed',
|
|
114
|
+
'&, :hover, :active': {
|
|
115
|
+
backgroundColor: 'transparent',
|
|
116
|
+
color: (0, _tokens.token)('color.text.disabled', _colors.N200)
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
var selectedStyles = (0, _core.css)({
|
|
120
|
+
backgroundColor: (0, _tokens.token)('color.background.selected.resting', _colors.N20),
|
|
121
|
+
// Suppress the need for a fallback as selected color isn't used in the non-tokens world.
|
|
122
|
+
// When removing fallbacks make sure to remove this supression.
|
|
123
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
124
|
+
color: (0, _tokens.token)('color.text.selected'),
|
|
125
|
+
':visited': {
|
|
126
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
127
|
+
color: (0, _tokens.token)('color.text.selected')
|
|
128
|
+
},
|
|
129
|
+
':hover': {
|
|
130
|
+
backgroundColor: (0, _tokens.token)('color.background.selected.hover', _colors.N20),
|
|
131
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
132
|
+
color: (0, _tokens.token)('color.text.selected')
|
|
133
|
+
},
|
|
134
|
+
':active': {
|
|
135
|
+
backgroundColor: (0, _tokens.token)('color.background.selected.pressed', _colors.N30),
|
|
136
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
137
|
+
color: (0, _tokens.token)('color.text.selected')
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* __Menu item primitive__
|
|
142
|
+
*
|
|
143
|
+
* Menu item primitive contains all the styles for menu items,
|
|
144
|
+
* including support for selected, disabled, and interaction states.
|
|
145
|
+
*
|
|
146
|
+
* Using children as function prop you wire up this to your own host element.
|
|
147
|
+
*
|
|
148
|
+
* ```jsx
|
|
149
|
+
* <MenuItemPrimitive>
|
|
150
|
+
* {({ children, ...props }) => <button {...props}>{children}</button>}
|
|
151
|
+
* </MenuItemPrimitive>
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
|
|
156
|
+
var children = _ref.children,
|
|
157
|
+
title = _ref.title,
|
|
158
|
+
description = _ref.description,
|
|
159
|
+
iconAfter = _ref.iconAfter,
|
|
160
|
+
iconBefore = _ref.iconBefore,
|
|
161
|
+
overrides = _ref.overrides,
|
|
162
|
+
className = _ref.className,
|
|
163
|
+
_ref$shouldTitleWrap = _ref.shouldTitleWrap,
|
|
164
|
+
shouldTitleWrap = _ref$shouldTitleWrap === void 0 ? false : _ref$shouldTitleWrap,
|
|
165
|
+
_ref$shouldDescriptio = _ref.shouldDescriptionWrap,
|
|
166
|
+
shouldDescriptionWrap = _ref$shouldDescriptio === void 0 ? false : _ref$shouldDescriptio,
|
|
167
|
+
_ref$isDisabled = _ref.isDisabled,
|
|
168
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
169
|
+
_ref$isSelected = _ref.isSelected,
|
|
170
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
|
|
171
|
+
var renderTitle = overrides && overrides.Title && overrides.Title.render || defaultRender;
|
|
172
|
+
return (0, _core.jsx)(_core.ClassNames, null, function (_ref2) {
|
|
173
|
+
var cn = _ref2.css,
|
|
174
|
+
cx = _ref2.cx;
|
|
175
|
+
return (0, _core.jsx)(_focusRing.default, {
|
|
176
|
+
isInset: true
|
|
177
|
+
}, children({
|
|
178
|
+
className: cx([cn([primitiveStyles, !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && selectedStyles, isDisabled ? disabledStyles : interactiveStyles]), className]),
|
|
179
|
+
children: (0, _core.jsx)(_react.Fragment, null, iconBefore && (0, _core.jsx)("span", {
|
|
180
|
+
"data-item-elem-before": true,
|
|
181
|
+
css: beforeElementStyles
|
|
182
|
+
}, iconBefore), title && (0, _core.jsx)("span", {
|
|
183
|
+
css: contentStyles
|
|
184
|
+
}, renderTitle('span', {
|
|
185
|
+
children: title,
|
|
186
|
+
className: cn(shouldTitleWrap ? wordBreakStyles : truncateStyles),
|
|
187
|
+
'data-item-title': true
|
|
188
|
+
}), description && (0, _core.jsx)("span", {
|
|
189
|
+
"data-item-description": true,
|
|
190
|
+
css: [descriptionStyles, shouldDescriptionWrap ? wordBreakStyles : truncateStyles]
|
|
191
|
+
}, description)), iconAfter && (0, _core.jsx)("span", {
|
|
192
|
+
"data-item-elem-after": true,
|
|
193
|
+
css: afterElementStyles
|
|
194
|
+
}, iconAfter))
|
|
195
|
+
}));
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
var _default = MenuItemPrimitive;
|
|
200
|
+
exports.default = _default;
|
|
@@ -15,18 +15,18 @@ var _react = require("react");
|
|
|
15
15
|
|
|
16
16
|
var _core = require("@emotion/core");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _menuItemPrimitive = _interopRequireDefault(require("../internal/components/menu-item-primitive"));
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _useBlurOnMouseDown = require("../internal/hooks/use-blur-on-mouse-down");
|
|
23
23
|
|
|
24
24
|
/** @jsx jsx */
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* __Button item__
|
|
28
28
|
*
|
|
29
|
-
* A button item is used to populate a menu with items that
|
|
29
|
+
* A button item is used to populate a menu with items that are buttons.
|
|
30
30
|
*
|
|
31
31
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/button-item)
|
|
32
32
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
@@ -35,9 +35,7 @@ var ButtonItem = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardR
|
|
|
35
35
|
function (props, ref) {
|
|
36
36
|
var children = props.children,
|
|
37
37
|
_props$cssFn = props.cssFn,
|
|
38
|
-
cssFn = _props$cssFn === void 0 ?
|
|
39
|
-
return {};
|
|
40
|
-
} : _props$cssFn,
|
|
38
|
+
cssFn = _props$cssFn === void 0 ? _noop.default : _props$cssFn,
|
|
41
39
|
description = props.description,
|
|
42
40
|
iconAfter = props.iconAfter,
|
|
43
41
|
iconBefore = props.iconBefore,
|
|
@@ -51,35 +49,43 @@ function (props, ref) {
|
|
|
51
49
|
onMouseDown = props.onMouseDown,
|
|
52
50
|
shouldTitleWrap = props.shouldTitleWrap,
|
|
53
51
|
shouldDescriptionWrap = props.shouldDescriptionWrap,
|
|
54
|
-
|
|
52
|
+
rest = (0, _objectWithoutProperties2.default)(props, ["children", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap"]);
|
|
55
53
|
var onMouseDownHandler = (0, _useBlurOnMouseDown.useBlurOnMouseDown)(onMouseDown);
|
|
56
54
|
|
|
57
55
|
if (!children) {
|
|
58
56
|
return null;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
return (0, _core.jsx)(
|
|
62
|
-
|
|
63
|
-
(0, _buttonItem.buttonItemCSS)(isDisabled, isSelected), // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
64
|
-
cssFn({
|
|
65
|
-
isSelected: isSelected,
|
|
66
|
-
isDisabled: isDisabled
|
|
67
|
-
})],
|
|
68
|
-
type: "button",
|
|
69
|
-
"data-testid": testId,
|
|
70
|
-
disabled: isDisabled,
|
|
71
|
-
onClick: onClick,
|
|
72
|
-
onMouseDown: onMouseDownHandler,
|
|
73
|
-
ref: ref
|
|
74
|
-
}, others), (0, _core.jsx)(_baseItem.default // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
75
|
-
, {
|
|
59
|
+
return (0, _core.jsx)(_menuItemPrimitive.default, (0, _extends2.default)({}, rest, {
|
|
60
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
76
61
|
overrides: overrides,
|
|
77
62
|
iconBefore: iconBefore,
|
|
78
63
|
iconAfter: iconAfter,
|
|
64
|
+
isDisabled: isDisabled,
|
|
65
|
+
isSelected: isSelected,
|
|
79
66
|
description: description,
|
|
67
|
+
title: children,
|
|
80
68
|
shouldTitleWrap: shouldTitleWrap,
|
|
81
|
-
shouldDescriptionWrap: shouldDescriptionWrap
|
|
82
|
-
|
|
69
|
+
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
70
|
+
css: // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
71
|
+
cssFn({
|
|
72
|
+
isSelected: isSelected,
|
|
73
|
+
isDisabled: isDisabled
|
|
74
|
+
})
|
|
75
|
+
}), function (_ref) {
|
|
76
|
+
var children = _ref.children,
|
|
77
|
+
className = _ref.className;
|
|
78
|
+
return (0, _core.jsx)("button", (0, _extends2.default)({
|
|
79
|
+
"data-testid": testId
|
|
80
|
+
}, rest, {
|
|
81
|
+
className: className,
|
|
82
|
+
ref: ref,
|
|
83
|
+
disabled: isDisabled,
|
|
84
|
+
onClick: onClick,
|
|
85
|
+
onMouseDown: onMouseDownHandler,
|
|
86
|
+
type: "button"
|
|
87
|
+
}), children);
|
|
88
|
+
});
|
|
83
89
|
}));
|
|
84
90
|
var _default = ButtonItem;
|
|
85
91
|
exports.default = _default;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
@@ -13,20 +11,17 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
11
|
|
|
14
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
13
|
|
|
16
|
-
var _react =
|
|
14
|
+
var _react = require("react");
|
|
17
15
|
|
|
18
16
|
var _core = require("@emotion/core");
|
|
19
17
|
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var _useBlurOnMouseDown = require("../internal/hooks/use-blur-on-mouse-down");
|
|
18
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
23
19
|
|
|
24
|
-
var
|
|
20
|
+
var _menuItemPrimitive = _interopRequireDefault(require("../internal/components/menu-item-primitive"));
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
var _useBlurOnMouseDown = require("../internal/hooks/use-blur-on-mouse-down");
|
|
29
23
|
|
|
24
|
+
/** @jsx jsx */
|
|
30
25
|
var preventEvent = function preventEvent(e) {
|
|
31
26
|
e.preventDefault();
|
|
32
27
|
}; // Dirty hack to get generics working with forward ref [1/2]
|
|
@@ -35,7 +30,7 @@ var preventEvent = function preventEvent(e) {
|
|
|
35
30
|
/**
|
|
36
31
|
* __Custom item__
|
|
37
32
|
*
|
|
38
|
-
* A custom item is used to populate a menu with items that
|
|
33
|
+
* A custom item is used to populate a menu with items that can be any element.
|
|
39
34
|
*
|
|
40
35
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/custom-item)
|
|
41
36
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
@@ -43,9 +38,7 @@ var preventEvent = function preventEvent(e) {
|
|
|
43
38
|
var CustomItem = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
44
39
|
var Component = _ref.component,
|
|
45
40
|
_ref$cssFn = _ref.cssFn,
|
|
46
|
-
cssFn = _ref$cssFn === void 0 ?
|
|
47
|
-
return {};
|
|
48
|
-
} : _ref$cssFn,
|
|
41
|
+
cssFn = _ref$cssFn === void 0 ? _noop.default : _ref$cssFn,
|
|
49
42
|
_ref$isDisabled = _ref.isDisabled,
|
|
50
43
|
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
51
44
|
_ref$isSelected = _ref.isSelected,
|
|
@@ -67,31 +60,37 @@ var CustomItem = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardR
|
|
|
67
60
|
return null;
|
|
68
61
|
}
|
|
69
62
|
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
return (0, _core.jsx)(_menuItemPrimitive.default, (0, _extends2.default)({}, rest, {
|
|
64
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
65
|
+
overrides: overrides,
|
|
66
|
+
description: description,
|
|
67
|
+
iconAfter: iconAfter,
|
|
68
|
+
title: children,
|
|
69
|
+
iconBefore: iconBefore,
|
|
70
|
+
isSelected: isSelected,
|
|
71
|
+
isDisabled: isDisabled,
|
|
72
|
+
shouldTitleWrap: shouldTitleWrap,
|
|
73
|
+
shouldDescriptionWrap: shouldDescriptionWrap // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
74
|
+
,
|
|
75
|
+
css: (0, _core.css)(cssFn({
|
|
76
|
+
isDisabled: isDisabled,
|
|
77
|
+
isSelected: isSelected
|
|
78
|
+
}))
|
|
79
|
+
}), function (_ref2) {
|
|
80
|
+
var children = _ref2.children,
|
|
81
|
+
className = _ref2.className;
|
|
82
|
+
return (0, _core.jsx)(Component, (0, _extends2.default)({
|
|
83
|
+
"data-testid": testId
|
|
84
|
+
}, rest, {
|
|
85
|
+
className: className,
|
|
73
86
|
ref: ref,
|
|
74
|
-
"data-testid": testId,
|
|
75
87
|
draggable: false,
|
|
76
|
-
className: css([(0, _customItem.customItemCSS)(isDisabled, isSelected), cssFn({
|
|
77
|
-
isDisabled: isDisabled,
|
|
78
|
-
isSelected: isSelected
|
|
79
|
-
})]),
|
|
80
88
|
onDragStart: preventEvent,
|
|
81
89
|
onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
|
|
82
90
|
onClick: isDisabled ? preventEvent : onClick,
|
|
83
91
|
tabIndex: isDisabled ? -1 : undefined,
|
|
84
92
|
"aria-disabled": isDisabled
|
|
85
|
-
},
|
|
86
|
-
, {
|
|
87
|
-
overrides: overrides,
|
|
88
|
-
children: children,
|
|
89
|
-
description: description,
|
|
90
|
-
iconAfter: iconAfter,
|
|
91
|
-
iconBefore: iconBefore,
|
|
92
|
-
shouldTitleWrap: shouldTitleWrap,
|
|
93
|
-
shouldDescriptionWrap: shouldDescriptionWrap
|
|
94
|
-
}));
|
|
93
|
+
}), children);
|
|
95
94
|
});
|
|
96
95
|
}) // Dirty hack to get generics working with forward ref [2/2]
|
|
97
96
|
);
|
|
@@ -15,10 +15,29 @@ var _react = require("react");
|
|
|
15
15
|
|
|
16
16
|
var _core = require("@emotion/core");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
21
|
+
|
|
22
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
23
|
+
|
|
24
|
+
var _typography = require("@atlaskit/theme/typography");
|
|
25
|
+
|
|
26
|
+
var _tokens = require("@atlaskit/tokens");
|
|
21
27
|
|
|
28
|
+
/** @jsx jsx */
|
|
29
|
+
var gridSize = (0, _constants.gridSize)();
|
|
30
|
+
var itemSidePadding = gridSize * 2.5;
|
|
31
|
+
var itemHeadingContentHeight = _typography.headingSizes.h100.lineHeight;
|
|
32
|
+
var itemHeadingFontSize = _typography.headingSizes.h100.size;
|
|
33
|
+
var headingStyles = (0, _core.css)({
|
|
34
|
+
padding: "0 ".concat(itemSidePadding, "px"),
|
|
35
|
+
color: (0, _tokens.token)('color.text.lowEmphasis', _colors.N200),
|
|
36
|
+
fontSize: itemHeadingFontSize,
|
|
37
|
+
fontWeight: 700,
|
|
38
|
+
lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
|
|
39
|
+
textTransform: 'uppercase'
|
|
40
|
+
});
|
|
22
41
|
/**
|
|
23
42
|
* __Heading item__
|
|
24
43
|
*
|
|
@@ -27,18 +46,17 @@ var _headingItem = require("../internal/styles/menu-item/heading-item");
|
|
|
27
46
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/heading-item)
|
|
28
47
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
29
48
|
*/
|
|
49
|
+
|
|
30
50
|
var HeadingItem = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
31
51
|
var children = _ref.children,
|
|
32
52
|
testId = _ref.testId,
|
|
33
53
|
id = _ref.id,
|
|
34
54
|
_ref$cssFn = _ref.cssFn,
|
|
35
|
-
cssFn = _ref$cssFn === void 0 ?
|
|
36
|
-
return {};
|
|
37
|
-
} : _ref$cssFn,
|
|
55
|
+
cssFn = _ref$cssFn === void 0 ? _noop.default : _ref$cssFn,
|
|
38
56
|
rest = (0, _objectWithoutProperties2.default)(_ref, ["children", "testId", "id", "cssFn"]);
|
|
39
57
|
return (0, _core.jsx)("div", (0, _extends2.default)({
|
|
40
|
-
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
41
|
-
|
|
58
|
+
css: [headingStyles, // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
59
|
+
cssFn(undefined)],
|
|
42
60
|
"data-testid": testId,
|
|
43
61
|
"data-ds--menu--heading-item": true,
|
|
44
62
|
id: id
|
|
@@ -15,11 +15,11 @@ var _react = require("react");
|
|
|
15
15
|
|
|
16
16
|
var _core = require("@emotion/core");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _menuItemPrimitive = _interopRequireDefault(require("../internal/components/menu-item-primitive"));
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _useBlurOnMouseDown = require("../internal/hooks/use-blur-on-mouse-down");
|
|
23
23
|
|
|
24
24
|
/** @jsx jsx */
|
|
25
25
|
var preventEvent = function preventEvent(e) {
|
|
@@ -36,59 +36,64 @@ var preventEvent = function preventEvent(e) {
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
var LinkItem = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)( // Type needed on props to extract types with extract react types.
|
|
39
|
-
function (
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
shouldTitleWrap = rest.shouldTitleWrap,
|
|
59
|
-
shouldDescriptionWrap = rest.shouldDescriptionWrap,
|
|
60
|
-
others = (0, _objectWithoutProperties2.default)(rest, ["children", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap"]);
|
|
39
|
+
function (props, ref) {
|
|
40
|
+
var children = props.children,
|
|
41
|
+
href = props.href,
|
|
42
|
+
_props$cssFn = props.cssFn,
|
|
43
|
+
cssFn = _props$cssFn === void 0 ? _noop.default : _props$cssFn,
|
|
44
|
+
description = props.description,
|
|
45
|
+
iconAfter = props.iconAfter,
|
|
46
|
+
iconBefore = props.iconBefore,
|
|
47
|
+
_props$isDisabled = props.isDisabled,
|
|
48
|
+
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
49
|
+
_props$isSelected = props.isSelected,
|
|
50
|
+
isSelected = _props$isSelected === void 0 ? false : _props$isSelected,
|
|
51
|
+
onClick = props.onClick,
|
|
52
|
+
testId = props.testId,
|
|
53
|
+
overrides = props.overrides,
|
|
54
|
+
onMouseDown = props.onMouseDown,
|
|
55
|
+
shouldTitleWrap = props.shouldTitleWrap,
|
|
56
|
+
shouldDescriptionWrap = props.shouldDescriptionWrap,
|
|
57
|
+
rest = (0, _objectWithoutProperties2.default)(props, ["children", "href", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap"]);
|
|
61
58
|
var onMouseDownHandler = (0, _useBlurOnMouseDown.useBlurOnMouseDown)(onMouseDown);
|
|
62
59
|
|
|
63
60
|
if (!children) {
|
|
64
61
|
return null;
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
return (0, _core.jsx)(
|
|
68
|
-
|
|
69
|
-
css: [// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
70
|
-
(0, _linkItem.linkItemCSS)(isDisabled, isSelected), // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
71
|
-
cssFn({
|
|
72
|
-
isSelected: isSelected,
|
|
73
|
-
isDisabled: isDisabled
|
|
74
|
-
})],
|
|
75
|
-
draggable: false,
|
|
76
|
-
href: isDisabled ? undefined : href,
|
|
77
|
-
"data-testid": testId,
|
|
78
|
-
onDragStart: preventEvent,
|
|
79
|
-
onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
|
|
80
|
-
onClick: isDisabled ? preventEvent : onClick,
|
|
81
|
-
"aria-current": isSelected ? 'page' : undefined,
|
|
82
|
-
"aria-disabled": isDisabled
|
|
83
|
-
}, others), (0, _core.jsx)(_baseItem.default // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
84
|
-
, {
|
|
64
|
+
return (0, _core.jsx)(_menuItemPrimitive.default, (0, _extends2.default)({}, rest, {
|
|
65
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
85
66
|
overrides: overrides,
|
|
86
67
|
iconBefore: iconBefore,
|
|
87
68
|
iconAfter: iconAfter,
|
|
69
|
+
isSelected: isSelected,
|
|
70
|
+
isDisabled: isDisabled,
|
|
88
71
|
description: description,
|
|
89
72
|
shouldTitleWrap: shouldTitleWrap,
|
|
90
|
-
shouldDescriptionWrap: shouldDescriptionWrap
|
|
91
|
-
|
|
73
|
+
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
74
|
+
css: // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
75
|
+
cssFn({
|
|
76
|
+
isSelected: isSelected,
|
|
77
|
+
isDisabled: isDisabled
|
|
78
|
+
}),
|
|
79
|
+
title: children
|
|
80
|
+
}), function (_ref) {
|
|
81
|
+
var children = _ref.children,
|
|
82
|
+
className = _ref.className;
|
|
83
|
+
return (0, _core.jsx)("a", (0, _extends2.default)({
|
|
84
|
+
"data-testid": testId
|
|
85
|
+
}, rest, {
|
|
86
|
+
className: className,
|
|
87
|
+
href: isDisabled ? undefined : href,
|
|
88
|
+
draggable: false,
|
|
89
|
+
onDragStart: preventEvent,
|
|
90
|
+
onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
|
|
91
|
+
onClick: isDisabled ? preventEvent : onClick,
|
|
92
|
+
"aria-current": isSelected ? 'page' : undefined,
|
|
93
|
+
"aria-disabled": isDisabled,
|
|
94
|
+
ref: ref
|
|
95
|
+
}), children);
|
|
96
|
+
});
|
|
92
97
|
}));
|
|
93
98
|
var _default = LinkItem;
|
|
94
99
|
exports.default = _default;
|