@atlaskit/select 20.1.0 → 20.2.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 +16 -0
- package/dist/cjs/PopupSelect/PopupSelect.js +13 -4
- package/dist/cjs/PopupSelect/notify-open-layer-observer.js +28 -0
- package/dist/cjs/Select.js +1 -1
- package/dist/es2019/PopupSelect/PopupSelect.js +14 -5
- package/dist/es2019/PopupSelect/notify-open-layer-observer.js +23 -0
- package/dist/es2019/Select.js +1 -1
- package/dist/esm/PopupSelect/PopupSelect.js +13 -4
- package/dist/esm/PopupSelect/notify-open-layer-observer.js +22 -0
- package/dist/esm/Select.js +1 -1
- package/dist/types/PopupSelect/PopupSelect.d.ts +1 -0
- package/dist/types/PopupSelect/notify-open-layer-observer.d.ts +18 -0
- package/dist/types-ts4.5/PopupSelect/PopupSelect.d.ts +1 -0
- package/dist/types-ts4.5/PopupSelect/notify-open-layer-observer.d.ts +18 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/select
|
|
2
2
|
|
|
3
|
+
## 20.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#138461](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/138461)
|
|
8
|
+
[`455c7f648d71a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/455c7f648d71a) -
|
|
9
|
+
Internal refactor to PopupSelect behind a feature flag.
|
|
10
|
+
|
|
11
|
+
- No longer closing the popup when the internal select menu's onMenuClose is called.
|
|
12
|
+
- It now registers with the experimental open layer observer, allowing it to close when the
|
|
13
|
+
observer gives the close signal (e.g. when resizing a page layout slot).
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 20.1.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -28,6 +28,7 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
28
28
|
var _Select = _interopRequireDefault(require("../Select"));
|
|
29
29
|
var _groupedOptionsAnnouncement = require("../utils/grouped-options-announcement");
|
|
30
30
|
var _components = require("./components");
|
|
31
|
+
var _notifyOpenLayerObserver = require("./notify-open-layer-observer");
|
|
31
32
|
var _excluded = ["footer", "label", "maxMenuWidth", "minMenuWidth", "placeholder", "target", "testId", "onMenuOpen", "onMenuClose"];
|
|
32
33
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
33
34
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -452,14 +453,19 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
452
453
|
// Overwriting ariaLiveMessages builtin onFocus method to announce selected option when popup has been opened
|
|
453
454
|
onFocus: onReactSelectFocus
|
|
454
455
|
}, props.ariaLiveMessages)
|
|
455
|
-
//
|
|
456
|
-
//
|
|
457
|
-
|
|
458
|
-
onMenuClose: (0, _platformFeatureFlags.fg)('platform_dst_layer_observer_select') ? _this.close : undefined
|
|
456
|
+
// Note: We are intentionally not using `onMenuClose={this.close}` here, due to state management conflicts
|
|
457
|
+
// between PopupSelect's popup and the internal select menu. This can result in the PopupSelect closing
|
|
458
|
+
// or opening unexpectedly.
|
|
459
459
|
})), footer));
|
|
460
460
|
});
|
|
461
461
|
return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/(0, _reactDom.createPortal)(popper, portalDestination);
|
|
462
462
|
});
|
|
463
|
+
(0, _defineProperty2.default)(_this, "handleOpenLayerObserverCloseSignal", function () {
|
|
464
|
+
if (!(0, _platformFeatureFlags.fg)('platform_dst_layer_observer_select')) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
_this.close();
|
|
468
|
+
});
|
|
463
469
|
return _this;
|
|
464
470
|
}
|
|
465
471
|
(0, _inherits2.default)(PopupSelect, _PureComponent);
|
|
@@ -526,6 +532,9 @@ var PopupSelect = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
|
526
532
|
'aria-controls': isOpen ? id : undefined
|
|
527
533
|
});
|
|
528
534
|
}), _this3.renderSelect(id));
|
|
535
|
+
}), /*#__PURE__*/_react.default.createElement(_notifyOpenLayerObserver.NotifyOpenLayerObserver, {
|
|
536
|
+
isOpen: (0, _platformFeatureFlags.fg)('platform_dst_layer_observer_select') && this.state.isOpen,
|
|
537
|
+
onClose: this.handleOpenLayerObserverCloseSignal
|
|
529
538
|
}));
|
|
530
539
|
}
|
|
531
540
|
}], [{
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NotifyOpenLayerObserver = NotifyOpenLayerObserver;
|
|
7
|
+
var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
|
|
8
|
+
/**
|
|
9
|
+
* Functional component wrapper around `useNotifyOpenLayerObserver`.
|
|
10
|
+
*
|
|
11
|
+
* This is needed as PopupSelect is a class component, which cannot use hooks directly.
|
|
12
|
+
*
|
|
13
|
+
* Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
|
|
14
|
+
* the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
|
|
15
|
+
* the `PopupSelect`'s outer popup.
|
|
16
|
+
*
|
|
17
|
+
* This will technically count as 2 open layers, however the specific count is not important - the main
|
|
18
|
+
* concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
|
|
19
|
+
*/
|
|
20
|
+
function NotifyOpenLayerObserver(_ref) {
|
|
21
|
+
var isOpen = _ref.isOpen,
|
|
22
|
+
onClose = _ref.onClose;
|
|
23
|
+
(0, _openLayerObserver.useNotifyOpenLayerObserver)({
|
|
24
|
+
isOpen: isOpen,
|
|
25
|
+
onClose: onClose
|
|
26
|
+
});
|
|
27
|
+
return null;
|
|
28
|
+
}
|
package/dist/cjs/Select.js
CHANGED
|
@@ -11,7 +11,7 @@ var _createSelect = _interopRequireDefault(require("./createSelect"));
|
|
|
11
11
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
12
12
|
|
|
13
13
|
var packageName = "@atlaskit/select";
|
|
14
|
-
var packageVersion = "20.
|
|
14
|
+
var packageVersion = "20.2.0";
|
|
15
15
|
var SelectWithoutAnalytics = exports.SelectWithoutAnalytics = (0, _createSelect.default)(_async.default);
|
|
16
16
|
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
|
17
17
|
var Select = (0, _analyticsNext.withAnalyticsContext)({
|
|
@@ -16,6 +16,7 @@ import { N80 } from '@atlaskit/theme/colors';
|
|
|
16
16
|
import Select from '../Select';
|
|
17
17
|
import { countAllOptions, isOptionsGrouped, onFocus } from '../utils/grouped-options-announcement';
|
|
18
18
|
import { defaultComponents, DummyControl, MenuDialog } from './components';
|
|
19
|
+
import { NotifyOpenLayerObserver } from './notify-open-layer-observer';
|
|
19
20
|
/**
|
|
20
21
|
* Are we rendering on the client or server?
|
|
21
22
|
*/
|
|
@@ -436,13 +437,18 @@ export default class PopupSelect extends PureComponent {
|
|
|
436
437
|
onFocus: onReactSelectFocus,
|
|
437
438
|
...props.ariaLiveMessages // priority to use user handlers if provided
|
|
438
439
|
}
|
|
439
|
-
//
|
|
440
|
-
//
|
|
441
|
-
|
|
442
|
-
onMenuClose: fg('platform_dst_layer_observer_select') ? this.close : undefined
|
|
440
|
+
// Note: We are intentionally not using `onMenuClose={this.close}` here, due to state management conflicts
|
|
441
|
+
// between PopupSelect's popup and the internal select menu. This can result in the PopupSelect closing
|
|
442
|
+
// or opening unexpectedly.
|
|
443
443
|
})), footer)));
|
|
444
444
|
return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/createPortal(popper, portalDestination);
|
|
445
445
|
});
|
|
446
|
+
_defineProperty(this, "handleOpenLayerObserverCloseSignal", () => {
|
|
447
|
+
if (!fg('platform_dst_layer_observer_select')) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
this.close();
|
|
451
|
+
});
|
|
446
452
|
}
|
|
447
453
|
static getDerivedStateFromProps(props, state) {
|
|
448
454
|
const newState = {};
|
|
@@ -527,7 +533,10 @@ export default class PopupSelect extends PureComponent {
|
|
|
527
533
|
'aria-haspopup': 'true',
|
|
528
534
|
'aria-expanded': isOpen,
|
|
529
535
|
'aria-controls': isOpen ? id : undefined
|
|
530
|
-
})), this.renderSelect(id)))
|
|
536
|
+
})), this.renderSelect(id))), /*#__PURE__*/React.createElement(NotifyOpenLayerObserver, {
|
|
537
|
+
isOpen: fg('platform_dst_layer_observer_select') && this.state.isOpen,
|
|
538
|
+
onClose: this.handleOpenLayerObserverCloseSignal
|
|
539
|
+
}));
|
|
531
540
|
}
|
|
532
541
|
}
|
|
533
542
|
_defineProperty(PopupSelect, "defaultProps", {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
2
|
+
/**
|
|
3
|
+
* Functional component wrapper around `useNotifyOpenLayerObserver`.
|
|
4
|
+
*
|
|
5
|
+
* This is needed as PopupSelect is a class component, which cannot use hooks directly.
|
|
6
|
+
*
|
|
7
|
+
* Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
|
|
8
|
+
* the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
|
|
9
|
+
* the `PopupSelect`'s outer popup.
|
|
10
|
+
*
|
|
11
|
+
* This will technically count as 2 open layers, however the specific count is not important - the main
|
|
12
|
+
* concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
|
|
13
|
+
*/
|
|
14
|
+
export function NotifyOpenLayerObserver({
|
|
15
|
+
isOpen,
|
|
16
|
+
onClose
|
|
17
|
+
}) {
|
|
18
|
+
useNotifyOpenLayerObserver({
|
|
19
|
+
isOpen,
|
|
20
|
+
onClose
|
|
21
|
+
});
|
|
22
|
+
return null;
|
|
23
|
+
}
|
package/dist/es2019/Select.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
3
3
|
import AsyncSelect from '@atlaskit/react-select/async';
|
|
4
4
|
import createSelect from './createSelect';
|
|
5
5
|
const packageName = "@atlaskit/select";
|
|
6
|
-
const packageVersion = "20.
|
|
6
|
+
const packageVersion = "20.2.0";
|
|
7
7
|
export const SelectWithoutAnalytics = createSelect(AsyncSelect);
|
|
8
8
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
9
9
|
const Select = withAnalyticsContext({
|
|
@@ -27,6 +27,7 @@ import { N80 } from '@atlaskit/theme/colors';
|
|
|
27
27
|
import Select from '../Select';
|
|
28
28
|
import { countAllOptions, isOptionsGrouped, onFocus } from '../utils/grouped-options-announcement';
|
|
29
29
|
import { defaultComponents, DummyControl, MenuDialog } from './components';
|
|
30
|
+
import { NotifyOpenLayerObserver } from './notify-open-layer-observer';
|
|
30
31
|
/**
|
|
31
32
|
* Are we rendering on the client or server?
|
|
32
33
|
*/
|
|
@@ -444,14 +445,19 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
444
445
|
// Overwriting ariaLiveMessages builtin onFocus method to announce selected option when popup has been opened
|
|
445
446
|
onFocus: onReactSelectFocus
|
|
446
447
|
}, props.ariaLiveMessages)
|
|
447
|
-
//
|
|
448
|
-
//
|
|
449
|
-
|
|
450
|
-
onMenuClose: fg('platform_dst_layer_observer_select') ? _this.close : undefined
|
|
448
|
+
// Note: We are intentionally not using `onMenuClose={this.close}` here, due to state management conflicts
|
|
449
|
+
// between PopupSelect's popup and the internal select menu. This can result in the PopupSelect closing
|
|
450
|
+
// or opening unexpectedly.
|
|
451
451
|
})), footer));
|
|
452
452
|
});
|
|
453
453
|
return mergedPopperProps.strategy === 'fixed' ? popper : /*#__PURE__*/createPortal(popper, portalDestination);
|
|
454
454
|
});
|
|
455
|
+
_defineProperty(_this, "handleOpenLayerObserverCloseSignal", function () {
|
|
456
|
+
if (!fg('platform_dst_layer_observer_select')) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
_this.close();
|
|
460
|
+
});
|
|
455
461
|
return _this;
|
|
456
462
|
}
|
|
457
463
|
_inherits(PopupSelect, _PureComponent);
|
|
@@ -518,6 +524,9 @@ var PopupSelect = /*#__PURE__*/function (_PureComponent) {
|
|
|
518
524
|
'aria-controls': isOpen ? id : undefined
|
|
519
525
|
});
|
|
520
526
|
}), _this3.renderSelect(id));
|
|
527
|
+
}), /*#__PURE__*/React.createElement(NotifyOpenLayerObserver, {
|
|
528
|
+
isOpen: fg('platform_dst_layer_observer_select') && this.state.isOpen,
|
|
529
|
+
onClose: this.handleOpenLayerObserverCloseSignal
|
|
521
530
|
}));
|
|
522
531
|
}
|
|
523
532
|
}], [{
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
2
|
+
/**
|
|
3
|
+
* Functional component wrapper around `useNotifyOpenLayerObserver`.
|
|
4
|
+
*
|
|
5
|
+
* This is needed as PopupSelect is a class component, which cannot use hooks directly.
|
|
6
|
+
*
|
|
7
|
+
* Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
|
|
8
|
+
* the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
|
|
9
|
+
* the `PopupSelect`'s outer popup.
|
|
10
|
+
*
|
|
11
|
+
* This will technically count as 2 open layers, however the specific count is not important - the main
|
|
12
|
+
* concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
|
|
13
|
+
*/
|
|
14
|
+
export function NotifyOpenLayerObserver(_ref) {
|
|
15
|
+
var isOpen = _ref.isOpen,
|
|
16
|
+
onClose = _ref.onClose;
|
|
17
|
+
useNotifyOpenLayerObserver({
|
|
18
|
+
isOpen: isOpen,
|
|
19
|
+
onClose: onClose
|
|
20
|
+
});
|
|
21
|
+
return null;
|
|
22
|
+
}
|
package/dist/esm/Select.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
3
3
|
import AsyncSelect from '@atlaskit/react-select/async';
|
|
4
4
|
import createSelect from './createSelect';
|
|
5
5
|
var packageName = "@atlaskit/select";
|
|
6
|
-
var packageVersion = "20.
|
|
6
|
+
var packageVersion = "20.2.0";
|
|
7
7
|
export var SelectWithoutAnalytics = createSelect(AsyncSelect);
|
|
8
8
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
9
9
|
var Select = withAnalyticsContext({
|
|
@@ -164,6 +164,7 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
|
|
|
164
164
|
getMaxHeight: () => number | undefined;
|
|
165
165
|
showSearchControl: () => boolean | undefined;
|
|
166
166
|
renderSelect: (id: string) => React.JSX.Element | null;
|
|
167
|
+
handleOpenLayerObserverCloseSignal: () => void;
|
|
167
168
|
render(): React.JSX.Element;
|
|
168
169
|
}
|
|
169
170
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type NotifyOpenLayerObserverProps = {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Functional component wrapper around `useNotifyOpenLayerObserver`.
|
|
7
|
+
*
|
|
8
|
+
* This is needed as PopupSelect is a class component, which cannot use hooks directly.
|
|
9
|
+
*
|
|
10
|
+
* Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
|
|
11
|
+
* the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
|
|
12
|
+
* the `PopupSelect`'s outer popup.
|
|
13
|
+
*
|
|
14
|
+
* This will technically count as 2 open layers, however the specific count is not important - the main
|
|
15
|
+
* concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
|
|
16
|
+
*/
|
|
17
|
+
export declare function NotifyOpenLayerObserver({ isOpen, onClose }: NotifyOpenLayerObserverProps): null;
|
|
18
|
+
export {};
|
|
@@ -164,6 +164,7 @@ export default class PopupSelect<Option = OptionType, IsMulti extends boolean =
|
|
|
164
164
|
getMaxHeight: () => number | undefined;
|
|
165
165
|
showSearchControl: () => boolean | undefined;
|
|
166
166
|
renderSelect: (id: string) => React.JSX.Element | null;
|
|
167
|
+
handleOpenLayerObserverCloseSignal: () => void;
|
|
167
168
|
render(): React.JSX.Element;
|
|
168
169
|
}
|
|
169
170
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type NotifyOpenLayerObserverProps = {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Functional component wrapper around `useNotifyOpenLayerObserver`.
|
|
7
|
+
*
|
|
8
|
+
* This is needed as PopupSelect is a class component, which cannot use hooks directly.
|
|
9
|
+
*
|
|
10
|
+
* Even though the internal `Select` component (used internally by `PopupSelect`) also registers with
|
|
11
|
+
* the OpenLayerObserver, we are also registering `PopupSelect` as well, to allow the observer to close
|
|
12
|
+
* the `PopupSelect`'s outer popup.
|
|
13
|
+
*
|
|
14
|
+
* This will technically count as 2 open layers, however the specific count is not important - the main
|
|
15
|
+
* concern is that the observer can know if there are _any_ open layers (0, or 1+), and how to close them.
|
|
16
|
+
*/
|
|
17
|
+
export declare function NotifyOpenLayerObserver({ isOpen, onClose }: NotifyOpenLayerObserverProps): null;
|
|
18
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/select",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.2.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/"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@atlaskit/react-select": "^2.1.0",
|
|
50
50
|
"@atlaskit/spinner": "^18.0.0",
|
|
51
51
|
"@atlaskit/theme": "^18.0.0",
|
|
52
|
-
"@atlaskit/tokens": "^4.
|
|
52
|
+
"@atlaskit/tokens": "^4.7.0",
|
|
53
53
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@compiled/react": "^0.18.3",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@atlaskit/button": "^23.0.0",
|
|
71
71
|
"@atlaskit/checkbox": "^17.0.0",
|
|
72
72
|
"@atlaskit/docs": "^10.0.0",
|
|
73
|
-
"@atlaskit/drawer": "^10.
|
|
73
|
+
"@atlaskit/drawer": "^10.1.0",
|
|
74
74
|
"@atlaskit/form": "^12.0.0",
|
|
75
75
|
"@atlaskit/link": "^3.1.0",
|
|
76
76
|
"@atlaskit/logo": "^16.0.0",
|