@atlaskit/menu 2.0.0 → 2.1.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/codemods/2.1.0-invalid-link-item-to-button-item.tsx +208 -0
  3. package/codemods/__tests__/next-invalid-link-item-to-button-item.tsx +308 -0
  4. package/dist/cjs/internal/components/menu-item-primitive.js +22 -30
  5. package/dist/cjs/menu-item/button-item.js +2 -1
  6. package/dist/cjs/menu-item/custom-item.js +2 -1
  7. package/dist/cjs/menu-item/link-item.js +2 -1
  8. package/dist/es2019/internal/components/menu-item-primitive.js +22 -30
  9. package/dist/es2019/menu-item/button-item.js +2 -1
  10. package/dist/es2019/menu-item/custom-item.js +2 -1
  11. package/dist/es2019/menu-item/link-item.js +2 -1
  12. package/dist/esm/internal/components/menu-item-primitive.js +22 -30
  13. package/dist/esm/menu-item/button-item.js +2 -1
  14. package/dist/esm/menu-item/custom-item.js +2 -1
  15. package/dist/esm/menu-item/link-item.js +2 -1
  16. package/dist/types/internal/components/menu-item-primitive.d.ts +1 -1
  17. package/dist/types/types.d.ts +1 -0
  18. package/dist/types-ts4.5/entry-points/menu-item/button-item.d.ts +1 -0
  19. package/dist/types-ts4.5/entry-points/menu-item/custom-item.d.ts +1 -0
  20. package/dist/types-ts4.5/entry-points/menu-item/heading-item.d.ts +1 -0
  21. package/dist/types-ts4.5/entry-points/menu-item/link-item.d.ts +1 -0
  22. package/dist/types-ts4.5/entry-points/menu-item/skeleton-heading-item.d.ts +1 -0
  23. package/dist/types-ts4.5/entry-points/menu-item/skeleton-item.d.ts +1 -0
  24. package/dist/types-ts4.5/entry-points/menu-section/menu-group.d.ts +1 -0
  25. package/dist/types-ts4.5/entry-points/menu-section/popup-menu-group.d.ts +1 -0
  26. package/dist/types-ts4.5/entry-points/menu-section/section.d.ts +1 -0
  27. package/dist/types-ts4.5/index.d.ts +11 -0
  28. package/dist/types-ts4.5/internal/components/menu-context.d.ts +18 -0
  29. package/dist/types-ts4.5/internal/components/menu-item-primitive.d.ts +18 -0
  30. package/dist/types-ts4.5/internal/components/skeleton-shimmer.d.ts +24 -0
  31. package/dist/types-ts4.5/menu-item/button-item.d.ts +12 -0
  32. package/dist/types-ts4.5/menu-item/custom-item.d.ts +18 -0
  33. package/dist/types-ts4.5/menu-item/heading-item.d.ts +13 -0
  34. package/dist/types-ts4.5/menu-item/link-item.d.ts +12 -0
  35. package/dist/types-ts4.5/menu-item/skeleton-heading-item.d.ts +12 -0
  36. package/dist/types-ts4.5/menu-item/skeleton-item.d.ts +12 -0
  37. package/dist/types-ts4.5/menu-section/menu-group.d.ts +13 -0
  38. package/dist/types-ts4.5/menu-section/popup-menu-group.d.ts +8 -0
  39. package/dist/types-ts4.5/menu-section/section.d.ts +12 -0
  40. package/dist/types-ts4.5/types.d.ts +397 -0
  41. package/package.json +2 -2
  42. package/tmp/api-report-tmp.d.ts +222 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/menu
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#41571](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41571) [`997b0489687`](https://bitbucket.org/atlassian/atlassian-frontend/commits/997b0489687) - Add codemod to convert link item components with invalid `href` attributes to button items. The `href` attribute will be required for link items in a later major upgrade. Using this will ease the transition.
8
+
9
+ ## 2.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#40650](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40650) [`07aa588c8a4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/07aa588c8a4) - Reverts the fix to text descender cut-off, due to incompatibilities with Firefox and Safari.
14
+
3
15
  ## 2.0.0
4
16
 
5
17
  ### Major Changes
@@ -0,0 +1,208 @@
1
+ import core, {
2
+ API,
3
+ ASTPath,
4
+ FileInfo,
5
+ ImportDeclaration,
6
+ ImportSpecifier,
7
+ Options,
8
+ } from 'jscodeshift';
9
+
10
+ const invalidHrefValues = ['', '#'];
11
+ const pkg = '@atlaskit/menu';
12
+
13
+ function getJSXAttributesByName(
14
+ j: core.JSCodeshift,
15
+ element: ASTPath<any>,
16
+ attributeName: string,
17
+ ) {
18
+ return j(element)
19
+ .find(j.JSXOpeningElement)
20
+ .find(j.JSXAttribute)
21
+ .filter((attribute) => {
22
+ const matches = j(attribute)
23
+ .find(j.JSXIdentifier)
24
+ .filter((identifier) => identifier.value.name === attributeName);
25
+ return Boolean(matches.length);
26
+ });
27
+ }
28
+
29
+ function getImportSpecifier(
30
+ j: core.JSCodeshift,
31
+ source: ReturnType<typeof j>,
32
+ specifier: string,
33
+ imported: string,
34
+ ) {
35
+ const specifiers = source
36
+ .find(j.ImportDeclaration)
37
+ .filter(
38
+ (path: ASTPath<ImportDeclaration>) =>
39
+ path.node.source.value === specifier,
40
+ )
41
+ .find(j.ImportSpecifier)
42
+ .filter(
43
+ (path: ASTPath<ImportSpecifier>) => path.value.imported.name === imported,
44
+ );
45
+
46
+ if (!specifiers.length) {
47
+ return null;
48
+ }
49
+
50
+ return specifiers.nodes()[0]!.local!.name;
51
+ }
52
+
53
+ function convertInvalidLinkItemsToButtonItems(
54
+ j: core.JSCodeshift,
55
+ source: ReturnType<typeof j>,
56
+ specifier: string,
57
+ ) {
58
+ // For each instance of LinkItem
59
+ source.findJSXElements(specifier).forEach((element) => {
60
+ const hrefPropCollection = getJSXAttributesByName(j, element, 'href');
61
+
62
+ // base case: no `href` prop exists, it is invalid
63
+ let validHref = false;
64
+
65
+ // if `href` exists
66
+ if (hrefPropCollection.length > 0) {
67
+ const hrefProp = hrefPropCollection.get();
68
+
69
+ const hrefStringLiteral = j(hrefProp).find(j.StringLiteral);
70
+ const hrefExpressionContainer = j(hrefProp)
71
+ .find(j.JSXExpressionContainer)
72
+ .find(j.Expression);
73
+
74
+ // This is tin foil hattery. Can something be neither a string literal
75
+ // nor an expression container? Don't know but gonna cover that
76
+ if (
77
+ hrefStringLiteral.length === 0 &&
78
+ hrefExpressionContainer.length === 0
79
+ ) {
80
+ return;
81
+ }
82
+
83
+ if (hrefStringLiteral.length > 0) {
84
+ const hrefValue = hrefStringLiteral.get().value.value;
85
+ if (invalidHrefValues.includes(hrefValue)) {
86
+ j(hrefProp).forEach((el) => j(el).remove());
87
+ } else {
88
+ validHref = true;
89
+ }
90
+ } else {
91
+ // It seems foolish to try and resolve variables, so we will assume it
92
+ // is valid
93
+ validHref = true;
94
+ }
95
+ }
96
+
97
+ if (!validHref) {
98
+ const pkgImport = source
99
+ .find(j.ImportDeclaration)
100
+ .filter((path) => path.node.source.value === pkg);
101
+ const buttonItemIsImported =
102
+ pkgImport
103
+ .find(j.ImportSpecifier)
104
+ .nodes()
105
+ .filter((node) => node.imported.name === 'ButtonItem').length > 0;
106
+ if (!buttonItemIsImported) {
107
+ // Add ButtonItem to imports
108
+ const newSpecifier = j.importSpecifier(j.identifier('ButtonItem'));
109
+ pkgImport.forEach((moduleImport) => {
110
+ const specifiers = moduleImport.node.specifiers
111
+ ? [...moduleImport.node.specifiers]
112
+ : [];
113
+ j(moduleImport).replaceWith(
114
+ j.importDeclaration(
115
+ specifiers.concat([newSpecifier]),
116
+ moduleImport.node.source,
117
+ ),
118
+ );
119
+ });
120
+ }
121
+
122
+ // Replace existing LinkItem with ButtonItem, while maintaining the same props
123
+ if (element.value.openingElement.name.type === 'JSXIdentifier') {
124
+ element.value.openingElement.name.name = 'ButtonItem';
125
+ if (
126
+ element.value.closingElement &&
127
+ element.value.closingElement.name.type === 'JSXIdentifier'
128
+ ) {
129
+ element.value.closingElement.name.name = 'ButtonItem';
130
+ }
131
+ }
132
+ }
133
+ });
134
+ }
135
+
136
+ function removeLinkItemImportIfNoLinkItemsExist(
137
+ j: core.JSCodeshift,
138
+ source: ReturnType<typeof j>,
139
+ specifier: string,
140
+ ) {
141
+ // Get all instances of LinkItem
142
+ const linkItemInstances = source.findJSXElements(specifier);
143
+
144
+ // if none, delete from imports
145
+ if (linkItemInstances.length === 0) {
146
+ source
147
+ .find(j.ImportDeclaration)
148
+ .filter((path) => path.node.source.value === pkg)
149
+ .forEach((moduleImport) => {
150
+ j(moduleImport).replaceWith(
151
+ j.importDeclaration(
152
+ moduleImport.node.specifiers &&
153
+ moduleImport.node.specifiers
154
+ .filter(
155
+ // This should be `ImportSpecifier | ImportDefaultSpecifier |
156
+ // ImportNamespaceSpecifier` but it still throws even though
157
+ // I'm filtering
158
+ (
159
+ currentSpecifier: any,
160
+ ): currentSpecifier is ImportSpecifier =>
161
+ currentSpecifier?.imported,
162
+ )
163
+ .filter(
164
+ (currentSpecifier: ImportSpecifier) =>
165
+ currentSpecifier.imported.name !== specifier,
166
+ ),
167
+ moduleImport.node.source,
168
+ ),
169
+ );
170
+ });
171
+ }
172
+ }
173
+
174
+ function hasImportDeclaration(
175
+ j: core.JSCodeshift,
176
+ source: ReturnType<typeof j>,
177
+ importPath: string,
178
+ ) {
179
+ return !!source
180
+ .find(j.ImportDeclaration)
181
+ .filter((path) => path.node.source.value === importPath).length;
182
+ }
183
+
184
+ export default function transformer(
185
+ fileInfo: FileInfo,
186
+ { jscodeshift: j }: API,
187
+ options: Options,
188
+ ) {
189
+ const source = j(fileInfo.source);
190
+
191
+ if (hasImportDeclaration(j, source, pkg)) {
192
+ const importSpecifier = getImportSpecifier(j, source, pkg, 'LinkItem');
193
+
194
+ if (importSpecifier != null) {
195
+ convertInvalidLinkItemsToButtonItems(j, source, importSpecifier);
196
+ removeLinkItemImportIfNoLinkItemsExist(j, source, importSpecifier);
197
+ }
198
+
199
+ return source.toSource(
200
+ options.printOptions || {
201
+ quote: 'single',
202
+ trailingComma: true,
203
+ },
204
+ );
205
+ }
206
+
207
+ return fileInfo.source;
208
+ }
@@ -0,0 +1,308 @@
1
+ jest.autoMockOff();
2
+
3
+ import * as transformer from '../2.1.0-invalid-link-item-to-button-item';
4
+
5
+ const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
6
+
7
+ describe('Converts link items with invalid or missing `href` to button items', () => {
8
+ /**
9
+ *
10
+ * Success cases
11
+ *
12
+ */
13
+ defineInlineTest(
14
+ { ...transformer, parser: 'tsx' },
15
+ {},
16
+ `
17
+ import { LinkItem } from '@atlaskit/something';
18
+
19
+ const App = () => {
20
+ return <LinkItem />;
21
+ }
22
+ `,
23
+ `
24
+ import { LinkItem } from '@atlaskit/something';
25
+
26
+ const App = () => {
27
+ return <LinkItem />;
28
+ }
29
+ `,
30
+ 'leaves unrelated code untouched',
31
+ );
32
+
33
+ defineInlineTest(
34
+ { ...transformer, parser: 'tsx' },
35
+ {},
36
+ `
37
+ import { LinkItem } from '@atlaskit/menu';
38
+ import { variable } from 'somewhere';
39
+
40
+ const App = () => {
41
+ return <LinkItem href={variable}>test</LinkItem>;
42
+ }
43
+ `,
44
+ `
45
+ import { LinkItem } from '@atlaskit/menu';
46
+ import { variable } from 'somewhere';
47
+
48
+ const App = () => {
49
+ return <LinkItem href={variable}>test</LinkItem>;
50
+ }
51
+ `,
52
+ 'should not do anything with `href`s that are variables',
53
+ );
54
+
55
+ defineInlineTest(
56
+ { ...transformer, parser: 'tsx' },
57
+ {},
58
+ `
59
+ import { LinkItem } from '@atlaskit/menu';
60
+
61
+ const App = () => {
62
+ return <LinkItem href="http://valid.com">test</LinkItem>;
63
+ }
64
+ `,
65
+ `
66
+ import { LinkItem } from '@atlaskit/menu';
67
+
68
+ const App = () => {
69
+ return <LinkItem href="http://valid.com">test</LinkItem>;
70
+ }
71
+ `,
72
+ 'should not do anything with a valid `href`',
73
+ );
74
+
75
+ /**
76
+ *
77
+ * Missing `href`
78
+ *
79
+ */
80
+
81
+ defineInlineTest(
82
+ { ...transformer, parser: 'tsx' },
83
+ {},
84
+ `
85
+ import { LinkItem } from '@atlaskit/menu';
86
+
87
+ const App = () => {
88
+ return <LinkItem>test</LinkItem>;
89
+ }
90
+ `,
91
+ `
92
+ import { ButtonItem } from '@atlaskit/menu';
93
+
94
+ const App = () => {
95
+ return <ButtonItem>test</ButtonItem>;
96
+ }
97
+ `,
98
+ 'Should convert to ButtonItem if no href exists on LinkItem',
99
+ );
100
+
101
+ defineInlineTest(
102
+ { ...transformer, parser: 'tsx' },
103
+ {},
104
+ `
105
+ import { LinkItem } from '@atlaskit/menu';
106
+
107
+ const App = () => {
108
+ return <LinkItem id="test">test</LinkItem>;
109
+ }
110
+ `,
111
+ `
112
+ import { ButtonItem } from '@atlaskit/menu';
113
+
114
+ const App = () => {
115
+ return <ButtonItem id="test">test</ButtonItem>;
116
+ }
117
+ `,
118
+ 'Should convert to ButtonItem but keep existing props if no href exists on LinkItem',
119
+ );
120
+
121
+ /**
122
+ *
123
+ * Invalid `href`
124
+ *
125
+ */
126
+
127
+ defineInlineTest(
128
+ { ...transformer, parser: 'tsx' },
129
+ {},
130
+ `
131
+ import { LinkItem } from '@atlaskit/menu';
132
+
133
+ const App = () => {
134
+ return <LinkItem href="#">test</LinkItem>;
135
+ }
136
+ `,
137
+ `
138
+ import { ButtonItem } from '@atlaskit/menu';
139
+
140
+ const App = () => {
141
+ return <ButtonItem>test</ButtonItem>;
142
+ }
143
+ `,
144
+ 'Should convert to ButtonItem if invalid `href`',
145
+ );
146
+
147
+ defineInlineTest(
148
+ { ...transformer, parser: 'tsx' },
149
+ {},
150
+ `
151
+ import { LinkItem } from '@atlaskit/menu';
152
+
153
+ const App = () => {
154
+ return <LinkItem href="#" id="test">test</LinkItem>;
155
+ }
156
+ `,
157
+ `
158
+ import { ButtonItem } from '@atlaskit/menu';
159
+
160
+ const App = () => {
161
+ return <ButtonItem id="test">test</ButtonItem>;
162
+ }
163
+ `,
164
+ 'Should convert to ButtonItem but keep existing props if invalid `href`',
165
+ );
166
+
167
+ defineInlineTest(
168
+ { ...transformer, parser: 'tsx' },
169
+ {},
170
+ `
171
+ import { LinkItem } from '@atlaskit/menu';
172
+
173
+ const App = () => {
174
+ return <LinkItem href="">test</LinkItem>;
175
+ }
176
+ `,
177
+ `
178
+ import { ButtonItem } from '@atlaskit/menu';
179
+
180
+ const App = () => {
181
+ return <ButtonItem>test</ButtonItem>;
182
+ }
183
+ `,
184
+ 'Should convert to ButtonItem if invalid `href`',
185
+ );
186
+
187
+ /**
188
+ *
189
+ * Expressions
190
+ *
191
+ */
192
+
193
+ defineInlineTest(
194
+ { ...transformer, parser: 'tsx' },
195
+ {},
196
+ `
197
+ import { LinkItem } from '@atlaskit/menu';
198
+
199
+ const App = () => {
200
+ return <LinkItem href={''}>test</LinkItem>;
201
+ }
202
+ `,
203
+ `
204
+ import { ButtonItem } from '@atlaskit/menu';
205
+
206
+ const App = () => {
207
+ return <ButtonItem>test</ButtonItem>;
208
+ }
209
+ `,
210
+ 'should handle strings in expression containers',
211
+ );
212
+
213
+ /**
214
+ *
215
+ * Edge cases
216
+ *
217
+ */
218
+
219
+ defineInlineTest(
220
+ { ...transformer, parser: 'tsx' },
221
+ {},
222
+ `
223
+ import { LinkItem, ButtonItem } from '@atlaskit/menu';
224
+
225
+ const App = () => {
226
+ return (
227
+ <div>
228
+ <LinkItem href="">test 1</LinkItem>
229
+ <ButtonItem>test 2</ButtonItem>
230
+ </div>
231
+ );
232
+ }
233
+ `,
234
+ `
235
+ import { ButtonItem } from '@atlaskit/menu';
236
+
237
+ const App = () => {
238
+ return (
239
+ <div>
240
+ <ButtonItem>test 1</ButtonItem>
241
+ <ButtonItem>test 2</ButtonItem>
242
+ </div>
243
+ );
244
+ }
245
+ `,
246
+ 'Should handle multiple item types',
247
+ );
248
+
249
+ defineInlineTest(
250
+ { ...transformer, parser: 'tsx' },
251
+ {},
252
+ `
253
+ import { LinkItem, CustomItem } from '@atlaskit/menu';
254
+
255
+ const App = () => {
256
+ return (
257
+ <div>
258
+ <LinkItem href="">test 1</LinkItem>
259
+ <CustomItem>test 2</CustomItem>
260
+ </div>
261
+ );
262
+ }
263
+ `,
264
+ `
265
+ import { CustomItem, ButtonItem } from '@atlaskit/menu';
266
+
267
+ const App = () => {
268
+ return (
269
+ <div>
270
+ <ButtonItem>test 1</ButtonItem>
271
+ <CustomItem>test 2</CustomItem>
272
+ </div>
273
+ );
274
+ }
275
+ `,
276
+ 'Should not delete other imports',
277
+ );
278
+
279
+ defineInlineTest(
280
+ { ...transformer, parser: 'tsx' },
281
+ {},
282
+ `
283
+ import { LinkItem } from '@atlaskit/menu';
284
+
285
+ const App = () => {
286
+ return (
287
+ <div>
288
+ <LinkItem href="">test 1</LinkItem>
289
+ <LinkItem href="http://example.com">test 2</LinkItem>
290
+ </div>
291
+ );
292
+ }
293
+ `,
294
+ `
295
+ import { LinkItem, ButtonItem } from '@atlaskit/menu';
296
+
297
+ const App = () => {
298
+ return (
299
+ <div>
300
+ <ButtonItem>test 1</ButtonItem>
301
+ <LinkItem href="http://example.com">test 2</LinkItem>
302
+ </div>
303
+ );
304
+ }
305
+ `,
306
+ 'Should allow valid `href` and convert invalid ones',
307
+ );
308
+ });
@@ -34,34 +34,22 @@ var contentStyles = (0, _react2.css)({
34
34
  flexGrow: 1,
35
35
  lineHeight: "var(--ds-font-lineHeight-100, 16px)",
36
36
  outline: 'none',
37
- textAlign: 'left',
38
- // Use "clip" overflow to allow ellipses on x-axis without clipping descenders
39
- '@supports not (overflow-x: clip)': {
40
- overflow: 'hidden'
41
- },
42
- '@supports (overflow-x: clip)': {
43
- overflowX: 'clip'
44
- }
37
+ overflow: 'hidden',
38
+ textAlign: 'left'
45
39
  });
46
40
  var truncateStyles = (0, _react2.css)({
47
41
  display: 'block',
42
+ overflow: 'hidden',
48
43
  textOverflow: 'ellipsis',
49
- whiteSpace: 'nowrap',
50
- // Use "clip" overflow to allow ellipses on x-axis without clipping descenders
51
- '@supports not (overflow-x: clip)': {
52
- overflow: 'hidden'
53
- },
54
- '@supports (overflow-x: clip)': {
55
- overflowX: 'clip'
56
- }
44
+ whiteSpace: 'nowrap'
57
45
  });
58
46
  var wordBreakStyles = (0, _react2.css)({
59
47
  wordBreak: 'break-word'
60
48
  });
61
49
  var descriptionStyles = (0, _react2.css)({
50
+ marginTop: "var(--ds-space-050, 4px)",
62
51
  color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")"),
63
- fontSize: "var(--ds-font-size-075, 12px)",
64
- marginBlockStart: "var(--ds-space-050, 4px)"
52
+ fontSize: "var(--ds-font-size-075, 12px)"
65
53
  });
66
54
  var disabledDescriptionStyles = (0, _react2.css)({
67
55
  color: "var(--ds-text-disabled, ".concat(_colors.N200, ")")
@@ -131,23 +119,23 @@ var selectedBorderStyles = (0, _react2.css)({
131
119
  '&::before': {
132
120
  width: 2,
133
121
  position: 'absolute',
122
+ top: 0,
123
+ bottom: 0,
124
+ left: 0,
134
125
  background: "var(--ds-border-selected, transparent)",
135
- content: '""',
136
- insetBlockEnd: 0,
137
- insetBlockStart: 0,
138
- insetInlineStart: 0
126
+ content: '""'
139
127
  }
140
128
  });
141
129
  var selectedNotchStyles = (0, _react2.css)({
142
130
  '&::before': {
143
131
  width: 4,
144
132
  position: 'absolute',
133
+ top: "var(--ds-space-150, 12px)",
134
+ bottom: "var(--ds-space-150, 12px)",
135
+ left: 0,
145
136
  background: "var(--ds-border-selected, transparent)",
146
137
  borderRadius: "0 ".concat("var(--ds-border-radius, 4px)", " ", "var(--ds-border-radius, 4px)", " 0"),
147
- content: '""',
148
- insetBlockEnd: "var(--ds-space-150, 12px)",
149
- insetBlockStart: "var(--ds-space-150, 12px)",
150
- insetInlineStart: 0
138
+ content: '""'
151
139
  }
152
140
  });
153
141
  var selectedStyles = (0, _react2.css)({
@@ -200,7 +188,8 @@ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
200
188
  _ref$isDisabled = _ref.isDisabled,
201
189
  isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
202
190
  _ref$isSelected = _ref.isSelected,
203
- isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
191
+ isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
192
+ testId = _ref.testId;
204
193
  (0, _deprecationWarning.propDeprecationWarning)("@atlaskit/menu" || '', 'overrides', overrides !== undefined, '' // TODO: Create DAC post when primitives/xcss are available as alternatives
205
194
  );
206
195
 
@@ -220,10 +209,12 @@ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
220
209
  spread: "space-between",
221
210
  alignBlock: "center",
222
211
  space: gapMap[spacing],
223
- grow: "fill"
212
+ grow: "fill",
213
+ testId: testId && "".concat(testId, "--container")
224
214
  }, iconBefore && (0, _react2.jsx)("span", {
225
215
  "data-item-elem-before": true,
226
- css: beforeAfterElementStyles
216
+ css: beforeAfterElementStyles,
217
+ "data-testid": testId && "".concat(testId, "--icon-before")
227
218
  }, iconBefore), title && (0, _react2.jsx)("span", {
228
219
  css: contentStyles
229
220
  }, renderTitle('span', {
@@ -235,7 +226,8 @@ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
235
226
  css: [descriptionStyles, isDisabled && disabledDescriptionStyles, shouldDescriptionWrap ? wordBreakStyles : truncateStyles]
236
227
  }, description)), iconAfter && (0, _react2.jsx)("span", {
237
228
  "data-item-elem-after": true,
238
- css: beforeAfterElementStyles
229
+ css: beforeAfterElementStyles,
230
+ "data-testid": testId && "".concat(testId, "--icon-after")
239
231
  }, iconAfter))
240
232
  }));
241
233
  });
@@ -69,7 +69,8 @@ function (props, ref) {
69
69
  cssFn({
70
70
  isSelected: isSelected,
71
71
  isDisabled: isDisabled
72
- })
72
+ }),
73
+ testId: testId && "".concat(testId, "--primitive")
73
74
  }), function (_ref) {
74
75
  var children = _ref.children,
75
76
  className = _ref.className;
@@ -74,7 +74,8 @@ var CustomItem = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardR
74
74
  css: (0, _react2.css)(cssFn({
75
75
  isDisabled: isDisabled,
76
76
  isSelected: isSelected
77
- }))
77
+ })),
78
+ testId: testId && "".concat(testId, "--primitive")
78
79
  }), function (_ref2) {
79
80
  var children = _ref2.children,
80
81
  className = _ref2.className;
@@ -74,7 +74,8 @@ function (props, ref) {
74
74
  isSelected: isSelected,
75
75
  isDisabled: isDisabled
76
76
  }),
77
- title: children
77
+ title: children,
78
+ testId: testId && "".concat(testId, "--primitive")
78
79
  }), function (_ref) {
79
80
  var children = _ref.children,
80
81
  className = _ref.className;