@atlaskit/select 17.11.10 → 17.11.12
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 +18 -0
- package/dist/cjs/CountrySelect.js +26 -7
- package/dist/cjs/PopupSelect/PopupSelect.js +13 -13
- package/dist/cjs/PopupSelect/components.js +31 -8
- package/dist/cjs/Select.js +1 -1
- package/dist/cjs/createSelect.js +3 -1
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/utils/country-groups-announcement.js +29 -0
- package/dist/cjs/utils/grouped-options-announcement.js +4 -5
- package/dist/es2019/CountrySelect.js +36 -11
- package/dist/es2019/PopupSelect/PopupSelect.js +14 -14
- package/dist/es2019/PopupSelect/components.js +25 -8
- package/dist/es2019/Select.js +1 -1
- package/dist/es2019/createSelect.js +1 -1
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/utils/country-groups-announcement.js +22 -0
- package/dist/es2019/utils/grouped-options-announcement.js +5 -6
- package/dist/esm/CountrySelect.js +27 -4
- package/dist/esm/PopupSelect/PopupSelect.js +14 -14
- package/dist/esm/PopupSelect/components.js +31 -8
- package/dist/esm/Select.js +1 -1
- package/dist/esm/createSelect.js +4 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/country-groups-announcement.js +22 -0
- package/dist/esm/utils/grouped-options-announcement.js +4 -5
- package/dist/types/CountrySelect.d.ts +13 -0
- package/dist/types/PopupSelect/PopupSelect.d.ts +5 -1
- package/dist/types/PopupSelect/components.d.ts +14 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/country-groups-announcement.d.ts +15 -0
- package/dist/types/utils/grouped-options-announcement.d.ts +1 -1
- package/dist/types-ts4.5/CountrySelect.d.ts +13 -0
- package/dist/types-ts4.5/PopupSelect/PopupSelect.d.ts +5 -1
- package/dist/types-ts4.5/PopupSelect/components.d.ts +14 -2
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/utils/country-groups-announcement.d.ts +15 -0
- package/dist/types-ts4.5/utils/grouped-options-announcement.d.ts +1 -1
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/select
|
|
2
2
|
|
|
3
|
+
## 17.11.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`941edf62401ae`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/941edf62401ae) -
|
|
8
|
+
This version removes `platform.design-system-team.use-default-select-in-popup-select_46rmj`
|
|
9
|
+
feature flag. The `PopupSelect` component now uses the internal `Select` component ensure the
|
|
10
|
+
accessibility of options with group labels for assistive technologies.
|
|
11
|
+
|
|
12
|
+
## 17.11.11
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#125980](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/125980)
|
|
17
|
+
[`d908d9c41ed27`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d908d9c41ed27) -
|
|
18
|
+
The parent group label in `CountrySelect` must be announced with options.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 17.11.10
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -6,20 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _react = require("@emotion/react");
|
|
10
11
|
var _countries = require("./data/countries");
|
|
11
12
|
var _Select = _interopRequireDefault(require("./Select"));
|
|
12
|
-
|
|
13
|
+
var _countryGroupsAnnouncement = require("./utils/country-groups-announcement");
|
|
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
|
+
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; } /**
|
|
13
16
|
* @jsxRuntime classic
|
|
14
17
|
* @jsx jsx
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
18
|
-
|
|
18
|
+
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
19
19
|
// custom option renderer
|
|
20
20
|
var labelStyles = (0, _react.css)({
|
|
21
|
-
alignItems: 'center',
|
|
22
21
|
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
23
|
lineHeight: 1.2
|
|
24
24
|
});
|
|
25
25
|
var flagStyles = (0, _react.css)({
|
|
@@ -78,14 +78,33 @@ var formatOptionLabel = function formatOptionLabel(opt, _ref4) {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
// put it all together
|
|
81
|
+
// TODO: Fill in the component {description} and ensure links point to the correct {packageName} location.
|
|
82
|
+
// Remove links that the component does not have (such as usage). If there are no links remove them all.
|
|
83
|
+
/**
|
|
84
|
+
* __Country select__
|
|
85
|
+
*
|
|
86
|
+
* A country select {description}.
|
|
87
|
+
*
|
|
88
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
89
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
90
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
91
|
+
*/
|
|
81
92
|
var CountrySelect = function CountrySelect(props) {
|
|
93
|
+
var ariaLiveMessages = props.ariaLiveMessages,
|
|
94
|
+
options = props.options;
|
|
95
|
+
var countryOptions = options || _countries.groupedCountries;
|
|
82
96
|
return (0, _react.jsx)(_Select.default, (0, _extends2.default)({
|
|
83
97
|
isClearable: false,
|
|
84
98
|
formatOptionLabel: formatOptionLabel,
|
|
85
99
|
getOptionLabel: getOptionLabel,
|
|
86
100
|
getOptionValue: getOptionValue,
|
|
87
101
|
isMulti: false,
|
|
88
|
-
options:
|
|
102
|
+
options: countryOptions,
|
|
103
|
+
ariaLiveMessages: (0, _countryGroupsAnnouncement.isCountryOptionsGrouped)(countryOptions) ? _objectSpread({
|
|
104
|
+
onFocus: function onFocus(data) {
|
|
105
|
+
return (0, _countryGroupsAnnouncement.onCountryOptionFocus)(data, countryOptions);
|
|
106
|
+
}
|
|
107
|
+
}, ariaLiveMessages) : _objectSpread({}, ariaLiveMessages)
|
|
89
108
|
}, props));
|
|
90
109
|
};
|
|
91
110
|
var _default = exports.default = CountrySelect;
|
|
@@ -21,10 +21,9 @@ var _reactDom = require("react-dom");
|
|
|
21
21
|
var _reactFocusLock = _interopRequireDefault(require("react-focus-lock"));
|
|
22
22
|
var _reactNodeResolver = _interopRequireDefault(require("react-node-resolver"));
|
|
23
23
|
var _reactPopper = require("react-popper");
|
|
24
|
-
var _reactSelect =
|
|
24
|
+
var _reactSelect = require("react-select");
|
|
25
25
|
var _reactUid = require("react-uid");
|
|
26
26
|
var _shallowEqual = require("shallow-equal");
|
|
27
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
28
27
|
var _colors = require("@atlaskit/theme/colors");
|
|
29
28
|
var _Select = _interopRequireDefault(require("../Select"));
|
|
30
29
|
var _styles = _interopRequireDefault(require("../styles"));
|
|
@@ -86,6 +85,7 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
86
85
|
}
|
|
87
86
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
88
87
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "menuRef", null);
|
|
88
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectRef", null);
|
|
89
89
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "targetRef", null);
|
|
90
90
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unbindWindowClick", null);
|
|
91
91
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unbindWindowKeydown", null);
|
|
@@ -191,7 +191,7 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
191
191
|
});
|
|
192
192
|
if (_this.selectRef) {
|
|
193
193
|
var _this$selectRef$selec;
|
|
194
|
-
(
|
|
194
|
+
(_this$selectRef$selec = _this.selectRef.select) === null || _this$selectRef$selec === void 0 || _this$selectRef$selec.openMenu('first');
|
|
195
195
|
}
|
|
196
196
|
if (typeof window === 'undefined') {
|
|
197
197
|
return;
|
|
@@ -289,7 +289,7 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
289
289
|
|
|
290
290
|
// subtract the control height to maintain consistency
|
|
291
291
|
var showSearchControl = _this.showSearchControl();
|
|
292
|
-
var controlRef = (
|
|
292
|
+
var controlRef = (_this$selectRef$selec2 = _this.selectRef.select) === null || _this$selectRef$selec2 === void 0 ? void 0 : _this$selectRef$selec2.controlRef;
|
|
293
293
|
var offsetHeight = showSearchControl && controlRef ? controlRef.offsetHeight : 0;
|
|
294
294
|
var maxHeight = maxMenuHeight - offsetHeight;
|
|
295
295
|
return maxHeight;
|
|
@@ -333,29 +333,28 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
333
333
|
return placeholder;
|
|
334
334
|
}
|
|
335
335
|
};
|
|
336
|
-
var InternalSelect = (0, _platformFeatureFlags.fg)('platform.design-system-team.use-default-select-in-popup-select_46rmj') ? _Select.default : _reactSelect.default;
|
|
337
336
|
var providedAriaLabel = getLabel();
|
|
338
337
|
var updateInputAriaLabel = function updateInputAriaLabel(ariaLabelText) {
|
|
339
|
-
var _this$selectRef
|
|
338
|
+
var _this$selectRef;
|
|
340
339
|
// Update aria-label to get first announcement when popup opened.
|
|
341
|
-
if ((_this$selectRef = _this.selectRef) !== null && _this$selectRef !== void 0 && (_this$selectRef = _this$selectRef.select) !== null && _this$selectRef !== void 0 && _this$selectRef.inputRef
|
|
342
|
-
var _this$
|
|
340
|
+
if ((_this$selectRef = _this.selectRef) !== null && _this$selectRef !== void 0 && (_this$selectRef = _this$selectRef.select) !== null && _this$selectRef !== void 0 && _this$selectRef.inputRef) {
|
|
341
|
+
var _this$selectRef2;
|
|
343
342
|
if (providedAriaLabel) {
|
|
344
343
|
ariaLabelText = "".concat(providedAriaLabel, ". ").concat(ariaLabelText);
|
|
345
344
|
}
|
|
346
|
-
(
|
|
345
|
+
(_this$selectRef2 = _this.selectRef) === null || _this$selectRef2 === void 0 || (_this$selectRef2 = _this$selectRef2.select.inputRef) === null || _this$selectRef2 === void 0 || _this$selectRef2.setAttribute('aria-label', ariaLabelText);
|
|
347
346
|
}
|
|
348
347
|
};
|
|
349
348
|
var generateNoGroupsAriaText = function generateNoGroupsAriaText(onFocusProps, ariaLabelSuffix) {
|
|
350
349
|
var _options$findIndex;
|
|
351
350
|
var focused = onFocusProps.focused;
|
|
352
351
|
var options = (props === null || props === void 0 ? void 0 : props.options) || [];
|
|
353
|
-
var totalLength =
|
|
352
|
+
var totalLength = options === null || options === void 0 ? void 0 : options.length;
|
|
354
353
|
var optionIndex = (_options$findIndex = options === null || options === void 0 ? void 0 : options.findIndex(function (option) {
|
|
355
354
|
return option === focused;
|
|
356
355
|
})) !== null && _options$findIndex !== void 0 ? _options$findIndex : 0;
|
|
357
356
|
var optionName = typeof (props === null || props === void 0 ? void 0 : props.getOptionLabel) === 'function' ? props.getOptionLabel(focused) : focused.label;
|
|
358
|
-
var ariaLabelText = "Option ".concat(optionName, " focused, ").concat(optionIndex, " of ").concat(totalLength, ".\n\t\t\t").concat(totalLength, " results available.\n\t\t\t").concat(ariaLabelSuffix, "\n\t\t\t");
|
|
357
|
+
var ariaLabelText = "Option ".concat(optionName, " focused, ").concat(optionIndex + 1, " of ").concat(totalLength, ".\n\t\t\t").concat(totalLength, " results available.\n\t\t\t").concat(ariaLabelSuffix, "\n\t\t\t");
|
|
359
358
|
// Option LABEL focused, 1 of 8. 8 results available.
|
|
360
359
|
// Use Up and Down to choose options, press Enter to select the currently focused option,
|
|
361
360
|
// press Escape to exit the menu.
|
|
@@ -369,7 +368,7 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
369
368
|
if ((_props$options = props.options) !== null && _props$options !== void 0 && _props$options.length) {
|
|
370
369
|
if ((0, _groupedOptionsAnnouncement.isOptionsGrouped)(props.options)) {
|
|
371
370
|
var totalLength = (0, _groupedOptionsAnnouncement.countAllOptions)(props.options);
|
|
372
|
-
ariaLiveMessage = (0, _groupedOptionsAnnouncement.onFocus)(onFocusProps);
|
|
371
|
+
ariaLiveMessage = (0, _groupedOptionsAnnouncement.onFocus)(onFocusProps, props.options);
|
|
373
372
|
ariaLabelText = "".concat(ariaLiveMessage, " ").concat(totalLength, " results available. ").concat(ariaLabelSuffix);
|
|
374
373
|
} else {
|
|
375
374
|
ariaLabelText = generateNoGroupsAriaText(onFocusProps, ariaLabelSuffix);
|
|
@@ -378,6 +377,7 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
378
377
|
updateInputAriaLabel(ariaLabelText);
|
|
379
378
|
return ariaLiveMessage;
|
|
380
379
|
}
|
|
380
|
+
return ariaLiveMessage;
|
|
381
381
|
};
|
|
382
382
|
var popper = /*#__PURE__*/_react.default.createElement(_reactPopper.Popper, (0, _extends2.default)({}, mergedPopperProps, {
|
|
383
383
|
onFirstUpdate: function onFirstUpdate(state) {
|
|
@@ -403,7 +403,7 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
403
403
|
}, /*#__PURE__*/_react.default.createElement(_reactFocusLock.default, {
|
|
404
404
|
disabled: !focusLockEnabled,
|
|
405
405
|
returnFocus: true
|
|
406
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
406
|
+
}, /*#__PURE__*/_react.default.createElement(_Select.default, (0, _extends2.default)({
|
|
407
407
|
"aria-label": providedAriaLabel,
|
|
408
408
|
backspaceRemovesValue: false,
|
|
409
409
|
controlShouldRenderValue: false,
|
|
@@ -7,12 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.defaultComponents = exports.MenuDialog = exports.DummyControl = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
-
var _reactSelect = require("react-select");
|
|
11
10
|
var _react = require("@emotion/react");
|
|
12
|
-
var
|
|
11
|
+
var _reactSelect = require("react-select");
|
|
13
12
|
var _search = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/search"));
|
|
14
|
-
var _constants = require("@atlaskit/theme/constants");
|
|
15
13
|
var _colors = require("@atlaskit/theme/colors");
|
|
14
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
15
|
+
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
16
16
|
var _excluded = ["innerRef", "innerProps"];
|
|
17
17
|
/**
|
|
18
18
|
* @jsxRuntime classic
|
|
@@ -24,11 +24,17 @@ var _excluded = ["innerRef", "innerProps"];
|
|
|
24
24
|
// ==============================
|
|
25
25
|
|
|
26
26
|
var menuDialogStyles = (0, _react.css)({
|
|
27
|
+
zIndex: _constants.layers.modal(),
|
|
27
28
|
backgroundColor: "var(--ds-surface-overlay, white)",
|
|
28
29
|
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
29
|
-
boxShadow: "var(--ds-shadow-overlay, ".concat("0 0 0 1px ".concat(_colors.N40A, ", 0 4px 11px ").concat(_colors.N40A), ")")
|
|
30
|
-
zIndex: _constants.layers.modal()
|
|
30
|
+
boxShadow: "var(--ds-shadow-overlay, ".concat("0 0 0 1px ".concat(_colors.N40A, ", 0 4px 11px ").concat(_colors.N40A), ")")
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* __Menu dialog__
|
|
35
|
+
* Wrapper for PopupSelect component.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
32
38
|
var MenuDialog = exports.MenuDialog = function MenuDialog(_ref) {
|
|
33
39
|
var maxWidth = _ref.maxWidth,
|
|
34
40
|
minWidth = _ref.minWidth,
|
|
@@ -58,9 +64,9 @@ var MenuDialog = exports.MenuDialog = function MenuDialog(_ref) {
|
|
|
58
64
|
// ==============================
|
|
59
65
|
|
|
60
66
|
var dropdownStyles = (0, _react.css)({
|
|
67
|
+
width: 32,
|
|
61
68
|
marginInlineEnd: "var(--ds-space-025, 2px)",
|
|
62
|
-
textAlign: 'center'
|
|
63
|
-
width: 32
|
|
69
|
+
textAlign: 'center'
|
|
64
70
|
});
|
|
65
71
|
var DropdownIndicator = function DropdownIndicator() {
|
|
66
72
|
return (0, _react.jsx)("div", {
|
|
@@ -83,6 +89,11 @@ var Control = function Control(_ref2) {
|
|
|
83
89
|
innerProps: innerProps
|
|
84
90
|
})));
|
|
85
91
|
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* __Dummy control__
|
|
95
|
+
* Overrides the default DummyControl component in Select.
|
|
96
|
+
*/
|
|
86
97
|
var DummyControl = exports.DummyControl = function DummyControl(props) {
|
|
87
98
|
return (0, _react.jsx)(_visuallyHidden.default, null, (0, _react.jsx)(_reactSelect.components.Control, props));
|
|
88
99
|
};
|
|
@@ -93,8 +104,20 @@ var Menu = function Menu(_ref3) {
|
|
|
93
104
|
innerProps = _ref3.innerProps;
|
|
94
105
|
return (0, _react.jsx)("div", innerProps, children);
|
|
95
106
|
};
|
|
107
|
+
var IndicatorSeparator = function IndicatorSeparator(props) {
|
|
108
|
+
return (0, _react.jsx)(_reactSelect.components.IndicatorSeparator, props);
|
|
109
|
+
};
|
|
110
|
+
var ClearIndicator = function ClearIndicator(props) {
|
|
111
|
+
return (0, _react.jsx)(_reactSelect.components.ClearIndicator, props);
|
|
112
|
+
};
|
|
113
|
+
var MultiValueRemove = function MultiValueRemove(props) {
|
|
114
|
+
return (0, _react.jsx)(_reactSelect.components.MultiValueRemove, props);
|
|
115
|
+
};
|
|
96
116
|
var defaultComponents = exports.defaultComponents = {
|
|
97
117
|
Control: Control,
|
|
98
118
|
DropdownIndicator: DropdownIndicator,
|
|
99
|
-
Menu: Menu
|
|
119
|
+
Menu: Menu,
|
|
120
|
+
IndicatorSeparator: IndicatorSeparator,
|
|
121
|
+
ClearIndicator: ClearIndicator,
|
|
122
|
+
MultiValueRemove: MultiValueRemove
|
|
100
123
|
};
|
package/dist/cjs/Select.js
CHANGED
|
@@ -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 = "17.11.
|
|
12
|
+
var packageVersion = "17.11.12";
|
|
13
13
|
var SelectWithoutAnalytics = exports.SelectWithoutAnalytics = (0, _createSelect.default)(_reactSelect.default);
|
|
14
14
|
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
|
15
15
|
var Select = (0, _analyticsNext.withAnalyticsContext)({
|
package/dist/cjs/createSelect.js
CHANGED
|
@@ -90,7 +90,9 @@ function createSelect(WrappedComponent) {
|
|
|
90
90
|
ref: internalSelectRef,
|
|
91
91
|
"aria-live": "assertive",
|
|
92
92
|
ariaLiveMessages: (0, _groupedOptionsAnnouncement.isOptionsGrouped)(props.options) ? _objectSpread({
|
|
93
|
-
onFocus:
|
|
93
|
+
onFocus: function onFocus(data) {
|
|
94
|
+
return (0, _groupedOptionsAnnouncement.onFocus)(data, props.options);
|
|
95
|
+
}
|
|
94
96
|
}, ariaLiveMessages) : _objectSpread({}, ariaLiveMessages),
|
|
95
97
|
tabSelectsValue: tabSelectsValue,
|
|
96
98
|
onClickPreventDefault: onClickPreventDefault
|
package/dist/cjs/index.js
CHANGED
|
@@ -83,6 +83,12 @@ Object.defineProperty(exports, "default", {
|
|
|
83
83
|
return _select.default;
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
|
+
Object.defineProperty(exports, "isCountryOptionsGrouped", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function get() {
|
|
89
|
+
return _countryGroupsAnnouncement.isCountryOptionsGrouped;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
86
92
|
Object.defineProperty(exports, "isOptionsGrouped", {
|
|
87
93
|
enumerable: true,
|
|
88
94
|
get: function get() {
|
|
@@ -95,6 +101,12 @@ Object.defineProperty(exports, "mergeStyles", {
|
|
|
95
101
|
return _reactSelect.mergeStyles;
|
|
96
102
|
}
|
|
97
103
|
});
|
|
104
|
+
Object.defineProperty(exports, "onCountryOptionFocus", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function get() {
|
|
107
|
+
return _countryGroupsAnnouncement.onCountryOptionFocus;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
98
110
|
Object.defineProperty(exports, "useAsync", {
|
|
99
111
|
enumerable: true,
|
|
100
112
|
get: function get() {
|
|
@@ -116,6 +128,7 @@ var _asyncSelect = _interopRequireDefault(require("./entry-points/async-select")
|
|
|
116
128
|
var _creatableSelect = _interopRequireDefault(require("./entry-points/creatable-select"));
|
|
117
129
|
var _asyncCreatableSelect = _interopRequireDefault(require("./entry-points/async-creatable-select"));
|
|
118
130
|
var _groupedOptionsAnnouncement = require("./utils/grouped-options-announcement");
|
|
131
|
+
var _countryGroupsAnnouncement = require("./utils/country-groups-announcement");
|
|
119
132
|
var _CheckboxSelect = _interopRequireDefault(require("./CheckboxSelect"));
|
|
120
133
|
var _CountrySelect = _interopRequireDefault(require("./CountrySelect"));
|
|
121
134
|
var _RadioSelect = _interopRequireDefault(require("./RadioSelect"));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isCountryOptionsGrouped = void 0;
|
|
7
|
+
exports.onCountryOptionFocus = onCountryOptionFocus;
|
|
8
|
+
// Used for overwriting ariaLiveMessages builtin onFocus method.
|
|
9
|
+
// Returns custom built string while focusing each group option. This string is used for screen reader announcement.
|
|
10
|
+
function onCountryOptionFocus(onFocusProps, defaultOptions) {
|
|
11
|
+
var _groupData$options$fi;
|
|
12
|
+
var focused = onFocusProps.focused;
|
|
13
|
+
var isOptionFocused = function isOptionFocused(option) {
|
|
14
|
+
return option.name === focused.name;
|
|
15
|
+
};
|
|
16
|
+
var groupData = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.find(function (option) {
|
|
17
|
+
var _option$options;
|
|
18
|
+
return (_option$options = option.options) === null || _option$options === void 0 ? void 0 : _option$options.some(isOptionFocused);
|
|
19
|
+
});
|
|
20
|
+
var groupOptionIndex = (_groupData$options$fi = groupData === null || groupData === void 0 ? void 0 : groupData.options.findIndex(isOptionFocused)) !== null && _groupData$options$fi !== void 0 ? _groupData$options$fi : 0;
|
|
21
|
+
return "Option ".concat(focused.name, " (").concat(focused.abbr.toUpperCase(), ") +").concat(focused.code, ", ").concat(groupData === null || groupData === void 0 ? void 0 : groupData.label, " group, item ").concat(groupOptionIndex + 1, " out of ").concat(groupData === null || groupData === void 0 ? void 0 : groupData.options.length, ". All in all ");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Helper function which identifies if options are grouped.
|
|
25
|
+
var isCountryOptionsGrouped = exports.isCountryOptionsGrouped = function isCountryOptionsGrouped(arr) {
|
|
26
|
+
return arr === null || arr === void 0 ? void 0 : arr.every(function (obj) {
|
|
27
|
+
return obj.hasOwnProperty('options');
|
|
28
|
+
});
|
|
29
|
+
};
|
|
@@ -7,14 +7,13 @@ exports.isOptionsGrouped = exports.countAllOptions = void 0;
|
|
|
7
7
|
exports.onFocus = onFocus;
|
|
8
8
|
// Used for overwriting ariaLiveMessages builtin onFocus method.
|
|
9
9
|
// Returns custom built string while focusing each group option. This string is used for screen reader announcement.
|
|
10
|
-
function onFocus(
|
|
10
|
+
function onFocus(onFocusProps, defaultOptions) {
|
|
11
11
|
var _groupData$options$fi;
|
|
12
|
-
var focused =
|
|
13
|
-
options = props.options;
|
|
12
|
+
var focused = onFocusProps.focused;
|
|
14
13
|
var isOptionFocused = function isOptionFocused(option) {
|
|
15
|
-
return option === focused;
|
|
14
|
+
return option.label === focused.label;
|
|
16
15
|
};
|
|
17
|
-
var groupData =
|
|
16
|
+
var groupData = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.find(function (option) {
|
|
18
17
|
var _option$options;
|
|
19
18
|
return (_option$options = option.options) === null || _option$options === void 0 ? void 0 : _option$options.some(isOptionFocused);
|
|
20
19
|
});
|
|
@@ -3,15 +3,16 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
* @jsxRuntime classic
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
import { groupedCountries } from './data/countries';
|
|
10
10
|
import Select from './Select';
|
|
11
|
+
import { isCountryOptionsGrouped, onCountryOptionFocus } from './utils/country-groups-announcement';
|
|
11
12
|
// custom option renderer
|
|
12
13
|
const labelStyles = css({
|
|
13
|
-
alignItems: 'center',
|
|
14
14
|
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
15
16
|
lineHeight: 1.2
|
|
16
17
|
});
|
|
17
18
|
const flagStyles = css({
|
|
@@ -62,12 +63,36 @@ const formatOptionLabel = (opt, {
|
|
|
62
63
|
}) => context === 'value' ? controlLabel(opt) : optionLabel(opt);
|
|
63
64
|
|
|
64
65
|
// put it all together
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
66
|
+
// TODO: Fill in the component {description} and ensure links point to the correct {packageName} location.
|
|
67
|
+
// Remove links that the component does not have (such as usage). If there are no links remove them all.
|
|
68
|
+
/**
|
|
69
|
+
* __Country select__
|
|
70
|
+
*
|
|
71
|
+
* A country select {description}.
|
|
72
|
+
*
|
|
73
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
74
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
75
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
76
|
+
*/
|
|
77
|
+
const CountrySelect = props => {
|
|
78
|
+
const {
|
|
79
|
+
ariaLiveMessages,
|
|
80
|
+
options
|
|
81
|
+
} = props;
|
|
82
|
+
const countryOptions = options || groupedCountries;
|
|
83
|
+
return jsx(Select, _extends({
|
|
84
|
+
isClearable: false,
|
|
85
|
+
formatOptionLabel: formatOptionLabel,
|
|
86
|
+
getOptionLabel: getOptionLabel,
|
|
87
|
+
getOptionValue: getOptionValue,
|
|
88
|
+
isMulti: false,
|
|
89
|
+
options: countryOptions,
|
|
90
|
+
ariaLiveMessages: isCountryOptionsGrouped(countryOptions) ? {
|
|
91
|
+
onFocus: data => onCountryOptionFocus(data, countryOptions),
|
|
92
|
+
...ariaLiveMessages
|
|
93
|
+
} : {
|
|
94
|
+
...ariaLiveMessages
|
|
95
|
+
}
|
|
96
|
+
}, props));
|
|
97
|
+
};
|
|
73
98
|
export default CountrySelect;
|
|
@@ -6,12 +6,11 @@ import { createPortal } from 'react-dom';
|
|
|
6
6
|
import FocusLock from 'react-focus-lock';
|
|
7
7
|
import NodeResolver from 'react-node-resolver';
|
|
8
8
|
import { Manager, Popper, Reference } from 'react-popper';
|
|
9
|
-
import
|
|
9
|
+
import { mergeStyles } from 'react-select';
|
|
10
10
|
import { uid } from 'react-uid';
|
|
11
11
|
import { shallowEqualObjects } from 'shallow-equal';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
12
|
import { N80 } from '@atlaskit/theme/colors';
|
|
14
|
-
import
|
|
13
|
+
import Select from '../Select';
|
|
15
14
|
import baseStyles from '../styles';
|
|
16
15
|
import { countAllOptions, isOptionsGrouped, onFocus } from '../utils/grouped-options-announcement';
|
|
17
16
|
import { defaultComponents, DummyControl, MenuDialog } from './components';
|
|
@@ -53,6 +52,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
53
52
|
var _this$defaultOpenStat;
|
|
54
53
|
super(...args);
|
|
55
54
|
_defineProperty(this, "menuRef", null);
|
|
55
|
+
_defineProperty(this, "selectRef", null);
|
|
56
56
|
_defineProperty(this, "targetRef", null);
|
|
57
57
|
_defineProperty(this, "unbindWindowClick", null);
|
|
58
58
|
_defineProperty(this, "unbindWindowKeydown", null);
|
|
@@ -163,7 +163,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
163
163
|
});
|
|
164
164
|
if (this.selectRef) {
|
|
165
165
|
var _this$selectRef$selec;
|
|
166
|
-
|
|
166
|
+
(_this$selectRef$selec = this.selectRef.select) === null || _this$selectRef$selec === void 0 ? void 0 : _this$selectRef$selec.openMenu('first');
|
|
167
167
|
}
|
|
168
168
|
if (typeof window === 'undefined') {
|
|
169
169
|
return;
|
|
@@ -261,7 +261,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
261
261
|
|
|
262
262
|
// subtract the control height to maintain consistency
|
|
263
263
|
const showSearchControl = this.showSearchControl();
|
|
264
|
-
|
|
264
|
+
const controlRef = (_this$selectRef$selec2 = this.selectRef.select) === null || _this$selectRef$selec2 === void 0 ? void 0 : _this$selectRef$selec2.controlRef;
|
|
265
265
|
const offsetHeight = showSearchControl && controlRef ? controlRef.offsetHeight : 0;
|
|
266
266
|
const maxHeight = maxMenuHeight - offsetHeight;
|
|
267
267
|
return maxHeight;
|
|
@@ -309,17 +309,16 @@ export default class PopupSelect extends PureComponent {
|
|
|
309
309
|
return placeholder;
|
|
310
310
|
}
|
|
311
311
|
};
|
|
312
|
-
const InternalSelect = fg('platform.design-system-team.use-default-select-in-popup-select_46rmj') ? DefaultSelect : Select;
|
|
313
312
|
const providedAriaLabel = getLabel();
|
|
314
313
|
const updateInputAriaLabel = ariaLabelText => {
|
|
315
|
-
var _this$selectRef, _this$selectRef$selec3
|
|
314
|
+
var _this$selectRef, _this$selectRef$selec3;
|
|
316
315
|
// Update aria-label to get first announcement when popup opened.
|
|
317
|
-
if ((_this$selectRef = this.selectRef) !== null && _this$selectRef !== void 0 && (_this$selectRef$selec3 = _this$selectRef.select) !== null && _this$selectRef$selec3 !== void 0 && _this$selectRef$selec3.inputRef
|
|
318
|
-
var _this$
|
|
316
|
+
if ((_this$selectRef = this.selectRef) !== null && _this$selectRef !== void 0 && (_this$selectRef$selec3 = _this$selectRef.select) !== null && _this$selectRef$selec3 !== void 0 && _this$selectRef$selec3.inputRef) {
|
|
317
|
+
var _this$selectRef2, _this$selectRef2$sele;
|
|
319
318
|
if (providedAriaLabel) {
|
|
320
319
|
ariaLabelText = `${providedAriaLabel}. ${ariaLabelText}`;
|
|
321
320
|
}
|
|
322
|
-
|
|
321
|
+
(_this$selectRef2 = this.selectRef) === null || _this$selectRef2 === void 0 ? void 0 : (_this$selectRef2$sele = _this$selectRef2.select.inputRef) === null || _this$selectRef2$sele === void 0 ? void 0 : _this$selectRef2$sele.setAttribute('aria-label', ariaLabelText);
|
|
323
322
|
}
|
|
324
323
|
};
|
|
325
324
|
const generateNoGroupsAriaText = (onFocusProps, ariaLabelSuffix) => {
|
|
@@ -328,10 +327,10 @@ export default class PopupSelect extends PureComponent {
|
|
|
328
327
|
focused
|
|
329
328
|
} = onFocusProps;
|
|
330
329
|
const options = (props === null || props === void 0 ? void 0 : props.options) || [];
|
|
331
|
-
const totalLength =
|
|
330
|
+
const totalLength = options === null || options === void 0 ? void 0 : options.length;
|
|
332
331
|
const optionIndex = (_options$findIndex = options === null || options === void 0 ? void 0 : options.findIndex(option => option === focused)) !== null && _options$findIndex !== void 0 ? _options$findIndex : 0;
|
|
333
332
|
const optionName = typeof (props === null || props === void 0 ? void 0 : props.getOptionLabel) === 'function' ? props.getOptionLabel(focused) : focused.label;
|
|
334
|
-
const ariaLabelText = `Option ${optionName} focused, ${optionIndex} of ${totalLength}.
|
|
333
|
+
const ariaLabelText = `Option ${optionName} focused, ${optionIndex + 1} of ${totalLength}.
|
|
335
334
|
${totalLength} results available.
|
|
336
335
|
${ariaLabelSuffix}
|
|
337
336
|
`;
|
|
@@ -348,7 +347,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
348
347
|
if ((_props$options = props.options) !== null && _props$options !== void 0 && _props$options.length) {
|
|
349
348
|
if (isOptionsGrouped(props.options)) {
|
|
350
349
|
const totalLength = countAllOptions(props.options);
|
|
351
|
-
ariaLiveMessage = onFocus(onFocusProps);
|
|
350
|
+
ariaLiveMessage = onFocus(onFocusProps, props.options);
|
|
352
351
|
ariaLabelText = `${ariaLiveMessage} ${totalLength} results available. ${ariaLabelSuffix}`;
|
|
353
352
|
} else {
|
|
354
353
|
ariaLabelText = generateNoGroupsAriaText(onFocusProps, ariaLabelSuffix);
|
|
@@ -357,6 +356,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
357
356
|
updateInputAriaLabel(ariaLabelText);
|
|
358
357
|
return ariaLiveMessage;
|
|
359
358
|
}
|
|
359
|
+
return ariaLiveMessage;
|
|
360
360
|
};
|
|
361
361
|
const popper = /*#__PURE__*/React.createElement(Popper, _extends({}, mergedPopperProps, {
|
|
362
362
|
onFirstUpdate: state => {
|
|
@@ -382,7 +382,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
382
382
|
}, /*#__PURE__*/React.createElement(FocusLock, {
|
|
383
383
|
disabled: !focusLockEnabled,
|
|
384
384
|
returnFocus: true
|
|
385
|
-
}, /*#__PURE__*/React.createElement(
|
|
385
|
+
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
386
386
|
"aria-label": providedAriaLabel,
|
|
387
387
|
backspaceRemovesValue: false,
|
|
388
388
|
controlShouldRenderValue: false,
|
|
@@ -4,24 +4,30 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { components } from 'react-select';
|
|
8
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
8
|
import { css, jsx } from '@emotion/react';
|
|
10
|
-
import
|
|
9
|
+
import { components } from 'react-select';
|
|
11
10
|
import SearchIcon from '@atlaskit/icon/glyph/editor/search';
|
|
12
|
-
import { layers } from '@atlaskit/theme/constants';
|
|
13
11
|
import { N40A } from '@atlaskit/theme/colors';
|
|
12
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
13
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
14
14
|
|
|
15
15
|
// ==============================
|
|
16
16
|
// Styled Components
|
|
17
17
|
// ==============================
|
|
18
18
|
|
|
19
19
|
const menuDialogStyles = css({
|
|
20
|
+
zIndex: layers.modal(),
|
|
20
21
|
backgroundColor: "var(--ds-surface-overlay, white)",
|
|
21
22
|
borderRadius: "var(--ds-border-radius-100, 4px)",
|
|
22
|
-
boxShadow: `var(--ds-shadow-overlay, ${`0 0 0 1px ${N40A}, 0 4px 11px ${N40A}`})
|
|
23
|
-
zIndex: layers.modal()
|
|
23
|
+
boxShadow: `var(--ds-shadow-overlay, ${`0 0 0 1px ${N40A}, 0 4px 11px ${N40A}`})`
|
|
24
24
|
});
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* __Menu dialog__
|
|
28
|
+
* Wrapper for PopupSelect component.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
25
31
|
export const MenuDialog = ({
|
|
26
32
|
maxWidth,
|
|
27
33
|
minWidth,
|
|
@@ -50,9 +56,9 @@ export const MenuDialog = ({
|
|
|
50
56
|
// ==============================
|
|
51
57
|
|
|
52
58
|
const dropdownStyles = css({
|
|
59
|
+
width: 32,
|
|
53
60
|
marginInlineEnd: "var(--ds-space-025, 2px)",
|
|
54
|
-
textAlign: 'center'
|
|
55
|
-
width: 32
|
|
61
|
+
textAlign: 'center'
|
|
56
62
|
});
|
|
57
63
|
const DropdownIndicator = () => jsx("div", {
|
|
58
64
|
css: dropdownStyles
|
|
@@ -72,6 +78,11 @@ const Control = ({
|
|
|
72
78
|
}, jsx(components.Control, _extends({}, props, {
|
|
73
79
|
innerProps: innerProps
|
|
74
80
|
})));
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* __Dummy control__
|
|
84
|
+
* Overrides the default DummyControl component in Select.
|
|
85
|
+
*/
|
|
75
86
|
export const DummyControl = props => jsx(VisuallyHidden, null, jsx(components.Control, props));
|
|
76
87
|
|
|
77
88
|
// NOTE `props` intentionally omitted from `Fragment`
|
|
@@ -79,8 +90,14 @@ const Menu = ({
|
|
|
79
90
|
children,
|
|
80
91
|
innerProps
|
|
81
92
|
}) => jsx("div", innerProps, children);
|
|
93
|
+
const IndicatorSeparator = props => jsx(components.IndicatorSeparator, props);
|
|
94
|
+
const ClearIndicator = props => jsx(components.ClearIndicator, props);
|
|
95
|
+
const MultiValueRemove = props => jsx(components.MultiValueRemove, props);
|
|
82
96
|
export const defaultComponents = {
|
|
83
97
|
Control,
|
|
84
98
|
DropdownIndicator,
|
|
85
|
-
Menu
|
|
99
|
+
Menu,
|
|
100
|
+
IndicatorSeparator,
|
|
101
|
+
ClearIndicator,
|
|
102
|
+
MultiValueRemove
|
|
86
103
|
};
|
package/dist/es2019/Select.js
CHANGED
|
@@ -2,7 +2,7 @@ import ReactSelect 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 = "17.11.
|
|
5
|
+
const packageVersion = "17.11.12";
|
|
6
6
|
export const SelectWithoutAnalytics = createSelect(ReactSelect);
|
|
7
7
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
8
8
|
const Select = withAnalyticsContext({
|
|
@@ -70,7 +70,7 @@ export default function createSelect(WrappedComponent) {
|
|
|
70
70
|
ref: internalSelectRef,
|
|
71
71
|
"aria-live": "assertive",
|
|
72
72
|
ariaLiveMessages: isOptionsGrouped(props.options) ? {
|
|
73
|
-
onFocus,
|
|
73
|
+
onFocus: data => onFocus(data, props.options),
|
|
74
74
|
...ariaLiveMessages
|
|
75
75
|
} : {
|
|
76
76
|
...ariaLiveMessages
|
package/dist/es2019/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { default as AsyncSelect } from './entry-points/async-select';
|
|
|
7
7
|
export { default as CreatableSelect } from './entry-points/creatable-select';
|
|
8
8
|
export { default as AsyncCreatableSelect } from './entry-points/async-creatable-select';
|
|
9
9
|
export { isOptionsGrouped } from './utils/grouped-options-announcement';
|
|
10
|
+
export { isCountryOptionsGrouped, onCountryOptionFocus } from './utils/country-groups-announcement';
|
|
10
11
|
export { default as CheckboxSelect } from './CheckboxSelect';
|
|
11
12
|
export { default as CountrySelect } from './CountrySelect';
|
|
12
13
|
export { default as RadioSelect } from './RadioSelect';
|