@atlaskit/dropdown-menu 16.8.5 → 16.8.7
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 +15 -0
- package/dist/cjs/internal/components/focus-manager-context.js +19 -0
- package/dist/cjs/internal/components/focus-manager.js +3 -16
- package/dist/cjs/internal/components/menu-wrapper.js +2 -2
- package/dist/cjs/internal/context/selection-store-context.js +24 -0
- package/dist/cjs/internal/context/selection-store.js +3 -20
- package/dist/cjs/internal/hooks/use-checkbox-state.js +2 -2
- package/dist/cjs/internal/hooks/use-radio-state.js +2 -2
- package/dist/cjs/internal/hooks/use-register-item-with-focus-manager.js +2 -2
- package/dist/cjs/radio/dropdown-item-radio-group.js +2 -2
- package/dist/es2019/internal/components/focus-manager-context.js +12 -0
- package/dist/es2019/internal/components/focus-manager.js +2 -15
- package/dist/es2019/internal/components/menu-wrapper.js +1 -1
- package/dist/es2019/internal/context/selection-store-context.js +13 -0
- package/dist/es2019/internal/context/selection-store.js +2 -14
- package/dist/es2019/internal/hooks/use-checkbox-state.js +1 -1
- package/dist/es2019/internal/hooks/use-radio-state.js +1 -1
- package/dist/es2019/internal/hooks/use-register-item-with-focus-manager.js +1 -1
- package/dist/es2019/radio/dropdown-item-radio-group.js +1 -1
- package/dist/esm/internal/components/focus-manager-context.js +12 -0
- package/dist/esm/internal/components/focus-manager.js +2 -15
- package/dist/esm/internal/components/menu-wrapper.js +1 -1
- package/dist/esm/internal/context/selection-store-context.js +17 -0
- package/dist/esm/internal/context/selection-store.js +2 -18
- package/dist/esm/internal/hooks/use-checkbox-state.js +1 -1
- package/dist/esm/internal/hooks/use-radio-state.js +1 -1
- package/dist/esm/internal/hooks/use-register-item-with-focus-manager.js +1 -1
- package/dist/esm/radio/dropdown-item-radio-group.js +1 -1
- package/dist/types/internal/components/focus-manager-context.d.ts +12 -0
- package/dist/types/internal/components/focus-manager.d.ts +1 -14
- package/dist/types/internal/context/selection-store-context.d.ts +16 -0
- package/dist/types/internal/context/selection-store.d.ts +0 -16
- package/dist/types-ts4.5/internal/components/focus-manager-context.d.ts +12 -0
- package/dist/types-ts4.5/internal/components/focus-manager.d.ts +1 -14
- package/dist/types-ts4.5/internal/context/selection-store-context.d.ts +16 -0
- package/dist/types-ts4.5/internal/context/selection-store.d.ts +0 -16
- package/package.json +16 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/dropdown-menu
|
|
2
2
|
|
|
3
|
+
## 16.8.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 16.8.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`02483200273ec`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/02483200273ec) -
|
|
14
|
+
Enrol all Design System UI packages into the React Compiler with platform gating via
|
|
15
|
+
isReactCompilerActivePlatform.
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 16.8.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.FocusManagerContext = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
10
|
+
/**
|
|
11
|
+
* __Focus manager context__
|
|
12
|
+
*
|
|
13
|
+
* A context that stores dropdown menu item refs and provides a way to register
|
|
14
|
+
* them for focus management within the dropdown menu.
|
|
15
|
+
*/
|
|
16
|
+
var FocusManagerContext = exports.FocusManagerContext = /*#__PURE__*/(0, _react.createContext)({
|
|
17
|
+
menuItemRefs: [],
|
|
18
|
+
registerRef: _noop.default
|
|
19
|
+
});
|
|
@@ -5,27 +5,14 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _bindEventListener = require("bind-event-listener");
|
|
12
|
-
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
13
12
|
var _layering = require("@atlaskit/layering");
|
|
14
13
|
var _handleFocus = _interopRequireDefault(require("../utils/handle-focus"));
|
|
14
|
+
var _focusManagerContext = require("./focus-manager-context");
|
|
15
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Context provider which maintains the list of focusable elements and a method to
|
|
20
|
-
* register new menu items.
|
|
21
|
-
* This list drives the keyboard navigation of the menu.
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
var FocusManagerContext = exports.FocusManagerContext = /*#__PURE__*/(0, _react.createContext)({
|
|
25
|
-
menuItemRefs: [],
|
|
26
|
-
registerRef: _noop.default
|
|
27
|
-
});
|
|
28
|
-
|
|
29
16
|
/**
|
|
30
17
|
* Focus manager logic.
|
|
31
18
|
*/
|
|
@@ -85,7 +72,7 @@ var FocusManager = function FocusManager(_ref) {
|
|
|
85
72
|
menuItemRefs: menuItemRefs.current,
|
|
86
73
|
registerRef: registerRef
|
|
87
74
|
};
|
|
88
|
-
return /*#__PURE__*/_react.default.createElement(FocusManagerContext.Provider, {
|
|
75
|
+
return /*#__PURE__*/_react.default.createElement(_focusManagerContext.FocusManagerContext.Provider, {
|
|
89
76
|
value: contextValue
|
|
90
77
|
}, children);
|
|
91
78
|
};
|
|
@@ -17,7 +17,7 @@ var _compiled = require("@atlaskit/primitives/compiled");
|
|
|
17
17
|
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
18
18
|
var _isCheckboxItem = _interopRequireDefault(require("../utils/is-checkbox-item"));
|
|
19
19
|
var _isRadioItem = _interopRequireDefault(require("../utils/is-radio-item"));
|
|
20
|
-
var
|
|
20
|
+
var _focusManagerContext = require("./focus-manager-context");
|
|
21
21
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
22
22
|
var styles = {
|
|
23
23
|
spinnerContainer: "_1e0c1txw _1ul91lit _1bah1h6o _1q51v47k _y4tiv47k _85i5v47k _bozgv47k"
|
|
@@ -57,7 +57,7 @@ var MenuWrapper = function MenuWrapper(_ref2) {
|
|
|
57
57
|
isTriggeredUsingKeyboard = _ref2.isTriggeredUsingKeyboard,
|
|
58
58
|
autoFocus = _ref2.autoFocus,
|
|
59
59
|
menuLabel = _ref2.menuLabel;
|
|
60
|
-
var _useContext = (0, _react.useContext)(
|
|
60
|
+
var _useContext = (0, _react.useContext)(_focusManagerContext.FocusManagerContext),
|
|
61
61
|
menuItemRefs = _useContext.menuItemRefs;
|
|
62
62
|
var closeOnMenuItemClick = function closeOnMenuItemClick(e) {
|
|
63
63
|
var isTargetMenuItemOrDescendant = menuItemRefs.some(function (menuItemRef) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SelectionStoreContext = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
10
|
+
/**
|
|
11
|
+
* __Selection store context__
|
|
12
|
+
*
|
|
13
|
+
* A context that stores the selection state of the dropdown menu items.
|
|
14
|
+
*/
|
|
15
|
+
var SelectionStoreContext = exports.SelectionStoreContext = /*#__PURE__*/(0, _react.createContext)({
|
|
16
|
+
setItemState: _noop.default,
|
|
17
|
+
getItemState: function getItemState() {
|
|
18
|
+
return undefined;
|
|
19
|
+
},
|
|
20
|
+
setGroupState: _noop.default,
|
|
21
|
+
getGroupState: function getGroupState() {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.default =
|
|
7
|
+
exports.default = void 0;
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var
|
|
9
|
+
var _selectionStoreContext = require("./selection-store-context");
|
|
11
10
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* SelectionStoreContext maintains the state of the selected items
|
|
15
|
-
* and getter setters.
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
var SelectionStoreContext = exports.SelectionStoreContext = /*#__PURE__*/(0, _react.createContext)({
|
|
19
|
-
setItemState: _noop.default,
|
|
20
|
-
getItemState: function getItemState() {
|
|
21
|
-
return undefined;
|
|
22
|
-
},
|
|
23
|
-
setGroupState: _noop.default,
|
|
24
|
-
getGroupState: function getGroupState() {
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
11
|
/**
|
|
29
12
|
* Selection store will persist data as long as it remains mounted.
|
|
30
13
|
* It handles the uncontrolled story for dropdown menu when the menu
|
|
@@ -55,7 +38,7 @@ var SelectionStore = function SelectionStore(props) {
|
|
|
55
38
|
}
|
|
56
39
|
};
|
|
57
40
|
}, []);
|
|
58
|
-
return /*#__PURE__*/_react.default.createElement(SelectionStoreContext.Provider, {
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(_selectionStoreContext.SelectionStoreContext.Provider, {
|
|
59
42
|
value: context
|
|
60
43
|
}, children);
|
|
61
44
|
};
|
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _checkboxGroupContext = require("../context/checkbox-group-context");
|
|
11
|
-
var
|
|
11
|
+
var _selectionStoreContext = require("../context/selection-store-context");
|
|
12
12
|
/**
|
|
13
13
|
* Custom hook to handle checkbox state for dropdown menu.
|
|
14
14
|
* It works in tandem with the selection store context when the
|
|
@@ -18,7 +18,7 @@ var useCheckboxState = function useCheckboxState(_ref) {
|
|
|
18
18
|
var isSelected = _ref.isSelected,
|
|
19
19
|
id = _ref.id,
|
|
20
20
|
defaultSelected = _ref.defaultSelected;
|
|
21
|
-
var _useContext = (0, _react.useContext)(
|
|
21
|
+
var _useContext = (0, _react.useContext)(_selectionStoreContext.SelectionStoreContext),
|
|
22
22
|
setItemState = _useContext.setItemState,
|
|
23
23
|
getItemState = _useContext.getItemState;
|
|
24
24
|
var groupId = (0, _react.useContext)(_checkboxGroupContext.CheckboxGroupContext);
|
|
@@ -9,14 +9,14 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _radioGroupContext = require("../../radio/radio-group-context");
|
|
12
|
-
var
|
|
12
|
+
var _selectionStoreContext = require("../context/selection-store-context");
|
|
13
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
15
|
function useRadioState(_ref) {
|
|
16
16
|
var id = _ref.id,
|
|
17
17
|
isSelected = _ref.isSelected,
|
|
18
18
|
defaultSelected = _ref.defaultSelected;
|
|
19
|
-
var _useContext = (0, _react.useContext)(
|
|
19
|
+
var _useContext = (0, _react.useContext)(_selectionStoreContext.SelectionStoreContext),
|
|
20
20
|
setGroupState = _useContext.setGroupState,
|
|
21
21
|
getGroupState = _useContext.getGroupState;
|
|
22
22
|
var _useContext2 = (0, _react.useContext)(_radioGroupContext.RadioGroupContext),
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
|
-
var
|
|
9
|
+
var _focusManagerContext = require("../components/focus-manager-context");
|
|
10
10
|
// eslint-disable-next-line sort-imports
|
|
11
11
|
|
|
12
12
|
// This function is called whenever a MenuItem mounts.
|
|
@@ -14,7 +14,7 @@ var _focusManager = require("../components/focus-manager");
|
|
|
14
14
|
// control focus on a user navigates using the keyboard.
|
|
15
15
|
function useRegisterItemWithFocusManager() {
|
|
16
16
|
var hasPopup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
17
|
-
var _useContext = (0, _react.useContext)(
|
|
17
|
+
var _useContext = (0, _react.useContext)(_focusManagerContext.FocusManagerContext),
|
|
18
18
|
registerRef = _useContext.registerRef;
|
|
19
19
|
var itemRef = (0, _react.useRef)(null);
|
|
20
20
|
(0, _react.useEffect)(function () {
|
|
@@ -14,7 +14,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
14
14
|
var _useId = require("@atlaskit/ds-lib/use-id");
|
|
15
15
|
var _menu = require("@atlaskit/menu");
|
|
16
16
|
var _groupTitle = _interopRequireDefault(require("../internal/components/group-title"));
|
|
17
|
-
var
|
|
17
|
+
var _selectionStoreContext = require("../internal/context/selection-store-context");
|
|
18
18
|
var _resetOptionsInGroup = _interopRequireDefault(require("../internal/utils/reset-options-in-group"));
|
|
19
19
|
var _radioGroupContext = require("./radio-group-context");
|
|
20
20
|
var _excluded = ["children", "hasSeparator", "id", "isList", "isScrollable", "testId", "title"];
|
|
@@ -36,7 +36,7 @@ var DropdownItemRadioGroup = function DropdownItemRadioGroup(_ref) {
|
|
|
36
36
|
testId = _ref.testId,
|
|
37
37
|
title = _ref.title,
|
|
38
38
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
39
|
-
var _useContext = (0, _react.useContext)(
|
|
39
|
+
var _useContext = (0, _react.useContext)(_selectionStoreContext.SelectionStoreContext),
|
|
40
40
|
setGroupState = _useContext.setGroupState,
|
|
41
41
|
getGroupState = _useContext.getGroupState;
|
|
42
42
|
var uid = (0, _useId.useId)();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import __noop from '@atlaskit/ds-lib/noop';
|
|
3
|
+
/**
|
|
4
|
+
* __Focus manager context__
|
|
5
|
+
*
|
|
6
|
+
* A context that stores dropdown menu item refs and provides a way to register
|
|
7
|
+
* them for focus management within the dropdown menu.
|
|
8
|
+
*/
|
|
9
|
+
export const FocusManagerContext = /*#__PURE__*/createContext({
|
|
10
|
+
menuItemRefs: [],
|
|
11
|
+
registerRef: __noop
|
|
12
|
+
});
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { bind } from 'bind-event-listener';
|
|
3
|
-
import __noop from '@atlaskit/ds-lib/noop';
|
|
4
3
|
import { useLayering } from '@atlaskit/layering';
|
|
5
4
|
import handleFocus from '../utils/handle-focus';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Context provider which maintains the list of focusable elements and a method to
|
|
11
|
-
* register new menu items.
|
|
12
|
-
* This list drives the keyboard navigation of the menu.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
export const FocusManagerContext = /*#__PURE__*/createContext({
|
|
16
|
-
menuItemRefs: [],
|
|
17
|
-
registerRef: __noop
|
|
18
|
-
});
|
|
5
|
+
import { FocusManagerContext } from './focus-manager-context';
|
|
19
6
|
|
|
20
7
|
/**
|
|
21
8
|
* Focus manager logic.
|
|
@@ -9,7 +9,7 @@ import { Box } from '@atlaskit/primitives/compiled';
|
|
|
9
9
|
import Spinner from '@atlaskit/spinner';
|
|
10
10
|
import isCheckboxItem from '../utils/is-checkbox-item';
|
|
11
11
|
import isRadioItem from '../utils/is-radio-item';
|
|
12
|
-
import { FocusManagerContext } from './focus-manager';
|
|
12
|
+
import { FocusManagerContext } from './focus-manager-context';
|
|
13
13
|
const styles = {
|
|
14
14
|
spinnerContainer: "_1e0c1txw _1ul91lit _1bah1h6o _1q51v47k _y4tiv47k _85i5v47k _bozgv47k"
|
|
15
15
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
3
|
+
/**
|
|
4
|
+
* __Selection store context__
|
|
5
|
+
*
|
|
6
|
+
* A context that stores the selection state of the dropdown menu items.
|
|
7
|
+
*/
|
|
8
|
+
export const SelectionStoreContext = /*#__PURE__*/createContext({
|
|
9
|
+
setItemState: noop,
|
|
10
|
+
getItemState: () => undefined,
|
|
11
|
+
setGroupState: noop,
|
|
12
|
+
getGroupState: () => ({})
|
|
13
|
+
});
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* SelectionStoreContext maintains the state of the selected items
|
|
6
|
-
* and getter setters.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export const SelectionStoreContext = /*#__PURE__*/createContext({
|
|
10
|
-
setItemState: noop,
|
|
11
|
-
getItemState: () => undefined,
|
|
12
|
-
setGroupState: noop,
|
|
13
|
-
getGroupState: () => ({})
|
|
14
|
-
});
|
|
1
|
+
import React, { useMemo, useRef } from 'react';
|
|
2
|
+
import { SelectionStoreContext } from './selection-store-context';
|
|
15
3
|
/**
|
|
16
4
|
* Selection store will persist data as long as it remains mounted.
|
|
17
5
|
* It handles the uncontrolled story for dropdown menu when the menu
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useContext, useState } from 'react';
|
|
2
2
|
import { CheckboxGroupContext } from '../context/checkbox-group-context';
|
|
3
|
-
import { SelectionStoreContext } from '../context/selection-store';
|
|
3
|
+
import { SelectionStoreContext } from '../context/selection-store-context';
|
|
4
4
|
/**
|
|
5
5
|
* Custom hook to handle checkbox state for dropdown menu.
|
|
6
6
|
* It works in tandem with the selection store context when the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useContext, useEffect, useState } from 'react';
|
|
2
2
|
import { RadioGroupContext } from '../../radio/radio-group-context';
|
|
3
|
-
import { SelectionStoreContext } from '../context/selection-store';
|
|
3
|
+
import { SelectionStoreContext } from '../context/selection-store-context';
|
|
4
4
|
function useRadioState({
|
|
5
5
|
id,
|
|
6
6
|
isSelected,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line sort-imports
|
|
2
2
|
import { useContext, useEffect, useRef } from 'react';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
-
import { FocusManagerContext } from '../components/focus-manager';
|
|
4
|
+
import { FocusManagerContext } from '../components/focus-manager-context';
|
|
5
5
|
// This function is called whenever a MenuItem mounts.
|
|
6
6
|
// The refs stored in the context are used to programmatically
|
|
7
7
|
// control focus on a user navigates using the keyboard.
|
|
@@ -3,7 +3,7 @@ import React, { useContext, useState } from 'react';
|
|
|
3
3
|
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
4
4
|
import { Section } from '@atlaskit/menu';
|
|
5
5
|
import GroupTitle from '../internal/components/group-title';
|
|
6
|
-
import { SelectionStoreContext } from '../internal/context/selection-store';
|
|
6
|
+
import { SelectionStoreContext } from '../internal/context/selection-store-context';
|
|
7
7
|
import resetOptionsInGroup from '../internal/utils/reset-options-in-group';
|
|
8
8
|
import { RadioGroupContext } from './radio-group-context';
|
|
9
9
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import __noop from '@atlaskit/ds-lib/noop';
|
|
3
|
+
/**
|
|
4
|
+
* __Focus manager context__
|
|
5
|
+
*
|
|
6
|
+
* A context that stores dropdown menu item refs and provides a way to register
|
|
7
|
+
* them for focus management within the dropdown menu.
|
|
8
|
+
*/
|
|
9
|
+
export var FocusManagerContext = /*#__PURE__*/createContext({
|
|
10
|
+
menuItemRefs: [],
|
|
11
|
+
registerRef: __noop
|
|
12
|
+
});
|
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { bind } from 'bind-event-listener';
|
|
4
|
-
import __noop from '@atlaskit/ds-lib/noop';
|
|
5
4
|
import { useLayering } from '@atlaskit/layering';
|
|
6
5
|
import handleFocus from '../utils/handle-focus';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Context provider which maintains the list of focusable elements and a method to
|
|
12
|
-
* register new menu items.
|
|
13
|
-
* This list drives the keyboard navigation of the menu.
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export var FocusManagerContext = /*#__PURE__*/createContext({
|
|
17
|
-
menuItemRefs: [],
|
|
18
|
-
registerRef: __noop
|
|
19
|
-
});
|
|
6
|
+
import { FocusManagerContext } from './focus-manager-context';
|
|
20
7
|
|
|
21
8
|
/**
|
|
22
9
|
* Focus manager logic.
|
|
@@ -9,7 +9,7 @@ import { Box } from '@atlaskit/primitives/compiled';
|
|
|
9
9
|
import Spinner from '@atlaskit/spinner';
|
|
10
10
|
import isCheckboxItem from '../utils/is-checkbox-item';
|
|
11
11
|
import isRadioItem from '../utils/is-radio-item';
|
|
12
|
-
import { FocusManagerContext } from './focus-manager';
|
|
12
|
+
import { FocusManagerContext } from './focus-manager-context';
|
|
13
13
|
var styles = {
|
|
14
14
|
spinnerContainer: "_1e0c1txw _1ul91lit _1bah1h6o _1q51v47k _y4tiv47k _85i5v47k _bozgv47k"
|
|
15
15
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
3
|
+
/**
|
|
4
|
+
* __Selection store context__
|
|
5
|
+
*
|
|
6
|
+
* A context that stores the selection state of the dropdown menu items.
|
|
7
|
+
*/
|
|
8
|
+
export var SelectionStoreContext = /*#__PURE__*/createContext({
|
|
9
|
+
setItemState: noop,
|
|
10
|
+
getItemState: function getItemState() {
|
|
11
|
+
return undefined;
|
|
12
|
+
},
|
|
13
|
+
setGroupState: noop,
|
|
14
|
+
getGroupState: function getGroupState() {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* SelectionStoreContext maintains the state of the selected items
|
|
6
|
-
* and getter setters.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export var SelectionStoreContext = /*#__PURE__*/createContext({
|
|
10
|
-
setItemState: noop,
|
|
11
|
-
getItemState: function getItemState() {
|
|
12
|
-
return undefined;
|
|
13
|
-
},
|
|
14
|
-
setGroupState: noop,
|
|
15
|
-
getGroupState: function getGroupState() {
|
|
16
|
-
return {};
|
|
17
|
-
}
|
|
18
|
-
});
|
|
1
|
+
import React, { useMemo, useRef } from 'react';
|
|
2
|
+
import { SelectionStoreContext } from './selection-store-context';
|
|
19
3
|
/**
|
|
20
4
|
* Selection store will persist data as long as it remains mounted.
|
|
21
5
|
* It handles the uncontrolled story for dropdown menu when the menu
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import { useCallback, useContext, useState } from 'react';
|
|
3
3
|
import { CheckboxGroupContext } from '../context/checkbox-group-context';
|
|
4
|
-
import { SelectionStoreContext } from '../context/selection-store';
|
|
4
|
+
import { SelectionStoreContext } from '../context/selection-store-context';
|
|
5
5
|
/**
|
|
6
6
|
* Custom hook to handle checkbox state for dropdown menu.
|
|
7
7
|
* It works in tandem with the selection store context when the
|
|
@@ -4,7 +4,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
import { useCallback, useContext, useEffect, useState } from 'react';
|
|
6
6
|
import { RadioGroupContext } from '../../radio/radio-group-context';
|
|
7
|
-
import { SelectionStoreContext } from '../context/selection-store';
|
|
7
|
+
import { SelectionStoreContext } from '../context/selection-store-context';
|
|
8
8
|
function useRadioState(_ref) {
|
|
9
9
|
var id = _ref.id,
|
|
10
10
|
isSelected = _ref.isSelected,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line sort-imports
|
|
2
2
|
import { useContext, useEffect, useRef } from 'react';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
-
import { FocusManagerContext } from '../components/focus-manager';
|
|
4
|
+
import { FocusManagerContext } from '../components/focus-manager-context';
|
|
5
5
|
// This function is called whenever a MenuItem mounts.
|
|
6
6
|
// The refs stored in the context are used to programmatically
|
|
7
7
|
// control focus on a user navigates using the keyboard.
|
|
@@ -9,7 +9,7 @@ import React, { useContext, useState } from 'react';
|
|
|
9
9
|
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
10
10
|
import { Section } from '@atlaskit/menu';
|
|
11
11
|
import GroupTitle from '../internal/components/group-title';
|
|
12
|
-
import { SelectionStoreContext } from '../internal/context/selection-store';
|
|
12
|
+
import { SelectionStoreContext } from '../internal/context/selection-store-context';
|
|
13
13
|
import resetOptionsInGroup from '../internal/utils/reset-options-in-group';
|
|
14
14
|
import { RadioGroupContext } from './radio-group-context';
|
|
15
15
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type FocusableElementRef } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* __Focus manager context__
|
|
5
|
+
*
|
|
6
|
+
* A context that stores dropdown menu item refs and provides a way to register
|
|
7
|
+
* them for focus management within the dropdown menu.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FocusManagerContext: React.Context<{
|
|
10
|
+
menuItemRefs: FocusableElementRef[];
|
|
11
|
+
registerRef(ref: FocusableElementRef): void;
|
|
12
|
+
}>;
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type FocusableElementRef } from '../../types';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Context provider which maintains the list of focusable elements and a method to
|
|
7
|
-
* register new menu items.
|
|
8
|
-
* This list drives the keyboard navigation of the menu.
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
export declare const FocusManagerContext: React.Context<{
|
|
12
|
-
menuItemRefs: FocusableElementRef[];
|
|
13
|
-
registerRef(ref: FocusableElementRef): void;
|
|
14
|
-
}>;
|
|
1
|
+
import { type FC, type ReactNode } from 'react';
|
|
15
2
|
/**
|
|
16
3
|
* Focus manager logic.
|
|
17
4
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type OptionsInGroup = {
|
|
3
|
+
[key: string]: boolean | undefined;
|
|
4
|
+
};
|
|
5
|
+
export type SelectionStoreContextProps = {
|
|
6
|
+
setItemState: (group: string, id: string, value: boolean | undefined) => void;
|
|
7
|
+
getItemState: (group: string, id: string) => boolean | undefined;
|
|
8
|
+
setGroupState: (group: string, value: OptionsInGroup) => void;
|
|
9
|
+
getGroupState: (group: string) => OptionsInGroup;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* __Selection store context__
|
|
13
|
+
*
|
|
14
|
+
* A context that stores the selection state of the dropdown menu items.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SelectionStoreContext: React.Context<SelectionStoreContextProps>;
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
type OptionsInGroup = {
|
|
3
|
-
[key: string]: boolean | undefined;
|
|
4
|
-
};
|
|
5
|
-
type SelectionStoreContextProps = {
|
|
6
|
-
setItemState: (group: string, id: string, value: boolean | undefined) => void;
|
|
7
|
-
getItemState: (group: string, id: string) => boolean | undefined;
|
|
8
|
-
setGroupState: (group: string, value: OptionsInGroup) => void;
|
|
9
|
-
getGroupState: (group: string) => OptionsInGroup;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* SelectionStoreContext maintains the state of the selected items
|
|
14
|
-
* and getter setters.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export declare const SelectionStoreContext: React.Context<SelectionStoreContextProps>;
|
|
18
2
|
type SelectionStoreProps = {
|
|
19
3
|
children: React.ReactNode;
|
|
20
4
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type FocusableElementRef } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* __Focus manager context__
|
|
5
|
+
*
|
|
6
|
+
* A context that stores dropdown menu item refs and provides a way to register
|
|
7
|
+
* them for focus management within the dropdown menu.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FocusManagerContext: React.Context<{
|
|
10
|
+
menuItemRefs: FocusableElementRef[];
|
|
11
|
+
registerRef(ref: FocusableElementRef): void;
|
|
12
|
+
}>;
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type FocusableElementRef } from '../../types';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Context provider which maintains the list of focusable elements and a method to
|
|
7
|
-
* register new menu items.
|
|
8
|
-
* This list drives the keyboard navigation of the menu.
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
export declare const FocusManagerContext: React.Context<{
|
|
12
|
-
menuItemRefs: FocusableElementRef[];
|
|
13
|
-
registerRef(ref: FocusableElementRef): void;
|
|
14
|
-
}>;
|
|
1
|
+
import { type FC, type ReactNode } from 'react';
|
|
15
2
|
/**
|
|
16
3
|
* Focus manager logic.
|
|
17
4
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type OptionsInGroup = {
|
|
3
|
+
[key: string]: boolean | undefined;
|
|
4
|
+
};
|
|
5
|
+
export type SelectionStoreContextProps = {
|
|
6
|
+
setItemState: (group: string, id: string, value: boolean | undefined) => void;
|
|
7
|
+
getItemState: (group: string, id: string) => boolean | undefined;
|
|
8
|
+
setGroupState: (group: string, value: OptionsInGroup) => void;
|
|
9
|
+
getGroupState: (group: string) => OptionsInGroup;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* __Selection store context__
|
|
13
|
+
*
|
|
14
|
+
* A context that stores the selection state of the dropdown menu items.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SelectionStoreContext: React.Context<SelectionStoreContextProps>;
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
type OptionsInGroup = {
|
|
3
|
-
[key: string]: boolean | undefined;
|
|
4
|
-
};
|
|
5
|
-
type SelectionStoreContextProps = {
|
|
6
|
-
setItemState: (group: string, id: string, value: boolean | undefined) => void;
|
|
7
|
-
getItemState: (group: string, id: string) => boolean | undefined;
|
|
8
|
-
setGroupState: (group: string, value: OptionsInGroup) => void;
|
|
9
|
-
getGroupState: (group: string) => OptionsInGroup;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* SelectionStoreContext maintains the state of the selected items
|
|
14
|
-
* and getter setters.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export declare const SelectionStoreContext: React.Context<SelectionStoreContextProps>;
|
|
18
2
|
type SelectionStoreProps = {
|
|
19
3
|
children: React.ReactNode;
|
|
20
4
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dropdown-menu",
|
|
3
|
-
"version": "16.8.
|
|
3
|
+
"version": "16.8.7",
|
|
4
4
|
"description": "A dropdown menu displays a list of actions or options to a user.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
],
|
|
18
18
|
"atlaskit:src": "src/index.tsx",
|
|
19
19
|
"atlassian": {
|
|
20
|
+
"react-compiler": {
|
|
21
|
+
"enabled": true,
|
|
22
|
+
"gating": {
|
|
23
|
+
"source": "@atlassian/react-compiler-gating",
|
|
24
|
+
"importSpecifierName": "isReactCompilerActivePlatform"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
20
27
|
"team": "Design System Team",
|
|
21
28
|
"website": {
|
|
22
29
|
"name": "Dropdown menu",
|
|
@@ -24,7 +31,7 @@
|
|
|
24
31
|
}
|
|
25
32
|
},
|
|
26
33
|
"dependencies": {
|
|
27
|
-
"@atlaskit/button": "^23.
|
|
34
|
+
"@atlaskit/button": "^23.11.0",
|
|
28
35
|
"@atlaskit/css": "^0.19.0",
|
|
29
36
|
"@atlaskit/ds-lib": "^6.0.0",
|
|
30
37
|
"@atlaskit/icon": "^34.0.0",
|
|
@@ -33,8 +40,8 @@
|
|
|
33
40
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
34
41
|
"@atlaskit/popup": "^4.16.0",
|
|
35
42
|
"@atlaskit/primitives": "^18.1.0",
|
|
36
|
-
"@atlaskit/spinner": "^19.
|
|
37
|
-
"@atlaskit/theme": "^
|
|
43
|
+
"@atlaskit/spinner": "^19.1.0",
|
|
44
|
+
"@atlaskit/theme": "^23.0.0",
|
|
38
45
|
"@atlaskit/tokens": "^11.4.0",
|
|
39
46
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
40
47
|
"@babel/runtime": "^7.0.0",
|
|
@@ -54,15 +61,16 @@
|
|
|
54
61
|
"@atlaskit/checkbox": "^17.3.0",
|
|
55
62
|
"@atlaskit/docs": "^11.7.0",
|
|
56
63
|
"@atlaskit/form": "^15.5.0",
|
|
57
|
-
"@atlaskit/heading": "^5.
|
|
58
|
-
"@atlaskit/link": "^3.
|
|
64
|
+
"@atlaskit/heading": "^5.4.0",
|
|
65
|
+
"@atlaskit/link": "^3.4.0",
|
|
59
66
|
"@atlaskit/lozenge": "^13.5.0",
|
|
60
67
|
"@atlaskit/modal-dialog": "^14.14.0",
|
|
61
68
|
"@atlaskit/section-message": "^8.12.0",
|
|
62
|
-
"@atlaskit/textfield": "^8.
|
|
63
|
-
"@atlaskit/toggle": "^15.
|
|
69
|
+
"@atlaskit/textfield": "^8.3.0",
|
|
70
|
+
"@atlaskit/toggle": "^15.3.0",
|
|
64
71
|
"@atlassian/a11y-jest-testing": "^0.11.0",
|
|
65
72
|
"@atlassian/feature-flags-test-utils": "^1.0.0",
|
|
73
|
+
"@atlassian/react-compiler-gating": "workspace:^",
|
|
66
74
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
67
75
|
"@testing-library/react": "^16.3.0",
|
|
68
76
|
"@testing-library/user-event": "^14.4.3",
|