@atlaskit/menu 2.2.1 → 2.3.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +610 -596
  2. package/__perf__/custom.tsx +1 -1
  3. package/__perf__/utils/interaction-tasks.tsx +2 -2
  4. package/codemods/0.7.0-change-css-fn-prop.tsx +3 -2
  5. package/codemods/2.1.0-invalid-link-item-to-button-item.tsx +2 -1
  6. package/codemods/helpers/generic.tsx +4 -3
  7. package/dist/cjs/internal/components/menu-item-primitive.js +35 -25
  8. package/dist/cjs/menu-item/button-item.js +4 -1
  9. package/dist/cjs/menu-item/custom-item.js +4 -1
  10. package/dist/cjs/menu-item/heading-item.js +12 -5
  11. package/dist/cjs/menu-item/link-item.js +2 -0
  12. package/dist/cjs/menu-item/skeleton-heading-item.js +4 -1
  13. package/dist/cjs/menu-item/skeleton-item.js +4 -1
  14. package/dist/cjs/menu-section/menu-group.js +3 -1
  15. package/dist/cjs/menu-section/section.js +4 -0
  16. package/dist/es2019/internal/components/menu-item-primitive.js +34 -24
  17. package/dist/es2019/menu-item/button-item.js +4 -1
  18. package/dist/es2019/menu-item/custom-item.js +4 -1
  19. package/dist/es2019/menu-item/heading-item.js +12 -5
  20. package/dist/es2019/menu-item/link-item.js +2 -0
  21. package/dist/es2019/menu-item/skeleton-heading-item.js +4 -1
  22. package/dist/es2019/menu-item/skeleton-item.js +4 -1
  23. package/dist/es2019/menu-section/menu-group.js +3 -1
  24. package/dist/es2019/menu-section/section.js +4 -0
  25. package/dist/esm/internal/components/menu-item-primitive.js +34 -24
  26. package/dist/esm/menu-item/button-item.js +4 -1
  27. package/dist/esm/menu-item/custom-item.js +4 -1
  28. package/dist/esm/menu-item/heading-item.js +12 -5
  29. package/dist/esm/menu-item/link-item.js +2 -0
  30. package/dist/esm/menu-item/skeleton-heading-item.js +4 -1
  31. package/dist/esm/menu-item/skeleton-item.js +4 -1
  32. package/dist/esm/menu-section/menu-group.js +3 -1
  33. package/dist/esm/menu-section/section.js +4 -0
  34. package/dist/types/internal/components/skeleton-shimmer.d.ts +1 -1
  35. package/dist/types/types.d.ts +2 -2
  36. package/dist/types-ts4.5/internal/components/skeleton-shimmer.d.ts +1 -1
  37. package/dist/types-ts4.5/types.d.ts +2 -2
  38. package/package.json +8 -7
@@ -1,4 +1,4 @@
1
- import React, { Ref } from 'react';
1
+ import React, { type Ref } from 'react';
2
2
 
3
3
  import CustomItem from '../src/menu-item/custom-item';
4
4
  import type { CustomItemComponentProps, CustomItemProps } from '../src/types';
@@ -1,7 +1,7 @@
1
1
  import { fireEvent } from '@testing-library/dom';
2
2
  import {
3
- InteractionTaskArgs,
4
- PublicInteractionTask,
3
+ type InteractionTaskArgs,
4
+ type PublicInteractionTask,
5
5
  } from 'storybook-addon-performance';
6
6
 
7
7
  export const interactionTasks: PublicInteractionTask[] = [
@@ -1,7 +1,8 @@
1
- import { NodePath } from 'ast-types/lib/node-path';
2
- import core, {
1
+ import { type NodePath } from 'ast-types/lib/node-path';
2
+ import type {
3
3
  API,
4
4
  ASTPath,
5
+ default as core,
5
6
  FileInfo,
6
7
  ImportDeclaration,
7
8
  ImportSpecifier,
@@ -1,6 +1,7 @@
1
- import core, {
1
+ import type {
2
2
  API,
3
3
  ASTPath,
4
+ default as core,
4
5
  FileInfo,
5
6
  ImportDeclaration,
6
7
  ImportSpecifier,
@@ -1,6 +1,7 @@
1
- import { NodePath } from 'ast-types/lib/node-path';
2
- import core, {
1
+ import { type NodePath } from 'ast-types/lib/node-path';
2
+ import type {
3
3
  ASTPath,
4
+ default as core,
4
5
  ImportDeclaration,
5
6
  ImportDefaultSpecifier,
6
7
  ImportSpecifier,
@@ -9,7 +10,7 @@ import core, {
9
10
  Node,
10
11
  Program,
11
12
  } from 'jscodeshift';
12
- import { Collection } from 'jscodeshift/src/Collection';
13
+ import { type Collection } from 'jscodeshift/src/Collection';
13
14
 
14
15
  export type Nullable<T> = T | null;
15
16
 
@@ -10,7 +10,7 @@ var _react2 = require("@emotion/react");
10
10
  var _deprecationWarning = require("@atlaskit/ds-lib/deprecation-warning");
11
11
  var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
12
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
- var _inline = _interopRequireDefault(require("@atlaskit/primitives/inline"));
13
+ var _primitives = require("@atlaskit/primitives");
14
14
  var _colors = require("@atlaskit/theme/colors");
15
15
  var _menuContext = require("./menu-context");
16
16
  /** @jsx jsx */
@@ -27,29 +27,35 @@ var beforeAfterElementStyles = (0, _react2.css)({
27
27
  justifyContent: 'center',
28
28
  flexShrink: 0
29
29
  });
30
- var contentStyles = (0, _react2.css)({
31
- display: 'flex',
32
- justifyContent: 'center',
33
- flexDirection: 'column',
34
- flexGrow: 1,
35
- lineHeight: "var(--ds-font-lineHeight-100, 16px)",
30
+ var contentStyles = (0, _primitives.xcss)({
36
31
  outline: 'none',
37
32
  overflow: 'hidden',
38
33
  textAlign: 'left'
39
34
  });
35
+ var baseContentStyles = (0, _primitives.xcss)({
36
+ lineHeight: "var(--ds-font-lineHeight-100, 16px)"
37
+ });
40
38
  var truncateStyles = (0, _react2.css)({
41
39
  display: 'block',
42
40
  overflow: 'hidden',
43
41
  textOverflow: 'ellipsis',
44
42
  whiteSpace: 'nowrap'
45
43
  });
44
+ var titleStyles = (0, _react2.css)({
45
+ font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
46
+ });
46
47
  var wordBreakStyles = (0, _react2.css)({
47
48
  wordBreak: 'break-word'
48
49
  });
49
50
  var descriptionStyles = (0, _react2.css)({
50
- marginTop: "var(--ds-space-050, 4px)",
51
- color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")"),
52
- fontSize: "var(--ds-font-size-075, 12px)"
51
+ color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")")
52
+ });
53
+ var baseDescriptionStyles = (0, _react2.css)({
54
+ fontSize: "var(--ds-font-size-075, 12px)",
55
+ marginBlockStart: "var(--ds-space-050, 4px)"
56
+ });
57
+ var tokenizedDescriptionStyles = (0, _react2.css)({
58
+ font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
53
59
  });
54
60
  var disabledDescriptionStyles = (0, _react2.css)({
55
61
  color: "var(--ds-text-disabled, ".concat(_colors.N200, ")")
@@ -65,7 +71,6 @@ var primitiveStyles = (0, _react2.css)({
65
71
  margin: "var(--ds-space-0, 0px)",
66
72
  alignItems: 'center',
67
73
  border: 0,
68
- fontSize: "var(--ds-font-size-100, 14px)",
69
74
  outline: 0,
70
75
  textDecoration: 'none',
71
76
  userSelect: 'none',
@@ -76,6 +81,9 @@ var primitiveStyles = (0, _react2.css)({
76
81
  textDecoration: 'none'
77
82
  }
78
83
  });
84
+ var primitiveBaseStyles = (0, _react2.css)({
85
+ fontSize: "var(--ds-font-size-100, 14px)"
86
+ });
79
87
  var spacingMapStyles = {
80
88
  cozy: (0, _react2.css)({
81
89
  // 8 * 2 (16) + icon (24) === 40
@@ -119,23 +127,23 @@ var selectedBorderStyles = (0, _react2.css)({
119
127
  '&::before': {
120
128
  width: 2,
121
129
  position: 'absolute',
122
- top: 0,
123
- bottom: 0,
124
- left: 0,
125
130
  background: "var(--ds-border-selected, transparent)",
126
- content: '""'
131
+ content: '""',
132
+ insetBlockEnd: 0,
133
+ insetBlockStart: 0,
134
+ insetInlineStart: 0
127
135
  }
128
136
  });
129
137
  var selectedNotchStyles = (0, _react2.css)({
130
138
  '&::before': {
131
139
  width: 4,
132
140
  position: 'absolute',
133
- top: "var(--ds-space-150, 12px)",
134
- bottom: "var(--ds-space-150, 12px)",
135
- left: 0,
136
141
  background: "var(--ds-border-selected, transparent)",
137
142
  borderRadius: "0 ".concat("var(--ds-border-radius, 4px)", " ", "var(--ds-border-radius, 4px)", " 0"),
138
- content: '""'
143
+ content: '""',
144
+ insetBlockEnd: "var(--ds-space-150, 12px)",
145
+ insetBlockStart: "var(--ds-space-150, 12px)",
146
+ insetInlineStart: 0
139
147
  }
140
148
  });
141
149
  var selectedStyles = (0, _react2.css)({
@@ -202,8 +210,8 @@ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
202
210
  return (0, _react2.jsx)(_focusRing.default, {
203
211
  isInset: true
204
212
  }, children({
205
- className: cx([cn([positionRelativeStyles, primitiveStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && [selectedStyles, [selectionStyle === 'border' && selectedBorderStyles, selectionStyle === 'notch' && selectedNotchStyles]], isDisabled ? disabledStyles : interactiveStyles]), UNSAFE_className]),
206
- children: (0, _react2.jsx)(_inline.default, {
213
+ className: cx([cn([positionRelativeStyles, primitiveStyles, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.menu-tokenised-typography-styles') ? undefined : primitiveBaseStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && [selectedStyles, [selectionStyle === 'border' && selectedBorderStyles, selectionStyle === 'notch' && selectedNotchStyles]], isDisabled ? disabledStyles : interactiveStyles]), UNSAFE_className]),
214
+ children: (0, _react2.jsx)(_primitives.Inline, {
207
215
  as: "span",
208
216
  spread: "space-between",
209
217
  alignBlock: "center",
@@ -214,15 +222,17 @@ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
214
222
  "data-item-elem-before": true,
215
223
  css: beforeAfterElementStyles,
216
224
  "data-testid": testId && "".concat(testId, "--icon-before")
217
- }, iconBefore), title && (0, _react2.jsx)("span", {
218
- css: contentStyles
225
+ }, iconBefore), title && (0, _react2.jsx)(_primitives.Stack, {
226
+ alignBlock: "center",
227
+ grow: "fill",
228
+ xcss: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.menu-tokenised-typography-styles') ? contentStyles : [contentStyles, baseContentStyles]
219
229
  }, renderTitle('span', {
220
230
  children: title,
221
- className: cn(shouldTitleWrap ? wordBreakStyles : truncateStyles),
231
+ className: cn((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.menu-tokenised-typography-styles') ? titleStyles : undefined, shouldTitleWrap ? wordBreakStyles : truncateStyles),
222
232
  'data-item-title': true
223
233
  }), description && (0, _react2.jsx)("span", {
224
234
  "data-item-description": true,
225
- css: [descriptionStyles, isDisabled && disabledDescriptionStyles, shouldDescriptionWrap ? wordBreakStyles : truncateStyles]
235
+ css: [descriptionStyles, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.menu-tokenised-typography-styles') ? tokenizedDescriptionStyles : baseDescriptionStyles, isDisabled && disabledDescriptionStyles, shouldDescriptionWrap ? wordBreakStyles : truncateStyles]
226
236
  }, description)), iconAfter && (0, _react2.jsx)("span", {
227
237
  "data-item-elem-after": true,
228
238
  css: beforeAfterElementStyles,
@@ -50,7 +50,9 @@ function (props, ref) {
50
50
  }
51
51
  (0, _deprecationWarning.propDeprecationWarning)("@atlaskit/menu" || '', 'cssFn', cssFn !== _noop.default, '' // TODO: Create DAC post when primitives/xcss are available as alternatives
52
52
  );
53
- return (0, _react2.jsx)(_menuItemPrimitive.default, (0, _extends2.default)({
53
+ return (0, _react2.jsx)(_menuItemPrimitive.default
54
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
55
+ , (0, _extends2.default)({
54
56
  className: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
55
57
  }, rest, {
56
58
  // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
@@ -76,6 +78,7 @@ function (props, ref) {
76
78
  return (0, _react2.jsx)("button", (0, _extends2.default)({
77
79
  "data-testid": testId
78
80
  }, rest, {
81
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
79
82
  className: className,
80
83
  ref: ref,
81
84
  disabled: isDisabled,
@@ -55,7 +55,9 @@ var CustomItem = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardR
55
55
  }
56
56
  (0, _deprecationWarning.propDeprecationWarning)("@atlaskit/menu" || '', 'cssFn', cssFn !== _noop.default, '' // TODO: Create DAC post when primitives/xcss are available as alternatives
57
57
  );
58
- return (0, _react2.jsx)(_menuItemPrimitive.default, (0, _extends2.default)({
58
+ return (0, _react2.jsx)(_menuItemPrimitive.default
59
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
60
+ , (0, _extends2.default)({
59
61
  className: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
60
62
  }, rest, {
61
63
  // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
@@ -81,6 +83,7 @@ var CustomItem = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardR
81
83
  return (0, _react2.jsx)(Component, (0, _extends2.default)({
82
84
  "data-testid": testId
83
85
  }, rest, {
86
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
84
87
  className: className,
85
88
  ref: ref,
86
89
  draggable: false,
@@ -20,13 +20,18 @@ var itemHeadingContentHeight = _typography.headingSizes.h100.lineHeight;
20
20
  var itemHeadingFontSize = _typography.headingSizes.h100.size;
21
21
  var headingStyles = (0, _react2.css)({
22
22
  color: "var(--ds-text-subtle, ".concat(_colors.N300, ")"),
23
- fontSize: itemHeadingFontSize,
24
- fontWeight: "var(--ds-font-weight-bold, 700)",
25
- lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
26
23
  paddingBlock: "var(--ds-space-0, 0px)",
27
24
  paddingInline: "var(--ds-space-200, 16px)",
28
25
  textTransform: 'uppercase'
29
26
  });
27
+ var baseHeadingStyles = (0, _react2.css)({
28
+ fontSize: itemHeadingFontSize,
29
+ fontWeight: "var(--ds-font-weight-bold, 700)",
30
+ lineHeight: itemHeadingContentHeight / itemHeadingFontSize
31
+ });
32
+ var tokenizedHeadingStyles = (0, _react2.css)({
33
+ font: "var(--ds-font-heading-xxsmall, normal 600 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
34
+ });
30
35
 
31
36
  /**
32
37
  * __Heading item__
@@ -50,14 +55,16 @@ var HeadingItem = /*#__PURE__*/(0, _react.memo)(function (_ref) {
50
55
  );
51
56
  var UNSAFE_overrides = (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : (0, _react2.css)(cssFn(undefined));
52
57
  return (0, _react2.jsx)("div", (0, _extends2.default)({
53
- css: [headingStyles,
58
+ css: [headingStyles, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.menu-tokenised-typography-styles') ? tokenizedHeadingStyles : baseHeadingStyles,
54
59
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
55
60
  UNSAFE_overrides],
56
61
  role: "heading",
57
62
  "aria-level": headingLevel,
58
63
  "data-testid": testId,
59
64
  "data-ds--menu--heading-item": true,
60
- id: id,
65
+ id: id
66
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
67
+ ,
61
68
  className: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
62
69
  }, rest), children);
63
70
  });
@@ -56,6 +56,7 @@ function (props, ref) {
56
56
  (0, _deprecationWarning.propDeprecationWarning)("@atlaskit/menu" || '', 'cssFn', cssFn !== _noop.default, '' // TODO: Create DAC post when primitives/xcss are available as alternatives
57
57
  );
58
58
  return (0, _react2.jsx)(_menuItemPrimitive.default, (0, _extends2.default)({}, rest, {
59
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
59
60
  className: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
60
61
  // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
61
62
  ,
@@ -81,6 +82,7 @@ function (props, ref) {
81
82
  return (0, _react2.jsx)("a", (0, _extends2.default)({
82
83
  "data-testid": testId
83
84
  }, rest, {
85
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
84
86
  className: className,
85
87
  href: isDisabled ? undefined : href,
86
88
  draggable: false
@@ -59,7 +59,10 @@ var SkeletonHeadingItem = function SkeletonHeadingItem(_ref) {
59
59
  }, function (_ref2) {
60
60
  var className = _ref2.className;
61
61
  return (0, _react.jsx)("div", {
62
- className: className,
62
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
63
+ className: className
64
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
65
+ ,
63
66
  style: {
64
67
  '--width': width
65
68
  },
@@ -113,7 +113,10 @@ var SkeletonItem = function SkeletonItem(_ref) {
113
113
  }, function (_ref2) {
114
114
  var className = _ref2.className;
115
115
  return (0, _react.jsx)("div", {
116
- className: className,
116
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
117
+ className: className
118
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
119
+ ,
117
120
  style: {
118
121
  '--width': width
119
122
  },
@@ -53,7 +53,9 @@ var MenuGroup = function MenuGroup(_ref) {
53
53
  },
54
54
  css: baseStyles,
55
55
  "data-testid": testId,
56
- role: role,
56
+ role: role
57
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
58
+ ,
57
59
  className: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
58
60
  // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
59
61
  }, rest))));
@@ -109,11 +109,14 @@ var Section = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
109
109
  var UNSAFE_headingOverrides = (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : overrides && overrides.HeadingItem && overrides.HeadingItem.cssFn;
110
110
  var content = isList ? (0, _react2.jsx)("ul", {
111
111
  style: {
112
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
112
113
  margin: 0,
114
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
113
115
  padding: 0
114
116
  }
115
117
  }, _react.Children.map(_react.Children.toArray(children), function (child, index) {
116
118
  return (0, _react2.jsx)("li", {
119
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
117
120
  style: {
118
121
  listStyleType: 'none',
119
122
  margin: 0,
@@ -130,6 +133,7 @@ var Section = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
130
133
  "aria-hidden": true
131
134
  }, title), content) : (0, _react2.jsx)(_react.Fragment, null, content);
132
135
  return (0, _react2.jsx)("div", (0, _extends2.default)({}, rest, {
136
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
133
137
  className: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className,
134
138
  id: id
135
139
  // NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
@@ -4,7 +4,7 @@ import { ClassNames, css, jsx } from '@emotion/react';
4
4
  import { propDeprecationWarning } from '@atlaskit/ds-lib/deprecation-warning';
5
5
  import FocusRing from '@atlaskit/focus-ring';
6
6
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
- import Inline from '@atlaskit/primitives/inline';
7
+ import { Inline, Stack, xcss } from '@atlaskit/primitives';
8
8
  import { N20, N200, N30 } from '@atlaskit/theme/colors';
9
9
  import { SELECTION_STYLE_CONTEXT_DO_NOT_USE, SpacingContext } from './menu-context';
10
10
  const defaultRender = (Component, props) =>
@@ -16,29 +16,35 @@ const beforeAfterElementStyles = css({
16
16
  justifyContent: 'center',
17
17
  flexShrink: 0
18
18
  });
19
- const contentStyles = css({
20
- display: 'flex',
21
- justifyContent: 'center',
22
- flexDirection: 'column',
23
- flexGrow: 1,
24
- lineHeight: "var(--ds-font-lineHeight-100, 16px)",
19
+ const contentStyles = xcss({
25
20
  outline: 'none',
26
21
  overflow: 'hidden',
27
22
  textAlign: 'left'
28
23
  });
24
+ const baseContentStyles = xcss({
25
+ lineHeight: "var(--ds-font-lineHeight-100, 16px)"
26
+ });
29
27
  const truncateStyles = css({
30
28
  display: 'block',
31
29
  overflow: 'hidden',
32
30
  textOverflow: 'ellipsis',
33
31
  whiteSpace: 'nowrap'
34
32
  });
33
+ const titleStyles = css({
34
+ font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
35
+ });
35
36
  const wordBreakStyles = css({
36
37
  wordBreak: 'break-word'
37
38
  });
38
39
  const descriptionStyles = css({
39
- marginTop: "var(--ds-space-050, 4px)",
40
- color: `var(--ds-text-subtlest, ${N200})`,
41
- fontSize: "var(--ds-font-size-075, 12px)"
40
+ color: `var(--ds-text-subtlest, ${N200})`
41
+ });
42
+ const baseDescriptionStyles = css({
43
+ fontSize: "var(--ds-font-size-075, 12px)",
44
+ marginBlockStart: "var(--ds-space-050, 4px)"
45
+ });
46
+ const tokenizedDescriptionStyles = css({
47
+ font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
42
48
  });
43
49
  const disabledDescriptionStyles = css({
44
50
  color: `var(--ds-text-disabled, ${N200})`
@@ -54,7 +60,6 @@ const primitiveStyles = css({
54
60
  margin: "var(--ds-space-0, 0px)",
55
61
  alignItems: 'center',
56
62
  border: 0,
57
- fontSize: "var(--ds-font-size-100, 14px)",
58
63
  outline: 0,
59
64
  textDecoration: 'none',
60
65
  userSelect: 'none',
@@ -65,6 +70,9 @@ const primitiveStyles = css({
65
70
  textDecoration: 'none'
66
71
  }
67
72
  });
73
+ const primitiveBaseStyles = css({
74
+ fontSize: "var(--ds-font-size-100, 14px)"
75
+ });
68
76
  const spacingMapStyles = {
69
77
  cozy: css({
70
78
  // 8 * 2 (16) + icon (24) === 40
@@ -108,23 +116,23 @@ const selectedBorderStyles = css({
108
116
  '&::before': {
109
117
  width: 2,
110
118
  position: 'absolute',
111
- top: 0,
112
- bottom: 0,
113
- left: 0,
114
119
  background: "var(--ds-border-selected, transparent)",
115
- content: '""'
120
+ content: '""',
121
+ insetBlockEnd: 0,
122
+ insetBlockStart: 0,
123
+ insetInlineStart: 0
116
124
  }
117
125
  });
118
126
  const selectedNotchStyles = css({
119
127
  '&::before': {
120
128
  width: 4,
121
129
  position: 'absolute',
122
- top: "var(--ds-space-150, 12px)",
123
- bottom: "var(--ds-space-150, 12px)",
124
- left: 0,
125
130
  background: "var(--ds-border-selected, transparent)",
126
131
  borderRadius: `0 ${"var(--ds-border-radius, 4px)"} ${"var(--ds-border-radius, 4px)"} 0`,
127
- content: '""'
132
+ content: '""',
133
+ insetBlockEnd: "var(--ds-space-150, 12px)",
134
+ insetBlockStart: "var(--ds-space-150, 12px)",
135
+ insetInlineStart: 0
128
136
  }
129
137
  });
130
138
  const selectedStyles = css({
@@ -189,7 +197,7 @@ const MenuItemPrimitive = ({
189
197
  return jsx(FocusRing, {
190
198
  isInset: true
191
199
  }, children({
192
- className: cx([cn([positionRelativeStyles, primitiveStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && [selectedStyles, [selectionStyle === 'border' && selectedBorderStyles, selectionStyle === 'notch' && selectedNotchStyles]], isDisabled ? disabledStyles : interactiveStyles]), UNSAFE_className]),
200
+ className: cx([cn([positionRelativeStyles, primitiveStyles, getBooleanFF('platform.design-system-team.menu-tokenised-typography-styles') ? undefined : primitiveBaseStyles, spacingMapStyles[spacing], !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && [selectedStyles, [selectionStyle === 'border' && selectedBorderStyles, selectionStyle === 'notch' && selectedNotchStyles]], isDisabled ? disabledStyles : interactiveStyles]), UNSAFE_className]),
193
201
  children: jsx(Inline, {
194
202
  as: "span",
195
203
  spread: "space-between",
@@ -201,15 +209,17 @@ const MenuItemPrimitive = ({
201
209
  "data-item-elem-before": true,
202
210
  css: beforeAfterElementStyles,
203
211
  "data-testid": testId && `${testId}--icon-before`
204
- }, iconBefore), title && jsx("span", {
205
- css: contentStyles
212
+ }, iconBefore), title && jsx(Stack, {
213
+ alignBlock: "center",
214
+ grow: "fill",
215
+ xcss: getBooleanFF('platform.design-system-team.menu-tokenised-typography-styles') ? contentStyles : [contentStyles, baseContentStyles]
206
216
  }, renderTitle('span', {
207
217
  children: title,
208
- className: cn(shouldTitleWrap ? wordBreakStyles : truncateStyles),
218
+ className: cn(getBooleanFF('platform.design-system-team.menu-tokenised-typography-styles') ? titleStyles : undefined, shouldTitleWrap ? wordBreakStyles : truncateStyles),
209
219
  'data-item-title': true
210
220
  }), description && jsx("span", {
211
221
  "data-item-description": true,
212
- css: [descriptionStyles, isDisabled && disabledDescriptionStyles, shouldDescriptionWrap ? wordBreakStyles : truncateStyles]
222
+ css: [descriptionStyles, getBooleanFF('platform.design-system-team.menu-tokenised-typography-styles') ? tokenizedDescriptionStyles : baseDescriptionStyles, isDisabled && disabledDescriptionStyles, shouldDescriptionWrap ? wordBreakStyles : truncateStyles]
213
223
  }, description)), iconAfter && jsx("span", {
214
224
  "data-item-elem-after": true,
215
225
  css: beforeAfterElementStyles,
@@ -44,7 +44,9 @@ const ButtonItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(
44
44
  }
45
45
  propDeprecationWarning("@atlaskit/menu" || '', 'cssFn', cssFn !== noop, '' // TODO: Create DAC post when primitives/xcss are available as alternatives
46
46
  );
47
- return jsx(MenuItemPrimitive, _extends({
47
+ return jsx(MenuItemPrimitive
48
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
49
+ , _extends({
48
50
  className: getBooleanFF('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
49
51
  }, rest, {
50
52
  // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
@@ -70,6 +72,7 @@ const ButtonItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(
70
72
  }) => jsx("button", _extends({
71
73
  "data-testid": testId
72
74
  }, rest, {
75
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
73
76
  className: className,
74
77
  ref: ref,
75
78
  disabled: isDisabled,
@@ -49,7 +49,9 @@ const CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
49
49
  }
50
50
  propDeprecationWarning("@atlaskit/menu" || '', 'cssFn', cssFn !== noop, '' // TODO: Create DAC post when primitives/xcss are available as alternatives
51
51
  );
52
- return jsx(MenuItemPrimitive, _extends({
52
+ return jsx(MenuItemPrimitive
53
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
54
+ , _extends({
53
55
  className: getBooleanFF('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
54
56
  }, rest, {
55
57
  // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
@@ -75,6 +77,7 @@ const CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
75
77
  }) => jsx(Component, _extends({
76
78
  "data-testid": testId
77
79
  }, rest, {
80
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
78
81
  className: className,
79
82
  ref: ref,
80
83
  draggable: false,
@@ -11,13 +11,18 @@ const itemHeadingContentHeight = headingSizes.h100.lineHeight;
11
11
  const itemHeadingFontSize = headingSizes.h100.size;
12
12
  const headingStyles = css({
13
13
  color: `var(--ds-text-subtle, ${N300})`,
14
- fontSize: itemHeadingFontSize,
15
- fontWeight: "var(--ds-font-weight-bold, 700)",
16
- lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
17
14
  paddingBlock: "var(--ds-space-0, 0px)",
18
15
  paddingInline: "var(--ds-space-200, 16px)",
19
16
  textTransform: 'uppercase'
20
17
  });
18
+ const baseHeadingStyles = css({
19
+ fontSize: itemHeadingFontSize,
20
+ fontWeight: "var(--ds-font-weight-bold, 700)",
21
+ lineHeight: itemHeadingContentHeight / itemHeadingFontSize
22
+ });
23
+ const tokenizedHeadingStyles = css({
24
+ font: "var(--ds-font-heading-xxsmall, normal 600 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
25
+ });
21
26
 
22
27
  /**
23
28
  * __Heading item__
@@ -44,14 +49,16 @@ const HeadingItem = /*#__PURE__*/memo(({
44
49
  );
45
50
  const UNSAFE_overrides = getBooleanFF('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : css(cssFn(undefined));
46
51
  return jsx("div", _extends({
47
- css: [headingStyles,
52
+ css: [headingStyles, getBooleanFF('platform.design-system-team.menu-tokenised-typography-styles') ? tokenizedHeadingStyles : baseHeadingStyles,
48
53
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
49
54
  UNSAFE_overrides],
50
55
  role: "heading",
51
56
  "aria-level": headingLevel,
52
57
  "data-testid": testId,
53
58
  "data-ds--menu--heading-item": true,
54
- id: id,
59
+ id: id
60
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
61
+ ,
55
62
  className: getBooleanFF('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
56
63
  }, rest), children);
57
64
  });
@@ -50,6 +50,7 @@ const LinkItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(
50
50
  propDeprecationWarning("@atlaskit/menu" || '', 'cssFn', cssFn !== noop, '' // TODO: Create DAC post when primitives/xcss are available as alternatives
51
51
  );
52
52
  return jsx(MenuItemPrimitive, _extends({}, rest, {
53
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
53
54
  className: getBooleanFF('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
54
55
  // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
55
56
  ,
@@ -75,6 +76,7 @@ const LinkItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(
75
76
  }) => jsx("a", _extends({
76
77
  "data-testid": testId
77
78
  }, rest, {
79
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
78
80
  className: className,
79
81
  href: isDisabled ? undefined : href,
80
82
  draggable: false
@@ -51,7 +51,10 @@ const SkeletonHeadingItem = ({
51
51
  }, ({
52
52
  className
53
53
  }) => jsx("div", {
54
- className: className,
54
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
55
+ className: className
56
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
57
+ ,
55
58
  style: {
56
59
  '--width': width
57
60
  },
@@ -107,7 +107,10 @@ const SkeletonItem = ({
107
107
  }, ({
108
108
  className
109
109
  }) => jsx("div", {
110
- className: className,
110
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
111
+ className: className
112
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
113
+ ,
111
114
  style: {
112
115
  '--width': width
113
116
  },
@@ -47,7 +47,9 @@ const MenuGroup = ({
47
47
  },
48
48
  css: baseStyles,
49
49
  "data-testid": testId,
50
- role: role,
50
+ role: role
51
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
52
+ ,
51
53
  className: getBooleanFF('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className
52
54
  // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
53
55
  }, rest))));
@@ -104,10 +104,13 @@ const Section = /*#__PURE__*/forwardRef(({
104
104
  const UNSAFE_headingOverrides = getBooleanFF('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : overrides && overrides.HeadingItem && overrides.HeadingItem.cssFn;
105
105
  const content = isList ? jsx("ul", {
106
106
  style: {
107
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
107
108
  margin: 0,
109
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
108
110
  padding: 0
109
111
  }
110
112
  }, Children.map(Children.toArray(children), (child, index) => jsx("li", {
113
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
111
114
  style: {
112
115
  listStyleType: 'none',
113
116
  margin: 0,
@@ -123,6 +126,7 @@ const Section = /*#__PURE__*/forwardRef(({
123
126
  "aria-hidden": true
124
127
  }, title), content) : jsx(Fragment, null, content);
125
128
  return jsx("div", _extends({}, rest, {
129
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
126
130
  className: getBooleanFF('platform.design-system-team.unsafe-overrides-killswitch_c8j9m') ? undefined : UNSAFE_className,
127
131
  id: id
128
132
  // NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")