@atlaskit/select 15.4.0 → 15.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/cjs/CountrySelect.js +18 -41
- package/dist/cjs/PopupSelect/PopupSelect.js +20 -34
- package/dist/cjs/Select.js +1 -1
- package/dist/cjs/createSelect.js +3 -2
- package/dist/cjs/styles.js +26 -10
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/CountrySelect.js +11 -20
- package/dist/es2019/PopupSelect/PopupSelect.js +12 -27
- package/dist/es2019/Select.js +1 -1
- package/dist/es2019/createSelect.js +2 -1
- package/dist/es2019/styles.js +26 -10
- package/dist/es2019/version.json +1 -1
- package/dist/esm/CountrySelect.js +18 -42
- package/dist/esm/PopupSelect/PopupSelect.js +19 -35
- package/dist/esm/Select.js +1 -1
- package/dist/esm/createSelect.js +3 -2
- package/dist/esm/styles.js +26 -10
- package/dist/esm/version.json +1 -1
- package/dist/types/CountrySelect.d.ts +4 -1
- package/dist/types/PopupSelect/PopupSelect.d.ts +0 -3
- package/dist/types/data/countries.d.ts +7 -4
- package/dist/types/styles.d.ts +1 -1
- package/dist/types/types.d.ts +1 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @atlaskit/select
|
|
2
2
|
|
|
3
|
+
## 15.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`d9f112c7b09`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d9f112c7b09) - Reverts change to multiSelect's remove behaviour when using tokens, fixing issue with a pointer-events: none style
|
|
8
|
+
|
|
9
|
+
## 15.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`68cc8008851`](https://bitbucket.org/atlassian/atlassian-frontend/commits/68cc8008851) - [ux] Introduces appearance prop to component, with 'default', 'subtle' and 'none' variants
|
|
14
|
+
|
|
15
|
+
## 15.5.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [`c17c6943be2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c17c6943be2) - Updated appearance of multi-select tags; when delete button is hovered, the appearance now matches @atlaskit/tag. The change is only visible with design token CSS enabled (in light or dark mode)
|
|
20
|
+
- [`45cae79ec0f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/45cae79ec0f) - [ux] Internal changes to <CountrySelect /> to no longer override container and menu width. The behaviour is now the same as the default Select component. Visual changes are possible if the <CountrySelect /> is being used in an unconstrained container (it will now expand to fill as is the default).
|
|
21
|
+
|
|
22
|
+
Component now also uses the correct types (previously set to `any`). Props are still passed through so there is no runtime effect, but this may effect compilation for users providing props that are unsupported by the runtime.
|
|
23
|
+
|
|
24
|
+
- [`6e6ff42cd4c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6e6ff42cd4c) - Replaces focus-trap with react-focus-lock in line with implementation in Jira Frontend.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- [`1c4840e546a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1c4840e546a) - fix popup select alignment bug
|
|
29
|
+
- [`dec5021eefd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dec5021eefd) - [ux] Trigger onMenuClose prop when popup select closes.
|
|
30
|
+
- [`fe575d49d66`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fe575d49d66) - Updated styles to use new input design tokens
|
|
31
|
+
|
|
3
32
|
## 15.4.0
|
|
4
33
|
|
|
5
34
|
### Minor Changes
|
|
@@ -9,41 +9,31 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
12
|
var _core = require("@emotion/core");
|
|
15
13
|
|
|
16
14
|
var _countries = require("./data/countries");
|
|
17
15
|
|
|
18
16
|
var _Select = _interopRequireDefault(require("./Select"));
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
-
|
|
18
|
+
/** @jsx jsx */
|
|
24
19
|
// custom option renderer
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
fontSize: '18px',
|
|
36
|
-
marginRight: '8px'
|
|
37
|
-
};
|
|
38
|
-
};
|
|
20
|
+
var labelStyles = (0, _core.css)({
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
display: 'flex',
|
|
23
|
+
lineHeight: 1.2
|
|
24
|
+
});
|
|
25
|
+
var flagStyles = (0, _core.css)({
|
|
26
|
+
fontSize: '18px',
|
|
27
|
+
marginRight: '8px'
|
|
28
|
+
});
|
|
39
29
|
|
|
40
30
|
var Opt = function Opt(_ref) {
|
|
41
31
|
var children = _ref.children,
|
|
42
32
|
icon = _ref.icon;
|
|
43
33
|
return (0, _core.jsx)("div", {
|
|
44
|
-
css:
|
|
34
|
+
css: labelStyles
|
|
45
35
|
}, (0, _core.jsx)("span", {
|
|
46
|
-
css:
|
|
36
|
+
css: flagStyles
|
|
47
37
|
}, icon), children);
|
|
48
38
|
}; // return the country name; used for searching
|
|
49
39
|
|
|
@@ -75,7 +65,11 @@ var optionLabel = function optionLabel(_ref3) {
|
|
|
75
65
|
name = _ref3.name;
|
|
76
66
|
return (0, _core.jsx)(Opt, {
|
|
77
67
|
icon: icon
|
|
78
|
-
},
|
|
68
|
+
}, getOptionLabel({
|
|
69
|
+
abbr: abbr,
|
|
70
|
+
code: code,
|
|
71
|
+
name: name
|
|
72
|
+
}));
|
|
79
73
|
}; // switch formatters based on render context (menu | value)
|
|
80
74
|
|
|
81
75
|
|
|
@@ -92,24 +86,7 @@ var CountrySelect = function CountrySelect(props) {
|
|
|
92
86
|
getOptionLabel: getOptionLabel,
|
|
93
87
|
getOptionValue: getOptionValue,
|
|
94
88
|
isMulti: false,
|
|
95
|
-
options: _countries.groupedCountries
|
|
96
|
-
styles: {
|
|
97
|
-
container: function container(css) {
|
|
98
|
-
return _objectSpread(_objectSpread({}, css), {}, {
|
|
99
|
-
width: 105
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
dropdownIndicator: function dropdownIndicator(css) {
|
|
103
|
-
return _objectSpread(_objectSpread({}, css), {}, {
|
|
104
|
-
paddingLeft: 0
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
menu: function menu(css) {
|
|
108
|
-
return _objectSpread(_objectSpread({}, css), {}, {
|
|
109
|
-
width: 300
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
89
|
+
options: _countries.groupedCountries
|
|
113
90
|
}, props));
|
|
114
91
|
};
|
|
115
92
|
|
|
@@ -31,12 +31,12 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
31
31
|
|
|
32
32
|
var _reactDom = require("react-dom");
|
|
33
33
|
|
|
34
|
+
var _reactFocusLock = _interopRequireDefault(require("react-focus-lock"));
|
|
35
|
+
|
|
34
36
|
var _reactSelect = _interopRequireWildcard(require("react-select"));
|
|
35
37
|
|
|
36
38
|
var _reactUid = require("react-uid");
|
|
37
39
|
|
|
38
|
-
var _focusTrap = _interopRequireDefault(require("focus-trap"));
|
|
39
|
-
|
|
40
40
|
var _reactPopper = require("react-popper");
|
|
41
41
|
|
|
42
42
|
var _reactNodeResolver = _interopRequireDefault(require("react-node-resolver"));
|
|
@@ -116,13 +116,12 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
119
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "focusTrap", null);
|
|
120
119
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "menuRef", null);
|
|
121
120
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectRef", null);
|
|
122
121
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "targetRef", null);
|
|
123
122
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unbindWindowClick", null);
|
|
124
123
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unbindWindowKeydown", null);
|
|
125
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "defaultStyles", (0, _reactSelect.mergeStyles)((0, _styles.default)(_this.props.validationState, _this.props.spacing === 'compact'), {
|
|
124
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "defaultStyles", (0, _reactSelect.mergeStyles)((0, _styles.default)(_this.props.validationState, _this.props.spacing === 'compact', 'default'), {
|
|
126
125
|
groupHeading: function groupHeading(provided) {
|
|
127
126
|
return _objectSpread(_objectSpread({}, provided), {}, {
|
|
128
127
|
color: "var(--ds-text-subtlest, ".concat(_colors.N80, ")")
|
|
@@ -202,7 +201,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
202
201
|
|
|
203
202
|
_this.setState({
|
|
204
203
|
isOpen: true
|
|
205
|
-
}
|
|
204
|
+
});
|
|
206
205
|
|
|
207
206
|
if (_this.selectRef) {
|
|
208
207
|
_this.selectRef.select.openMenu('first'); // HACK
|
|
@@ -221,27 +220,12 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
221
220
|
}
|
|
222
221
|
});
|
|
223
222
|
});
|
|
224
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "initialiseFocusTrap", function () {
|
|
225
|
-
if (!_this.menuRef) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
var trapConfig = {
|
|
230
|
-
clickOutsideDeactivates: true,
|
|
231
|
-
escapeDeactivates: true,
|
|
232
|
-
fallbackFocus: _this.menuRef,
|
|
233
|
-
returnFocusOnDeactivate: true
|
|
234
|
-
};
|
|
235
|
-
_this.focusTrap = (0, _focusTrap.default)(_this.menuRef, trapConfig); // allow time for the HTMLElement to render
|
|
236
|
-
|
|
237
|
-
setTimeout(function () {
|
|
238
|
-
return _this.focusTrap.activate();
|
|
239
|
-
}, 1);
|
|
240
|
-
});
|
|
241
223
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "close", function (options) {
|
|
242
224
|
var _this$unbindWindowKey, _this2;
|
|
243
225
|
|
|
244
|
-
var
|
|
226
|
+
var _this$props2 = _this.props,
|
|
227
|
+
onClose = _this$props2.onClose,
|
|
228
|
+
onMenuClose = _this$props2.onMenuClose;
|
|
245
229
|
|
|
246
230
|
if (!(options !== null && options !== void 0 && options.controlOverride) && _this.isOpenControlled) {
|
|
247
231
|
// Prevent popup closing if it's open state is already being controlled
|
|
@@ -252,14 +236,14 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
252
236
|
onClose();
|
|
253
237
|
}
|
|
254
238
|
|
|
239
|
+
if (onMenuClose) {
|
|
240
|
+
onMenuClose();
|
|
241
|
+
}
|
|
242
|
+
|
|
255
243
|
_this.setState({
|
|
256
244
|
isOpen: false
|
|
257
245
|
});
|
|
258
246
|
|
|
259
|
-
if (_this.focusTrap) {
|
|
260
|
-
_this.focusTrap.deactivate();
|
|
261
|
-
}
|
|
262
|
-
|
|
263
247
|
if (_this.targetRef != null) {
|
|
264
248
|
_this.targetRef.focus();
|
|
265
249
|
}
|
|
@@ -334,12 +318,12 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
334
318
|
return _this.getItemCount() > searchThreshold;
|
|
335
319
|
});
|
|
336
320
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderSelect", function () {
|
|
337
|
-
var _this$
|
|
338
|
-
footer = _this$
|
|
339
|
-
maxMenuWidth = _this$
|
|
340
|
-
minMenuWidth = _this$
|
|
341
|
-
target = _this$
|
|
342
|
-
props = (0, _objectWithoutProperties2.default)(_this$
|
|
321
|
+
var _this$props3 = _this.props,
|
|
322
|
+
footer = _this$props3.footer,
|
|
323
|
+
maxMenuWidth = _this$props3.maxMenuWidth,
|
|
324
|
+
minMenuWidth = _this$props3.minMenuWidth,
|
|
325
|
+
target = _this$props3.target,
|
|
326
|
+
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
343
327
|
var _this$state = _this.state,
|
|
344
328
|
isOpen = _this$state.isOpen,
|
|
345
329
|
mergedComponents = _this$state.mergedComponents,
|
|
@@ -369,6 +353,8 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
369
353
|
minWidth: minMenuWidth,
|
|
370
354
|
maxWidth: maxMenuWidth,
|
|
371
355
|
id: _this.popperWrapperId
|
|
356
|
+
}, /*#__PURE__*/_react.default.createElement(_reactFocusLock.default, {
|
|
357
|
+
returnFocus: true
|
|
372
358
|
}, /*#__PURE__*/_react.default.createElement(_reactSelect.default, (0, _extends2.default)({
|
|
373
359
|
backspaceRemovesValue: false,
|
|
374
360
|
controlShouldRenderValue: false,
|
|
@@ -382,7 +368,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
382
368
|
maxMenuHeight: _this.getMaxHeight(),
|
|
383
369
|
components: components,
|
|
384
370
|
onChange: _this.handleSelectChange
|
|
385
|
-
})), footer));
|
|
371
|
+
})), footer)));
|
|
386
372
|
});
|
|
387
373
|
|
|
388
374
|
return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/(0, _reactDom.createPortal)(popper, portalDestination);
|
package/dist/cjs/Select.js
CHANGED
|
@@ -14,7 +14,7 @@ var _analyticsNext = require("@atlaskit/analytics-next");
|
|
|
14
14
|
var _createSelect = _interopRequireDefault(require("./createSelect"));
|
|
15
15
|
|
|
16
16
|
var packageName = "@atlaskit/select";
|
|
17
|
-
var packageVersion = "15.
|
|
17
|
+
var packageVersion = "15.6.1";
|
|
18
18
|
var SelectWithoutAnalytics = (0, _createSelect.default)(_reactSelect.default);
|
|
19
19
|
exports.SelectWithoutAnalytics = SelectWithoutAnalytics;
|
|
20
20
|
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
package/dist/cjs/createSelect.js
CHANGED
|
@@ -41,7 +41,7 @@ var defaultComponents = _interopRequireWildcard(require("./components"));
|
|
|
41
41
|
|
|
42
42
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
43
43
|
|
|
44
|
-
var _excluded = ["styles", "validationState", "spacing", "isMulti"];
|
|
44
|
+
var _excluded = ["styles", "validationState", "spacing", "isMulti", "appearance"];
|
|
45
45
|
|
|
46
46
|
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); }
|
|
47
47
|
|
|
@@ -119,6 +119,7 @@ function createSelect(WrappedComponent) {
|
|
|
119
119
|
validationState = _this$props.validationState,
|
|
120
120
|
spacing = _this$props.spacing,
|
|
121
121
|
isMulti = _this$props.isMulti,
|
|
122
|
+
appearance = _this$props.appearance,
|
|
122
123
|
props = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
|
|
123
124
|
var isCompact = spacing === 'compact'; // props must be spread first to stop `components` being overridden
|
|
124
125
|
|
|
@@ -128,7 +129,7 @@ function createSelect(WrappedComponent) {
|
|
|
128
129
|
"aria-live": "assertive"
|
|
129
130
|
}, props, {
|
|
130
131
|
components: this.components,
|
|
131
|
-
styles: (0, _reactSelect.mergeStyles)((0, _styles.default)(validationState, isCompact), styles)
|
|
132
|
+
styles: (0, _reactSelect.mergeStyles)((0, _styles.default)(validationState, isCompact, this.props.appearance || 'default'), styles)
|
|
132
133
|
}));
|
|
133
134
|
}
|
|
134
135
|
}]);
|
package/dist/cjs/styles.js
CHANGED
|
@@ -21,7 +21,7 @@ var BORDER_WIDTH = 2;
|
|
|
21
21
|
var ICON_PADDING = 2;
|
|
22
22
|
var paddingExcludingBorder = (0, _constants.gridSize)() - BORDER_WIDTH;
|
|
23
23
|
|
|
24
|
-
function baseStyles(validationState, isCompact) {
|
|
24
|
+
function baseStyles(validationState, isCompact, appearance) {
|
|
25
25
|
return {
|
|
26
26
|
container: function container(css, _ref) {
|
|
27
27
|
var isDisabled = _ref.isDisabled;
|
|
@@ -41,12 +41,12 @@ function baseStyles(validationState, isCompact) {
|
|
|
41
41
|
control: function control(css, _ref2) {
|
|
42
42
|
var isFocused = _ref2.isFocused,
|
|
43
43
|
isDisabled = _ref2.isDisabled;
|
|
44
|
-
var borderColor = isFocused ? "var(--ds-border-focused, ".concat(_colors.B100, ")") : "var(--ds-border, ".concat(_colors.N20, ")");
|
|
45
|
-
var backgroundColor = isFocused ? "var(--ds-
|
|
46
|
-
var backgroundColorHover = isFocused ? "var(--ds-
|
|
44
|
+
var borderColor = isFocused ? "var(--ds-border-focused, ".concat(_colors.B100, ")") : "var(--ds-border-input, ".concat(_colors.N20, ")");
|
|
45
|
+
var backgroundColor = isFocused ? "var(--ds-background-input-pressed, ".concat(_colors.N0, ")") : "var(--ds-background-input, ".concat(_colors.N20, ")");
|
|
46
|
+
var backgroundColorHover = isFocused ? "var(--ds-background-input-pressed, ".concat(_colors.N0, ")") : "var(--ds-background-input-hovered, ".concat(_colors.N30, ")");
|
|
47
47
|
|
|
48
48
|
if (isDisabled) {
|
|
49
|
-
backgroundColor = "var(--ds-background-
|
|
49
|
+
backgroundColor = "var(--ds-background-disabled, ".concat(_colors.N20, ")");
|
|
50
50
|
borderColor = "var(--ds-background-disabled, ".concat(_colors.N20, ")");
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -69,6 +69,20 @@ function baseStyles(validationState, isCompact) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
var transitionDuration = '200ms';
|
|
72
|
+
|
|
73
|
+
if (appearance === 'subtle') {
|
|
74
|
+
borderColor = isFocused ? "var(--ds-border-focused, ".concat(_colors.B100, ")") : 'transparent';
|
|
75
|
+
backgroundColor = isFocused ? "var(--ds-surface, ".concat(_colors.N0, ")") : 'transparent';
|
|
76
|
+
backgroundColorHover = isFocused ? "var(--ds-surface, ".concat(_colors.N0, ")") : "var(--ds-surface, ".concat(_colors.N30, ")");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (appearance === 'none') {
|
|
80
|
+
borderColor = 'transparent';
|
|
81
|
+
backgroundColor = 'transparent';
|
|
82
|
+
backgroundColorHover = 'transparent';
|
|
83
|
+
borderColorHover = 'transparent';
|
|
84
|
+
}
|
|
85
|
+
|
|
72
86
|
return _objectSpread(_objectSpread({}, css), {}, {
|
|
73
87
|
// Turn pointer events off when disabled - this makes it so hover etc don't work.
|
|
74
88
|
pointerEvents: isDisabled ? 'none' : undefined,
|
|
@@ -176,7 +190,7 @@ function baseStyles(validationState, isCompact) {
|
|
|
176
190
|
} else if (isSelected) {
|
|
177
191
|
backgroundColor = "var(--ds-background-selected, ".concat(_colors.B50, ")");
|
|
178
192
|
} else if (isFocused) {
|
|
179
|
-
backgroundColor = "var(--ds-background-
|
|
193
|
+
backgroundColor = "var(--ds-background-neutral-subtle-hovered, ".concat(_colors.N20, ")");
|
|
180
194
|
}
|
|
181
195
|
|
|
182
196
|
if (!isDisabled && (isFocused || isSelected)) {
|
|
@@ -228,30 +242,32 @@ function baseStyles(validationState, isCompact) {
|
|
|
228
242
|
var isFocused = _ref7.isFocused;
|
|
229
243
|
return _objectSpread(_objectSpread({}, css), {}, {
|
|
230
244
|
borderRadius: '2px',
|
|
231
|
-
backgroundColor: isFocused ? "var(--ds-background-selected, ".concat(_colors.N40, ")") : "var(--ds-background-neutral
|
|
245
|
+
backgroundColor: isFocused ? "var(--ds-background-selected, ".concat(_colors.N40, ")") : "var(--ds-background-neutral, ".concat(_colors.N40, ")"),
|
|
232
246
|
boxShadow: isFocused ? "0 0 0 2px ".concat("var(--ds-surface, transparent)", ", 0 0 0 4px ", "var(--ds-border-focused, transparent)") : 'none',
|
|
233
247
|
maxWidth: '100%',
|
|
234
248
|
'@media screen and (-ms-high-contrast: active)': {
|
|
235
249
|
border: isFocused ? '1px solid transparent' : 'none'
|
|
236
|
-
}
|
|
250
|
+
},
|
|
251
|
+
color: isFocused ? "var(--ds-text-selected, hsl(0, 0%, 20%))" : "var(--ds-text, hsl(0, 0%, 20%))"
|
|
237
252
|
});
|
|
238
253
|
},
|
|
239
254
|
multiValueLabel: function multiValueLabel(css, _ref8) {
|
|
240
255
|
var isFocused = _ref8.isFocused;
|
|
241
256
|
return _objectSpread(_objectSpread({}, css), {}, {
|
|
242
257
|
padding: '2px',
|
|
243
|
-
color:
|
|
258
|
+
color: 'inherit',
|
|
244
259
|
paddingRight: '2px'
|
|
245
260
|
});
|
|
246
261
|
},
|
|
247
262
|
multiValueRemove: function multiValueRemove(css, _ref9) {
|
|
248
263
|
var isFocused = _ref9.isFocused;
|
|
249
264
|
return _objectSpread(_objectSpread({}, css), {}, {
|
|
250
|
-
backgroundColor: isFocused && "var(--ds-
|
|
265
|
+
backgroundColor: isFocused && "var(--ds-UNSAFE_util-transparent, ".concat(_colors.R75, ")"),
|
|
251
266
|
fill: isFocused ? "var(--ds-text-selected, #000)" : "var(--ds-text, #000)",
|
|
252
267
|
paddingLeft: '2px',
|
|
253
268
|
paddingRight: '2px',
|
|
254
269
|
borderRadius: '0px 2px 2px 0px',
|
|
270
|
+
// DSP-6470 we should style like Tag once we have the :has selector
|
|
255
271
|
':hover': {
|
|
256
272
|
backgroundColor: "var(--ds-background-danger-hovered, ".concat(_colors.R75, ")"),
|
|
257
273
|
fill: "var(--ds-text-danger, #000)"
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { jsx } from '@emotion/core';
|
|
4
|
+
import { jsx, css } from '@emotion/core';
|
|
5
5
|
import { groupedCountries } from './data/countries';
|
|
6
6
|
import Select from './Select';
|
|
7
|
-
|
|
8
7
|
// custom option renderer
|
|
9
|
-
const
|
|
8
|
+
const labelStyles = css({
|
|
10
9
|
alignItems: 'center',
|
|
11
10
|
display: 'flex',
|
|
12
11
|
lineHeight: 1.2
|
|
13
12
|
});
|
|
14
|
-
|
|
15
|
-
const flagCSS = () => ({
|
|
13
|
+
const flagStyles = css({
|
|
16
14
|
fontSize: '18px',
|
|
17
15
|
marginRight: '8px'
|
|
18
16
|
});
|
|
@@ -21,9 +19,9 @@ const Opt = ({
|
|
|
21
19
|
children,
|
|
22
20
|
icon
|
|
23
21
|
}) => jsx("div", {
|
|
24
|
-
css:
|
|
22
|
+
css: labelStyles
|
|
25
23
|
}, jsx("span", {
|
|
26
|
-
css:
|
|
24
|
+
css: flagStyles
|
|
27
25
|
}, icon), children); // return the country name; used for searching
|
|
28
26
|
|
|
29
27
|
|
|
@@ -49,7 +47,11 @@ const optionLabel = ({
|
|
|
49
47
|
name
|
|
50
48
|
}) => jsx(Opt, {
|
|
51
49
|
icon: icon
|
|
52
|
-
},
|
|
50
|
+
}, getOptionLabel({
|
|
51
|
+
abbr,
|
|
52
|
+
code,
|
|
53
|
+
name
|
|
54
|
+
})); // switch formatters based on render context (menu | value)
|
|
53
55
|
|
|
54
56
|
|
|
55
57
|
const formatOptionLabel = (opt, {
|
|
@@ -63,18 +65,7 @@ const CountrySelect = props => jsx(Select, _extends({
|
|
|
63
65
|
getOptionLabel: getOptionLabel,
|
|
64
66
|
getOptionValue: getOptionValue,
|
|
65
67
|
isMulti: false,
|
|
66
|
-
options: groupedCountries
|
|
67
|
-
styles: {
|
|
68
|
-
container: css => ({ ...css,
|
|
69
|
-
width: 105
|
|
70
|
-
}),
|
|
71
|
-
dropdownIndicator: css => ({ ...css,
|
|
72
|
-
paddingLeft: 0
|
|
73
|
-
}),
|
|
74
|
-
menu: css => ({ ...css,
|
|
75
|
-
width: 300
|
|
76
|
-
})
|
|
77
|
-
}
|
|
68
|
+
options: groupedCountries
|
|
78
69
|
}, props));
|
|
79
70
|
|
|
80
71
|
export default CountrySelect;
|
|
@@ -2,9 +2,9 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import React, { PureComponent } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
|
+
import FocusLock from 'react-focus-lock';
|
|
5
6
|
import Select, { mergeStyles } from 'react-select';
|
|
6
7
|
import { uid } from 'react-uid';
|
|
7
|
-
import createFocusTrap from 'focus-trap';
|
|
8
8
|
import { Manager, Reference, Popper } from 'react-popper';
|
|
9
9
|
import NodeResolver from 'react-node-resolver';
|
|
10
10
|
import shallowEqualObjects from 'shallow-equal/objects';
|
|
@@ -49,8 +49,6 @@ export default class PopupSelect extends PureComponent {
|
|
|
49
49
|
|
|
50
50
|
super(...args);
|
|
51
51
|
|
|
52
|
-
_defineProperty(this, "focusTrap", null);
|
|
53
|
-
|
|
54
52
|
_defineProperty(this, "menuRef", null);
|
|
55
53
|
|
|
56
54
|
_defineProperty(this, "selectRef", null);
|
|
@@ -61,7 +59,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
61
59
|
|
|
62
60
|
_defineProperty(this, "unbindWindowKeydown", null);
|
|
63
61
|
|
|
64
|
-
_defineProperty(this, "defaultStyles", mergeStyles(baseStyles(this.props.validationState, this.props.spacing === 'compact'), {
|
|
62
|
+
_defineProperty(this, "defaultStyles", mergeStyles(baseStyles(this.props.validationState, this.props.spacing === 'compact', 'default'), {
|
|
65
63
|
groupHeading: provided => ({ ...provided,
|
|
66
64
|
color: `var(--ds-text-subtlest, ${N80})`
|
|
67
65
|
})
|
|
@@ -152,7 +150,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
152
150
|
|
|
153
151
|
this.setState({
|
|
154
152
|
isOpen: true
|
|
155
|
-
}
|
|
153
|
+
});
|
|
156
154
|
|
|
157
155
|
if (this.selectRef) {
|
|
158
156
|
this.selectRef.select.openMenu('first'); // HACK
|
|
@@ -171,27 +169,12 @@ export default class PopupSelect extends PureComponent {
|
|
|
171
169
|
});
|
|
172
170
|
});
|
|
173
171
|
|
|
174
|
-
_defineProperty(this, "initialiseFocusTrap", () => {
|
|
175
|
-
if (!this.menuRef) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const trapConfig = {
|
|
180
|
-
clickOutsideDeactivates: true,
|
|
181
|
-
escapeDeactivates: true,
|
|
182
|
-
fallbackFocus: this.menuRef,
|
|
183
|
-
returnFocusOnDeactivate: true
|
|
184
|
-
};
|
|
185
|
-
this.focusTrap = createFocusTrap(this.menuRef, trapConfig); // allow time for the HTMLElement to render
|
|
186
|
-
|
|
187
|
-
setTimeout(() => this.focusTrap.activate(), 1);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
172
|
_defineProperty(this, "close", options => {
|
|
191
173
|
var _this$unbindWindowKey;
|
|
192
174
|
|
|
193
175
|
const {
|
|
194
|
-
onClose
|
|
176
|
+
onClose,
|
|
177
|
+
onMenuClose
|
|
195
178
|
} = this.props;
|
|
196
179
|
|
|
197
180
|
if (!(options !== null && options !== void 0 && options.controlOverride) && this.isOpenControlled) {
|
|
@@ -203,14 +186,14 @@ export default class PopupSelect extends PureComponent {
|
|
|
203
186
|
onClose();
|
|
204
187
|
}
|
|
205
188
|
|
|
189
|
+
if (onMenuClose) {
|
|
190
|
+
onMenuClose();
|
|
191
|
+
}
|
|
192
|
+
|
|
206
193
|
this.setState({
|
|
207
194
|
isOpen: false
|
|
208
195
|
});
|
|
209
196
|
|
|
210
|
-
if (this.focusTrap) {
|
|
211
|
-
this.focusTrap.deactivate();
|
|
212
|
-
}
|
|
213
|
-
|
|
214
197
|
if (this.targetRef != null) {
|
|
215
198
|
this.targetRef.focus();
|
|
216
199
|
}
|
|
@@ -328,6 +311,8 @@ export default class PopupSelect extends PureComponent {
|
|
|
328
311
|
minWidth: minMenuWidth,
|
|
329
312
|
maxWidth: maxMenuWidth,
|
|
330
313
|
id: this.popperWrapperId
|
|
314
|
+
}, /*#__PURE__*/React.createElement(FocusLock, {
|
|
315
|
+
returnFocus: true
|
|
331
316
|
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
332
317
|
backspaceRemovesValue: false,
|
|
333
318
|
controlShouldRenderValue: false,
|
|
@@ -343,7 +328,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
343
328
|
maxMenuHeight: this.getMaxHeight(),
|
|
344
329
|
components: components,
|
|
345
330
|
onChange: this.handleSelectChange
|
|
346
|
-
})), footer));
|
|
331
|
+
})), footer)));
|
|
347
332
|
});
|
|
348
333
|
return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/createPortal(popper, portalDestination);
|
|
349
334
|
});
|
package/dist/es2019/Select.js
CHANGED
|
@@ -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 = "15.
|
|
5
|
+
const packageVersion = "15.6.1";
|
|
6
6
|
export const SelectWithoutAnalytics = createSelect(Select);
|
|
7
7
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
8
8
|
export default withAnalyticsContext({
|
|
@@ -64,6 +64,7 @@ export default function createSelect(WrappedComponent) {
|
|
|
64
64
|
validationState,
|
|
65
65
|
spacing,
|
|
66
66
|
isMulti,
|
|
67
|
+
appearance,
|
|
67
68
|
...props
|
|
68
69
|
} = this.props;
|
|
69
70
|
const isCompact = spacing === 'compact'; // props must be spread first to stop `components` being overridden
|
|
@@ -74,7 +75,7 @@ export default function createSelect(WrappedComponent) {
|
|
|
74
75
|
"aria-live": "assertive"
|
|
75
76
|
}, props, {
|
|
76
77
|
components: this.components,
|
|
77
|
-
styles: mergeStyles(baseStyles(validationState, isCompact), styles)
|
|
78
|
+
styles: mergeStyles(baseStyles(validationState, isCompact, this.props.appearance || 'default'), styles)
|
|
78
79
|
}));
|
|
79
80
|
}
|
|
80
81
|
|
package/dist/es2019/styles.js
CHANGED
|
@@ -3,7 +3,7 @@ import { B100, B400, B50, G400, N0, N20, N200, N30, N300, N40, N500, N70, N800,
|
|
|
3
3
|
const BORDER_WIDTH = 2;
|
|
4
4
|
const ICON_PADDING = 2;
|
|
5
5
|
const paddingExcludingBorder = gridSize() - BORDER_WIDTH;
|
|
6
|
-
export default function baseStyles(validationState, isCompact) {
|
|
6
|
+
export default function baseStyles(validationState, isCompact, appearance) {
|
|
7
7
|
return {
|
|
8
8
|
container: (css, {
|
|
9
9
|
isDisabled
|
|
@@ -21,12 +21,12 @@ export default function baseStyles(validationState, isCompact) {
|
|
|
21
21
|
isFocused,
|
|
22
22
|
isDisabled
|
|
23
23
|
}) => {
|
|
24
|
-
let borderColor = isFocused ? `var(--ds-border-focused, ${B100})` : `var(--ds-border, ${N20})`;
|
|
25
|
-
let backgroundColor = isFocused ? `var(--ds-
|
|
26
|
-
let backgroundColorHover = isFocused ? `var(--ds-
|
|
24
|
+
let borderColor = isFocused ? `var(--ds-border-focused, ${B100})` : `var(--ds-border-input, ${N20})`;
|
|
25
|
+
let backgroundColor = isFocused ? `var(--ds-background-input-pressed, ${N0})` : `var(--ds-background-input, ${N20})`;
|
|
26
|
+
let backgroundColorHover = isFocused ? `var(--ds-background-input-pressed, ${N0})` : `var(--ds-background-input-hovered, ${N30})`;
|
|
27
27
|
|
|
28
28
|
if (isDisabled) {
|
|
29
|
-
backgroundColor = `var(--ds-background-
|
|
29
|
+
backgroundColor = `var(--ds-background-disabled, ${N20})`;
|
|
30
30
|
borderColor = `var(--ds-background-disabled, ${N20})`;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -49,6 +49,20 @@ export default function baseStyles(validationState, isCompact) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
const transitionDuration = '200ms';
|
|
52
|
+
|
|
53
|
+
if (appearance === 'subtle') {
|
|
54
|
+
borderColor = isFocused ? `var(--ds-border-focused, ${B100})` : 'transparent';
|
|
55
|
+
backgroundColor = isFocused ? `var(--ds-surface, ${N0})` : 'transparent';
|
|
56
|
+
backgroundColorHover = isFocused ? `var(--ds-surface, ${N0})` : `var(--ds-surface, ${N30})`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (appearance === 'none') {
|
|
60
|
+
borderColor = 'transparent';
|
|
61
|
+
backgroundColor = 'transparent';
|
|
62
|
+
backgroundColorHover = 'transparent';
|
|
63
|
+
borderColorHover = 'transparent';
|
|
64
|
+
}
|
|
65
|
+
|
|
52
66
|
return { ...css,
|
|
53
67
|
// Turn pointer events off when disabled - this makes it so hover etc don't work.
|
|
54
68
|
pointerEvents: isDisabled ? 'none' : undefined,
|
|
@@ -151,7 +165,7 @@ export default function baseStyles(validationState, isCompact) {
|
|
|
151
165
|
} else if (isSelected) {
|
|
152
166
|
backgroundColor = `var(--ds-background-selected, ${B50})`;
|
|
153
167
|
} else if (isFocused) {
|
|
154
|
-
backgroundColor = `var(--ds-background-
|
|
168
|
+
backgroundColor = `var(--ds-background-neutral-subtle-hovered, ${N20})`;
|
|
155
169
|
}
|
|
156
170
|
|
|
157
171
|
if (!isDisabled && (isFocused || isSelected)) {
|
|
@@ -197,29 +211,31 @@ export default function baseStyles(validationState, isCompact) {
|
|
|
197
211
|
isFocused
|
|
198
212
|
}) => ({ ...css,
|
|
199
213
|
borderRadius: '2px',
|
|
200
|
-
backgroundColor: isFocused ? `var(--ds-background-selected, ${N40})` : `var(--ds-background-neutral
|
|
214
|
+
backgroundColor: isFocused ? `var(--ds-background-selected, ${N40})` : `var(--ds-background-neutral, ${N40})`,
|
|
201
215
|
boxShadow: isFocused ? `0 0 0 2px ${"var(--ds-surface, transparent)"}, 0 0 0 4px ${"var(--ds-border-focused, transparent)"}` : 'none',
|
|
202
216
|
maxWidth: '100%',
|
|
203
217
|
'@media screen and (-ms-high-contrast: active)': {
|
|
204
218
|
border: isFocused ? '1px solid transparent' : 'none'
|
|
205
|
-
}
|
|
219
|
+
},
|
|
220
|
+
color: isFocused ? "var(--ds-text-selected, hsl(0, 0%, 20%))" : "var(--ds-text, hsl(0, 0%, 20%))"
|
|
206
221
|
}),
|
|
207
222
|
multiValueLabel: (css, {
|
|
208
223
|
isFocused
|
|
209
224
|
}) => ({ ...css,
|
|
210
225
|
padding: '2px',
|
|
211
|
-
color:
|
|
226
|
+
color: 'inherit',
|
|
212
227
|
paddingRight: '2px'
|
|
213
228
|
}),
|
|
214
229
|
multiValueRemove: (css, {
|
|
215
230
|
// @ts-ignore: missing in @types/react-select
|
|
216
231
|
isFocused
|
|
217
232
|
}) => ({ ...css,
|
|
218
|
-
backgroundColor: isFocused && `var(--ds-
|
|
233
|
+
backgroundColor: isFocused && `var(--ds-UNSAFE_util-transparent, ${R75})`,
|
|
219
234
|
fill: isFocused ? "var(--ds-text-selected, #000)" : "var(--ds-text, #000)",
|
|
220
235
|
paddingLeft: '2px',
|
|
221
236
|
paddingRight: '2px',
|
|
222
237
|
borderRadius: '0px 2px 2px 0px',
|
|
238
|
+
// DSP-6470 we should style like Tag once we have the :has selector
|
|
223
239
|
':hover': {
|
|
224
240
|
backgroundColor: `var(--ds-background-danger-hovered, ${R75})`,
|
|
225
241
|
fill: "var(--ds-text-danger, #000)"
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,38 +1,27 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
2
|
|
|
8
3
|
/** @jsx jsx */
|
|
9
|
-
import { jsx } from '@emotion/core';
|
|
4
|
+
import { jsx, css } from '@emotion/core';
|
|
10
5
|
import { groupedCountries } from './data/countries';
|
|
11
6
|
import Select from './Select';
|
|
12
|
-
|
|
13
7
|
// custom option renderer
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
fontSize: '18px',
|
|
25
|
-
marginRight: '8px'
|
|
26
|
-
};
|
|
27
|
-
};
|
|
8
|
+
var labelStyles = css({
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
display: 'flex',
|
|
11
|
+
lineHeight: 1.2
|
|
12
|
+
});
|
|
13
|
+
var flagStyles = css({
|
|
14
|
+
fontSize: '18px',
|
|
15
|
+
marginRight: '8px'
|
|
16
|
+
});
|
|
28
17
|
|
|
29
18
|
var Opt = function Opt(_ref) {
|
|
30
19
|
var children = _ref.children,
|
|
31
20
|
icon = _ref.icon;
|
|
32
21
|
return jsx("div", {
|
|
33
|
-
css:
|
|
22
|
+
css: labelStyles
|
|
34
23
|
}, jsx("span", {
|
|
35
|
-
css:
|
|
24
|
+
css: flagStyles
|
|
36
25
|
}, icon), children);
|
|
37
26
|
}; // return the country name; used for searching
|
|
38
27
|
|
|
@@ -64,7 +53,11 @@ var optionLabel = function optionLabel(_ref3) {
|
|
|
64
53
|
name = _ref3.name;
|
|
65
54
|
return jsx(Opt, {
|
|
66
55
|
icon: icon
|
|
67
|
-
},
|
|
56
|
+
}, getOptionLabel({
|
|
57
|
+
abbr: abbr,
|
|
58
|
+
code: code,
|
|
59
|
+
name: name
|
|
60
|
+
}));
|
|
68
61
|
}; // switch formatters based on render context (menu | value)
|
|
69
62
|
|
|
70
63
|
|
|
@@ -81,24 +74,7 @@ var CountrySelect = function CountrySelect(props) {
|
|
|
81
74
|
getOptionLabel: getOptionLabel,
|
|
82
75
|
getOptionValue: getOptionValue,
|
|
83
76
|
isMulti: false,
|
|
84
|
-
options: groupedCountries
|
|
85
|
-
styles: {
|
|
86
|
-
container: function container(css) {
|
|
87
|
-
return _objectSpread(_objectSpread({}, css), {}, {
|
|
88
|
-
width: 105
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
dropdownIndicator: function dropdownIndicator(css) {
|
|
92
|
-
return _objectSpread(_objectSpread({}, css), {}, {
|
|
93
|
-
paddingLeft: 0
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
menu: function menu(css) {
|
|
97
|
-
return _objectSpread(_objectSpread({}, css), {}, {
|
|
98
|
-
width: 300
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
77
|
+
options: groupedCountries
|
|
102
78
|
}, props));
|
|
103
79
|
};
|
|
104
80
|
|
|
@@ -19,9 +19,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
19
19
|
|
|
20
20
|
import React, { PureComponent } from 'react';
|
|
21
21
|
import { createPortal } from 'react-dom';
|
|
22
|
+
import FocusLock from 'react-focus-lock';
|
|
22
23
|
import Select, { mergeStyles } from 'react-select';
|
|
23
24
|
import { uid } from 'react-uid';
|
|
24
|
-
import createFocusTrap from 'focus-trap';
|
|
25
25
|
import { Manager, Reference, Popper } from 'react-popper';
|
|
26
26
|
import NodeResolver from 'react-node-resolver';
|
|
27
27
|
import shallowEqualObjects from 'shallow-equal/objects';
|
|
@@ -82,8 +82,6 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
82
82
|
|
|
83
83
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
84
84
|
|
|
85
|
-
_defineProperty(_assertThisInitialized(_this), "focusTrap", null);
|
|
86
|
-
|
|
87
85
|
_defineProperty(_assertThisInitialized(_this), "menuRef", null);
|
|
88
86
|
|
|
89
87
|
_defineProperty(_assertThisInitialized(_this), "selectRef", null);
|
|
@@ -94,7 +92,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
94
92
|
|
|
95
93
|
_defineProperty(_assertThisInitialized(_this), "unbindWindowKeydown", null);
|
|
96
94
|
|
|
97
|
-
_defineProperty(_assertThisInitialized(_this), "defaultStyles", mergeStyles(baseStyles(_this.props.validationState, _this.props.spacing === 'compact'), {
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this), "defaultStyles", mergeStyles(baseStyles(_this.props.validationState, _this.props.spacing === 'compact', 'default'), {
|
|
98
96
|
groupHeading: function groupHeading(provided) {
|
|
99
97
|
return _objectSpread(_objectSpread({}, provided), {}, {
|
|
100
98
|
color: "var(--ds-text-subtlest, ".concat(N80, ")")
|
|
@@ -182,7 +180,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
182
180
|
|
|
183
181
|
_this.setState({
|
|
184
182
|
isOpen: true
|
|
185
|
-
}
|
|
183
|
+
});
|
|
186
184
|
|
|
187
185
|
if (_this.selectRef) {
|
|
188
186
|
_this.selectRef.select.openMenu('first'); // HACK
|
|
@@ -202,28 +200,12 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
202
200
|
});
|
|
203
201
|
});
|
|
204
202
|
|
|
205
|
-
_defineProperty(_assertThisInitialized(_this), "initialiseFocusTrap", function () {
|
|
206
|
-
if (!_this.menuRef) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
var trapConfig = {
|
|
211
|
-
clickOutsideDeactivates: true,
|
|
212
|
-
escapeDeactivates: true,
|
|
213
|
-
fallbackFocus: _this.menuRef,
|
|
214
|
-
returnFocusOnDeactivate: true
|
|
215
|
-
};
|
|
216
|
-
_this.focusTrap = createFocusTrap(_this.menuRef, trapConfig); // allow time for the HTMLElement to render
|
|
217
|
-
|
|
218
|
-
setTimeout(function () {
|
|
219
|
-
return _this.focusTrap.activate();
|
|
220
|
-
}, 1);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
203
|
_defineProperty(_assertThisInitialized(_this), "close", function (options) {
|
|
224
204
|
var _this$unbindWindowKey, _this2;
|
|
225
205
|
|
|
226
|
-
var
|
|
206
|
+
var _this$props2 = _this.props,
|
|
207
|
+
onClose = _this$props2.onClose,
|
|
208
|
+
onMenuClose = _this$props2.onMenuClose;
|
|
227
209
|
|
|
228
210
|
if (!(options !== null && options !== void 0 && options.controlOverride) && _this.isOpenControlled) {
|
|
229
211
|
// Prevent popup closing if it's open state is already being controlled
|
|
@@ -234,14 +216,14 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
234
216
|
onClose();
|
|
235
217
|
}
|
|
236
218
|
|
|
219
|
+
if (onMenuClose) {
|
|
220
|
+
onMenuClose();
|
|
221
|
+
}
|
|
222
|
+
|
|
237
223
|
_this.setState({
|
|
238
224
|
isOpen: false
|
|
239
225
|
});
|
|
240
226
|
|
|
241
|
-
if (_this.focusTrap) {
|
|
242
|
-
_this.focusTrap.deactivate();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
227
|
if (_this.targetRef != null) {
|
|
246
228
|
_this.targetRef.focus();
|
|
247
229
|
}
|
|
@@ -323,12 +305,12 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
323
305
|
});
|
|
324
306
|
|
|
325
307
|
_defineProperty(_assertThisInitialized(_this), "renderSelect", function () {
|
|
326
|
-
var _this$
|
|
327
|
-
footer = _this$
|
|
328
|
-
maxMenuWidth = _this$
|
|
329
|
-
minMenuWidth = _this$
|
|
330
|
-
target = _this$
|
|
331
|
-
props = _objectWithoutProperties(_this$
|
|
308
|
+
var _this$props3 = _this.props,
|
|
309
|
+
footer = _this$props3.footer,
|
|
310
|
+
maxMenuWidth = _this$props3.maxMenuWidth,
|
|
311
|
+
minMenuWidth = _this$props3.minMenuWidth,
|
|
312
|
+
target = _this$props3.target,
|
|
313
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
332
314
|
|
|
333
315
|
var _this$state = _this.state,
|
|
334
316
|
isOpen = _this$state.isOpen,
|
|
@@ -359,6 +341,8 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
359
341
|
minWidth: minMenuWidth,
|
|
360
342
|
maxWidth: maxMenuWidth,
|
|
361
343
|
id: _this.popperWrapperId
|
|
344
|
+
}, /*#__PURE__*/React.createElement(FocusLock, {
|
|
345
|
+
returnFocus: true
|
|
362
346
|
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
363
347
|
backspaceRemovesValue: false,
|
|
364
348
|
controlShouldRenderValue: false,
|
|
@@ -372,7 +356,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
372
356
|
maxMenuHeight: _this.getMaxHeight(),
|
|
373
357
|
components: components,
|
|
374
358
|
onChange: _this.handleSelectChange
|
|
375
|
-
})), footer));
|
|
359
|
+
})), footer)));
|
|
376
360
|
});
|
|
377
361
|
return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/createPortal(popper, portalDestination);
|
|
378
362
|
});
|
package/dist/esm/Select.js
CHANGED
|
@@ -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 = "15.
|
|
5
|
+
var packageVersion = "15.6.1";
|
|
6
6
|
export var SelectWithoutAnalytics = createSelect(Select);
|
|
7
7
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
8
8
|
export default withAnalyticsContext({
|
package/dist/esm/createSelect.js
CHANGED
|
@@ -8,7 +8,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
8
8
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
9
9
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
|
-
var _excluded = ["styles", "validationState", "spacing", "isMulti"];
|
|
11
|
+
var _excluded = ["styles", "validationState", "spacing", "isMulti", "appearance"];
|
|
12
12
|
|
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
14
|
|
|
@@ -94,6 +94,7 @@ export default function createSelect(WrappedComponent) {
|
|
|
94
94
|
validationState = _this$props.validationState,
|
|
95
95
|
spacing = _this$props.spacing,
|
|
96
96
|
isMulti = _this$props.isMulti,
|
|
97
|
+
appearance = _this$props.appearance,
|
|
97
98
|
props = _objectWithoutProperties(_this$props, _excluded);
|
|
98
99
|
|
|
99
100
|
var isCompact = spacing === 'compact'; // props must be spread first to stop `components` being overridden
|
|
@@ -104,7 +105,7 @@ export default function createSelect(WrappedComponent) {
|
|
|
104
105
|
"aria-live": "assertive"
|
|
105
106
|
}, props, {
|
|
106
107
|
components: this.components,
|
|
107
|
-
styles: mergeStyles(baseStyles(validationState, isCompact), styles)
|
|
108
|
+
styles: mergeStyles(baseStyles(validationState, isCompact, this.props.appearance || 'default'), styles)
|
|
108
109
|
}));
|
|
109
110
|
}
|
|
110
111
|
}]);
|
package/dist/esm/styles.js
CHANGED
|
@@ -9,7 +9,7 @@ import { B100, B400, B50, G400, N0, N20, N200, N30, N300, N40, N500, N70, N800,
|
|
|
9
9
|
var BORDER_WIDTH = 2;
|
|
10
10
|
var ICON_PADDING = 2;
|
|
11
11
|
var paddingExcludingBorder = gridSize() - BORDER_WIDTH;
|
|
12
|
-
export default function baseStyles(validationState, isCompact) {
|
|
12
|
+
export default function baseStyles(validationState, isCompact, appearance) {
|
|
13
13
|
return {
|
|
14
14
|
container: function container(css, _ref) {
|
|
15
15
|
var isDisabled = _ref.isDisabled;
|
|
@@ -29,12 +29,12 @@ export default function baseStyles(validationState, isCompact) {
|
|
|
29
29
|
control: function control(css, _ref2) {
|
|
30
30
|
var isFocused = _ref2.isFocused,
|
|
31
31
|
isDisabled = _ref2.isDisabled;
|
|
32
|
-
var borderColor = isFocused ? "var(--ds-border-focused, ".concat(B100, ")") : "var(--ds-border, ".concat(N20, ")");
|
|
33
|
-
var backgroundColor = isFocused ? "var(--ds-
|
|
34
|
-
var backgroundColorHover = isFocused ? "var(--ds-
|
|
32
|
+
var borderColor = isFocused ? "var(--ds-border-focused, ".concat(B100, ")") : "var(--ds-border-input, ".concat(N20, ")");
|
|
33
|
+
var backgroundColor = isFocused ? "var(--ds-background-input-pressed, ".concat(N0, ")") : "var(--ds-background-input, ".concat(N20, ")");
|
|
34
|
+
var backgroundColorHover = isFocused ? "var(--ds-background-input-pressed, ".concat(N0, ")") : "var(--ds-background-input-hovered, ".concat(N30, ")");
|
|
35
35
|
|
|
36
36
|
if (isDisabled) {
|
|
37
|
-
backgroundColor = "var(--ds-background-
|
|
37
|
+
backgroundColor = "var(--ds-background-disabled, ".concat(N20, ")");
|
|
38
38
|
borderColor = "var(--ds-background-disabled, ".concat(N20, ")");
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -57,6 +57,20 @@ export default function baseStyles(validationState, isCompact) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
var transitionDuration = '200ms';
|
|
60
|
+
|
|
61
|
+
if (appearance === 'subtle') {
|
|
62
|
+
borderColor = isFocused ? "var(--ds-border-focused, ".concat(B100, ")") : 'transparent';
|
|
63
|
+
backgroundColor = isFocused ? "var(--ds-surface, ".concat(N0, ")") : 'transparent';
|
|
64
|
+
backgroundColorHover = isFocused ? "var(--ds-surface, ".concat(N0, ")") : "var(--ds-surface, ".concat(N30, ")");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (appearance === 'none') {
|
|
68
|
+
borderColor = 'transparent';
|
|
69
|
+
backgroundColor = 'transparent';
|
|
70
|
+
backgroundColorHover = 'transparent';
|
|
71
|
+
borderColorHover = 'transparent';
|
|
72
|
+
}
|
|
73
|
+
|
|
60
74
|
return _objectSpread(_objectSpread({}, css), {}, {
|
|
61
75
|
// Turn pointer events off when disabled - this makes it so hover etc don't work.
|
|
62
76
|
pointerEvents: isDisabled ? 'none' : undefined,
|
|
@@ -164,7 +178,7 @@ export default function baseStyles(validationState, isCompact) {
|
|
|
164
178
|
} else if (isSelected) {
|
|
165
179
|
backgroundColor = "var(--ds-background-selected, ".concat(B50, ")");
|
|
166
180
|
} else if (isFocused) {
|
|
167
|
-
backgroundColor = "var(--ds-background-
|
|
181
|
+
backgroundColor = "var(--ds-background-neutral-subtle-hovered, ".concat(N20, ")");
|
|
168
182
|
}
|
|
169
183
|
|
|
170
184
|
if (!isDisabled && (isFocused || isSelected)) {
|
|
@@ -216,30 +230,32 @@ export default function baseStyles(validationState, isCompact) {
|
|
|
216
230
|
var isFocused = _ref7.isFocused;
|
|
217
231
|
return _objectSpread(_objectSpread({}, css), {}, {
|
|
218
232
|
borderRadius: '2px',
|
|
219
|
-
backgroundColor: isFocused ? "var(--ds-background-selected, ".concat(N40, ")") : "var(--ds-background-neutral
|
|
233
|
+
backgroundColor: isFocused ? "var(--ds-background-selected, ".concat(N40, ")") : "var(--ds-background-neutral, ".concat(N40, ")"),
|
|
220
234
|
boxShadow: isFocused ? "0 0 0 2px ".concat("var(--ds-surface, transparent)", ", 0 0 0 4px ", "var(--ds-border-focused, transparent)") : 'none',
|
|
221
235
|
maxWidth: '100%',
|
|
222
236
|
'@media screen and (-ms-high-contrast: active)': {
|
|
223
237
|
border: isFocused ? '1px solid transparent' : 'none'
|
|
224
|
-
}
|
|
238
|
+
},
|
|
239
|
+
color: isFocused ? "var(--ds-text-selected, hsl(0, 0%, 20%))" : "var(--ds-text, hsl(0, 0%, 20%))"
|
|
225
240
|
});
|
|
226
241
|
},
|
|
227
242
|
multiValueLabel: function multiValueLabel(css, _ref8) {
|
|
228
243
|
var isFocused = _ref8.isFocused;
|
|
229
244
|
return _objectSpread(_objectSpread({}, css), {}, {
|
|
230
245
|
padding: '2px',
|
|
231
|
-
color:
|
|
246
|
+
color: 'inherit',
|
|
232
247
|
paddingRight: '2px'
|
|
233
248
|
});
|
|
234
249
|
},
|
|
235
250
|
multiValueRemove: function multiValueRemove(css, _ref9) {
|
|
236
251
|
var isFocused = _ref9.isFocused;
|
|
237
252
|
return _objectSpread(_objectSpread({}, css), {}, {
|
|
238
|
-
backgroundColor: isFocused && "var(--ds-
|
|
253
|
+
backgroundColor: isFocused && "var(--ds-UNSAFE_util-transparent, ".concat(R75, ")"),
|
|
239
254
|
fill: isFocused ? "var(--ds-text-selected, #000)" : "var(--ds-text, #000)",
|
|
240
255
|
paddingLeft: '2px',
|
|
241
256
|
paddingRight: '2px',
|
|
242
257
|
borderRadius: '0px 2px 2px 0px',
|
|
258
|
+
// DSP-6470 we should style like Tag once we have the :has selector
|
|
243
259
|
':hover': {
|
|
244
260
|
backgroundColor: "var(--ds-background-danger-hovered, ".concat(R75, ")"),
|
|
245
261
|
fill: "var(--ds-text-danger, #000)"
|
package/dist/esm/version.json
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { groupedCountries } from './data/countries';
|
|
3
|
+
import { SelectProps } from './types';
|
|
4
|
+
declare type Country = typeof groupedCountries[number]['options'][number];
|
|
5
|
+
declare const CountrySelect: (props: SelectProps<Country>) => JSX.Element;
|
|
3
6
|
export default CountrySelect;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { PureComponent, ReactNode } from 'react';
|
|
2
2
|
import Select from 'react-select';
|
|
3
|
-
import { FocusTrap } from 'focus-trap';
|
|
4
3
|
import { PopperProps } from 'react-popper';
|
|
5
4
|
import { OptionType, ActionMeta, ReactSelectProps, StylesConfig, ValueType } from '../types';
|
|
6
5
|
import { UnbindFn } from 'bind-event-listener';
|
|
@@ -67,7 +66,6 @@ interface State<Modifiers = string> {
|
|
|
67
66
|
mergedPopperProps: PopperPropsNoChildren<defaultModifiers | Modifiers>;
|
|
68
67
|
}
|
|
69
68
|
export default class PopupSelect<Option = OptionType, IsMulti extends boolean = false> extends PureComponent<PopupSelectProps<Option, IsMulti>, State> {
|
|
70
|
-
focusTrap: FocusTrap | null;
|
|
71
69
|
menuRef: HTMLElement | null;
|
|
72
70
|
selectRef: Select<Option, IsMulti> | null;
|
|
73
71
|
targetRef: HTMLElement | null;
|
|
@@ -112,7 +110,6 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
|
|
|
112
110
|
open: (options?: {
|
|
113
111
|
controlOverride?: boolean | undefined;
|
|
114
112
|
} | undefined) => void;
|
|
115
|
-
initialiseFocusTrap: () => void;
|
|
116
113
|
/**
|
|
117
114
|
* Closes the popup
|
|
118
115
|
*
|
|
@@ -6,8 +6,11 @@ interface Country {
|
|
|
6
6
|
suggested?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare const allCountries: Array<Country>;
|
|
9
|
-
export declare const groupedCountries:
|
|
10
|
-
label:
|
|
11
|
-
options:
|
|
12
|
-
}
|
|
9
|
+
export declare const groupedCountries: readonly [{
|
|
10
|
+
readonly label: "Suggested";
|
|
11
|
+
readonly options: Country[];
|
|
12
|
+
}, {
|
|
13
|
+
readonly label: "All Countries";
|
|
14
|
+
readonly options: Country[];
|
|
15
|
+
}];
|
|
13
16
|
export {};
|
package/dist/types/styles.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { StylesConfig, ValidationState } from './types';
|
|
2
|
-
export default function baseStyles<Option, IsMulti extends boolean>(validationState: ValidationState, isCompact: boolean): StylesConfig<Option, IsMulti>;
|
|
2
|
+
export default function baseStyles<Option, IsMulti extends boolean>(validationState: ValidationState, isCompact: boolean, appearance: 'default' | 'subtle' | 'none'): StylesConfig<Option, IsMulti>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface OptionProps<Option = OptionType, IsMulti extends boolean = fals
|
|
|
25
25
|
export interface SelectProps<OptionType, IsMulti extends boolean = false> extends ReactSelectProps<OptionType, IsMulti>, WithAnalyticsEventsProps {
|
|
26
26
|
spacing?: 'compact' | 'default';
|
|
27
27
|
validationState?: ValidationState;
|
|
28
|
+
appearance?: 'default' | 'subtle' | 'none';
|
|
28
29
|
}
|
|
29
30
|
export declare type ActionMeta<Option = OptionType> = RSActionMeta<Option>;
|
|
30
31
|
export declare type InputActionMeta = RSInputActionMeta;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/select",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.6.1",
|
|
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/"
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"@popperjs/core": "^2.9.1",
|
|
36
36
|
"@types/react-select": "^4.0.18",
|
|
37
37
|
"bind-event-listener": "^2.1.1",
|
|
38
|
-
"focus-trap": "^2.4.5",
|
|
39
38
|
"memoize-one": "^6.0.0",
|
|
40
39
|
"react-fast-compare": "^3.2.0",
|
|
40
|
+
"react-focus-lock": "^2.5.2",
|
|
41
41
|
"react-node-resolver": "^1.0.1",
|
|
42
42
|
"react-popper": "^2.2.3",
|
|
43
43
|
"react-select": "^4.3.1",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"@atlaskit/form": "^8.5.0",
|
|
57
57
|
"@atlaskit/logo": "^13.8.0",
|
|
58
58
|
"@atlaskit/modal-dialog": "^12.2.0",
|
|
59
|
+
"@atlaskit/radio": "^5.3.11",
|
|
59
60
|
"@atlaskit/section-message": "^6.0.0",
|
|
60
61
|
"@atlaskit/ssr": "*",
|
|
61
62
|
"@atlaskit/tooltip": "^17.5.0",
|
|
@@ -64,6 +65,7 @@
|
|
|
64
65
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
65
66
|
"@emotion/styled": "^10.0.7",
|
|
66
67
|
"@testing-library/react": "^8.0.1",
|
|
68
|
+
"@testing-library/user-event": "10.4.0",
|
|
67
69
|
"ast-types": "^0.13.3",
|
|
68
70
|
"enzyme": "^3.10.0",
|
|
69
71
|
"jscodeshift": "^0.13.0",
|