@atlaskit/react-select 1.7.1 → 1.7.3

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/react-select
2
2
 
3
+ ## 1.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#106179](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/106179)
8
+ [`84a6c5a582438`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/84a6c5a582438) -
9
+ Add support for testId to Select
10
+
11
+ ## 1.7.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 1.7.1
4
18
 
5
19
  ### Patch Changes
@@ -10,7 +10,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _react = require("@emotion/react");
12
12
  var _utils = require("../utils");
13
- var _excluded = ["innerRef", "isDisabled", "isHidden", "inputClassName"];
13
+ var _excluded = ["innerRef", "isDisabled", "isHidden", "inputClassName", "testId"];
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
16
16
  * @jsxRuntime classic
@@ -68,11 +68,14 @@ var Input = function Input(props) {
68
68
  isDisabled = _cleanCommonProps.isDisabled,
69
69
  isHidden = _cleanCommonProps.isHidden,
70
70
  inputClassName = _cleanCommonProps.inputClassName,
71
+ testId = _cleanCommonProps.testId,
71
72
  innerProps = (0, _objectWithoutProperties2.default)(_cleanCommonProps, _excluded);
73
+ var dataId = testId ? "".concat(testId, "-select--input") : null;
72
74
  return (0, _react.jsx)("div", (0, _extends2.default)({}, (0, _utils.getStyleProps)(props, 'input', {
73
75
  'input-container': true
74
76
  }), {
75
- "data-value": value || ''
77
+ "data-value": value || '',
78
+ "data-testid": dataId && "".concat(dataId, "-container")
76
79
  }), (0, _react.jsx)("input", (0, _extends2.default)({
77
80
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
78
81
  className: cx({
@@ -82,7 +85,8 @@ var Input = function Input(props) {
82
85
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
83
86
  ,
84
87
  style: inputStyle(isHidden),
85
- disabled: isDisabled
88
+ disabled: isDisabled,
89
+ "data-testid": dataId
86
90
  }, innerProps)));
87
91
  };
88
92
 
@@ -1238,7 +1238,8 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1238
1238
  menuIsOpen = _this$props8.menuIsOpen,
1239
1239
  required = _this$props8.required,
1240
1240
  _this$props8$tabIndex = _this$props8.tabIndex,
1241
- tabIndex = _this$props8$tabIndex === void 0 ? 0 : _this$props8$tabIndex;
1241
+ tabIndex = _this$props8$tabIndex === void 0 ? 0 : _this$props8$tabIndex,
1242
+ testId = _this$props8.testId;
1242
1243
  var _this$getComponents = this.getComponents(),
1243
1244
  Input = _this$getComponents.Input;
1244
1245
  var _this$state4 = this.state,
@@ -1280,7 +1281,8 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1280
1281
  tabIndex: tabIndex,
1281
1282
  inputMode: "none",
1282
1283
  form: form,
1283
- value: ""
1284
+ value: "",
1285
+ "data-testid": testId && "".concat(testId, "-select--input")
1284
1286
  }, ariaAttributes));
1285
1287
  }
1286
1288
  return /*#__PURE__*/_react.default.createElement(Input, (0, _extends2.default)({}, commonProps, {
@@ -1288,6 +1290,7 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1288
1290
  autoComplete: "off",
1289
1291
  autoCorrect: "off",
1290
1292
  id: id,
1293
+ testId: testId,
1291
1294
  innerRef: this.getInputRef,
1292
1295
  isDisabled: isDisabled,
1293
1296
  isHidden: inputIsHidden,
@@ -1318,7 +1321,8 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1318
1321
  isDisabled = _this$props9.isDisabled,
1319
1322
  isMulti = _this$props9.isMulti,
1320
1323
  inputValue = _this$props9.inputValue,
1321
- placeholder = _this$props9.placeholder;
1324
+ placeholder = _this$props9.placeholder,
1325
+ testId = _this$props9.testId;
1322
1326
  var _this$state5 = this.state,
1323
1327
  selectValue = _this$state5.selectValue,
1324
1328
  focusedValue = _this$state5.focusedValue,
@@ -1328,9 +1332,11 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1328
1332
  key: "placeholder",
1329
1333
  isDisabled: isDisabled,
1330
1334
  isFocused: isFocused,
1331
- innerProps: {
1335
+ innerProps: _objectSpread({
1332
1336
  id: this.getElementId('placeholder')
1333
- }
1337
+ }, testId && {
1338
+ 'data-testid': "".concat(testId, "-select--placeholder")
1339
+ })
1334
1340
  }), placeholder);
1335
1341
  }
1336
1342
  if (isMulti) {
@@ -1358,7 +1364,10 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1358
1364
  e.preventDefault();
1359
1365
  }
1360
1366
  },
1361
- data: opt
1367
+ data: opt,
1368
+ innerProps: _objectSpread({}, testId && {
1369
+ 'data-testid': "".concat(testId, "-select--multivalue")
1370
+ })
1362
1371
  }), _this3.formatOptionLabel(opt, 'value'));
1363
1372
  });
1364
1373
  }
@@ -1381,15 +1390,18 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1381
1390
  clearControlLabel = _this$props10.clearControlLabel,
1382
1391
  isDisabled = _this$props10.isDisabled,
1383
1392
  isLoading = _this$props10.isLoading,
1384
- spacing = _this$props10.spacing;
1393
+ spacing = _this$props10.spacing,
1394
+ testId = _this$props10.testId;
1385
1395
  var isFocused = this.state.isFocused;
1386
1396
  if (!this.isClearable() || !ClearIndicator || isDisabled || !this.hasValue() || isLoading) {
1387
1397
  return null;
1388
1398
  }
1389
- var innerProps = {
1399
+ var innerProps = _objectSpread({
1390
1400
  onMouseDown: this.onClearIndicatorMouseDown,
1391
1401
  onTouchEnd: this.onClearIndicatorTouchEnd
1392
- };
1402
+ }, testId && {
1403
+ 'data-testid': "".concat(testId, "-select--clear-indicator")
1404
+ });
1393
1405
  var isCompact = spacing === 'compact';
1394
1406
  return /*#__PURE__*/_react.default.createElement(ClearIndicator, (0, _extends2.default)({
1395
1407
  clearControlLabel: clearControlLabel
@@ -1408,7 +1420,8 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1408
1420
  var _this$props11 = this.props,
1409
1421
  isDisabled = _this$props11.isDisabled,
1410
1422
  isLoading = _this$props11.isLoading,
1411
- spacing = _this$props11.spacing;
1423
+ spacing = _this$props11.spacing,
1424
+ testId = _this$props11.testId;
1412
1425
  var isFocused = this.state.isFocused;
1413
1426
  if (!LoadingIndicator || !isLoading) {
1414
1427
  return null;
@@ -1417,7 +1430,9 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1417
1430
  var innerProps = {
1418
1431
  'aria-hidden': 'true'
1419
1432
  };
1420
- return /*#__PURE__*/_react.default.createElement(LoadingIndicator, (0, _extends2.default)({}, commonProps, {
1433
+ return /*#__PURE__*/_react.default.createElement(LoadingIndicator, (0, _extends2.default)({
1434
+ "data-testid": testId && "".concat(testId, "-select--loading-indicator")
1435
+ }, commonProps, {
1421
1436
  innerProps: innerProps,
1422
1437
  isDisabled: isDisabled,
1423
1438
  isFocused: isFocused,
@@ -1435,14 +1450,17 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1435
1450
  var commonProps = this.commonProps;
1436
1451
  var _this$props12 = this.props,
1437
1452
  isDisabled = _this$props12.isDisabled,
1438
- spacing = _this$props12.spacing;
1453
+ spacing = _this$props12.spacing,
1454
+ testId = _this$props12.testId;
1439
1455
  var isFocused = this.state.isFocused;
1440
1456
  var isCompact = spacing === 'compact';
1441
- var innerProps = {
1457
+ var innerProps = _objectSpread({
1442
1458
  onMouseDown: this.onDropdownIndicatorMouseDown,
1443
1459
  onTouchEnd: this.onDropdownIndicatorTouchEnd,
1444
1460
  'aria-hidden': 'true'
1445
- };
1461
+ }, testId && {
1462
+ 'data-testid': "".concat(testId, "-select--dropdown-indicator")
1463
+ });
1446
1464
  return /*#__PURE__*/_react.default.createElement(DropdownIndicator, (0, _extends2.default)({}, commonProps, {
1447
1465
  innerProps: innerProps,
1448
1466
  isDisabled: isDisabled,
@@ -1482,7 +1500,8 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1482
1500
  onMenuScrollToTop = _this$props13.onMenuScrollToTop,
1483
1501
  onMenuScrollToBottom = _this$props13.onMenuScrollToBottom,
1484
1502
  labelId = _this$props13.labelId,
1485
- label = _this$props13.label;
1503
+ label = _this$props13.label,
1504
+ testId = _this$props13.testId;
1486
1505
  if (!menuIsOpen) {
1487
1506
  return null;
1488
1507
  }
@@ -1503,7 +1522,7 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1503
1522
  return _this4.selectOption(data);
1504
1523
  };
1505
1524
  var optionId = "".concat(_this4.getElementId('option'), "-").concat(id);
1506
- var innerProps = {
1525
+ var innerProps = _objectSpread({
1507
1526
  id: optionId,
1508
1527
  onClick: onSelect,
1509
1528
  onMouseMove: onHover,
@@ -1514,7 +1533,9 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1514
1533
  // We don't want aria-disabled on Apple devices or if it's false. It's just noisy.
1515
1534
  'aria-disabled': ((0, _deviceCheck.isAppleDevice)() || !isDisabled) && (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') ? undefined : isDisabled,
1516
1535
  'aria-describedby': (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') ? headingId : undefined
1517
- };
1536
+ }, testId && {
1537
+ 'data-testid': "".concat(testId, "-select--option-").concat(id)
1538
+ });
1518
1539
  return /*#__PURE__*/_react.default.createElement(Option, (0, _extends2.default)({}, commonProps, {
1519
1540
  innerProps: innerProps,
1520
1541
  data: data,
@@ -1543,10 +1564,12 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1543
1564
  data: data,
1544
1565
  options: options,
1545
1566
  Heading: GroupHeading,
1546
- headingProps: {
1567
+ headingProps: _objectSpread({
1547
1568
  id: headingId,
1548
1569
  data: item.data
1549
- },
1570
+ }, testId && {
1571
+ 'data-testid': "".concat(testId, "-select--group-").concat(groupIndex, "-heading")
1572
+ }),
1550
1573
  label: _this4.formatGroupLabel(item.data)
1551
1574
  }), item.options.map(function (option) {
1552
1575
  return render(option, "".concat(groupIndex, "-").concat(option.index), headingId);
@@ -1570,7 +1593,13 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1570
1593
  if (_message === null) {
1571
1594
  return null;
1572
1595
  }
1573
- menuUI = /*#__PURE__*/_react.default.createElement(NoOptionsMessage, commonProps, _message);
1596
+ menuUI = /*#__PURE__*/_react.default.createElement(NoOptionsMessage, (0, _extends2.default)({}, commonProps, {
1597
+ innerProps: _objectSpread({
1598
+ 'data-testid': testId && "".concat(testId, "-select--no-options")
1599
+ }, testId && {
1600
+ 'data-testid': "".concat(testId, "-select--no-options")
1601
+ })
1602
+ }), _message);
1574
1603
  }
1575
1604
  var menuPlacementProps = {
1576
1605
  minMenuHeight: minMenuHeight,
@@ -1586,11 +1615,13 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1586
1615
  maxHeight = _ref4$placerProps.maxHeight;
1587
1616
  return /*#__PURE__*/_react.default.createElement(Menu, (0, _extends2.default)({}, commonProps, menuPlacementProps, {
1588
1617
  innerRef: ref,
1589
- innerProps: {
1618
+ innerProps: _objectSpread({
1590
1619
  onMouseDown: _this4.onMenuMouseDown,
1591
1620
  onMouseMove: _this4.onMenuMouseMove,
1592
1621
  id: _this4.props.components.Menu ? _this4.getElementId('listbox') : undefined
1593
- },
1622
+ }, testId && {
1623
+ 'data-testid': "".concat(testId, "-select--listbox-container")
1624
+ }),
1594
1625
  isLoading: isLoading,
1595
1626
  placement: placement
1596
1627
  }), /*#__PURE__*/_react.default.createElement(_internal.ScrollManager, {
@@ -1605,11 +1636,13 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1605
1636
  _this4.getMenuListRef(instance);
1606
1637
  scrollTargetRef(instance);
1607
1638
  },
1608
- innerProps: _objectSpread({
1639
+ innerProps: _objectSpread(_objectSpread({
1609
1640
  role: 'listbox',
1610
1641
  'aria-multiselectable': (_this4.isVoiceOver || !commonProps.isMulti) && (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') ? undefined : commonProps.isMulti,
1611
1642
  id: _this4.getElementId('listbox')
1612
- }, (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') && {
1643
+ }, testId && {
1644
+ 'data-testid': "".concat(testId, "-select--listbox")
1645
+ }), (0, _platformFeatureFlags.fg)('design_system_select-a11y-improvement') && {
1613
1646
  'aria-label': label,
1614
1647
  'aria-labelledby': "".concat(labelId || ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input'), " ").concat(commonProps.isMulti && (0, _deviceCheck.isSafari)() ? _this4.getElementId('multi-message') : '')
1615
1648
  }),
@@ -1732,6 +1765,7 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1732
1765
  isDisabled = _this$props15.isDisabled,
1733
1766
  menuIsOpen = _this$props15.menuIsOpen,
1734
1767
  isInvalid = _this$props15.isInvalid,
1768
+ testId = _this$props15.testId,
1735
1769
  _this$props15$appeara = _this$props15.appearance,
1736
1770
  appearance = _this$props15$appeara === void 0 ? 'default' : _this$props15$appeara,
1737
1771
  _this$props15$spacing = _this$props15.spacing,
@@ -1742,18 +1776,22 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1742
1776
  return /*#__PURE__*/_react.default.createElement(SelectContainer, (0, _extends2.default)({}, commonProps, {
1743
1777
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
1744
1778
  className: className,
1745
- innerProps: {
1779
+ innerProps: _objectSpread({
1746
1780
  id: id,
1747
1781
  onKeyDown: this.onKeyDown
1748
- },
1782
+ }, testId && {
1783
+ 'data-testid': testId && "".concat(testId, "-select--container")
1784
+ }),
1749
1785
  isDisabled: isDisabled,
1750
1786
  isFocused: isFocused
1751
1787
  }), this.renderLiveRegion(), commonProps.isMulti && this.isVoiceOver && this.renderMultiselectMessage(), /*#__PURE__*/_react.default.createElement(Control, (0, _extends2.default)({}, commonProps, {
1752
1788
  innerRef: this.getControlRef,
1753
- innerProps: {
1789
+ innerProps: _objectSpread({
1754
1790
  onMouseDown: this.onControlMouseDown,
1755
1791
  onTouchEnd: this.onControlTouchEnd
1756
- },
1792
+ }, testId && {
1793
+ 'data-testid': "".concat(testId, "-select--control")
1794
+ }),
1757
1795
  appearance: appearance,
1758
1796
  isInvalid: isInvalid,
1759
1797
  isDisabled: isDisabled,
@@ -1762,9 +1800,15 @@ var Select = exports.default = /*#__PURE__*/function (_Component) {
1762
1800
  isCompact: isCompact
1763
1801
  }), /*#__PURE__*/_react.default.createElement(ValueContainer, (0, _extends2.default)({}, commonProps, {
1764
1802
  isDisabled: isDisabled,
1765
- isCompact: isCompact
1803
+ isCompact: isCompact,
1804
+ innerProps: _objectSpread({}, testId && {
1805
+ 'data-testid': "".concat(testId, "-select--value-container")
1806
+ })
1766
1807
  }), this.renderPlaceholderOrValue(), this.renderInput()), /*#__PURE__*/_react.default.createElement(IndicatorsContainer, (0, _extends2.default)({}, commonProps, {
1767
- isDisabled: isDisabled
1808
+ isDisabled: isDisabled,
1809
+ innerProps: _objectSpread({}, testId && {
1810
+ 'data-testid': "".concat(testId, "-select--indicators-container")
1811
+ })
1768
1812
  }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
1769
1813
  }
1770
1814
  }], [{
@@ -59,12 +59,15 @@ const Input = props => {
59
59
  isDisabled,
60
60
  isHidden,
61
61
  inputClassName,
62
+ testId,
62
63
  ...innerProps
63
64
  } = cleanCommonProps(props);
65
+ const dataId = testId ? `${testId}-select--input` : null;
64
66
  return jsx("div", _extends({}, getStyleProps(props, 'input', {
65
67
  'input-container': true
66
68
  }), {
67
- "data-value": value || ''
69
+ "data-value": value || '',
70
+ "data-testid": dataId && `${dataId}-container`
68
71
  }), jsx("input", _extends({
69
72
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
70
73
  className: cx({
@@ -74,7 +77,8 @@ const Input = props => {
74
77
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
75
78
  ,
76
79
  style: inputStyle(isHidden),
77
- disabled: isDisabled
80
+ disabled: isDisabled,
81
+ "data-testid": dataId
78
82
  }, innerProps)));
79
83
  };
80
84
 
@@ -1243,7 +1243,8 @@ export default class Select extends Component {
1243
1243
  labelId,
1244
1244
  menuIsOpen,
1245
1245
  required,
1246
- tabIndex = 0
1246
+ tabIndex = 0,
1247
+ testId
1247
1248
  } = this.props;
1248
1249
  const {
1249
1250
  Input
@@ -1294,7 +1295,8 @@ export default class Select extends Component {
1294
1295
  tabIndex: tabIndex,
1295
1296
  inputMode: "none",
1296
1297
  form: form,
1297
- value: ""
1298
+ value: "",
1299
+ "data-testid": testId && `${testId}-select--input`
1298
1300
  }, ariaAttributes));
1299
1301
  }
1300
1302
  return /*#__PURE__*/React.createElement(Input, _extends({}, commonProps, {
@@ -1302,6 +1304,7 @@ export default class Select extends Component {
1302
1304
  autoComplete: "off",
1303
1305
  autoCorrect: "off",
1304
1306
  id: id,
1307
+ testId: testId,
1305
1308
  innerRef: this.getInputRef,
1306
1309
  isDisabled: isDisabled,
1307
1310
  isHidden: inputIsHidden,
@@ -1332,7 +1335,8 @@ export default class Select extends Component {
1332
1335
  isDisabled,
1333
1336
  isMulti,
1334
1337
  inputValue,
1335
- placeholder
1338
+ placeholder,
1339
+ testId
1336
1340
  } = this.props;
1337
1341
  const {
1338
1342
  selectValue,
@@ -1345,7 +1349,10 @@ export default class Select extends Component {
1345
1349
  isDisabled: isDisabled,
1346
1350
  isFocused: isFocused,
1347
1351
  innerProps: {
1348
- id: this.getElementId('placeholder')
1352
+ id: this.getElementId('placeholder'),
1353
+ ...(testId && {
1354
+ 'data-testid': `${testId}-select--placeholder`
1355
+ })
1349
1356
  }
1350
1357
  }), placeholder);
1351
1358
  }
@@ -1370,7 +1377,12 @@ export default class Select extends Component {
1370
1377
  e.preventDefault();
1371
1378
  }
1372
1379
  },
1373
- data: opt
1380
+ data: opt,
1381
+ innerProps: {
1382
+ ...(testId && {
1383
+ 'data-testid': `${testId}-select--multivalue`
1384
+ })
1385
+ }
1374
1386
  }), this.formatOptionLabel(opt, 'value'));
1375
1387
  });
1376
1388
  }
@@ -1394,7 +1406,8 @@ export default class Select extends Component {
1394
1406
  clearControlLabel,
1395
1407
  isDisabled,
1396
1408
  isLoading,
1397
- spacing
1409
+ spacing,
1410
+ testId
1398
1411
  } = this.props;
1399
1412
  const {
1400
1413
  isFocused
@@ -1404,7 +1417,10 @@ export default class Select extends Component {
1404
1417
  }
1405
1418
  const innerProps = {
1406
1419
  onMouseDown: this.onClearIndicatorMouseDown,
1407
- onTouchEnd: this.onClearIndicatorTouchEnd
1420
+ onTouchEnd: this.onClearIndicatorTouchEnd,
1421
+ ...(testId && {
1422
+ 'data-testid': `${testId}-select--clear-indicator`
1423
+ })
1408
1424
  };
1409
1425
  const isCompact = spacing === 'compact';
1410
1426
  return /*#__PURE__*/React.createElement(ClearIndicator, _extends({
@@ -1425,7 +1441,8 @@ export default class Select extends Component {
1425
1441
  const {
1426
1442
  isDisabled,
1427
1443
  isLoading,
1428
- spacing
1444
+ spacing,
1445
+ testId
1429
1446
  } = this.props;
1430
1447
  const {
1431
1448
  isFocused
@@ -1437,7 +1454,9 @@ export default class Select extends Component {
1437
1454
  const innerProps = {
1438
1455
  'aria-hidden': 'true'
1439
1456
  };
1440
- return /*#__PURE__*/React.createElement(LoadingIndicator, _extends({}, commonProps, {
1457
+ return /*#__PURE__*/React.createElement(LoadingIndicator, _extends({
1458
+ "data-testid": testId && `${testId}-select--loading-indicator`
1459
+ }, commonProps, {
1441
1460
  innerProps: innerProps,
1442
1461
  isDisabled: isDisabled,
1443
1462
  isFocused: isFocused,
@@ -1456,7 +1475,8 @@ export default class Select extends Component {
1456
1475
  } = this;
1457
1476
  const {
1458
1477
  isDisabled,
1459
- spacing
1478
+ spacing,
1479
+ testId
1460
1480
  } = this.props;
1461
1481
  const {
1462
1482
  isFocused
@@ -1465,7 +1485,10 @@ export default class Select extends Component {
1465
1485
  const innerProps = {
1466
1486
  onMouseDown: this.onDropdownIndicatorMouseDown,
1467
1487
  onTouchEnd: this.onDropdownIndicatorTouchEnd,
1468
- 'aria-hidden': 'true'
1488
+ 'aria-hidden': 'true',
1489
+ ...(testId && {
1490
+ 'data-testid': `${testId}-select--dropdown-indicator`
1491
+ })
1469
1492
  };
1470
1493
  return /*#__PURE__*/React.createElement(DropdownIndicator, _extends({}, commonProps, {
1471
1494
  innerProps: innerProps,
@@ -1508,7 +1531,8 @@ export default class Select extends Component {
1508
1531
  onMenuScrollToTop,
1509
1532
  onMenuScrollToBottom,
1510
1533
  labelId,
1511
- label
1534
+ label,
1535
+ testId
1512
1536
  } = this.props;
1513
1537
  if (!menuIsOpen) {
1514
1538
  return null;
@@ -1538,7 +1562,10 @@ export default class Select extends Component {
1538
1562
  'aria-selected': (!commonProps.isMulti || this.isVoiceOver || !isSelected) && fg('design_system_select-a11y-improvement') ? undefined : isSelected,
1539
1563
  // We don't want aria-disabled on Apple devices or if it's false. It's just noisy.
1540
1564
  'aria-disabled': (isAppleDevice() || !isDisabled) && fg('design_system_select-a11y-improvement') ? undefined : isDisabled,
1541
- 'aria-describedby': fg('design_system_select-a11y-improvement') ? headingId : undefined
1565
+ 'aria-describedby': fg('design_system_select-a11y-improvement') ? headingId : undefined,
1566
+ ...(testId && {
1567
+ 'data-testid': `${testId}-select--option-${id}`
1568
+ })
1542
1569
  };
1543
1570
  return /*#__PURE__*/React.createElement(Option, _extends({}, commonProps, {
1544
1571
  innerProps: innerProps,
@@ -1572,7 +1599,10 @@ export default class Select extends Component {
1572
1599
  Heading: GroupHeading,
1573
1600
  headingProps: {
1574
1601
  id: headingId,
1575
- data: item.data
1602
+ data: item.data,
1603
+ ...(testId && {
1604
+ 'data-testid': `${testId}-select--group-${groupIndex}-heading`
1605
+ })
1576
1606
  },
1577
1607
  label: this.formatGroupLabel(item.data)
1578
1608
  }), item.options.map(option => render(option, `${groupIndex}-${option.index}`, headingId)));
@@ -1595,7 +1625,14 @@ export default class Select extends Component {
1595
1625
  if (message === null) {
1596
1626
  return null;
1597
1627
  }
1598
- menuUI = /*#__PURE__*/React.createElement(NoOptionsMessage, commonProps, message);
1628
+ menuUI = /*#__PURE__*/React.createElement(NoOptionsMessage, _extends({}, commonProps, {
1629
+ innerProps: {
1630
+ 'data-testid': testId && `${testId}-select--no-options`,
1631
+ ...(testId && {
1632
+ 'data-testid': `${testId}-select--no-options`
1633
+ })
1634
+ }
1635
+ }), message);
1599
1636
  }
1600
1637
  const menuPlacementProps = {
1601
1638
  minMenuHeight,
@@ -1615,7 +1652,10 @@ export default class Select extends Component {
1615
1652
  innerProps: {
1616
1653
  onMouseDown: this.onMenuMouseDown,
1617
1654
  onMouseMove: this.onMenuMouseMove,
1618
- id: this.props.components.Menu ? this.getElementId('listbox') : undefined
1655
+ id: this.props.components.Menu ? this.getElementId('listbox') : undefined,
1656
+ ...(testId && {
1657
+ 'data-testid': `${testId}-select--listbox-container`
1658
+ })
1619
1659
  },
1620
1660
  isLoading: isLoading,
1621
1661
  placement: placement
@@ -1635,6 +1675,9 @@ export default class Select extends Component {
1635
1675
  role: 'listbox',
1636
1676
  'aria-multiselectable': (this.isVoiceOver || !commonProps.isMulti) && fg('design_system_select-a11y-improvement') ? undefined : commonProps.isMulti,
1637
1677
  id: this.getElementId('listbox'),
1678
+ ...(testId && {
1679
+ 'data-testid': `${testId}-select--listbox`
1680
+ }),
1638
1681
  // add aditional label on listbox when ff is on
1639
1682
  ...(fg('design_system_select-a11y-improvement') && {
1640
1683
  'aria-label': label,
@@ -1753,6 +1796,7 @@ export default class Select extends Component {
1753
1796
  isDisabled,
1754
1797
  menuIsOpen,
1755
1798
  isInvalid,
1799
+ testId,
1756
1800
  appearance = 'default',
1757
1801
  spacing = 'default'
1758
1802
  } = this.props;
@@ -1766,7 +1810,10 @@ export default class Select extends Component {
1766
1810
  className: className,
1767
1811
  innerProps: {
1768
1812
  id: id,
1769
- onKeyDown: this.onKeyDown
1813
+ onKeyDown: this.onKeyDown,
1814
+ ...(testId && {
1815
+ 'data-testid': testId && `${testId}-select--container`
1816
+ })
1770
1817
  },
1771
1818
  isDisabled: isDisabled,
1772
1819
  isFocused: isFocused
@@ -1774,7 +1821,10 @@ export default class Select extends Component {
1774
1821
  innerRef: this.getControlRef,
1775
1822
  innerProps: {
1776
1823
  onMouseDown: this.onControlMouseDown,
1777
- onTouchEnd: this.onControlTouchEnd
1824
+ onTouchEnd: this.onControlTouchEnd,
1825
+ ...(testId && {
1826
+ 'data-testid': `${testId}-select--control`
1827
+ })
1778
1828
  },
1779
1829
  appearance: appearance,
1780
1830
  isInvalid: isInvalid,
@@ -1784,9 +1834,19 @@ export default class Select extends Component {
1784
1834
  isCompact: isCompact
1785
1835
  }), /*#__PURE__*/React.createElement(ValueContainer, _extends({}, commonProps, {
1786
1836
  isDisabled: isDisabled,
1787
- isCompact: isCompact
1837
+ isCompact: isCompact,
1838
+ innerProps: {
1839
+ ...(testId && {
1840
+ 'data-testid': `${testId}-select--value-container`
1841
+ })
1842
+ }
1788
1843
  }), this.renderPlaceholderOrValue(), this.renderInput()), /*#__PURE__*/React.createElement(IndicatorsContainer, _extends({}, commonProps, {
1789
- isDisabled: isDisabled
1844
+ isDisabled: isDisabled,
1845
+ innerProps: {
1846
+ ...(testId && {
1847
+ 'data-testid': `${testId}-select--indicators-container`
1848
+ })
1849
+ }
1790
1850
  }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
1791
1851
  }
1792
1852
  }
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- var _excluded = ["innerRef", "isDisabled", "isHidden", "inputClassName"];
4
+ var _excluded = ["innerRef", "isDisabled", "isHidden", "inputClassName", "testId"];
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  /**
@@ -63,11 +63,14 @@ var Input = function Input(props) {
63
63
  isDisabled = _cleanCommonProps.isDisabled,
64
64
  isHidden = _cleanCommonProps.isHidden,
65
65
  inputClassName = _cleanCommonProps.inputClassName,
66
+ testId = _cleanCommonProps.testId,
66
67
  innerProps = _objectWithoutProperties(_cleanCommonProps, _excluded);
68
+ var dataId = testId ? "".concat(testId, "-select--input") : null;
67
69
  return jsx("div", _extends({}, getStyleProps(props, 'input', {
68
70
  'input-container': true
69
71
  }), {
70
- "data-value": value || ''
72
+ "data-value": value || '',
73
+ "data-testid": dataId && "".concat(dataId, "-container")
71
74
  }), jsx("input", _extends({
72
75
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
73
76
  className: cx({
@@ -77,7 +80,8 @@ var Input = function Input(props) {
77
80
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
78
81
  ,
79
82
  style: inputStyle(isHidden),
80
- disabled: isDisabled
83
+ disabled: isDisabled,
84
+ "data-testid": dataId
81
85
  }, innerProps)));
82
86
  };
83
87
 
@@ -1229,7 +1229,8 @@ var Select = /*#__PURE__*/function (_Component) {
1229
1229
  menuIsOpen = _this$props8.menuIsOpen,
1230
1230
  required = _this$props8.required,
1231
1231
  _this$props8$tabIndex = _this$props8.tabIndex,
1232
- tabIndex = _this$props8$tabIndex === void 0 ? 0 : _this$props8$tabIndex;
1232
+ tabIndex = _this$props8$tabIndex === void 0 ? 0 : _this$props8$tabIndex,
1233
+ testId = _this$props8.testId;
1233
1234
  var _this$getComponents = this.getComponents(),
1234
1235
  Input = _this$getComponents.Input;
1235
1236
  var _this$state4 = this.state,
@@ -1271,7 +1272,8 @@ var Select = /*#__PURE__*/function (_Component) {
1271
1272
  tabIndex: tabIndex,
1272
1273
  inputMode: "none",
1273
1274
  form: form,
1274
- value: ""
1275
+ value: "",
1276
+ "data-testid": testId && "".concat(testId, "-select--input")
1275
1277
  }, ariaAttributes));
1276
1278
  }
1277
1279
  return /*#__PURE__*/React.createElement(Input, _extends({}, commonProps, {
@@ -1279,6 +1281,7 @@ var Select = /*#__PURE__*/function (_Component) {
1279
1281
  autoComplete: "off",
1280
1282
  autoCorrect: "off",
1281
1283
  id: id,
1284
+ testId: testId,
1282
1285
  innerRef: this.getInputRef,
1283
1286
  isDisabled: isDisabled,
1284
1287
  isHidden: inputIsHidden,
@@ -1309,7 +1312,8 @@ var Select = /*#__PURE__*/function (_Component) {
1309
1312
  isDisabled = _this$props9.isDisabled,
1310
1313
  isMulti = _this$props9.isMulti,
1311
1314
  inputValue = _this$props9.inputValue,
1312
- placeholder = _this$props9.placeholder;
1315
+ placeholder = _this$props9.placeholder,
1316
+ testId = _this$props9.testId;
1313
1317
  var _this$state5 = this.state,
1314
1318
  selectValue = _this$state5.selectValue,
1315
1319
  focusedValue = _this$state5.focusedValue,
@@ -1319,9 +1323,11 @@ var Select = /*#__PURE__*/function (_Component) {
1319
1323
  key: "placeholder",
1320
1324
  isDisabled: isDisabled,
1321
1325
  isFocused: isFocused,
1322
- innerProps: {
1326
+ innerProps: _objectSpread({
1323
1327
  id: this.getElementId('placeholder')
1324
- }
1328
+ }, testId && {
1329
+ 'data-testid': "".concat(testId, "-select--placeholder")
1330
+ })
1325
1331
  }), placeholder);
1326
1332
  }
1327
1333
  if (isMulti) {
@@ -1349,7 +1355,10 @@ var Select = /*#__PURE__*/function (_Component) {
1349
1355
  e.preventDefault();
1350
1356
  }
1351
1357
  },
1352
- data: opt
1358
+ data: opt,
1359
+ innerProps: _objectSpread({}, testId && {
1360
+ 'data-testid': "".concat(testId, "-select--multivalue")
1361
+ })
1353
1362
  }), _this3.formatOptionLabel(opt, 'value'));
1354
1363
  });
1355
1364
  }
@@ -1372,15 +1381,18 @@ var Select = /*#__PURE__*/function (_Component) {
1372
1381
  clearControlLabel = _this$props10.clearControlLabel,
1373
1382
  isDisabled = _this$props10.isDisabled,
1374
1383
  isLoading = _this$props10.isLoading,
1375
- spacing = _this$props10.spacing;
1384
+ spacing = _this$props10.spacing,
1385
+ testId = _this$props10.testId;
1376
1386
  var isFocused = this.state.isFocused;
1377
1387
  if (!this.isClearable() || !ClearIndicator || isDisabled || !this.hasValue() || isLoading) {
1378
1388
  return null;
1379
1389
  }
1380
- var innerProps = {
1390
+ var innerProps = _objectSpread({
1381
1391
  onMouseDown: this.onClearIndicatorMouseDown,
1382
1392
  onTouchEnd: this.onClearIndicatorTouchEnd
1383
- };
1393
+ }, testId && {
1394
+ 'data-testid': "".concat(testId, "-select--clear-indicator")
1395
+ });
1384
1396
  var isCompact = spacing === 'compact';
1385
1397
  return /*#__PURE__*/React.createElement(ClearIndicator, _extends({
1386
1398
  clearControlLabel: clearControlLabel
@@ -1399,7 +1411,8 @@ var Select = /*#__PURE__*/function (_Component) {
1399
1411
  var _this$props11 = this.props,
1400
1412
  isDisabled = _this$props11.isDisabled,
1401
1413
  isLoading = _this$props11.isLoading,
1402
- spacing = _this$props11.spacing;
1414
+ spacing = _this$props11.spacing,
1415
+ testId = _this$props11.testId;
1403
1416
  var isFocused = this.state.isFocused;
1404
1417
  if (!LoadingIndicator || !isLoading) {
1405
1418
  return null;
@@ -1408,7 +1421,9 @@ var Select = /*#__PURE__*/function (_Component) {
1408
1421
  var innerProps = {
1409
1422
  'aria-hidden': 'true'
1410
1423
  };
1411
- return /*#__PURE__*/React.createElement(LoadingIndicator, _extends({}, commonProps, {
1424
+ return /*#__PURE__*/React.createElement(LoadingIndicator, _extends({
1425
+ "data-testid": testId && "".concat(testId, "-select--loading-indicator")
1426
+ }, commonProps, {
1412
1427
  innerProps: innerProps,
1413
1428
  isDisabled: isDisabled,
1414
1429
  isFocused: isFocused,
@@ -1426,14 +1441,17 @@ var Select = /*#__PURE__*/function (_Component) {
1426
1441
  var commonProps = this.commonProps;
1427
1442
  var _this$props12 = this.props,
1428
1443
  isDisabled = _this$props12.isDisabled,
1429
- spacing = _this$props12.spacing;
1444
+ spacing = _this$props12.spacing,
1445
+ testId = _this$props12.testId;
1430
1446
  var isFocused = this.state.isFocused;
1431
1447
  var isCompact = spacing === 'compact';
1432
- var innerProps = {
1448
+ var innerProps = _objectSpread({
1433
1449
  onMouseDown: this.onDropdownIndicatorMouseDown,
1434
1450
  onTouchEnd: this.onDropdownIndicatorTouchEnd,
1435
1451
  'aria-hidden': 'true'
1436
- };
1452
+ }, testId && {
1453
+ 'data-testid': "".concat(testId, "-select--dropdown-indicator")
1454
+ });
1437
1455
  return /*#__PURE__*/React.createElement(DropdownIndicator, _extends({}, commonProps, {
1438
1456
  innerProps: innerProps,
1439
1457
  isDisabled: isDisabled,
@@ -1473,7 +1491,8 @@ var Select = /*#__PURE__*/function (_Component) {
1473
1491
  onMenuScrollToTop = _this$props13.onMenuScrollToTop,
1474
1492
  onMenuScrollToBottom = _this$props13.onMenuScrollToBottom,
1475
1493
  labelId = _this$props13.labelId,
1476
- label = _this$props13.label;
1494
+ label = _this$props13.label,
1495
+ testId = _this$props13.testId;
1477
1496
  if (!menuIsOpen) {
1478
1497
  return null;
1479
1498
  }
@@ -1494,7 +1513,7 @@ var Select = /*#__PURE__*/function (_Component) {
1494
1513
  return _this4.selectOption(data);
1495
1514
  };
1496
1515
  var optionId = "".concat(_this4.getElementId('option'), "-").concat(id);
1497
- var innerProps = {
1516
+ var innerProps = _objectSpread({
1498
1517
  id: optionId,
1499
1518
  onClick: onSelect,
1500
1519
  onMouseMove: onHover,
@@ -1505,7 +1524,9 @@ var Select = /*#__PURE__*/function (_Component) {
1505
1524
  // We don't want aria-disabled on Apple devices or if it's false. It's just noisy.
1506
1525
  'aria-disabled': (isAppleDevice() || !isDisabled) && fg('design_system_select-a11y-improvement') ? undefined : isDisabled,
1507
1526
  'aria-describedby': fg('design_system_select-a11y-improvement') ? headingId : undefined
1508
- };
1527
+ }, testId && {
1528
+ 'data-testid': "".concat(testId, "-select--option-").concat(id)
1529
+ });
1509
1530
  return /*#__PURE__*/React.createElement(Option, _extends({}, commonProps, {
1510
1531
  innerProps: innerProps,
1511
1532
  data: data,
@@ -1534,10 +1555,12 @@ var Select = /*#__PURE__*/function (_Component) {
1534
1555
  data: data,
1535
1556
  options: options,
1536
1557
  Heading: GroupHeading,
1537
- headingProps: {
1558
+ headingProps: _objectSpread({
1538
1559
  id: headingId,
1539
1560
  data: item.data
1540
- },
1561
+ }, testId && {
1562
+ 'data-testid': "".concat(testId, "-select--group-").concat(groupIndex, "-heading")
1563
+ }),
1541
1564
  label: _this4.formatGroupLabel(item.data)
1542
1565
  }), item.options.map(function (option) {
1543
1566
  return render(option, "".concat(groupIndex, "-").concat(option.index), headingId);
@@ -1561,7 +1584,13 @@ var Select = /*#__PURE__*/function (_Component) {
1561
1584
  if (_message === null) {
1562
1585
  return null;
1563
1586
  }
1564
- menuUI = /*#__PURE__*/React.createElement(NoOptionsMessage, commonProps, _message);
1587
+ menuUI = /*#__PURE__*/React.createElement(NoOptionsMessage, _extends({}, commonProps, {
1588
+ innerProps: _objectSpread({
1589
+ 'data-testid': testId && "".concat(testId, "-select--no-options")
1590
+ }, testId && {
1591
+ 'data-testid': "".concat(testId, "-select--no-options")
1592
+ })
1593
+ }), _message);
1565
1594
  }
1566
1595
  var menuPlacementProps = {
1567
1596
  minMenuHeight: minMenuHeight,
@@ -1577,11 +1606,13 @@ var Select = /*#__PURE__*/function (_Component) {
1577
1606
  maxHeight = _ref4$placerProps.maxHeight;
1578
1607
  return /*#__PURE__*/React.createElement(Menu, _extends({}, commonProps, menuPlacementProps, {
1579
1608
  innerRef: ref,
1580
- innerProps: {
1609
+ innerProps: _objectSpread({
1581
1610
  onMouseDown: _this4.onMenuMouseDown,
1582
1611
  onMouseMove: _this4.onMenuMouseMove,
1583
1612
  id: _this4.props.components.Menu ? _this4.getElementId('listbox') : undefined
1584
- },
1613
+ }, testId && {
1614
+ 'data-testid': "".concat(testId, "-select--listbox-container")
1615
+ }),
1585
1616
  isLoading: isLoading,
1586
1617
  placement: placement
1587
1618
  }), /*#__PURE__*/React.createElement(ScrollManager, {
@@ -1596,11 +1627,13 @@ var Select = /*#__PURE__*/function (_Component) {
1596
1627
  _this4.getMenuListRef(instance);
1597
1628
  scrollTargetRef(instance);
1598
1629
  },
1599
- innerProps: _objectSpread({
1630
+ innerProps: _objectSpread(_objectSpread({
1600
1631
  role: 'listbox',
1601
1632
  'aria-multiselectable': (_this4.isVoiceOver || !commonProps.isMulti) && fg('design_system_select-a11y-improvement') ? undefined : commonProps.isMulti,
1602
1633
  id: _this4.getElementId('listbox')
1603
- }, fg('design_system_select-a11y-improvement') && {
1634
+ }, testId && {
1635
+ 'data-testid': "".concat(testId, "-select--listbox")
1636
+ }), fg('design_system_select-a11y-improvement') && {
1604
1637
  'aria-label': label,
1605
1638
  'aria-labelledby': "".concat(labelId || ((_this4$inputRef = _this4.inputRef) === null || _this4$inputRef === void 0 ? void 0 : _this4$inputRef.id) || _this4.getElementId('input'), " ").concat(commonProps.isMulti && isSafari() ? _this4.getElementId('multi-message') : '')
1606
1639
  }),
@@ -1723,6 +1756,7 @@ var Select = /*#__PURE__*/function (_Component) {
1723
1756
  isDisabled = _this$props15.isDisabled,
1724
1757
  menuIsOpen = _this$props15.menuIsOpen,
1725
1758
  isInvalid = _this$props15.isInvalid,
1759
+ testId = _this$props15.testId,
1726
1760
  _this$props15$appeara = _this$props15.appearance,
1727
1761
  appearance = _this$props15$appeara === void 0 ? 'default' : _this$props15$appeara,
1728
1762
  _this$props15$spacing = _this$props15.spacing,
@@ -1733,18 +1767,22 @@ var Select = /*#__PURE__*/function (_Component) {
1733
1767
  return /*#__PURE__*/React.createElement(SelectContainer, _extends({}, commonProps, {
1734
1768
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
1735
1769
  className: className,
1736
- innerProps: {
1770
+ innerProps: _objectSpread({
1737
1771
  id: id,
1738
1772
  onKeyDown: this.onKeyDown
1739
- },
1773
+ }, testId && {
1774
+ 'data-testid': testId && "".concat(testId, "-select--container")
1775
+ }),
1740
1776
  isDisabled: isDisabled,
1741
1777
  isFocused: isFocused
1742
1778
  }), this.renderLiveRegion(), commonProps.isMulti && this.isVoiceOver && this.renderMultiselectMessage(), /*#__PURE__*/React.createElement(Control, _extends({}, commonProps, {
1743
1779
  innerRef: this.getControlRef,
1744
- innerProps: {
1780
+ innerProps: _objectSpread({
1745
1781
  onMouseDown: this.onControlMouseDown,
1746
1782
  onTouchEnd: this.onControlTouchEnd
1747
- },
1783
+ }, testId && {
1784
+ 'data-testid': "".concat(testId, "-select--control")
1785
+ }),
1748
1786
  appearance: appearance,
1749
1787
  isInvalid: isInvalid,
1750
1788
  isDisabled: isDisabled,
@@ -1753,9 +1791,15 @@ var Select = /*#__PURE__*/function (_Component) {
1753
1791
  isCompact: isCompact
1754
1792
  }), /*#__PURE__*/React.createElement(ValueContainer, _extends({}, commonProps, {
1755
1793
  isDisabled: isDisabled,
1756
- isCompact: isCompact
1794
+ isCompact: isCompact,
1795
+ innerProps: _objectSpread({}, testId && {
1796
+ 'data-testid': "".concat(testId, "-select--value-container")
1797
+ })
1757
1798
  }), this.renderPlaceholderOrValue(), this.renderInput()), /*#__PURE__*/React.createElement(IndicatorsContainer, _extends({}, commonProps, {
1758
- isDisabled: isDisabled
1799
+ isDisabled: isDisabled,
1800
+ innerProps: _objectSpread({}, testId && {
1801
+ 'data-testid': "".concat(testId, "-select--indicators-container")
1802
+ })
1759
1803
  }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
1760
1804
  }
1761
1805
  }], [{
@@ -18,7 +18,7 @@ export interface ContainerProps<Option = unknown, IsMulti extends boolean = bool
18
18
  /**
19
19
  * Inner props to be passed down to the container.
20
20
  */
21
- innerProps: JSX.IntrinsicElements['div'];
21
+ innerProps: {};
22
22
  }
23
23
  export declare const containerCSS: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({ isDisabled, isRtl, }: ContainerProps<Option, IsMulti, Group>) => CSSObjectWithLabel;
24
24
  export declare const SelectContainer: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(props: ContainerProps<Option, IsMulti, Group>) => jsx.JSX.Element;
@@ -26,7 +26,7 @@ export interface ValueContainerProps<Option = unknown, IsMulti extends boolean =
26
26
  /**
27
27
  * Props to be passed to the value container element.
28
28
  */
29
- innerProps?: JSX.IntrinsicElements['div'];
29
+ innerProps?: {};
30
30
  /**
31
31
  * The children to be rendered.
32
32
  */
@@ -14,7 +14,7 @@ export interface ControlProps<Option = unknown, IsMulti extends boolean = boolea
14
14
  /**
15
15
  * The mouse down event and the innerRef to pass down to the controller element.
16
16
  */
17
- innerProps: JSX.IntrinsicElements['div'];
17
+ innerProps: {};
18
18
  /**
19
19
  * Whether the select is disabled.
20
20
  */
@@ -26,6 +26,10 @@ export interface InputSpecificProps<Option = unknown, IsMulti extends boolean =
26
26
  * Set className for the input element
27
27
  */
28
28
  inputClassName?: string;
29
+ /**
30
+ * A testId prop is provided for specific elements. This is a unique string that appears as a data attribute data-testid in the rendered code and serves as a hook for automated tests.
31
+ */
32
+ testId?: string;
29
33
  }
30
34
  export type InputProps<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> = InputSpecificProps<Option, IsMulti, Group>;
31
35
  export declare const inputCSS: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({ isDisabled, value, }: InputProps<Option, IsMulti, Group>) => CSSObjectWithLabel;
@@ -383,6 +383,26 @@ export interface SelectProps<Option, IsMulti extends boolean, Group extends Grou
383
383
  * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}. Will soon be handled automatically to support expected keyboard accessibility.
384
384
  */
385
385
  tabSelectsValue: boolean;
386
+ /**
387
+ * A unique string that appears as data attribute data-testid in the rendered code, serving as a hook for automated tests.
388
+ * Use this instead of using ARIA properties as locators.
389
+ *
390
+ * - Container: `${testId}-select--container`
391
+ * - Control : `${testId}-select--control`
392
+ * - Value container: `${testId}-select--value-container`
393
+ * - Placeholder: `${testId}-select--placeholder`
394
+ * - Input container: `${testId}-select--input-container`
395
+ * - Input: `${testId}-select--input`
396
+ * - Indicators container: `${testId}-select--indicators-container`
397
+ * - Dropdown indicator: `${testId}-select--dropdown-indicator`
398
+ * - Clear indicator: `${testId}-select--clear-indicator`
399
+ * - Loading indicator: `${testId}-select--loading-indicator`
400
+ * - Listbox container: `${testId}-select--listbox-container`
401
+ * - Listbox: `${testId}-select--listbox`
402
+ * - Option group heading: `${testId}-select--group-${groupIndex}-heading`
403
+ * - Option: `${testId}-select--option-${id}`
404
+ */
405
+ testId?: string;
386
406
  /**
387
407
  * The value of the select; reflected by the selected option
388
408
  */
@@ -664,16 +684,16 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
664
684
  shouldHideSelectedOptions: () => boolean;
665
685
  onValueInputFocus: FocusEventHandler;
666
686
  onKeyDown: KeyboardEventHandler<HTMLDivElement>;
667
- renderInput(): JSX.Element;
668
- renderPlaceholderOrValue(): JSX.Element | JSX.Element[] | null;
669
- renderClearIndicator(): JSX.Element | null;
670
- renderLoadingIndicator(): JSX.Element | null;
671
- renderDropdownIndicator(): JSX.Element | null;
672
- renderMenu(): JSX.Element | null;
673
- renderFormField(): JSX.Element | undefined;
674
- renderLiveRegion(): JSX.Element;
675
- renderMultiselectMessage(): JSX.Element;
676
- render(): JSX.Element;
687
+ renderInput(): React.JSX.Element;
688
+ renderPlaceholderOrValue(): React.JSX.Element | React.JSX.Element[] | null;
689
+ renderClearIndicator(): React.JSX.Element | null;
690
+ renderLoadingIndicator(): React.JSX.Element | null;
691
+ renderDropdownIndicator(): React.JSX.Element | null;
692
+ renderMenu(): React.JSX.Element | null;
693
+ renderFormField(): React.JSX.Element | undefined;
694
+ renderLiveRegion(): React.JSX.Element;
695
+ renderMultiselectMessage(): React.JSX.Element;
696
+ render(): React.JSX.Element;
677
697
  }
678
698
  export type PublicBaseSelectProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = JSX.LibraryManagedAttributes<typeof Select, SelectProps<Option, IsMulti, Group>>;
679
699
  export {};
@@ -18,7 +18,7 @@ export interface ContainerProps<Option = unknown, IsMulti extends boolean = bool
18
18
  /**
19
19
  * Inner props to be passed down to the container.
20
20
  */
21
- innerProps: JSX.IntrinsicElements['div'];
21
+ innerProps: {};
22
22
  }
23
23
  export declare const containerCSS: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({ isDisabled, isRtl, }: ContainerProps<Option, IsMulti, Group>) => CSSObjectWithLabel;
24
24
  export declare const SelectContainer: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(props: ContainerProps<Option, IsMulti, Group>) => jsx.JSX.Element;
@@ -26,7 +26,7 @@ export interface ValueContainerProps<Option = unknown, IsMulti extends boolean =
26
26
  /**
27
27
  * Props to be passed to the value container element.
28
28
  */
29
- innerProps?: JSX.IntrinsicElements['div'];
29
+ innerProps?: {};
30
30
  /**
31
31
  * The children to be rendered.
32
32
  */
@@ -14,7 +14,7 @@ export interface ControlProps<Option = unknown, IsMulti extends boolean = boolea
14
14
  /**
15
15
  * The mouse down event and the innerRef to pass down to the controller element.
16
16
  */
17
- innerProps: JSX.IntrinsicElements['div'];
17
+ innerProps: {};
18
18
  /**
19
19
  * Whether the select is disabled.
20
20
  */
@@ -26,6 +26,10 @@ export interface InputSpecificProps<Option = unknown, IsMulti extends boolean =
26
26
  * Set className for the input element
27
27
  */
28
28
  inputClassName?: string;
29
+ /**
30
+ * A testId prop is provided for specific elements. This is a unique string that appears as a data attribute data-testid in the rendered code and serves as a hook for automated tests.
31
+ */
32
+ testId?: string;
29
33
  }
30
34
  export type InputProps<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> = InputSpecificProps<Option, IsMulti, Group>;
31
35
  export declare const inputCSS: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({ isDisabled, value, }: InputProps<Option, IsMulti, Group>) => CSSObjectWithLabel;
@@ -383,6 +383,26 @@ export interface SelectProps<Option, IsMulti extends boolean, Group extends Grou
383
383
  * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-14529 Internal documentation for deprecation (no external access)}. Will soon be handled automatically to support expected keyboard accessibility.
384
384
  */
385
385
  tabSelectsValue: boolean;
386
+ /**
387
+ * A unique string that appears as data attribute data-testid in the rendered code, serving as a hook for automated tests.
388
+ * Use this instead of using ARIA properties as locators.
389
+ *
390
+ * - Container: `${testId}-select--container`
391
+ * - Control : `${testId}-select--control`
392
+ * - Value container: `${testId}-select--value-container`
393
+ * - Placeholder: `${testId}-select--placeholder`
394
+ * - Input container: `${testId}-select--input-container`
395
+ * - Input: `${testId}-select--input`
396
+ * - Indicators container: `${testId}-select--indicators-container`
397
+ * - Dropdown indicator: `${testId}-select--dropdown-indicator`
398
+ * - Clear indicator: `${testId}-select--clear-indicator`
399
+ * - Loading indicator: `${testId}-select--loading-indicator`
400
+ * - Listbox container: `${testId}-select--listbox-container`
401
+ * - Listbox: `${testId}-select--listbox`
402
+ * - Option group heading: `${testId}-select--group-${groupIndex}-heading`
403
+ * - Option: `${testId}-select--option-${id}`
404
+ */
405
+ testId?: string;
386
406
  /**
387
407
  * The value of the select; reflected by the selected option
388
408
  */
@@ -664,16 +684,16 @@ export default class Select<Option = unknown, IsMulti extends boolean = false, G
664
684
  shouldHideSelectedOptions: () => boolean;
665
685
  onValueInputFocus: FocusEventHandler;
666
686
  onKeyDown: KeyboardEventHandler<HTMLDivElement>;
667
- renderInput(): JSX.Element;
668
- renderPlaceholderOrValue(): JSX.Element | JSX.Element[] | null;
669
- renderClearIndicator(): JSX.Element | null;
670
- renderLoadingIndicator(): JSX.Element | null;
671
- renderDropdownIndicator(): JSX.Element | null;
672
- renderMenu(): JSX.Element | null;
673
- renderFormField(): JSX.Element | undefined;
674
- renderLiveRegion(): JSX.Element;
675
- renderMultiselectMessage(): JSX.Element;
676
- render(): JSX.Element;
687
+ renderInput(): React.JSX.Element;
688
+ renderPlaceholderOrValue(): React.JSX.Element | React.JSX.Element[] | null;
689
+ renderClearIndicator(): React.JSX.Element | null;
690
+ renderLoadingIndicator(): React.JSX.Element | null;
691
+ renderDropdownIndicator(): React.JSX.Element | null;
692
+ renderMenu(): React.JSX.Element | null;
693
+ renderFormField(): React.JSX.Element | undefined;
694
+ renderLiveRegion(): React.JSX.Element;
695
+ renderMultiselectMessage(): React.JSX.Element;
696
+ render(): React.JSX.Element;
677
697
  }
678
698
  export type PublicBaseSelectProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = JSX.LibraryManagedAttributes<typeof Select, SelectProps<Option, IsMulti, Group>>;
679
699
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-select",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "A forked version of react-select to only be used in atlaskit/select",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,9 +30,9 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@atlaskit/ds-lib": "^3.5.0",
33
- "@atlaskit/icon": "^23.5.0",
34
- "@atlaskit/platform-feature-flags": "^0.3.0",
35
- "@atlaskit/primitives": "^13.4.0",
33
+ "@atlaskit/icon": "^23.9.0",
34
+ "@atlaskit/platform-feature-flags": "^1.0.0",
35
+ "@atlaskit/primitives": "^13.5.0",
36
36
  "@atlaskit/spinner": "^17.1.0",
37
37
  "@atlaskit/tokens": "^3.3.0",
38
38
  "@babel/runtime": "^7.0.0",
@@ -50,6 +50,7 @@
50
50
  "@af/visual-regression": "*",
51
51
  "@atlaskit/ssr": "*",
52
52
  "@atlaskit/visual-regression": "*",
53
+ "@atlassian/feature-flags-test-utils": "*",
53
54
  "@testing-library/react": "^13.4.0",
54
55
  "@testing-library/user-event": "^14.4.3",
55
56
  "jest-in-case": "^1.0.2",