@atlaskit/select 16.3.1 → 16.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/PopupSelect/PopupSelect.js +60 -16
- package/dist/cjs/Select.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/PopupSelect/PopupSelect.js +62 -17
- package/dist/es2019/Select.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/PopupSelect/PopupSelect.js +60 -16
- package/dist/esm/Select.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/PopupSelect/PopupSelect.d.ts +83 -1
- package/dist/types-ts4.5/PopupSelect/PopupSelect.d.ts +83 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/select
|
|
2
2
|
|
|
3
|
+
## 16.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`45bcfb68efb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/45bcfb68efb) - Testing behind a feature flag: reduce re-renders in `<PopupSelect>` by using an available renderProps to both disable and block scrolling at the right time as well as avoid rendering the `<Select>` to a portal not visible to the user.
|
|
8
|
+
|
|
3
9
|
## 16.3.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -24,9 +24,11 @@ var _reactPopper = require("react-popper");
|
|
|
24
24
|
var _reactNodeResolver = _interopRequireDefault(require("react-node-resolver"));
|
|
25
25
|
var _objects = _interopRequireDefault(require("shallow-equal/objects"));
|
|
26
26
|
var _colors = require("@atlaskit/theme/colors");
|
|
27
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
27
28
|
var _components = require("./components");
|
|
28
29
|
var _styles = _interopRequireDefault(require("../styles"));
|
|
29
30
|
var _bindEventListener = require("bind-event-listener");
|
|
31
|
+
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
30
32
|
var _excluded = ["footer", "maxMenuWidth", "minMenuWidth", "target"];
|
|
31
33
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -71,7 +73,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
71
73
|
(0, _inherits2.default)(PopupSelect, _PureComponent);
|
|
72
74
|
var _super = _createSuper(PopupSelect);
|
|
73
75
|
function PopupSelect() {
|
|
74
|
-
var _this$defaultOpenStat;
|
|
76
|
+
var _this$defaultOpenStat, _this$defaultOpenStat2;
|
|
75
77
|
var _this;
|
|
76
78
|
(0, _classCallCheck2.default)(this, PopupSelect);
|
|
77
79
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -92,11 +94,15 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
92
94
|
}));
|
|
93
95
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isOpenControlled", _this.props.isOpen !== undefined);
|
|
94
96
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "defaultOpenState", _this.isOpenControlled ? _this.props.isOpen : _this.props.defaultIsOpen);
|
|
95
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
96
|
-
focusLockEnabled: false,
|
|
97
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m') ? {
|
|
97
98
|
isOpen: (_this$defaultOpenStat = _this.defaultOpenState) !== null && _this$defaultOpenStat !== void 0 ? _this$defaultOpenStat : false,
|
|
98
99
|
mergedComponents: _components.defaultComponents,
|
|
99
100
|
mergedPopperProps: defaultPopperProps
|
|
101
|
+
} : {
|
|
102
|
+
focusLockEnabled: false,
|
|
103
|
+
isOpen: (_this$defaultOpenStat2 = _this.defaultOpenState) !== null && _this$defaultOpenStat2 !== void 0 ? _this$defaultOpenStat2 : false,
|
|
104
|
+
mergedComponents: _components.defaultComponents,
|
|
105
|
+
mergedPopperProps: defaultPopperProps
|
|
100
106
|
});
|
|
101
107
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "popperWrapperId", "".concat((0, _reactUid.uid)({
|
|
102
108
|
options: _this.props.options
|
|
@@ -207,9 +213,13 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
207
213
|
_this.setState({
|
|
208
214
|
isOpen: false
|
|
209
215
|
});
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
216
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m')) {
|
|
217
|
+
// Do nothing… (the pff eslint just doesn't like `!getBooleanFF(…)`)
|
|
218
|
+
} else {
|
|
219
|
+
_this.setState({
|
|
220
|
+
focusLockEnabled: false
|
|
221
|
+
});
|
|
222
|
+
}
|
|
213
223
|
if (_this.targetRef != null) {
|
|
214
224
|
_this.targetRef.focus();
|
|
215
225
|
}
|
|
@@ -249,6 +259,20 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
249
259
|
});
|
|
250
260
|
// Utils
|
|
251
261
|
// ==============================
|
|
262
|
+
// Get a memoized merge of the default styles and the prop's in styles
|
|
263
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSelectStyles", (0, _memoizeOne.default)(function (defaultStyles, propStyles) {
|
|
264
|
+
return (0, _reactSelect.mergeStyles)(defaultStyles, propStyles || {});
|
|
265
|
+
}));
|
|
266
|
+
// Get a memoized override of our `<Select components={…}>` overrides.
|
|
267
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSelectComponents", (0, _memoizeOne.default)(function (mergedComponents, showSearchControl) {
|
|
268
|
+
if (!showSearchControl) {
|
|
269
|
+
// When we have no search control, we use a dummy override to hide it visually.
|
|
270
|
+
return _objectSpread(_objectSpread({}, mergedComponents), {}, {
|
|
271
|
+
Control: _components.DummyControl
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return mergedComponents;
|
|
275
|
+
}));
|
|
252
276
|
// account for groups when counting options
|
|
253
277
|
// this may need to be recursive, right now it just counts one level
|
|
254
278
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getItemCount", function () {
|
|
@@ -294,6 +318,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
294
318
|
minMenuWidth = _this$props3.minMenuWidth,
|
|
295
319
|
target = _this$props3.target,
|
|
296
320
|
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
321
|
+
// TODO: If `platform.design-system-team.popup-select-render-perf_i0s6m` is kept, `focusLockEnabled` should be fully removed as we're preferring `isReferenceHidden`
|
|
297
322
|
var _this$state = _this.state,
|
|
298
323
|
focusLockEnabled = _this$state.focusLockEnabled,
|
|
299
324
|
isOpen = _this$state.isOpen,
|
|
@@ -301,13 +326,18 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
301
326
|
mergedPopperProps = _this$state.mergedPopperProps;
|
|
302
327
|
var showSearchControl = _this.showSearchControl();
|
|
303
328
|
var portalDestination = canUseDOM() ? document.body : null;
|
|
304
|
-
var components = _objectSpread(_objectSpread({}, mergedComponents), {}, {
|
|
305
|
-
Control: showSearchControl ? mergedComponents.Control : _components.DummyControl
|
|
306
|
-
});
|
|
307
329
|
if (!portalDestination || !isOpen) {
|
|
308
330
|
return null;
|
|
309
331
|
}
|
|
310
|
-
|
|
332
|
+
|
|
333
|
+
// Memoized merge of defaultStyles and props.styles
|
|
334
|
+
var selectStyles = (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m') ? _this.getSelectStyles(_this.defaultStyles, props.styles) : (0, _reactSelect.mergeStyles)(_this.defaultStyles, props.styles || {});
|
|
335
|
+
|
|
336
|
+
// Memoized variance of the default select components
|
|
337
|
+
var selectComponents = (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m') ? _this.getSelectComponents(mergedComponents, showSearchControl) : _objectSpread(_objectSpread({}, mergedComponents), {}, {
|
|
338
|
+
Control: showSearchControl ? mergedComponents.Control : _components.DummyControl
|
|
339
|
+
});
|
|
340
|
+
var popper = /*#__PURE__*/_react.default.createElement(_reactPopper.Popper, (0, _extends2.default)({}, mergedPopperProps, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m') ? undefined : {
|
|
311
341
|
onFirstUpdate: function onFirstUpdate(state) {
|
|
312
342
|
var _mergedPopperProps$on;
|
|
313
343
|
_this.handleFirstPopperUpdate();
|
|
@@ -316,7 +346,13 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
316
346
|
}), function (_ref2) {
|
|
317
347
|
var placement = _ref2.placement,
|
|
318
348
|
ref = _ref2.ref,
|
|
319
|
-
style = _ref2.style
|
|
349
|
+
style = _ref2.style,
|
|
350
|
+
isReferenceHidden = _ref2.isReferenceHidden;
|
|
351
|
+
/**
|
|
352
|
+
* The reference is not available yet, so the Popper and Portal is either being rendered at `0,0` (scrolled to the top)
|
|
353
|
+
* or not at all. There's no reason to render the Select or lock scrolling at the top of the page yet.
|
|
354
|
+
*/
|
|
355
|
+
var readyToRenderSelect = (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m') ? isReferenceHidden !== null : true;
|
|
320
356
|
return /*#__PURE__*/_react.default.createElement(_reactNodeResolver.default, {
|
|
321
357
|
innerRef: _this.resolveMenuRef(ref)
|
|
322
358
|
}, /*#__PURE__*/_react.default.createElement(_components.MenuDialog, {
|
|
@@ -325,10 +361,18 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
325
361
|
minWidth: minMenuWidth,
|
|
326
362
|
maxWidth: maxMenuWidth,
|
|
327
363
|
id: _this.popperWrapperId
|
|
328
|
-
}, /*#__PURE__*/_react.default.createElement(_reactFocusLock.default
|
|
329
|
-
|
|
364
|
+
}, /*#__PURE__*/_react.default.createElement(_reactFocusLock.default
|
|
365
|
+
/*
|
|
366
|
+
* NOTE: We intentionally want the FocusLock to be disabled until the refs are populated in Popper.
|
|
367
|
+
* Until then, the portal the Popper creates is at `0,0`, meaning the FocusLock forces the page to scroll to `0,0`.
|
|
368
|
+
* We do not want the user to scroll to the top of the page when they open their PopupSelect, so we disable it.
|
|
369
|
+
*
|
|
370
|
+
* WARNING: This causes additional renders, eg. ±5ms in our example, but unless
|
|
371
|
+
* FocusLock has a better way to avoid scrolling, this is necessary.
|
|
372
|
+
*/, {
|
|
373
|
+
disabled: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.popup-select-render-perf_i0s6m') ? !readyToRenderSelect : !focusLockEnabled,
|
|
330
374
|
returnFocus: true
|
|
331
|
-
}, /*#__PURE__*/_react.default.createElement(_reactSelect.default, (0, _extends2.default)({
|
|
375
|
+
}, readyToRenderSelect && /*#__PURE__*/_react.default.createElement(_reactSelect.default, (0, _extends2.default)({
|
|
332
376
|
backspaceRemovesValue: false,
|
|
333
377
|
controlShouldRenderValue: false,
|
|
334
378
|
isClearable: false,
|
|
@@ -337,9 +381,9 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
337
381
|
ref: _this.getSelectRef
|
|
338
382
|
}, props, {
|
|
339
383
|
isSearchable: showSearchControl,
|
|
340
|
-
styles:
|
|
384
|
+
styles: selectStyles,
|
|
341
385
|
maxMenuHeight: _this.getMaxHeight(),
|
|
342
|
-
components:
|
|
386
|
+
components: selectComponents,
|
|
343
387
|
onChange: _this.handleSelectChange
|
|
344
388
|
})), footer)));
|
|
345
389
|
});
|
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 = "16.
|
|
12
|
+
var packageVersion = "16.4.0";
|
|
13
13
|
var SelectWithoutAnalytics = (0, _createSelect.default)(_reactSelect.default);
|
|
14
14
|
exports.SelectWithoutAnalytics = SelectWithoutAnalytics;
|
|
15
15
|
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
package/dist/cjs/version.json
CHANGED
|
@@ -9,9 +9,11 @@ import { Manager, Reference, Popper } from 'react-popper';
|
|
|
9
9
|
import NodeResolver from 'react-node-resolver';
|
|
10
10
|
import shallowEqualObjects from 'shallow-equal/objects';
|
|
11
11
|
import { N80 } from '@atlaskit/theme/colors';
|
|
12
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { MenuDialog, DummyControl, defaultComponents } from './components';
|
|
13
14
|
import baseStyles from '../styles';
|
|
14
15
|
import { bind } from 'bind-event-listener';
|
|
16
|
+
import memoizeOne from 'memoize-one';
|
|
15
17
|
/** Are we rendering on the client or server? */
|
|
16
18
|
const canUseDOM = () => Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
17
19
|
|
|
@@ -43,7 +45,7 @@ const defaultPopperProps = {
|
|
|
43
45
|
const isEmpty = obj => Object.keys(obj).length === 0;
|
|
44
46
|
export default class PopupSelect extends PureComponent {
|
|
45
47
|
constructor(...args) {
|
|
46
|
-
var _this$defaultOpenStat;
|
|
48
|
+
var _this$defaultOpenStat, _this$defaultOpenStat2;
|
|
47
49
|
super(...args);
|
|
48
50
|
_defineProperty(this, "menuRef", null);
|
|
49
51
|
_defineProperty(this, "selectRef", null);
|
|
@@ -58,11 +60,15 @@ export default class PopupSelect extends PureComponent {
|
|
|
58
60
|
}));
|
|
59
61
|
_defineProperty(this, "isOpenControlled", this.props.isOpen !== undefined);
|
|
60
62
|
_defineProperty(this, "defaultOpenState", this.isOpenControlled ? this.props.isOpen : this.props.defaultIsOpen);
|
|
61
|
-
_defineProperty(this, "state", {
|
|
62
|
-
focusLockEnabled: false,
|
|
63
|
+
_defineProperty(this, "state", getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? {
|
|
63
64
|
isOpen: (_this$defaultOpenStat = this.defaultOpenState) !== null && _this$defaultOpenStat !== void 0 ? _this$defaultOpenStat : false,
|
|
64
65
|
mergedComponents: defaultComponents,
|
|
65
66
|
mergedPopperProps: defaultPopperProps
|
|
67
|
+
} : {
|
|
68
|
+
focusLockEnabled: false,
|
|
69
|
+
isOpen: (_this$defaultOpenStat2 = this.defaultOpenState) !== null && _this$defaultOpenStat2 !== void 0 ? _this$defaultOpenStat2 : false,
|
|
70
|
+
mergedComponents: defaultComponents,
|
|
71
|
+
mergedPopperProps: defaultPopperProps
|
|
66
72
|
});
|
|
67
73
|
_defineProperty(this, "popperWrapperId", `${uid({
|
|
68
74
|
options: this.props.options
|
|
@@ -181,9 +187,13 @@ export default class PopupSelect extends PureComponent {
|
|
|
181
187
|
this.setState({
|
|
182
188
|
isOpen: false
|
|
183
189
|
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
190
|
+
if (getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m')) {
|
|
191
|
+
// Do nothing… (the pff eslint just doesn't like `!getBooleanFF(…)`)
|
|
192
|
+
} else {
|
|
193
|
+
this.setState({
|
|
194
|
+
focusLockEnabled: false
|
|
195
|
+
});
|
|
196
|
+
}
|
|
187
197
|
if (this.targetRef != null) {
|
|
188
198
|
this.targetRef.focus();
|
|
189
199
|
}
|
|
@@ -219,6 +229,21 @@ export default class PopupSelect extends PureComponent {
|
|
|
219
229
|
});
|
|
220
230
|
// Utils
|
|
221
231
|
// ==============================
|
|
232
|
+
// Get a memoized merge of the default styles and the prop's in styles
|
|
233
|
+
_defineProperty(this, "getSelectStyles", memoizeOne((defaultStyles, propStyles) => {
|
|
234
|
+
return mergeStyles(defaultStyles, propStyles || {});
|
|
235
|
+
}));
|
|
236
|
+
// Get a memoized override of our `<Select components={…}>` overrides.
|
|
237
|
+
_defineProperty(this, "getSelectComponents", memoizeOne((mergedComponents, showSearchControl) => {
|
|
238
|
+
if (!showSearchControl) {
|
|
239
|
+
// When we have no search control, we use a dummy override to hide it visually.
|
|
240
|
+
return {
|
|
241
|
+
...mergedComponents,
|
|
242
|
+
Control: DummyControl
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return mergedComponents;
|
|
246
|
+
}));
|
|
222
247
|
// account for groups when counting options
|
|
223
248
|
// this may need to be recursive, right now it just counts one level
|
|
224
249
|
_defineProperty(this, "getItemCount", () => {
|
|
@@ -270,6 +295,7 @@ export default class PopupSelect extends PureComponent {
|
|
|
270
295
|
target,
|
|
271
296
|
...props
|
|
272
297
|
} = this.props;
|
|
298
|
+
// TODO: If `platform.design-system-team.popup-select-render-perf_i0s6m` is kept, `focusLockEnabled` should be fully removed as we're preferring `isReferenceHidden`
|
|
273
299
|
const {
|
|
274
300
|
focusLockEnabled,
|
|
275
301
|
isOpen,
|
|
@@ -278,14 +304,19 @@ export default class PopupSelect extends PureComponent {
|
|
|
278
304
|
} = this.state;
|
|
279
305
|
const showSearchControl = this.showSearchControl();
|
|
280
306
|
const portalDestination = canUseDOM() ? document.body : null;
|
|
281
|
-
const components = {
|
|
282
|
-
...mergedComponents,
|
|
283
|
-
Control: showSearchControl ? mergedComponents.Control : DummyControl
|
|
284
|
-
};
|
|
285
307
|
if (!portalDestination || !isOpen) {
|
|
286
308
|
return null;
|
|
287
309
|
}
|
|
288
|
-
|
|
310
|
+
|
|
311
|
+
// Memoized merge of defaultStyles and props.styles
|
|
312
|
+
const selectStyles = getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? this.getSelectStyles(this.defaultStyles, props.styles) : mergeStyles(this.defaultStyles, props.styles || {});
|
|
313
|
+
|
|
314
|
+
// Memoized variance of the default select components
|
|
315
|
+
const selectComponents = getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? this.getSelectComponents(mergedComponents, showSearchControl) : {
|
|
316
|
+
...mergedComponents,
|
|
317
|
+
Control: showSearchControl ? mergedComponents.Control : DummyControl
|
|
318
|
+
};
|
|
319
|
+
const popper = /*#__PURE__*/React.createElement(Popper, _extends({}, mergedPopperProps, getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? undefined : {
|
|
289
320
|
onFirstUpdate: state => {
|
|
290
321
|
var _mergedPopperProps$on;
|
|
291
322
|
this.handleFirstPopperUpdate();
|
|
@@ -294,8 +325,14 @@ export default class PopupSelect extends PureComponent {
|
|
|
294
325
|
}), ({
|
|
295
326
|
placement,
|
|
296
327
|
ref,
|
|
297
|
-
style
|
|
328
|
+
style,
|
|
329
|
+
isReferenceHidden
|
|
298
330
|
}) => {
|
|
331
|
+
/**
|
|
332
|
+
* The reference is not available yet, so the Popper and Portal is either being rendered at `0,0` (scrolled to the top)
|
|
333
|
+
* or not at all. There's no reason to render the Select or lock scrolling at the top of the page yet.
|
|
334
|
+
*/
|
|
335
|
+
const readyToRenderSelect = getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? isReferenceHidden !== null : true;
|
|
299
336
|
return /*#__PURE__*/React.createElement(NodeResolver, {
|
|
300
337
|
innerRef: this.resolveMenuRef(ref)
|
|
301
338
|
}, /*#__PURE__*/React.createElement(MenuDialog, {
|
|
@@ -304,10 +341,18 @@ export default class PopupSelect extends PureComponent {
|
|
|
304
341
|
minWidth: minMenuWidth,
|
|
305
342
|
maxWidth: maxMenuWidth,
|
|
306
343
|
id: this.popperWrapperId
|
|
307
|
-
}, /*#__PURE__*/React.createElement(FocusLock
|
|
308
|
-
|
|
344
|
+
}, /*#__PURE__*/React.createElement(FocusLock
|
|
345
|
+
/*
|
|
346
|
+
* NOTE: We intentionally want the FocusLock to be disabled until the refs are populated in Popper.
|
|
347
|
+
* Until then, the portal the Popper creates is at `0,0`, meaning the FocusLock forces the page to scroll to `0,0`.
|
|
348
|
+
* We do not want the user to scroll to the top of the page when they open their PopupSelect, so we disable it.
|
|
349
|
+
*
|
|
350
|
+
* WARNING: This causes additional renders, eg. ±5ms in our example, but unless
|
|
351
|
+
* FocusLock has a better way to avoid scrolling, this is necessary.
|
|
352
|
+
*/, {
|
|
353
|
+
disabled: getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? !readyToRenderSelect : !focusLockEnabled,
|
|
309
354
|
returnFocus: true
|
|
310
|
-
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
355
|
+
}, readyToRenderSelect && /*#__PURE__*/React.createElement(Select, _extends({
|
|
311
356
|
backspaceRemovesValue: false,
|
|
312
357
|
controlShouldRenderValue: false,
|
|
313
358
|
isClearable: false,
|
|
@@ -316,9 +361,9 @@ export default class PopupSelect extends PureComponent {
|
|
|
316
361
|
ref: this.getSelectRef
|
|
317
362
|
}, props, {
|
|
318
363
|
isSearchable: showSearchControl,
|
|
319
|
-
styles:
|
|
364
|
+
styles: selectStyles,
|
|
320
365
|
maxMenuHeight: this.getMaxHeight(),
|
|
321
|
-
components:
|
|
366
|
+
components: selectComponents,
|
|
322
367
|
onChange: this.handleSelectChange
|
|
323
368
|
})), footer)));
|
|
324
369
|
});
|
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 = "16.
|
|
5
|
+
const packageVersion = "16.4.0";
|
|
6
6
|
export const SelectWithoutAnalytics = createSelect(Select);
|
|
7
7
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
8
8
|
export default withAnalyticsContext({
|
package/dist/es2019/version.json
CHANGED
|
@@ -21,9 +21,11 @@ import { Manager, Reference, Popper } from 'react-popper';
|
|
|
21
21
|
import NodeResolver from 'react-node-resolver';
|
|
22
22
|
import shallowEqualObjects from 'shallow-equal/objects';
|
|
23
23
|
import { N80 } from '@atlaskit/theme/colors';
|
|
24
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
24
25
|
import { MenuDialog, DummyControl, defaultComponents } from './components';
|
|
25
26
|
import baseStyles from '../styles';
|
|
26
27
|
import { bind } from 'bind-event-listener';
|
|
28
|
+
import memoizeOne from 'memoize-one';
|
|
27
29
|
/** Are we rendering on the client or server? */
|
|
28
30
|
var canUseDOM = function canUseDOM() {
|
|
29
31
|
return Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
@@ -61,7 +63,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
61
63
|
_inherits(PopupSelect, _PureComponent);
|
|
62
64
|
var _super = _createSuper(PopupSelect);
|
|
63
65
|
function PopupSelect() {
|
|
64
|
-
var _this$defaultOpenStat;
|
|
66
|
+
var _this$defaultOpenStat, _this$defaultOpenStat2;
|
|
65
67
|
var _this;
|
|
66
68
|
_classCallCheck(this, PopupSelect);
|
|
67
69
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -82,11 +84,15 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
82
84
|
}));
|
|
83
85
|
_defineProperty(_assertThisInitialized(_this), "isOpenControlled", _this.props.isOpen !== undefined);
|
|
84
86
|
_defineProperty(_assertThisInitialized(_this), "defaultOpenState", _this.isOpenControlled ? _this.props.isOpen : _this.props.defaultIsOpen);
|
|
85
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
86
|
-
focusLockEnabled: false,
|
|
87
|
+
_defineProperty(_assertThisInitialized(_this), "state", getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? {
|
|
87
88
|
isOpen: (_this$defaultOpenStat = _this.defaultOpenState) !== null && _this$defaultOpenStat !== void 0 ? _this$defaultOpenStat : false,
|
|
88
89
|
mergedComponents: defaultComponents,
|
|
89
90
|
mergedPopperProps: defaultPopperProps
|
|
91
|
+
} : {
|
|
92
|
+
focusLockEnabled: false,
|
|
93
|
+
isOpen: (_this$defaultOpenStat2 = _this.defaultOpenState) !== null && _this$defaultOpenStat2 !== void 0 ? _this$defaultOpenStat2 : false,
|
|
94
|
+
mergedComponents: defaultComponents,
|
|
95
|
+
mergedPopperProps: defaultPopperProps
|
|
90
96
|
});
|
|
91
97
|
_defineProperty(_assertThisInitialized(_this), "popperWrapperId", "".concat(uid({
|
|
92
98
|
options: _this.props.options
|
|
@@ -197,9 +203,13 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
197
203
|
_this.setState({
|
|
198
204
|
isOpen: false
|
|
199
205
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
206
|
+
if (getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m')) {
|
|
207
|
+
// Do nothing… (the pff eslint just doesn't like `!getBooleanFF(…)`)
|
|
208
|
+
} else {
|
|
209
|
+
_this.setState({
|
|
210
|
+
focusLockEnabled: false
|
|
211
|
+
});
|
|
212
|
+
}
|
|
203
213
|
if (_this.targetRef != null) {
|
|
204
214
|
_this.targetRef.focus();
|
|
205
215
|
}
|
|
@@ -239,6 +249,20 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
239
249
|
});
|
|
240
250
|
// Utils
|
|
241
251
|
// ==============================
|
|
252
|
+
// Get a memoized merge of the default styles and the prop's in styles
|
|
253
|
+
_defineProperty(_assertThisInitialized(_this), "getSelectStyles", memoizeOne(function (defaultStyles, propStyles) {
|
|
254
|
+
return mergeStyles(defaultStyles, propStyles || {});
|
|
255
|
+
}));
|
|
256
|
+
// Get a memoized override of our `<Select components={…}>` overrides.
|
|
257
|
+
_defineProperty(_assertThisInitialized(_this), "getSelectComponents", memoizeOne(function (mergedComponents, showSearchControl) {
|
|
258
|
+
if (!showSearchControl) {
|
|
259
|
+
// When we have no search control, we use a dummy override to hide it visually.
|
|
260
|
+
return _objectSpread(_objectSpread({}, mergedComponents), {}, {
|
|
261
|
+
Control: DummyControl
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return mergedComponents;
|
|
265
|
+
}));
|
|
242
266
|
// account for groups when counting options
|
|
243
267
|
// this may need to be recursive, right now it just counts one level
|
|
244
268
|
_defineProperty(_assertThisInitialized(_this), "getItemCount", function () {
|
|
@@ -284,6 +308,7 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
284
308
|
minMenuWidth = _this$props3.minMenuWidth,
|
|
285
309
|
target = _this$props3.target,
|
|
286
310
|
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
311
|
+
// TODO: If `platform.design-system-team.popup-select-render-perf_i0s6m` is kept, `focusLockEnabled` should be fully removed as we're preferring `isReferenceHidden`
|
|
287
312
|
var _this$state = _this.state,
|
|
288
313
|
focusLockEnabled = _this$state.focusLockEnabled,
|
|
289
314
|
isOpen = _this$state.isOpen,
|
|
@@ -291,13 +316,18 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
291
316
|
mergedPopperProps = _this$state.mergedPopperProps;
|
|
292
317
|
var showSearchControl = _this.showSearchControl();
|
|
293
318
|
var portalDestination = canUseDOM() ? document.body : null;
|
|
294
|
-
var components = _objectSpread(_objectSpread({}, mergedComponents), {}, {
|
|
295
|
-
Control: showSearchControl ? mergedComponents.Control : DummyControl
|
|
296
|
-
});
|
|
297
319
|
if (!portalDestination || !isOpen) {
|
|
298
320
|
return null;
|
|
299
321
|
}
|
|
300
|
-
|
|
322
|
+
|
|
323
|
+
// Memoized merge of defaultStyles and props.styles
|
|
324
|
+
var selectStyles = getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? _this.getSelectStyles(_this.defaultStyles, props.styles) : mergeStyles(_this.defaultStyles, props.styles || {});
|
|
325
|
+
|
|
326
|
+
// Memoized variance of the default select components
|
|
327
|
+
var selectComponents = getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? _this.getSelectComponents(mergedComponents, showSearchControl) : _objectSpread(_objectSpread({}, mergedComponents), {}, {
|
|
328
|
+
Control: showSearchControl ? mergedComponents.Control : DummyControl
|
|
329
|
+
});
|
|
330
|
+
var popper = /*#__PURE__*/React.createElement(Popper, _extends({}, mergedPopperProps, getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? undefined : {
|
|
301
331
|
onFirstUpdate: function onFirstUpdate(state) {
|
|
302
332
|
var _mergedPopperProps$on;
|
|
303
333
|
_this.handleFirstPopperUpdate();
|
|
@@ -306,7 +336,13 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
306
336
|
}), function (_ref2) {
|
|
307
337
|
var placement = _ref2.placement,
|
|
308
338
|
ref = _ref2.ref,
|
|
309
|
-
style = _ref2.style
|
|
339
|
+
style = _ref2.style,
|
|
340
|
+
isReferenceHidden = _ref2.isReferenceHidden;
|
|
341
|
+
/**
|
|
342
|
+
* The reference is not available yet, so the Popper and Portal is either being rendered at `0,0` (scrolled to the top)
|
|
343
|
+
* or not at all. There's no reason to render the Select or lock scrolling at the top of the page yet.
|
|
344
|
+
*/
|
|
345
|
+
var readyToRenderSelect = getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? isReferenceHidden !== null : true;
|
|
310
346
|
return /*#__PURE__*/React.createElement(NodeResolver, {
|
|
311
347
|
innerRef: _this.resolveMenuRef(ref)
|
|
312
348
|
}, /*#__PURE__*/React.createElement(MenuDialog, {
|
|
@@ -315,10 +351,18 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
315
351
|
minWidth: minMenuWidth,
|
|
316
352
|
maxWidth: maxMenuWidth,
|
|
317
353
|
id: _this.popperWrapperId
|
|
318
|
-
}, /*#__PURE__*/React.createElement(FocusLock
|
|
319
|
-
|
|
354
|
+
}, /*#__PURE__*/React.createElement(FocusLock
|
|
355
|
+
/*
|
|
356
|
+
* NOTE: We intentionally want the FocusLock to be disabled until the refs are populated in Popper.
|
|
357
|
+
* Until then, the portal the Popper creates is at `0,0`, meaning the FocusLock forces the page to scroll to `0,0`.
|
|
358
|
+
* We do not want the user to scroll to the top of the page when they open their PopupSelect, so we disable it.
|
|
359
|
+
*
|
|
360
|
+
* WARNING: This causes additional renders, eg. ±5ms in our example, but unless
|
|
361
|
+
* FocusLock has a better way to avoid scrolling, this is necessary.
|
|
362
|
+
*/, {
|
|
363
|
+
disabled: getBooleanFF('platform.design-system-team.popup-select-render-perf_i0s6m') ? !readyToRenderSelect : !focusLockEnabled,
|
|
320
364
|
returnFocus: true
|
|
321
|
-
}, /*#__PURE__*/React.createElement(Select, _extends({
|
|
365
|
+
}, readyToRenderSelect && /*#__PURE__*/React.createElement(Select, _extends({
|
|
322
366
|
backspaceRemovesValue: false,
|
|
323
367
|
controlShouldRenderValue: false,
|
|
324
368
|
isClearable: false,
|
|
@@ -327,9 +371,9 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
327
371
|
ref: _this.getSelectRef
|
|
328
372
|
}, props, {
|
|
329
373
|
isSearchable: showSearchControl,
|
|
330
|
-
styles:
|
|
374
|
+
styles: selectStyles,
|
|
331
375
|
maxMenuHeight: _this.getMaxHeight(),
|
|
332
|
-
components:
|
|
376
|
+
components: selectComponents,
|
|
333
377
|
onChange: _this.handleSelectChange
|
|
334
378
|
})), footer)));
|
|
335
379
|
});
|
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 = "16.
|
|
5
|
+
var packageVersion = "16.4.0";
|
|
6
6
|
export var SelectWithoutAnalytics = createSelect(Select);
|
|
7
7
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
8
8
|
export default withAnalyticsContext({
|
package/dist/esm/version.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { PureComponent, ReactNode } from 'react';
|
|
2
|
+
import { GroupBase } from 'react-select';
|
|
2
3
|
import BaseSelect from 'react-select/base';
|
|
3
4
|
import { PopperProps } from 'react-popper';
|
|
5
|
+
import { defaultComponents } from './components';
|
|
4
6
|
import { OptionType, ActionMeta, ReactSelectProps, StylesConfig, ValueType, ValidationState } from '../types';
|
|
5
7
|
import { UnbindFn } from 'bind-event-listener';
|
|
6
8
|
type defaultModifiers = 'offset' | 'preventOverflow';
|
|
@@ -74,7 +76,12 @@ export interface PopupSelectProps<Option = OptionType, IsMulti extends boolean =
|
|
|
74
76
|
testId?: string;
|
|
75
77
|
}
|
|
76
78
|
interface State<Modifiers = string> {
|
|
77
|
-
|
|
79
|
+
/**
|
|
80
|
+
* TODO: This type should be cleaned up with `platform.design-system-team.popup-select-render-perf_i0s6m`.
|
|
81
|
+
* - If discarded, revert to `focusLockEnabled: boolean`
|
|
82
|
+
* - If kept, delete this type.
|
|
83
|
+
*/
|
|
84
|
+
focusLockEnabled?: boolean;
|
|
78
85
|
isOpen: boolean;
|
|
79
86
|
mergedComponents: Object;
|
|
80
87
|
mergedPopperProps: PopperPropsNoChildren<defaultModifiers | Modifiers>;
|
|
@@ -89,6 +96,15 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
|
|
|
89
96
|
isOpenControlled: boolean;
|
|
90
97
|
defaultOpenState: boolean | undefined;
|
|
91
98
|
state: {
|
|
99
|
+
isOpen: boolean;
|
|
100
|
+
mergedComponents: {
|
|
101
|
+
Control: React.FC<import("../types").ControlProps<OptionType, boolean>>;
|
|
102
|
+
DropdownIndicator: () => import("@emotion/react").jsx.JSX.Element;
|
|
103
|
+
Menu: ({ children, innerProps, ...props }: import("../types").MenuProps<OptionType, boolean>) => import("@emotion/react").jsx.JSX.Element;
|
|
104
|
+
};
|
|
105
|
+
mergedPopperProps: PopperPropsNoChildren<string>;
|
|
106
|
+
focusLockEnabled?: undefined;
|
|
107
|
+
} | {
|
|
92
108
|
focusLockEnabled: boolean;
|
|
93
109
|
isOpen: boolean;
|
|
94
110
|
mergedComponents: {
|
|
@@ -138,6 +154,72 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
|
|
|
138
154
|
resolveTargetRef: (popperRef: React.Ref<HTMLElement>) => (ref: HTMLElement) => void;
|
|
139
155
|
resolveMenuRef: (popperRef: React.Ref<HTMLElement>) => (ref: HTMLElement) => void;
|
|
140
156
|
getSelectRef: (ref: BaseSelect<Option, IsMulti>) => void;
|
|
157
|
+
getSelectStyles: import("memoize-one").MemoizedFn<(defaultStyles: StylesConfig<Option, IsMulti>, propStyles: StylesConfig<Option, IsMulti> | undefined) => {
|
|
158
|
+
clearIndicator?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").ClearIndicatorProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
159
|
+
container?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").ContainerProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
160
|
+
control?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").ControlProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
161
|
+
dropdownIndicator?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").DropdownIndicatorProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
162
|
+
group?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").GroupProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
163
|
+
groupHeading?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").GroupHeadingProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
164
|
+
indicatorsContainer?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").IndicatorsContainerProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
165
|
+
indicatorSeparator?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").IndicatorSeparatorProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
166
|
+
input?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").InputProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
167
|
+
loadingIndicator?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").LoadingIndicatorProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
168
|
+
loadingMessage?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").NoticeProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
169
|
+
menu?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MenuProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
170
|
+
menuList?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MenuListProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
171
|
+
menuPortal?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select/dist/declarations/src/components/Menu").PortalStyleArgs> | undefined;
|
|
172
|
+
multiValue?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
173
|
+
multiValueLabel?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
174
|
+
multiValueRemove?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
175
|
+
noOptionsMessage?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").NoticeProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
176
|
+
option?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").OptionProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
177
|
+
placeholder?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").PlaceholderProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
178
|
+
singleValue?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").SingleValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
179
|
+
valueContainer?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").ValueContainerProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
getSelectComponents: import("memoize-one").MemoizedFn<(mergedComponents: typeof defaultComponents, showSearchControl: boolean | undefined) => Partial<{
|
|
182
|
+
ClearIndicator: <Option_1, IsMulti_1 extends boolean, Group extends GroupBase<Option_1>>(props: import("react-select").ClearIndicatorProps<Option_1, IsMulti_1, Group>) => import("@emotion/react").jsx.JSX.Element;
|
|
183
|
+
Control: <Option_1, IsMulti_1 extends boolean, Group_1 extends GroupBase<Option_1>>(props: import("react-select").ControlProps<Option_1, IsMulti_1, Group_1>) => import("@emotion/react").jsx.JSX.Element;
|
|
184
|
+
DropdownIndicator: <Option_2, IsMulti_2 extends boolean, Group_2 extends GroupBase<Option_2>>(props: import("react-select").DropdownIndicatorProps<Option_2, IsMulti_2, Group_2>) => import("@emotion/react").jsx.JSX.Element;
|
|
185
|
+
DownChevron: (props: import("react-select/dist/declarations/src/components/indicators").DownChevronProps) => import("@emotion/react").jsx.JSX.Element;
|
|
186
|
+
CrossIcon: (props: import("react-select/dist/declarations/src/components/indicators").CrossIconProps) => import("@emotion/react").jsx.JSX.Element;
|
|
187
|
+
Group: <Option_3, IsMulti_3 extends boolean, Group_3 extends GroupBase<Option_3>>(props: import("react-select").GroupProps<Option_3, IsMulti_3, Group_3>) => import("@emotion/react").jsx.JSX.Element;
|
|
188
|
+
GroupHeading: <Option_4, IsMulti_4 extends boolean, Group_4 extends GroupBase<Option_4>>(props: import("react-select").GroupHeadingProps<Option_4, IsMulti_4, Group_4>) => import("@emotion/react").jsx.JSX.Element;
|
|
189
|
+
IndicatorsContainer: <Option_5, IsMulti_5 extends boolean, Group_5 extends GroupBase<Option_5>>(props: import("react-select").IndicatorsContainerProps<Option_5, IsMulti_5, Group_5>) => import("@emotion/react").jsx.JSX.Element;
|
|
190
|
+
IndicatorSeparator: <Option_6, IsMulti_6 extends boolean, Group_6 extends GroupBase<Option_6>>(props: import("react-select").IndicatorSeparatorProps<Option_6, IsMulti_6, Group_6>) => import("@emotion/react").jsx.JSX.Element;
|
|
191
|
+
Input: <Option_7, IsMulti_7 extends boolean, Group_7 extends GroupBase<Option_7>>(props: import("react-select").InputProps<Option_7, IsMulti_7, Group_7>) => import("@emotion/react").jsx.JSX.Element;
|
|
192
|
+
LoadingIndicator: {
|
|
193
|
+
<Option_8, IsMulti_8 extends boolean, Group_8 extends GroupBase<Option_8>>(props: import("react-select").LoadingIndicatorProps<Option_8, IsMulti_8, Group_8>): import("@emotion/react").jsx.JSX.Element;
|
|
194
|
+
defaultProps: {
|
|
195
|
+
size: number;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
Menu: <Option_9, IsMulti_9 extends boolean, Group_9 extends GroupBase<Option_9>>(props: import("react-select").MenuProps<Option_9, IsMulti_9, Group_9>) => import("@emotion/react").jsx.JSX.Element;
|
|
199
|
+
MenuList: <Option_10, IsMulti_10 extends boolean, Group_10 extends GroupBase<Option_10>>(props: import("react-select").MenuListProps<Option_10, IsMulti_10, Group_10>) => import("@emotion/react").jsx.JSX.Element;
|
|
200
|
+
MenuPortal: typeof import("react-select/dist/declarations/src/components/Menu").MenuPortal;
|
|
201
|
+
LoadingMessage: {
|
|
202
|
+
<Option_11, IsMulti_11 extends boolean, Group_11 extends GroupBase<Option_11>>(props: import("react-select").NoticeProps<Option_11, IsMulti_11, Group_11>): import("@emotion/react").jsx.JSX.Element;
|
|
203
|
+
defaultProps: {
|
|
204
|
+
children: string;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
NoOptionsMessage: {
|
|
208
|
+
<Option_12, IsMulti_12 extends boolean, Group_12 extends GroupBase<Option_12>>(props: import("react-select").NoticeProps<Option_12, IsMulti_12, Group_12>): import("@emotion/react").jsx.JSX.Element;
|
|
209
|
+
defaultProps: {
|
|
210
|
+
children: string;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
MultiValue: <Option_13, IsMulti_13 extends boolean, Group_13 extends GroupBase<Option_13>>(props: import("react-select").MultiValueProps<Option_13, IsMulti_13, Group_13>) => import("@emotion/react").jsx.JSX.Element;
|
|
214
|
+
MultiValueContainer: <Option_14, IsMulti_14 extends boolean, Group_14 extends GroupBase<Option_14>>({ children, innerProps, }: import("react-select").MultiValueGenericProps<Option_14, IsMulti_14, Group_14>) => import("@emotion/react").jsx.JSX.Element;
|
|
215
|
+
MultiValueLabel: <Option_14_1, IsMulti_14_1 extends boolean, Group_14_1 extends GroupBase<Option_14_1>>({ children, innerProps, }: import("react-select").MultiValueGenericProps<Option_14_1, IsMulti_14_1, Group_14_1>) => import("@emotion/react").jsx.JSX.Element;
|
|
216
|
+
MultiValueRemove: typeof import("react-select/dist/declarations/src/components/MultiValue").MultiValueRemove;
|
|
217
|
+
Option: <Option_15, IsMulti_15 extends boolean, Group_15 extends GroupBase<Option_15>>(props: import("react-select").OptionProps<Option_15, IsMulti_15, Group_15>) => import("@emotion/react").jsx.JSX.Element;
|
|
218
|
+
Placeholder: <Option_16, IsMulti_16 extends boolean, Group_16 extends GroupBase<Option_16>>(props: import("react-select").PlaceholderProps<Option_16, IsMulti_16, Group_16>) => import("@emotion/react").jsx.JSX.Element;
|
|
219
|
+
SelectContainer: <Option_17, IsMulti_17 extends boolean, Group_17 extends GroupBase<Option_17>>(props: import("react-select").ContainerProps<Option_17, IsMulti_17, Group_17>) => import("@emotion/react").jsx.JSX.Element;
|
|
220
|
+
SingleValue: <Option_18, IsMulti_18 extends boolean, Group_18 extends GroupBase<Option_18>>(props: import("react-select").SingleValueProps<Option_18, IsMulti_18, Group_18>) => import("@emotion/react").jsx.JSX.Element;
|
|
221
|
+
ValueContainer: <Option_19, IsMulti_19 extends boolean, Group_19 extends GroupBase<Option_19>>(props: import("react-select").ValueContainerProps<Option_19, IsMulti_19, Group_19>) => import("@emotion/react").jsx.JSX.Element;
|
|
222
|
+
}>>;
|
|
141
223
|
getItemCount: () => number;
|
|
142
224
|
getMaxHeight: () => number | undefined;
|
|
143
225
|
showSearchControl: () => boolean | undefined;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { PureComponent, ReactNode } from 'react';
|
|
2
|
+
import { GroupBase } from 'react-select';
|
|
2
3
|
import BaseSelect from 'react-select/base';
|
|
3
4
|
import { PopperProps } from 'react-popper';
|
|
5
|
+
import { defaultComponents } from './components';
|
|
4
6
|
import { OptionType, ActionMeta, ReactSelectProps, StylesConfig, ValueType, ValidationState } from '../types';
|
|
5
7
|
import { UnbindFn } from 'bind-event-listener';
|
|
6
8
|
type defaultModifiers = 'offset' | 'preventOverflow';
|
|
@@ -74,7 +76,12 @@ export interface PopupSelectProps<Option = OptionType, IsMulti extends boolean =
|
|
|
74
76
|
testId?: string;
|
|
75
77
|
}
|
|
76
78
|
interface State<Modifiers = string> {
|
|
77
|
-
|
|
79
|
+
/**
|
|
80
|
+
* TODO: This type should be cleaned up with `platform.design-system-team.popup-select-render-perf_i0s6m`.
|
|
81
|
+
* - If discarded, revert to `focusLockEnabled: boolean`
|
|
82
|
+
* - If kept, delete this type.
|
|
83
|
+
*/
|
|
84
|
+
focusLockEnabled?: boolean;
|
|
78
85
|
isOpen: boolean;
|
|
79
86
|
mergedComponents: Object;
|
|
80
87
|
mergedPopperProps: PopperPropsNoChildren<defaultModifiers | Modifiers>;
|
|
@@ -89,6 +96,15 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
|
|
|
89
96
|
isOpenControlled: boolean;
|
|
90
97
|
defaultOpenState: boolean | undefined;
|
|
91
98
|
state: {
|
|
99
|
+
isOpen: boolean;
|
|
100
|
+
mergedComponents: {
|
|
101
|
+
Control: React.FC<import("../types").ControlProps<OptionType, boolean>>;
|
|
102
|
+
DropdownIndicator: () => import("@emotion/react").jsx.JSX.Element;
|
|
103
|
+
Menu: ({ children, innerProps, ...props }: import("../types").MenuProps<OptionType, boolean>) => import("@emotion/react").jsx.JSX.Element;
|
|
104
|
+
};
|
|
105
|
+
mergedPopperProps: PopperPropsNoChildren<string>;
|
|
106
|
+
focusLockEnabled?: undefined;
|
|
107
|
+
} | {
|
|
92
108
|
focusLockEnabled: boolean;
|
|
93
109
|
isOpen: boolean;
|
|
94
110
|
mergedComponents: {
|
|
@@ -138,6 +154,72 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
|
|
|
138
154
|
resolveTargetRef: (popperRef: React.Ref<HTMLElement>) => (ref: HTMLElement) => void;
|
|
139
155
|
resolveMenuRef: (popperRef: React.Ref<HTMLElement>) => (ref: HTMLElement) => void;
|
|
140
156
|
getSelectRef: (ref: BaseSelect<Option, IsMulti>) => void;
|
|
157
|
+
getSelectStyles: import("memoize-one").MemoizedFn<(defaultStyles: StylesConfig<Option, IsMulti>, propStyles: StylesConfig<Option, IsMulti> | undefined) => {
|
|
158
|
+
clearIndicator?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").ClearIndicatorProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
159
|
+
container?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").ContainerProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
160
|
+
control?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").ControlProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
161
|
+
dropdownIndicator?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").DropdownIndicatorProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
162
|
+
group?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").GroupProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
163
|
+
groupHeading?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").GroupHeadingProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
164
|
+
indicatorsContainer?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").IndicatorsContainerProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
165
|
+
indicatorSeparator?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").IndicatorSeparatorProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
166
|
+
input?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").InputProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
167
|
+
loadingIndicator?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").LoadingIndicatorProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
168
|
+
loadingMessage?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").NoticeProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
169
|
+
menu?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MenuProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
170
|
+
menuList?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MenuListProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
171
|
+
menuPortal?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select/dist/declarations/src/components/Menu").PortalStyleArgs> | undefined;
|
|
172
|
+
multiValue?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
173
|
+
multiValueLabel?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
174
|
+
multiValueRemove?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").MultiValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
175
|
+
noOptionsMessage?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").NoticeProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
176
|
+
option?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").OptionProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
177
|
+
placeholder?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").PlaceholderProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
178
|
+
singleValue?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").SingleValueProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
179
|
+
valueContainer?: import("react-select/dist/declarations/src/styles").StylesConfigFunction<import("react-select").ValueContainerProps<Option, IsMulti, GroupBase<Option>>> | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
getSelectComponents: import("memoize-one").MemoizedFn<(mergedComponents: typeof defaultComponents, showSearchControl: boolean | undefined) => Partial<{
|
|
182
|
+
ClearIndicator: <Option_1, IsMulti_1 extends boolean, Group extends GroupBase<Option_1>>(props: import("react-select").ClearIndicatorProps<Option_1, IsMulti_1, Group>) => import("@emotion/react").jsx.JSX.Element;
|
|
183
|
+
Control: <Option_1, IsMulti_1 extends boolean, Group_1 extends GroupBase<Option_1>>(props: import("react-select").ControlProps<Option_1, IsMulti_1, Group_1>) => import("@emotion/react").jsx.JSX.Element;
|
|
184
|
+
DropdownIndicator: <Option_2, IsMulti_2 extends boolean, Group_2 extends GroupBase<Option_2>>(props: import("react-select").DropdownIndicatorProps<Option_2, IsMulti_2, Group_2>) => import("@emotion/react").jsx.JSX.Element;
|
|
185
|
+
DownChevron: (props: import("react-select/dist/declarations/src/components/indicators").DownChevronProps) => import("@emotion/react").jsx.JSX.Element;
|
|
186
|
+
CrossIcon: (props: import("react-select/dist/declarations/src/components/indicators").CrossIconProps) => import("@emotion/react").jsx.JSX.Element;
|
|
187
|
+
Group: <Option_3, IsMulti_3 extends boolean, Group_3 extends GroupBase<Option_3>>(props: import("react-select").GroupProps<Option_3, IsMulti_3, Group_3>) => import("@emotion/react").jsx.JSX.Element;
|
|
188
|
+
GroupHeading: <Option_4, IsMulti_4 extends boolean, Group_4 extends GroupBase<Option_4>>(props: import("react-select").GroupHeadingProps<Option_4, IsMulti_4, Group_4>) => import("@emotion/react").jsx.JSX.Element;
|
|
189
|
+
IndicatorsContainer: <Option_5, IsMulti_5 extends boolean, Group_5 extends GroupBase<Option_5>>(props: import("react-select").IndicatorsContainerProps<Option_5, IsMulti_5, Group_5>) => import("@emotion/react").jsx.JSX.Element;
|
|
190
|
+
IndicatorSeparator: <Option_6, IsMulti_6 extends boolean, Group_6 extends GroupBase<Option_6>>(props: import("react-select").IndicatorSeparatorProps<Option_6, IsMulti_6, Group_6>) => import("@emotion/react").jsx.JSX.Element;
|
|
191
|
+
Input: <Option_7, IsMulti_7 extends boolean, Group_7 extends GroupBase<Option_7>>(props: import("react-select").InputProps<Option_7, IsMulti_7, Group_7>) => import("@emotion/react").jsx.JSX.Element;
|
|
192
|
+
LoadingIndicator: {
|
|
193
|
+
<Option_8, IsMulti_8 extends boolean, Group_8 extends GroupBase<Option_8>>(props: import("react-select").LoadingIndicatorProps<Option_8, IsMulti_8, Group_8>): import("@emotion/react").jsx.JSX.Element;
|
|
194
|
+
defaultProps: {
|
|
195
|
+
size: number;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
Menu: <Option_9, IsMulti_9 extends boolean, Group_9 extends GroupBase<Option_9>>(props: import("react-select").MenuProps<Option_9, IsMulti_9, Group_9>) => import("@emotion/react").jsx.JSX.Element;
|
|
199
|
+
MenuList: <Option_10, IsMulti_10 extends boolean, Group_10 extends GroupBase<Option_10>>(props: import("react-select").MenuListProps<Option_10, IsMulti_10, Group_10>) => import("@emotion/react").jsx.JSX.Element;
|
|
200
|
+
MenuPortal: typeof import("react-select/dist/declarations/src/components/Menu").MenuPortal;
|
|
201
|
+
LoadingMessage: {
|
|
202
|
+
<Option_11, IsMulti_11 extends boolean, Group_11 extends GroupBase<Option_11>>(props: import("react-select").NoticeProps<Option_11, IsMulti_11, Group_11>): import("@emotion/react").jsx.JSX.Element;
|
|
203
|
+
defaultProps: {
|
|
204
|
+
children: string;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
NoOptionsMessage: {
|
|
208
|
+
<Option_12, IsMulti_12 extends boolean, Group_12 extends GroupBase<Option_12>>(props: import("react-select").NoticeProps<Option_12, IsMulti_12, Group_12>): import("@emotion/react").jsx.JSX.Element;
|
|
209
|
+
defaultProps: {
|
|
210
|
+
children: string;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
MultiValue: <Option_13, IsMulti_13 extends boolean, Group_13 extends GroupBase<Option_13>>(props: import("react-select").MultiValueProps<Option_13, IsMulti_13, Group_13>) => import("@emotion/react").jsx.JSX.Element;
|
|
214
|
+
MultiValueContainer: <Option_14, IsMulti_14 extends boolean, Group_14 extends GroupBase<Option_14>>({ children, innerProps, }: import("react-select").MultiValueGenericProps<Option_14, IsMulti_14, Group_14>) => import("@emotion/react").jsx.JSX.Element;
|
|
215
|
+
MultiValueLabel: <Option_14_1, IsMulti_14_1 extends boolean, Group_14_1 extends GroupBase<Option_14_1>>({ children, innerProps, }: import("react-select").MultiValueGenericProps<Option_14_1, IsMulti_14_1, Group_14_1>) => import("@emotion/react").jsx.JSX.Element;
|
|
216
|
+
MultiValueRemove: typeof import("react-select/dist/declarations/src/components/MultiValue").MultiValueRemove;
|
|
217
|
+
Option: <Option_15, IsMulti_15 extends boolean, Group_15 extends GroupBase<Option_15>>(props: import("react-select").OptionProps<Option_15, IsMulti_15, Group_15>) => import("@emotion/react").jsx.JSX.Element;
|
|
218
|
+
Placeholder: <Option_16, IsMulti_16 extends boolean, Group_16 extends GroupBase<Option_16>>(props: import("react-select").PlaceholderProps<Option_16, IsMulti_16, Group_16>) => import("@emotion/react").jsx.JSX.Element;
|
|
219
|
+
SelectContainer: <Option_17, IsMulti_17 extends boolean, Group_17 extends GroupBase<Option_17>>(props: import("react-select").ContainerProps<Option_17, IsMulti_17, Group_17>) => import("@emotion/react").jsx.JSX.Element;
|
|
220
|
+
SingleValue: <Option_18, IsMulti_18 extends boolean, Group_18 extends GroupBase<Option_18>>(props: import("react-select").SingleValueProps<Option_18, IsMulti_18, Group_18>) => import("@emotion/react").jsx.JSX.Element;
|
|
221
|
+
ValueContainer: <Option_19, IsMulti_19 extends boolean, Group_19 extends GroupBase<Option_19>>(props: import("react-select").ValueContainerProps<Option_19, IsMulti_19, Group_19>) => import("@emotion/react").jsx.JSX.Element;
|
|
222
|
+
}>>;
|
|
141
223
|
getItemCount: () => number;
|
|
142
224
|
getMaxHeight: () => number | undefined;
|
|
143
225
|
showSearchControl: () => boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/select",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.4.0",
|
|
4
4
|
"description": "Select allows users to make a single selection or multiple selections from a list of options.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -103,6 +103,9 @@
|
|
|
103
103
|
"platform-feature-flags": {
|
|
104
104
|
"platform.design-system-team.update-border-input_ff9l1": {
|
|
105
105
|
"type": "boolean"
|
|
106
|
+
},
|
|
107
|
+
"platform.design-system-team.popup-select-render-perf_i0s6m": {
|
|
108
|
+
"type": "boolean"
|
|
106
109
|
}
|
|
107
110
|
},
|
|
108
111
|
"homepage": "https://atlassian.design/components/select/",
|