@atlaskit/select 16.5.14 → 16.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/select
2
2
 
3
+ ## 16.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`31496cc7c8a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/31496cc7c8a) - [ux] Adds accessible name to the search input for popup select components via new `label` prop or `placeholder` prop if `label` is not provided.
8
+
9
+ ## 16.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`f03e630c03e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f03e630c03e) - [ux] Adds keydown handler to target spread props for better accessibility for keyboard users.
14
+
3
15
  ## 16.5.14
4
16
 
5
17
  ### Patch Changes
@@ -29,7 +29,7 @@ var _components = require("./components");
29
29
  var _styles = _interopRequireDefault(require("../styles"));
30
30
  var _bindEventListener = require("bind-event-listener");
31
31
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
32
- var _excluded = ["footer", "maxMenuWidth", "minMenuWidth", "target"];
32
+ var _excluded = ["footer", "label", "maxMenuWidth", "minMenuWidth", "placeholder", "target", "testId"];
33
33
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
34
34
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
35
  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; }
@@ -109,6 +109,14 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
109
109
  }), "-popup-select"));
110
110
  // Event Handlers
111
111
  // ==============================
112
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleTargetKeyDown", function (event) {
113
+ switch (event.key) {
114
+ case 'ArrowDown':
115
+ _this.open();
116
+ break;
117
+ default:
118
+ }
119
+ });
112
120
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleKeyDown", function (event) {
113
121
  switch (event.key) {
114
122
  case 'Escape':
@@ -314,9 +322,12 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
314
322
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderSelect", function () {
315
323
  var _this$props3 = _this.props,
316
324
  footer = _this$props3.footer,
325
+ label = _this$props3.label,
317
326
  maxMenuWidth = _this$props3.maxMenuWidth,
318
327
  minMenuWidth = _this$props3.minMenuWidth,
328
+ placeholder = _this$props3.placeholder,
319
329
  target = _this$props3.target,
330
+ testId = _this$props3.testId,
320
331
  props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
321
332
  // TODO: If `platform.design-system-team.popup-select-render-perf_i0s6m` is kept, `focusLockEnabled` should be fully removed as we're preferring `isReferenceHidden`
322
333
  var _this$state = _this.state,
@@ -337,6 +348,13 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
337
348
  var selectComponents = (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m') ? _this.getSelectComponents(mergedComponents, showSearchControl) : _objectSpread(_objectSpread({}, mergedComponents), {}, {
338
349
  Control: showSearchControl ? mergedComponents.Control : _components.DummyControl
339
350
  });
351
+ var getLabel = function getLabel() {
352
+ if (label) {
353
+ return label;
354
+ } else if (typeof placeholder === 'string') {
355
+ return placeholder;
356
+ }
357
+ };
340
358
  var popper = /*#__PURE__*/_react.default.createElement(_reactPopper.Popper, (0, _extends2.default)({}, mergedPopperProps, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m') ? undefined : {
341
359
  onFirstUpdate: function onFirstUpdate(state) {
342
360
  var _mergedPopperProps$on;
@@ -360,7 +378,8 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
360
378
  "data-placement": placement,
361
379
  minWidth: minMenuWidth,
362
380
  maxWidth: maxMenuWidth,
363
- id: _this.popperWrapperId
381
+ id: _this.popperWrapperId,
382
+ testId: testId
364
383
  }, /*#__PURE__*/_react.default.createElement(_reactFocusLock.default
365
384
  /*
366
385
  * NOTE: We intentionally want the FocusLock to be disabled until the refs are populated in Popper.
@@ -373,11 +392,13 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
373
392
  disabled: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m') ? !readyToRenderSelect : !focusLockEnabled,
374
393
  returnFocus: true
375
394
  }, readyToRenderSelect && /*#__PURE__*/_react.default.createElement(_reactSelect.default, (0, _extends2.default)({
395
+ "aria-label": getLabel(),
376
396
  backspaceRemovesValue: false,
377
397
  controlShouldRenderValue: false,
378
398
  isClearable: false,
379
399
  tabSelectsValue: false,
380
400
  menuIsOpen: true,
401
+ placeholder: placeholder,
381
402
  ref: _this.getSelectRef
382
403
  }, props, {
383
404
  isSearchable: showSearchControl,
@@ -443,6 +464,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
443
464
  var ref = _ref3.ref;
444
465
  return target && target({
445
466
  isOpen: isOpen,
467
+ onKeyDown: _this3.handleTargetKeyDown,
446
468
  ref: _this3.resolveTargetRef(ref),
447
469
  'aria-haspopup': 'true',
448
470
  'aria-expanded': isOpen,
@@ -30,7 +30,8 @@ var MenuDialog = function MenuDialog(_ref) {
30
30
  minWidth = _ref.minWidth,
31
31
  children = _ref.children,
32
32
  id = _ref.id,
33
- style = _ref.style;
33
+ style = _ref.style,
34
+ testId = _ref.testId;
34
35
  return (0, _react.jsx)("div", {
35
36
  css: [menuDialogStyles,
36
37
  // There is not a limited amount of values for the widths, so they need
@@ -41,7 +42,8 @@ var MenuDialog = function MenuDialog(_ref) {
41
42
  minWidth: minWidth
42
43
  }],
43
44
  style: style,
44
- id: id
45
+ id: id,
46
+ "data-testid": testId && "".concat(testId, "--menu")
45
47
  }, children);
46
48
  };
47
49
 
@@ -9,7 +9,7 @@ var _reactSelect = _interopRequireDefault(require("react-select"));
9
9
  var _analyticsNext = require("@atlaskit/analytics-next");
10
10
  var _createSelect = _interopRequireDefault(require("./createSelect"));
11
11
  var packageName = "@atlaskit/select";
12
- var packageVersion = "16.5.14";
12
+ var packageVersion = "16.7.0";
13
13
  var SelectWithoutAnalytics = (0, _createSelect.default)(_reactSelect.default);
14
14
  exports.SelectWithoutAnalytics = SelectWithoutAnalytics;
15
15
  var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
@@ -75,6 +75,14 @@ export default class PopupSelect extends PureComponent {
75
75
  })}-popup-select`);
76
76
  // Event Handlers
77
77
  // ==============================
78
+ _defineProperty(this, "handleTargetKeyDown", event => {
79
+ switch (event.key) {
80
+ case 'ArrowDown':
81
+ this.open();
82
+ break;
83
+ default:
84
+ }
85
+ });
78
86
  _defineProperty(this, "handleKeyDown", event => {
79
87
  switch (event.key) {
80
88
  case 'Escape':
@@ -290,9 +298,12 @@ export default class PopupSelect extends PureComponent {
290
298
  _defineProperty(this, "renderSelect", () => {
291
299
  const {
292
300
  footer,
301
+ label,
293
302
  maxMenuWidth,
294
303
  minMenuWidth,
304
+ placeholder,
295
305
  target,
306
+ testId,
296
307
  ...props
297
308
  } = this.props;
298
309
  // TODO: If `platform.design-system-team.popup-select-render-perf_i0s6m` is kept, `focusLockEnabled` should be fully removed as we're preferring `isReferenceHidden`
@@ -316,6 +327,13 @@ export default class PopupSelect extends PureComponent {
316
327
  ...mergedComponents,
317
328
  Control: showSearchControl ? mergedComponents.Control : DummyControl
318
329
  };
330
+ const getLabel = () => {
331
+ if (label) {
332
+ return label;
333
+ } else if (typeof placeholder === 'string') {
334
+ return placeholder;
335
+ }
336
+ };
319
337
  const popper = /*#__PURE__*/React.createElement(Popper, _extends({}, mergedPopperProps, getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? undefined : {
320
338
  onFirstUpdate: state => {
321
339
  var _mergedPopperProps$on;
@@ -340,7 +358,8 @@ export default class PopupSelect extends PureComponent {
340
358
  "data-placement": placement,
341
359
  minWidth: minMenuWidth,
342
360
  maxWidth: maxMenuWidth,
343
- id: this.popperWrapperId
361
+ id: this.popperWrapperId,
362
+ testId: testId
344
363
  }, /*#__PURE__*/React.createElement(FocusLock
345
364
  /*
346
365
  * NOTE: We intentionally want the FocusLock to be disabled until the refs are populated in Popper.
@@ -353,11 +372,13 @@ export default class PopupSelect extends PureComponent {
353
372
  disabled: getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? !readyToRenderSelect : !focusLockEnabled,
354
373
  returnFocus: true
355
374
  }, readyToRenderSelect && /*#__PURE__*/React.createElement(Select, _extends({
375
+ "aria-label": getLabel(),
356
376
  backspaceRemovesValue: false,
357
377
  controlShouldRenderValue: false,
358
378
  isClearable: false,
359
379
  tabSelectsValue: false,
360
380
  menuIsOpen: true,
381
+ placeholder: placeholder,
361
382
  ref: this.getSelectRef
362
383
  }, props, {
363
384
  isSearchable: showSearchControl,
@@ -444,6 +465,7 @@ export default class PopupSelect extends PureComponent {
444
465
  ref
445
466
  }) => target && target({
446
467
  isOpen,
468
+ onKeyDown: this.handleTargetKeyDown,
447
469
  ref: this.resolveTargetRef(ref),
448
470
  'aria-haspopup': 'true',
449
471
  'aria-expanded': isOpen,
@@ -22,7 +22,8 @@ export const MenuDialog = ({
22
22
  minWidth,
23
23
  children,
24
24
  id,
25
- style
25
+ style,
26
+ testId
26
27
  }) => jsx("div", {
27
28
  css: [menuDialogStyles,
28
29
  // There is not a limited amount of values for the widths, so they need
@@ -33,7 +34,8 @@ export const MenuDialog = ({
33
34
  minWidth
34
35
  }],
35
36
  style: style,
36
- id: id
37
+ id: id,
38
+ "data-testid": testId && `${testId}--menu`
37
39
  }, children);
38
40
 
39
41
  // ==============================
@@ -2,7 +2,7 @@ import Select from 'react-select';
2
2
  import { withAnalyticsEvents, withAnalyticsContext, createAndFireEvent } from '@atlaskit/analytics-next';
3
3
  import createSelect from './createSelect';
4
4
  const packageName = "@atlaskit/select";
5
- const packageVersion = "16.5.14";
5
+ const packageVersion = "16.7.0";
6
6
  export const SelectWithoutAnalytics = createSelect(Select);
7
7
  const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
8
8
  export default withAnalyticsContext({
@@ -7,7 +7,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
- var _excluded = ["footer", "maxMenuWidth", "minMenuWidth", "target"];
10
+ var _excluded = ["footer", "label", "maxMenuWidth", "minMenuWidth", "placeholder", "target", "testId"];
11
11
  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; }
12
12
  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; }
13
13
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -99,6 +99,14 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
99
99
  }), "-popup-select"));
100
100
  // Event Handlers
101
101
  // ==============================
102
+ _defineProperty(_assertThisInitialized(_this), "handleTargetKeyDown", function (event) {
103
+ switch (event.key) {
104
+ case 'ArrowDown':
105
+ _this.open();
106
+ break;
107
+ default:
108
+ }
109
+ });
102
110
  _defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (event) {
103
111
  switch (event.key) {
104
112
  case 'Escape':
@@ -304,9 +312,12 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
304
312
  _defineProperty(_assertThisInitialized(_this), "renderSelect", function () {
305
313
  var _this$props3 = _this.props,
306
314
  footer = _this$props3.footer,
315
+ label = _this$props3.label,
307
316
  maxMenuWidth = _this$props3.maxMenuWidth,
308
317
  minMenuWidth = _this$props3.minMenuWidth,
318
+ placeholder = _this$props3.placeholder,
309
319
  target = _this$props3.target,
320
+ testId = _this$props3.testId,
310
321
  props = _objectWithoutProperties(_this$props3, _excluded);
311
322
  // TODO: If `platform.design-system-team.popup-select-render-perf_i0s6m` is kept, `focusLockEnabled` should be fully removed as we're preferring `isReferenceHidden`
312
323
  var _this$state = _this.state,
@@ -327,6 +338,13 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
327
338
  var selectComponents = getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? _this.getSelectComponents(mergedComponents, showSearchControl) : _objectSpread(_objectSpread({}, mergedComponents), {}, {
328
339
  Control: showSearchControl ? mergedComponents.Control : DummyControl
329
340
  });
341
+ var getLabel = function getLabel() {
342
+ if (label) {
343
+ return label;
344
+ } else if (typeof placeholder === 'string') {
345
+ return placeholder;
346
+ }
347
+ };
330
348
  var popper = /*#__PURE__*/React.createElement(Popper, _extends({}, mergedPopperProps, getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? undefined : {
331
349
  onFirstUpdate: function onFirstUpdate(state) {
332
350
  var _mergedPopperProps$on;
@@ -350,7 +368,8 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
350
368
  "data-placement": placement,
351
369
  minWidth: minMenuWidth,
352
370
  maxWidth: maxMenuWidth,
353
- id: _this.popperWrapperId
371
+ id: _this.popperWrapperId,
372
+ testId: testId
354
373
  }, /*#__PURE__*/React.createElement(FocusLock
355
374
  /*
356
375
  * NOTE: We intentionally want the FocusLock to be disabled until the refs are populated in Popper.
@@ -363,11 +382,13 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
363
382
  disabled: getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? !readyToRenderSelect : !focusLockEnabled,
364
383
  returnFocus: true
365
384
  }, readyToRenderSelect && /*#__PURE__*/React.createElement(Select, _extends({
385
+ "aria-label": getLabel(),
366
386
  backspaceRemovesValue: false,
367
387
  controlShouldRenderValue: false,
368
388
  isClearable: false,
369
389
  tabSelectsValue: false,
370
390
  menuIsOpen: true,
391
+ placeholder: placeholder,
371
392
  ref: _this.getSelectRef
372
393
  }, props, {
373
394
  isSearchable: showSearchControl,
@@ -433,6 +454,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
433
454
  var ref = _ref3.ref;
434
455
  return target && target({
435
456
  isOpen: isOpen,
457
+ onKeyDown: _this3.handleTargetKeyDown,
436
458
  ref: _this3.resolveTargetRef(ref),
437
459
  'aria-haspopup': 'true',
438
460
  'aria-expanded': isOpen,
@@ -25,7 +25,8 @@ export var MenuDialog = function MenuDialog(_ref) {
25
25
  minWidth = _ref.minWidth,
26
26
  children = _ref.children,
27
27
  id = _ref.id,
28
- style = _ref.style;
28
+ style = _ref.style,
29
+ testId = _ref.testId;
29
30
  return jsx("div", {
30
31
  css: [menuDialogStyles,
31
32
  // There is not a limited amount of values for the widths, so they need
@@ -36,7 +37,8 @@ export var MenuDialog = function MenuDialog(_ref) {
36
37
  minWidth: minWidth
37
38
  }],
38
39
  style: style,
39
- id: id
40
+ id: id,
41
+ "data-testid": testId && "".concat(testId, "--menu")
40
42
  }, children);
41
43
  };
42
44
 
@@ -2,7 +2,7 @@ import Select from 'react-select';
2
2
  import { withAnalyticsEvents, withAnalyticsContext, createAndFireEvent } from '@atlaskit/analytics-next';
3
3
  import createSelect from './createSelect';
4
4
  var packageName = "@atlaskit/select";
5
- var packageVersion = "16.5.14";
5
+ var packageVersion = "16.7.0";
6
6
  export var SelectWithoutAnalytics = createSelect(Select);
7
7
  var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
8
8
  export default withAnalyticsContext({
@@ -1,4 +1,4 @@
1
- import React, { PureComponent, ReactNode } from 'react';
1
+ import React, { KeyboardEventHandler, PureComponent, ReactNode } from 'react';
2
2
  import { GroupBase } from 'react-select';
3
3
  import BaseSelect from 'react-select/base';
4
4
  import { PopperProps } from 'react-popper';
@@ -9,6 +9,7 @@ type defaultModifiers = 'offset' | 'preventOverflow';
9
9
  type PopperPropsNoChildren<Modifiers> = Omit<PopperProps<Modifiers>, 'children'>;
10
10
  interface PopupSelectTriggerProps {
11
11
  ref: any;
12
+ onKeyDown: KeyboardEventHandler<HTMLElement>;
12
13
  'aria-haspopup': 'true';
13
14
  'aria-expanded': boolean;
14
15
  'aria-controls'?: string;
@@ -59,6 +60,7 @@ export interface PopupSelectProps<Option = OptionType, IsMulti extends boolean =
59
60
  - `isOpen`: The current state of the popup.
60
61
  Use this to change the appearance of your target based on the state of your component
61
62
  - `ref`: Pass this ref to the element the Popup should be attached to
63
+ - `onKeyDown`: Pass this keydown handler to the element to allow keyboard users to access the element.
62
64
  - `aria-haspopup`, `aria-expanded`, `aria-controls`: Spread these onto a target element to
63
65
  ensure your experience is accessible
64
66
  */
@@ -73,6 +75,8 @@ export interface PopupSelectProps<Option = OptionType, IsMulti extends boolean =
73
75
  validationState?: ValidationState;
74
76
  /** This prop indicates if the component is in an error state */
75
77
  isInvalid?: boolean;
78
+ /** This gives an accessible name to the input for users of assistive technologies */
79
+ label?: string;
76
80
  testId?: string;
77
81
  }
78
82
  interface State<Modifiers = string> {
@@ -131,6 +135,7 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
131
135
  componentDidMount(): void;
132
136
  componentWillUnmount(): void;
133
137
  componentDidUpdate(prevProps: PopupSelectProps<Option, IsMulti, Modifiers>): void;
138
+ handleTargetKeyDown: (event: React.KeyboardEvent) => void;
134
139
  handleKeyDown: (event: KeyboardEvent) => void;
135
140
  handleClick: ({ target }: MouseEvent) => void;
136
141
  handleSelectChange: (value: ValueType<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void;
@@ -172,7 +177,11 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
172
177
  multiValue?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
173
178
  multiValueLabel?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
174
179
  multiValueRemove?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
175
- noOptionsMessage?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").NoticeProps<Option, IsMulti, GroupBase<Option>>> | undefined;
180
+ noOptionsMessage?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").NoticeProps<Option, IsMulti, GroupBase<Option>>> | undefined; /**
181
+ * TODO: This type should be cleaned up with `platform.design-system-team.popup-select-render-perf_i0s6m`.
182
+ * - If discarded, revert to `focusLockEnabled: boolean`
183
+ * - If kept, delete this type.
184
+ */
176
185
  option?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").OptionProps<Option, IsMulti, GroupBase<Option>>> | undefined;
177
186
  placeholder?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").PlaceholderProps<Option, IsMulti, GroupBase<Option>>> | undefined;
178
187
  singleValue?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").SingleValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
@@ -8,6 +8,7 @@ interface MenuDialogProps {
8
8
  style: CSSProperties;
9
9
  children: ReactNode;
10
10
  id: string;
11
+ testId?: string;
11
12
  }
12
13
  export declare const MenuDialog: FC<MenuDialogProps>;
13
14
  export declare const DummyControl: FC<ControlProps<OptionType, boolean>>;
@@ -32,13 +32,9 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
32
32
  closeMenuOnSelect?: boolean;
33
33
  closeMenuOnScroll?: boolean | EventListener;
34
34
  /**
35
- * This complex object includes all the compositional components that are used
36
- * in `react-select`. If you wish to overwrite a component, pass in an object
37
- * with the appropriate namespace.
38
- *
39
- * If you only wish to restyle a component, we recommend using the `styles` prop
40
- * instead. For a list of the components that can be passed in, and the shape
41
- * that will be passed to them, see [the components docs](/components)
35
+ This complex object includes all the compositional components that are used in `react-select`. If you wish to overwrite a component, pass in an object with the appropriate namespace.
36
+
37
+ If you only wish to restyle a component, we recommend using the `styles` prop instead. For a list of the components that can be passed in, and the shape that will be passed to them, see [the components docs](/components).
42
38
  */
43
39
  components?: SelectComponentsConfig<Option, IsMulti, Group>;
44
40
  /** Whether the value of the select, e.g. SingleValue, should be displayed in the control. */
@@ -49,19 +45,14 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
49
45
  escapeClearsValue?: boolean;
50
46
  /** Custom method to filter whether an option should be displayed in the menu */
51
47
  filterOption?: ((option?: FilterOptionOption<Option>, inputValue?: string) => boolean) | null;
52
- /**
53
- * Formats group labels in the menu as React components
54
- *
55
- * An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.
56
- */
48
+ /** Formats group labels in the menu as React components. [Custom label example](/components/select/examples#customization). */
57
49
  formatGroupLabel?: (group?: Group) => ReactNode;
58
50
  /** Formats option labels in the menu and control as React components */
59
51
  formatOptionLabel?: (data?: Option, formatOptionLabelMeta?: FormatOptionLabelMeta<Option>) => ReactNode;
60
52
  /**
61
- * Resolves option data to a string to be displayed as the label by components
62
- *
63
- * Note?: Failure to resolve to a string type can interfere with filtering and
64
- * screen reader support.
53
+ Resolves option data to a string to be displayed as the label by components.
54
+
55
+ Note?: Failure to resolve to a string type can interfere with filtering and screen reader support.
65
56
  */
66
57
  getOptionLabel?: GetOptionLabel<Option>;
67
58
  /** Resolves option data to a string to compare options and specify value attributes */
@@ -83,9 +74,7 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
83
74
  /** Is the select in a state of loading (async) */
84
75
  isLoading?: boolean;
85
76
  /**
86
- * Override the built-in logic to detect whether an option is disabled
87
- *
88
- * An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.
77
+ Override the built-in logic to detect whether an option is disabled.
89
78
  */
90
79
  isOptionDisabled?: (option?: Option, selectValue?: Options<Option>) => boolean;
91
80
  /** Override the built-in logic to detect whether an option is selected */
@@ -106,18 +95,11 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
106
95
  maxMenuHeight?: number;
107
96
  /** Whether the menu is open */
108
97
  menuIsOpen?: boolean;
109
- /**
110
- * Default placement of the menu in relation to the control. 'auto' will flip
111
- * when there isn't enough space below the control.
112
- */
98
+ /** Default placement of the menu in relation to the control. 'auto' will flip when there isn't enough space below the control. */
113
99
  menuPlacement?: MenuPlacement;
114
100
  /** The CSS position value of the menu, when "fixed" extra layout management is required */
115
101
  menuPosition?: MenuPosition;
116
- /**
117
- * Whether the menu should use a portal, and where it should attach
118
- *
119
- * An example can be found in the [Portaling](/advanced#portaling) documentation
120
- */
102
+ /** Whether the menu should use a portal, and where it should attach. */
121
103
  menuPortalTarget?: HTMLElement | null;
122
104
  /** Whether to block scroll events when the menu is open */
123
105
  menuShouldBlockScroll?: boolean;
@@ -161,11 +143,7 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
161
143
  screenReaderStatus?: (obj?: {
162
144
  count?: number;
163
145
  }) => string;
164
- /**
165
- * Style modifier methods
166
- *
167
- * A basic example can be found at the bottom of the [Replacing builtins](/advanced#replacing-builtins) documentation.
168
- */
146
+ /** Style modifier methods. */
169
147
  styles?: StylesConfig;
170
148
  /** Theme modifier method */
171
149
  theme?: ThemeConfig;
@@ -1,4 +1,4 @@
1
- import React, { PureComponent, ReactNode } from 'react';
1
+ import React, { KeyboardEventHandler, PureComponent, ReactNode } from 'react';
2
2
  import { GroupBase } from 'react-select';
3
3
  import BaseSelect from 'react-select/base';
4
4
  import { PopperProps } from 'react-popper';
@@ -9,6 +9,7 @@ type defaultModifiers = 'offset' | 'preventOverflow';
9
9
  type PopperPropsNoChildren<Modifiers> = Omit<PopperProps<Modifiers>, 'children'>;
10
10
  interface PopupSelectTriggerProps {
11
11
  ref: any;
12
+ onKeyDown: KeyboardEventHandler<HTMLElement>;
12
13
  'aria-haspopup': 'true';
13
14
  'aria-expanded': boolean;
14
15
  'aria-controls'?: string;
@@ -59,6 +60,7 @@ export interface PopupSelectProps<Option = OptionType, IsMulti extends boolean =
59
60
  - `isOpen`: The current state of the popup.
60
61
  Use this to change the appearance of your target based on the state of your component
61
62
  - `ref`: Pass this ref to the element the Popup should be attached to
63
+ - `onKeyDown`: Pass this keydown handler to the element to allow keyboard users to access the element.
62
64
  - `aria-haspopup`, `aria-expanded`, `aria-controls`: Spread these onto a target element to
63
65
  ensure your experience is accessible
64
66
  */
@@ -73,6 +75,8 @@ export interface PopupSelectProps<Option = OptionType, IsMulti extends boolean =
73
75
  validationState?: ValidationState;
74
76
  /** This prop indicates if the component is in an error state */
75
77
  isInvalid?: boolean;
78
+ /** This gives an accessible name to the input for users of assistive technologies */
79
+ label?: string;
76
80
  testId?: string;
77
81
  }
78
82
  interface State<Modifiers = string> {
@@ -131,6 +135,7 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
131
135
  componentDidMount(): void;
132
136
  componentWillUnmount(): void;
133
137
  componentDidUpdate(prevProps: PopupSelectProps<Option, IsMulti, Modifiers>): void;
138
+ handleTargetKeyDown: (event: React.KeyboardEvent) => void;
134
139
  handleKeyDown: (event: KeyboardEvent) => void;
135
140
  handleClick: ({ target }: MouseEvent) => void;
136
141
  handleSelectChange: (value: ValueType<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void;
@@ -172,7 +177,11 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
172
177
  multiValue?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
173
178
  multiValueLabel?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
174
179
  multiValueRemove?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
175
- noOptionsMessage?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").NoticeProps<Option, IsMulti, GroupBase<Option>>> | undefined;
180
+ noOptionsMessage?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").NoticeProps<Option, IsMulti, GroupBase<Option>>> | undefined; /**
181
+ * TODO: This type should be cleaned up with `platform.design-system-team.popup-select-render-perf_i0s6m`.
182
+ * - If discarded, revert to `focusLockEnabled: boolean`
183
+ * - If kept, delete this type.
184
+ */
176
185
  option?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").OptionProps<Option, IsMulti, GroupBase<Option>>> | undefined;
177
186
  placeholder?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").PlaceholderProps<Option, IsMulti, GroupBase<Option>>> | undefined;
178
187
  singleValue?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").SingleValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
@@ -8,6 +8,7 @@ interface MenuDialogProps {
8
8
  style: CSSProperties;
9
9
  children: ReactNode;
10
10
  id: string;
11
+ testId?: string;
11
12
  }
12
13
  export declare const MenuDialog: FC<MenuDialogProps>;
13
14
  export declare const DummyControl: FC<ControlProps<OptionType, boolean>>;
@@ -32,13 +32,9 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
32
32
  closeMenuOnSelect?: boolean;
33
33
  closeMenuOnScroll?: boolean | EventListener;
34
34
  /**
35
- * This complex object includes all the compositional components that are used
36
- * in `react-select`. If you wish to overwrite a component, pass in an object
37
- * with the appropriate namespace.
38
- *
39
- * If you only wish to restyle a component, we recommend using the `styles` prop
40
- * instead. For a list of the components that can be passed in, and the shape
41
- * that will be passed to them, see [the components docs](/components)
35
+ This complex object includes all the compositional components that are used in `react-select`. If you wish to overwrite a component, pass in an object with the appropriate namespace.
36
+
37
+ If you only wish to restyle a component, we recommend using the `styles` prop instead. For a list of the components that can be passed in, and the shape that will be passed to them, see [the components docs](/components).
42
38
  */
43
39
  components?: SelectComponentsConfig<Option, IsMulti, Group>;
44
40
  /** Whether the value of the select, e.g. SingleValue, should be displayed in the control. */
@@ -49,19 +45,14 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
49
45
  escapeClearsValue?: boolean;
50
46
  /** Custom method to filter whether an option should be displayed in the menu */
51
47
  filterOption?: ((option?: FilterOptionOption<Option>, inputValue?: string) => boolean) | null;
52
- /**
53
- * Formats group labels in the menu as React components
54
- *
55
- * An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.
56
- */
48
+ /** Formats group labels in the menu as React components. [Custom label example](/components/select/examples#customization). */
57
49
  formatGroupLabel?: (group?: Group) => ReactNode;
58
50
  /** Formats option labels in the menu and control as React components */
59
51
  formatOptionLabel?: (data?: Option, formatOptionLabelMeta?: FormatOptionLabelMeta<Option>) => ReactNode;
60
52
  /**
61
- * Resolves option data to a string to be displayed as the label by components
62
- *
63
- * Note?: Failure to resolve to a string type can interfere with filtering and
64
- * screen reader support.
53
+ Resolves option data to a string to be displayed as the label by components.
54
+
55
+ Note?: Failure to resolve to a string type can interfere with filtering and screen reader support.
65
56
  */
66
57
  getOptionLabel?: GetOptionLabel<Option>;
67
58
  /** Resolves option data to a string to compare options and specify value attributes */
@@ -83,9 +74,7 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
83
74
  /** Is the select in a state of loading (async) */
84
75
  isLoading?: boolean;
85
76
  /**
86
- * Override the built-in logic to detect whether an option is disabled
87
- *
88
- * An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.
77
+ Override the built-in logic to detect whether an option is disabled.
89
78
  */
90
79
  isOptionDisabled?: (option?: Option, selectValue?: Options<Option>) => boolean;
91
80
  /** Override the built-in logic to detect whether an option is selected */
@@ -106,18 +95,11 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
106
95
  maxMenuHeight?: number;
107
96
  /** Whether the menu is open */
108
97
  menuIsOpen?: boolean;
109
- /**
110
- * Default placement of the menu in relation to the control. 'auto' will flip
111
- * when there isn't enough space below the control.
112
- */
98
+ /** Default placement of the menu in relation to the control. 'auto' will flip when there isn't enough space below the control. */
113
99
  menuPlacement?: MenuPlacement;
114
100
  /** The CSS position value of the menu, when "fixed" extra layout management is required */
115
101
  menuPosition?: MenuPosition;
116
- /**
117
- * Whether the menu should use a portal, and where it should attach
118
- *
119
- * An example can be found in the [Portaling](/advanced#portaling) documentation
120
- */
102
+ /** Whether the menu should use a portal, and where it should attach. */
121
103
  menuPortalTarget?: HTMLElement | null;
122
104
  /** Whether to block scroll events when the menu is open */
123
105
  menuShouldBlockScroll?: boolean;
@@ -161,11 +143,7 @@ interface NativeReactSelectProps<Option = unknown, IsMulti extends boolean = fal
161
143
  screenReaderStatus?: (obj?: {
162
144
  count?: number;
163
145
  }) => string;
164
- /**
165
- * Style modifier methods
166
- *
167
- * A basic example can be found at the bottom of the [Replacing builtins](/advanced#replacing-builtins) documentation.
168
- */
146
+ /** Style modifier methods. */
169
147
  styles?: StylesConfig;
170
148
  /** Theme modifier method */
171
149
  theme?: ThemeConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/select",
3
- "version": "16.5.14",
3
+ "version": "16.7.0",
4
4
  "description": "Select allows users to make a single selection or multiple selections from a list of options.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -64,6 +64,7 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@af/accessibility-testing": "*",
67
+ "@af/integration-testing": "*",
67
68
  "@atlaskit/ssr": "*",
68
69
  "@atlaskit/visual-regression": "*",
69
70
  "@atlaskit/webdriver-runner": "*",
package/report.api.md CHANGED
@@ -42,6 +42,7 @@ import { IndicatorSeparatorProps } from 'react-select';
42
42
  import { InputActionMeta } from 'react-select';
43
43
  import { InputProps } from 'react-select';
44
44
  import { jsx } from '@emotion/react';
45
+ import { KeyboardEventHandler } from 'react';
45
46
  import { LoadingIndicatorProps } from 'react-select';
46
47
  import { MemoizedFn } from 'memoize-one';
47
48
  import { MenuListProps } from 'react-select';
@@ -1047,6 +1048,11 @@ export class PopupSelect<
1047
1048
  noOptionsMessage?:
1048
1049
  | StylesConfigFunction<NoticeProps<Option, IsMulti, GroupType<Option>>>
1049
1050
  | undefined;
1051
+ /**
1052
+ * TODO: This type should be cleaned up with `platform.design-system-team.popup-select-render-perf_i0s6m`.
1053
+ * - If discarded, revert to `focusLockEnabled: boolean`
1054
+ * - If kept, delete this type.
1055
+ */
1050
1056
  option?:
1051
1057
  | StylesConfigFunction<
1052
1058
  OptionProps_2<Option, IsMulti, GroupType<Option>>
@@ -1081,6 +1087,8 @@ export class PopupSelect<
1081
1087
  actionMeta: ActionMeta<Option>,
1082
1088
  ) => void;
1083
1089
  // (undocumented)
1090
+ handleTargetKeyDown: (event: React_2.KeyboardEvent) => void;
1091
+ // (undocumented)
1084
1092
  isOpenControlled: boolean;
1085
1093
  // (undocumented)
1086
1094
  menuRef: HTMLElement | null;
@@ -1155,6 +1163,7 @@ export interface PopupSelectProps<
1155
1163
  // (undocumented)
1156
1164
  isOpen?: boolean;
1157
1165
  isSearchable?: boolean;
1166
+ label?: string;
1158
1167
  maxMenuWidth?: number | string;
1159
1168
  minMenuWidth?: number | string;
1160
1169
  popperProps?: PopperPropsNoChildren<Modifiers>;
@@ -1180,6 +1189,8 @@ interface PopupSelectTriggerProps {
1180
1189
  // (undocumented)
1181
1190
  'aria-haspopup': 'true';
1182
1191
  // (undocumented)
1192
+ onKeyDown: KeyboardEventHandler<HTMLElement>;
1193
+ // (undocumented)
1183
1194
  ref: any;
1184
1195
  }
1185
1196
 
@@ -31,6 +31,7 @@ import { IndicatorSeparatorProps } from 'react-select';
31
31
  import { InputActionMeta } from 'react-select';
32
32
  import { InputProps } from 'react-select';
33
33
  import { jsx } from '@emotion/react';
34
+ import { KeyboardEventHandler } from 'react';
34
35
  import { LoadingIndicatorProps } from 'react-select';
35
36
  import { MemoizedFn } from 'memoize-one';
36
37
  import { MenuListProps } from 'react-select';
@@ -499,7 +500,11 @@ export class PopupSelect<Option = OptionType, IsMulti extends boolean = false, M
499
500
  multiValue?: StylesConfigFunction<MultiValueProps<Option, IsMulti, GroupType<Option>>> | undefined;
500
501
  multiValueLabel?: StylesConfigFunction<MultiValueProps<Option, IsMulti, GroupType<Option>>> | undefined;
501
502
  multiValueRemove?: StylesConfigFunction<MultiValueProps<Option, IsMulti, GroupType<Option>>> | undefined;
502
- noOptionsMessage?: StylesConfigFunction<NoticeProps<Option, IsMulti, GroupType<Option>>> | undefined;
503
+ noOptionsMessage?: StylesConfigFunction<NoticeProps<Option, IsMulti, GroupType<Option>>> | undefined; /**
504
+ * TODO: This type should be cleaned up with `platform.design-system-team.popup-select-render-perf_i0s6m`.
505
+ * - If discarded, revert to `focusLockEnabled: boolean`
506
+ * - If kept, delete this type.
507
+ */
503
508
  option?: StylesConfigFunction<OptionProps_2<Option, IsMulti, GroupType<Option>>> | undefined;
504
509
  placeholder?: StylesConfigFunction<PlaceholderProps_2<Option, IsMulti, GroupType<Option>>> | undefined;
505
510
  singleValue?: StylesConfigFunction<SingleValueProps<Option, IsMulti, GroupType<Option>>> | undefined;
@@ -514,6 +519,8 @@ export class PopupSelect<Option = OptionType, IsMulti extends boolean = false, M
514
519
  // (undocumented)
515
520
  handleSelectChange: (value: ValueType<Option, IsMulti>, actionMeta: ActionMeta<Option>) => void;
516
521
  // (undocumented)
522
+ handleTargetKeyDown: (event: React_2.KeyboardEvent) => void;
523
+ // (undocumented)
517
524
  isOpenControlled: boolean;
518
525
  // (undocumented)
519
526
  menuRef: HTMLElement | null;
@@ -572,6 +579,7 @@ export interface PopupSelectProps<Option = OptionType, IsMulti extends boolean =
572
579
  // (undocumented)
573
580
  isOpen?: boolean;
574
581
  isSearchable?: boolean;
582
+ label?: string;
575
583
  maxMenuWidth?: number | string;
576
584
  minMenuWidth?: number | string;
577
585
  popperProps?: PopperPropsNoChildren<Modifiers>;
@@ -595,6 +603,8 @@ interface PopupSelectTriggerProps {
595
603
  // (undocumented)
596
604
  'aria-haspopup': 'true';
597
605
  // (undocumented)
606
+ onKeyDown: KeyboardEventHandler<HTMLElement>;
607
+ // (undocumented)
598
608
  ref: any;
599
609
  }
600
610