@atlaskit/dropdown-menu 12.0.0 → 12.1.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/dropdown-menu.js +1 -17
  3. package/dist/es2019/dropdown-menu.js +1 -17
  4. package/dist/esm/dropdown-menu.js +1 -17
  5. package/dist/types-ts4.5/checkbox/dropdown-item-checkbox-group.d.ts +16 -0
  6. package/dist/types-ts4.5/checkbox/dropdown-item-checkbox.d.ts +13 -0
  7. package/dist/types-ts4.5/dropdown-menu-item-group.d.ts +11 -0
  8. package/dist/types-ts4.5/dropdown-menu-item.d.ts +13 -0
  9. package/dist/types-ts4.5/dropdown-menu.d.ts +13 -0
  10. package/dist/types-ts4.5/index.d.ts +8 -0
  11. package/dist/types-ts4.5/internal/components/checkbox-icon.d.ts +12 -0
  12. package/dist/types-ts4.5/internal/components/context.d.ts +27 -0
  13. package/dist/types-ts4.5/internal/components/focus-manager.d.ts +21 -0
  14. package/dist/types-ts4.5/internal/components/menu-wrapper.d.ts +11 -0
  15. package/dist/types-ts4.5/internal/components/radio-icon.d.ts +12 -0
  16. package/dist/types-ts4.5/internal/context/checkbox-group-context.d.ts +5 -0
  17. package/dist/types-ts4.5/internal/context/selection-store.d.ts +27 -0
  18. package/dist/types-ts4.5/internal/hooks/use-checkbox-state.d.ts +17 -0
  19. package/dist/types-ts4.5/internal/hooks/use-radio-state.d.ts +12 -0
  20. package/dist/types-ts4.5/internal/hooks/use-register-item-with-focus-manager.d.ts +4 -0
  21. package/dist/types-ts4.5/internal/utils/handle-focus.d.ts +2 -0
  22. package/dist/types-ts4.5/internal/utils/is-checkbox-item.d.ts +1 -0
  23. package/dist/types-ts4.5/internal/utils/is-radio-item.d.ts +1 -0
  24. package/dist/types-ts4.5/internal/utils/is-voice-over-supported.d.ts +2 -0
  25. package/dist/types-ts4.5/internal/utils/reset-options-in-group.d.ts +4 -0
  26. package/dist/types-ts4.5/internal/utils/use-generated-id.d.ts +6 -0
  27. package/dist/types-ts4.5/radio/dropdown-item-radio-group.d.ts +25 -0
  28. package/dist/types-ts4.5/radio/dropdown-item-radio.d.ts +13 -0
  29. package/dist/types-ts4.5/types.d.ts +303 -0
  30. package/package.json +3 -6
  31. package/tmp/api-report-tmp.d.ts +147 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/dropdown-menu
2
2
 
3
+ ## 12.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#41586](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41586) [`ef0466f92d9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ef0466f92d9) - We are removing previously added feature flag and unsafe entry point usage of the new Button inside DropdownMenu.
8
+
3
9
  ## 12.0.0
4
10
 
5
11
  ### Major Changes
@@ -12,14 +12,12 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
12
12
  var _react = _interopRequireWildcard(require("react"));
13
13
  var _bindEventListener = require("bind-event-listener");
14
14
  var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
15
- var _unsafe = require("@atlaskit/button/unsafe");
16
15
  var _keycodes = require("@atlaskit/ds-lib/keycodes");
17
16
  var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
18
17
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
19
18
  var _useControlled = _interopRequireDefault(require("@atlaskit/ds-lib/use-controlled"));
20
19
  var _useFocusEvent = _interopRequireDefault(require("@atlaskit/ds-lib/use-focus-event"));
21
20
  var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
22
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
23
21
  var _popup = _interopRequireDefault(require("@atlaskit/popup"));
24
22
  var _constants = require("@atlaskit/theme/constants");
25
23
  var _focusManager = _interopRequireDefault(require("./internal/components/focus-manager"));
@@ -201,21 +199,7 @@ var DropdownMenu = function DropdownMenu(_ref) {
201
199
  testId: testId && "".concat(testId, "--trigger")
202
200
  }));
203
201
  }
204
- return (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.new-button-adoption-in-dropdown_p8sn4') ? /*#__PURE__*/_react.default.createElement(_unsafe.UNSAFE_BUTTON, {
205
- iconAfter: /*#__PURE__*/_react.default.createElement(_chevronDown.default, {
206
- size: "medium",
207
- label: ""
208
- }),
209
- onFocus: bindFocus.onFocus,
210
- onBlur: bindFocus.onBlur,
211
- ref: (0, _mergeRefs.default)([ref, itemRef]),
212
- "aria-controls": ariaControls,
213
- "aria-expanded": ariaExpanded,
214
- "aria-haspopup": ariaHasPopup,
215
- isSelected: isLocalOpen,
216
- onClick: handleTriggerClicked,
217
- testId: testId && "".concat(testId, "--trigger")
218
- }, _trigger) : /*#__PURE__*/_react.default.createElement(_standardButton.default, (0, _extends2.default)({}, bindFocus, {
202
+ return /*#__PURE__*/_react.default.createElement(_standardButton.default, (0, _extends2.default)({}, bindFocus, {
219
203
  ref: (0, _mergeRefs.default)([ref, itemRef]),
220
204
  "aria-controls": ariaControls,
221
205
  "aria-expanded": ariaExpanded,
@@ -2,14 +2,12 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
3
  import { bind } from 'bind-event-listener';
4
4
  import Button from '@atlaskit/button/standard-button';
5
- import { UNSAFE_BUTTON } from '@atlaskit/button/unsafe';
6
5
  import { KEY_DOWN } from '@atlaskit/ds-lib/keycodes';
7
6
  import mergeRefs from '@atlaskit/ds-lib/merge-refs';
8
7
  import noop from '@atlaskit/ds-lib/noop';
9
8
  import useControlledState from '@atlaskit/ds-lib/use-controlled';
10
9
  import useFocus from '@atlaskit/ds-lib/use-focus-event';
11
10
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
12
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
11
  import Popup from '@atlaskit/popup';
14
12
  // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
15
13
  import { gridSize as gridSizeFn, layers } from '@atlaskit/theme/constants';
@@ -175,21 +173,7 @@ const DropdownMenu = ({
175
173
  testId: testId && `${testId}--trigger`
176
174
  });
177
175
  }
178
- return getBooleanFF('platform.design-system-team.new-button-adoption-in-dropdown_p8sn4') ? /*#__PURE__*/React.createElement(UNSAFE_BUTTON, {
179
- iconAfter: /*#__PURE__*/React.createElement(ExpandIcon, {
180
- size: "medium",
181
- label: ""
182
- }),
183
- onFocus: bindFocus.onFocus,
184
- onBlur: bindFocus.onBlur,
185
- ref: mergeRefs([ref, itemRef]),
186
- "aria-controls": ariaControls,
187
- "aria-expanded": ariaExpanded,
188
- "aria-haspopup": ariaHasPopup,
189
- isSelected: isLocalOpen,
190
- onClick: handleTriggerClicked,
191
- testId: testId && `${testId}--trigger`
192
- }, trigger) : /*#__PURE__*/React.createElement(Button, _extends({}, bindFocus, {
176
+ return /*#__PURE__*/React.createElement(Button, _extends({}, bindFocus, {
193
177
  ref: mergeRefs([ref, itemRef]),
194
178
  "aria-controls": ariaControls,
195
179
  "aria-expanded": ariaExpanded,
@@ -6,14 +6,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
6
6
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
7
7
  import { bind } from 'bind-event-listener';
8
8
  import Button from '@atlaskit/button/standard-button';
9
- import { UNSAFE_BUTTON } from '@atlaskit/button/unsafe';
10
9
  import { KEY_DOWN } from '@atlaskit/ds-lib/keycodes';
11
10
  import mergeRefs from '@atlaskit/ds-lib/merge-refs';
12
11
  import noop from '@atlaskit/ds-lib/noop';
13
12
  import useControlledState from '@atlaskit/ds-lib/use-controlled';
14
13
  import useFocus from '@atlaskit/ds-lib/use-focus-event';
15
14
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
16
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
17
15
  import Popup from '@atlaskit/popup';
18
16
  // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
19
17
  import { gridSize as gridSizeFn, layers } from '@atlaskit/theme/constants';
@@ -192,21 +190,7 @@ var DropdownMenu = function DropdownMenu(_ref) {
192
190
  testId: testId && "".concat(testId, "--trigger")
193
191
  }));
194
192
  }
195
- return getBooleanFF('platform.design-system-team.new-button-adoption-in-dropdown_p8sn4') ? /*#__PURE__*/React.createElement(UNSAFE_BUTTON, {
196
- iconAfter: /*#__PURE__*/React.createElement(ExpandIcon, {
197
- size: "medium",
198
- label: ""
199
- }),
200
- onFocus: bindFocus.onFocus,
201
- onBlur: bindFocus.onBlur,
202
- ref: mergeRefs([ref, itemRef]),
203
- "aria-controls": ariaControls,
204
- "aria-expanded": ariaExpanded,
205
- "aria-haspopup": ariaHasPopup,
206
- isSelected: isLocalOpen,
207
- onClick: handleTriggerClicked,
208
- testId: testId && "".concat(testId, "--trigger")
209
- }, _trigger) : /*#__PURE__*/React.createElement(Button, _extends({}, bindFocus, {
193
+ return /*#__PURE__*/React.createElement(Button, _extends({}, bindFocus, {
210
194
  ref: mergeRefs([ref, itemRef]),
211
195
  "aria-controls": ariaControls,
212
196
  "aria-expanded": ariaExpanded,
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import type { SectionProps } from '@atlaskit/menu';
3
+ interface DropdownItemCheckboxGroupProps extends SectionProps {
4
+ /**
5
+ * Unique identifier for the checkbox group.
6
+ */
7
+ id: string;
8
+ }
9
+ /**
10
+ * __Dropdown item checkbox group__
11
+ *
12
+ * A wrapping element for dropdown menu checkbox items.
13
+ *
14
+ */
15
+ declare const DropdownItemCheckboxGroup: ({ children, hasSeparator, id, isList, isScrollable, overrides, testId, title, }: DropdownItemCheckboxGroupProps) => JSX.Element;
16
+ export default DropdownItemCheckboxGroup;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { DropdownItemCheckboxProps } from '../types';
3
+ /**
4
+ * __Dropdown item checkbox__
5
+ *
6
+ * A dropdown item checkbox creates groups that have multiple selections.
7
+ *
8
+ * - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/examples)
9
+ * - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/code)
10
+ * - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/usage)
11
+ */
12
+ declare const DropdownItemCheckbox: ({ children, defaultSelected, description, id, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, testId, }: DropdownItemCheckboxProps) => JSX.Element;
13
+ export default DropdownItemCheckbox;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * __Section__
3
+ *
4
+ * A dropdown item group includes all the actions or items in a dropdown menu.
5
+ *
6
+ * - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item-group/examples)
7
+ * - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-group/code)
8
+ * - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-group/usage)
9
+ */
10
+ import Section from '@atlaskit/menu/section';
11
+ export default Section;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { DropdownItemProps } from './types';
3
+ /**
4
+ * __Dropdown menu item__
5
+ *
6
+ * A dropdown item populates the dropdown menu with items. Every item should be inside a dropdown item group.
7
+ *
8
+ * - [Examples](https://atlassian.design/components/dropdown-item/examples)
9
+ * - [Code](https://atlassian.design/components/dropdown-item/code)
10
+ * - [Usage](https://atlassian.design/components/dropdown-item/usage)
11
+ */
12
+ declare const DropdownMenuItem: React.ForwardRefExoticComponent<DropdownItemProps & React.RefAttributes<HTMLElement>>;
13
+ export default DropdownMenuItem;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import type { DropdownMenuProps } from './types';
3
+ /**
4
+ * __Dropdown menu__
5
+ *
6
+ * A dropdown menu displays a list of actions or options to a user.
7
+ *
8
+ * - [Examples](https://atlassian.design/components/dropdown-menu/examples)
9
+ * - [Code](https://atlassian.design/components/dropdown-menu/code)
10
+ * - [Usage](https://atlassian.design/components/dropdown-menu/usage)
11
+ */
12
+ declare const DropdownMenu: <T extends HTMLElement = HTMLElement>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFlip, shouldRenderToParent, spacing, statusLabel, testId, trigger, zIndex, }: DropdownMenuProps<T>) => JSX.Element;
13
+ export default DropdownMenu;
@@ -0,0 +1,8 @@
1
+ export { default } from './dropdown-menu';
2
+ export { default as DropdownItemGroup } from './dropdown-menu-item-group';
3
+ export { default as DropdownItem } from './dropdown-menu-item';
4
+ export { default as DropdownItemCheckbox } from './checkbox/dropdown-item-checkbox';
5
+ export { default as DropdownItemCheckboxGroup } from './checkbox/dropdown-item-checkbox-group';
6
+ export { default as DropdownItemRadio } from './radio/dropdown-item-radio';
7
+ export { default as DropdownItemRadioGroup } from './radio/dropdown-item-radio-group';
8
+ export type { DropdownMenuProps, DropdownMenuGroupProps, DropdownItemProps, OnOpenChangeArgs, CustomTriggerProps, } from './types';
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * __Checkbox icon__
4
+ *
5
+ * Used to visually represent the selected state in DropdownItemCheckbox
6
+ *
7
+ * @internal
8
+ */
9
+ declare const CheckboxIcon: ({ checked }: {
10
+ checked: boolean;
11
+ }) => JSX.Element;
12
+ export default CheckboxIcon;
@@ -0,0 +1,27 @@
1
+ import React, { FC, MutableRefObject } from 'react';
2
+ /**
3
+ *
4
+ * @internal
5
+ * Context which maintains the current level of dropdown menu if it is nested
6
+ * Default is 0
7
+ *
8
+ */
9
+ export declare const NestedLevelContext: React.Context<number>;
10
+ /**
11
+ *
12
+ * @internal
13
+ * Context which maintains the maximun level of dropdown menu if it is nested
14
+ * Default is 0
15
+ *
16
+ */
17
+ export declare const TrackMaxLevelContext: React.Context<{
18
+ maxLevelRef: MutableRefObject<number>;
19
+ setMaxLevel: (level: number, isMin?: boolean) => void;
20
+ }>;
21
+ /**
22
+ *
23
+ * @internal
24
+ * Context provider which maintains the maximun level of dropdown menu if it is nested
25
+ *
26
+ */
27
+ export declare const TrackLevelProvider: FC;
@@ -0,0 +1,21 @@
1
+ import React, { FC, ReactNode } from 'react';
2
+ import { FocusableElement } 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 navgation of the menu.
9
+ *
10
+ */
11
+ export declare const FocusManagerContext: React.Context<{
12
+ menuItemRefs: FocusableElement[];
13
+ registerRef: (ref: FocusableElement) => void;
14
+ }>;
15
+ /**
16
+ * Focus manager logic
17
+ */
18
+ declare const FocusManager: FC<{
19
+ children: ReactNode;
20
+ }>;
21
+ export default FocusManager;
@@ -0,0 +1,11 @@
1
+ import { jsx } from '@emotion/react';
2
+ import { MenuWrapperProps } from '../../types';
3
+ /**
4
+ *
5
+ * MenuWrapper wraps all the menu items.
6
+ * It handles the logic to close the menu when a MenuItem is clicked, but leaves it open
7
+ * if a CheckboxItem or RadioItem is clicked.
8
+ * It also sets focus to the first menu item when opened.
9
+ */
10
+ declare const MenuWrapper: ({ children, isLoading, maxHeight, maxWidth, onClose, onUpdate, statusLabel, setInitialFocusRef, spacing, testId, }: MenuWrapperProps) => jsx.JSX.Element;
11
+ export default MenuWrapper;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * __Radio icon__
4
+ *
5
+ * Used to visually represent the selected state in DropdownItemRadio
6
+ *
7
+ * @internal
8
+ */
9
+ declare const RadioIcon: ({ checked }: {
10
+ checked: boolean;
11
+ }) => JSX.Element;
12
+ export default RadioIcon;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Holds the unique identifier for the checkbox group.
4
+ */
5
+ export declare const CheckboxGroupContext: import("react").Context<string>;
@@ -0,0 +1,27 @@
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
+ type SelectionStoreProps = {
19
+ children: React.ReactNode;
20
+ };
21
+ /**
22
+ * Selection store will persist data as long as it remains mounted.
23
+ * It handles the uncontrolled story for dropdown menu when the menu
24
+ * items can be mounted/unmounted depending if the menu is open or closed.
25
+ */
26
+ declare const SelectionStore: (props: SelectionStoreProps) => JSX.Element;
27
+ export default SelectionStore;
@@ -0,0 +1,17 @@
1
+ type CheckboxStateArgs = {
2
+ id: string;
3
+ isSelected: boolean | undefined;
4
+ defaultSelected: boolean | undefined;
5
+ };
6
+ type SetStateCallback = (value: boolean | undefined) => boolean;
7
+ type CheckboxStateValue = [
8
+ boolean,
9
+ (newValue: SetStateCallback) => void
10
+ ];
11
+ /**
12
+ * Custom hook to handle checkbox state for dropdown menu.
13
+ * It works in tandem with the selection store context when the
14
+ * component is uncontrolled.
15
+ */
16
+ declare const useCheckboxState: ({ isSelected, id, defaultSelected, }: CheckboxStateArgs) => CheckboxStateValue;
17
+ export default useCheckboxState;
@@ -0,0 +1,12 @@
1
+ type RadioStateArgs = {
2
+ id: string;
3
+ isSelected: boolean | undefined;
4
+ defaultSelected: boolean | undefined;
5
+ };
6
+ type SetStateCallback = (value: boolean | undefined) => boolean;
7
+ type RadioStateValue = [
8
+ boolean,
9
+ (newValue: SetStateCallback) => void
10
+ ];
11
+ declare function useRadioState({ id, isSelected, defaultSelected, }: RadioStateArgs): RadioStateValue;
12
+ export default useRadioState;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { FocusableElement } from '../../types';
3
+ declare function useRegisterItemWithFocusManager(): import("react").RefObject<FocusableElement>;
4
+ export default useRegisterItemWithFocusManager;
@@ -0,0 +1,2 @@
1
+ import { FocusableElement } from '../../types';
2
+ export default function handleFocus(refs: Array<FocusableElement>, isLayerDisabled: () => boolean): (e: KeyboardEvent) => void;
@@ -0,0 +1 @@
1
+ export default function isCheckboxItem(element: HTMLElement): boolean;
@@ -0,0 +1 @@
1
+ export default function isCheckboxItem(element: HTMLElement): boolean;
@@ -0,0 +1,2 @@
1
+ declare const isVoiceOverSupported: () => boolean;
2
+ export default isVoiceOverSupported;
@@ -0,0 +1,4 @@
1
+ declare const resetOptionsInGroup: (group: {
2
+ [key: string]: boolean | undefined;
3
+ }) => {};
4
+ export default resetOptionsInGroup;
@@ -0,0 +1,6 @@
1
+ export declare const PREFIX = "ds--dropdown--";
2
+ /**
3
+ * useGeneratedId generates a random string which remains constant across
4
+ * renders when called without any parameter.
5
+ */
6
+ export default function useGeneratedId(): string;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import type { SectionProps } from '@atlaskit/menu';
3
+ interface DropdownItemRadioGroupProps extends SectionProps {
4
+ id: string;
5
+ }
6
+ interface RadioGroupContextProps {
7
+ id: string;
8
+ radioGroupState: {
9
+ [key: string]: boolean | undefined;
10
+ };
11
+ selectRadioItem: (id: string, value: boolean) => void;
12
+ }
13
+ /**
14
+ * __Radio group context__
15
+ * Context provider that wraps each DropdownItemRadioGroup
16
+ */
17
+ export declare const RadioGroupContext: React.Context<RadioGroupContextProps>;
18
+ /**
19
+ * __Dropdown item radio group__
20
+ * Store which manages the selection state for each DropdownItemRadio
21
+ * across mount and unmounts.
22
+ *
23
+ */
24
+ declare const DropdownItemRadioGroup: ({ children, hasSeparator, id, isList, isScrollable, overrides, testId, title, }: DropdownItemRadioGroupProps) => JSX.Element;
25
+ export default DropdownItemRadioGroup;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { DropdownItemRadioProps } from '../types';
3
+ /**
4
+ * __Dropdown item radio__
5
+ *
6
+ * A dropdown item radio displays groups that have a single selection.
7
+ *
8
+ * - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/examples)
9
+ * - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/code)
10
+ * - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/usage)
11
+ */
12
+ declare const DropdownItemRadio: ({ children, defaultSelected, testId, id, title, description, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, }: DropdownItemRadioProps) => JSX.Element;
13
+ export default DropdownItemRadio;
@@ -0,0 +1,303 @@
1
+ import { KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from 'react';
2
+ import type { CustomItemProps, MenuGroupProps, SectionProps } from '@atlaskit/menu/types';
3
+ import type { ContentProps, TriggerProps } from '@atlaskit/popup/types';
4
+ export type FocusableElement = HTMLAnchorElement | HTMLButtonElement;
5
+ export type Action = 'next' | 'prev' | 'first' | 'last';
6
+ export type Placement = 'auto-start' | 'auto' | 'auto-end' | 'top-start' | 'top' | 'top-end' | 'right-start' | 'right' | 'right-end' | 'bottom-end' | 'bottom' | 'bottom-start' | 'left-end' | 'left' | 'left-start';
7
+ export type ItemId = string;
8
+ export type GroupId = string;
9
+ export type CachedItem = {
10
+ id: ItemId;
11
+ groupId: GroupId;
12
+ };
13
+ export type FocusItem = {
14
+ itemId: ItemId;
15
+ itemNode: HTMLElement;
16
+ };
17
+ export type Behaviors = 'checkbox' | 'radio' | 'menuitemcheckbox' | 'menuitemradio';
18
+ export interface CustomTriggerProps<TriggerElement extends HTMLElement = HTMLElement> extends Omit<TriggerProps, 'ref'> {
19
+ /**
20
+ * Ref that should be applied to the trigger. This is used to calculate the menu position.
21
+ */
22
+ triggerRef: Ref<TriggerElement>;
23
+ /**
24
+ * Makes the trigger appear selected.
25
+ */
26
+ isSelected?: boolean;
27
+ /**
28
+ * Event that is triggered when the element is clicked.
29
+ */
30
+ onClick?: (e: MouseEvent | KeyboardEvent) => void;
31
+ /**
32
+ * A `testId` prop is provided for specified elements, which is a unique
33
+ * string that appears as a data attribute `data-testid` in the rendered code,
34
+ * serving as a hook for automated tests.
35
+ *
36
+ * As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
37
+ * - `testId--trigger` to get the menu trigger.
38
+ * - `testId--content` to get the dropdown content trigger.
39
+ */
40
+ testId?: string;
41
+ }
42
+ export interface OnOpenChangeArgs {
43
+ isOpen: boolean;
44
+ event: MouseEvent | KeyboardEvent;
45
+ }
46
+ export interface MenuWrapperProps extends MenuGroupProps {
47
+ setInitialFocusRef?: ContentProps['setInitialFocusRef'];
48
+ onClose?: ContentProps['onClose'];
49
+ onUpdate: ContentProps['update'];
50
+ isLoading?: DropdownMenuProps['isLoading'];
51
+ statusLabel?: DropdownMenuProps['statusLabel'];
52
+ }
53
+ export interface DropdownMenuGroupProps extends SectionProps {
54
+ }
55
+ export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> {
56
+ /**
57
+ * Controls the appearance of the menu.
58
+ * Default menu has scroll after its height exceeds the pre-defined amount.
59
+ * Tall menu has no scroll until the height exceeds the height of the viewport.
60
+ */
61
+ appearance?: 'default' | 'tall';
62
+ /**
63
+ * Controls if the first menu item receives focus when menu is opened. Note that the menu has a focus lock
64
+ * which traps the focus within the menu. Also, the first item gets fouced automatically
65
+ * if the menu is triggered using the keyboard.
66
+ *
67
+ */
68
+ autoFocus?: boolean;
69
+ /**
70
+ * Content that will be rendered inside the layer element. Should typically be
71
+ * `DropdownItemGroup` or `DropdownItem`, or checkbox / radio variants of those.
72
+ */
73
+ children?: ReactNode;
74
+ /**
75
+ * If true, a Spinner is rendered instead of the items
76
+ */
77
+ isLoading?: boolean;
78
+ /**
79
+ * Text to be used as status for assistive technologies. Defaults to "Loading".
80
+ */
81
+ statusLabel?: string;
82
+ /**
83
+ * Controls the open state of the dropdown.
84
+ */
85
+ isOpen?: boolean;
86
+ /**
87
+ * Position of the menu.
88
+ */
89
+ placement?: Placement;
90
+ /**
91
+ * Allows the dropdown menu to be placed on the opposite side of its trigger if it does not
92
+ * fit in the viewport.
93
+ */
94
+ shouldFlip?: boolean;
95
+ /**
96
+ * The root element where the DropdownMenu content should be rendered.
97
+ * `true` - rendering in the DOM node closest to the trigger. `false` - rendering in React.Portal.
98
+ * Defaults to `false`.
99
+ */
100
+ shouldRenderToParent?: boolean;
101
+ /**
102
+ * Controls the spacing density of the menu.
103
+ */
104
+ spacing?: Extract<MenuGroupProps['spacing'], 'cozy' | 'compact'>;
105
+ /**
106
+ * Content which will trigger the dropdown menu to open and close. Use with `triggerType`
107
+ * to easily get a button trigger.
108
+ */
109
+ trigger?: string | ((triggerButtonProps: CustomTriggerProps<TriggerElement>) => ReactElement);
110
+ /**
111
+ * A `testId` prop is provided for specified elements, which is a unique
112
+ * string that appears as a data attribute `data-testid` in the rendered code,
113
+ * serving as a hook for automated tests.
114
+ *
115
+ * As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
116
+ * - `testId--trigger` to get the menu trigger.
117
+ * - `testId--content` to get the dropdown content trigger.
118
+ */
119
+ testId?: string;
120
+ /**
121
+ * Controls the initial open state of the dropdown. If provided, the component is considered to be controlled
122
+ * which means that the user is responsible for managing the open and close state of the menu.
123
+ */
124
+ defaultOpen?: boolean;
125
+ /**
126
+ * Called when the menu should be open/closed. Receives an object with `isOpen` state.
127
+ */
128
+ onOpenChange?: (args: OnOpenChangeArgs) => void;
129
+ /**
130
+ * Z-index that the popup should be displayed in.
131
+ * This is passed to the portal component.
132
+ * Defaults to `layers.modal()` from `@atlaskit/theme` which is 510.
133
+ */
134
+ zIndex?: number;
135
+ }
136
+ export interface DropdownItemProps {
137
+ /**
138
+ * Primary content for the item.
139
+ */
140
+ children: React.ReactNode;
141
+ /**
142
+ * Custom component to render as an item.
143
+ * Should be wrapped in `forwardRef` to avoid accessibility issues when controlling keyboard focus.
144
+ */
145
+ component?: CustomItemProps['component'];
146
+ /**
147
+ * Description of the item.
148
+ * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
149
+ */
150
+ description?: string | JSX.Element;
151
+ /**
152
+ * Makes the element appear disabled as well as removing interactivity.
153
+ */
154
+ isDisabled?: boolean;
155
+ /**
156
+ * When `true` the title of the item will wrap multiple lines if it's long enough.
157
+ */
158
+ shouldTitleWrap?: boolean;
159
+ /**
160
+ * When `true` the description of the item will wrap multiple lines if it's long enough.
161
+ */
162
+ shouldDescriptionWrap?: boolean;
163
+ /**
164
+ * Event that is triggered when the element is clicked.
165
+ */
166
+ onClick?: (e: MouseEvent | KeyboardEvent) => void;
167
+ /**
168
+ * Makes the element appear selected.
169
+ */
170
+ isSelected?: boolean;
171
+ /**
172
+ * Link to another page.
173
+ */
174
+ href?: string;
175
+ /**
176
+ * Where to display the linked URL,
177
+ * see [anchor information](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) on mdn for more information.
178
+ */
179
+ target?: string;
180
+ /**
181
+ * Adds a title attribute to the root item element.
182
+ */
183
+ title?: string;
184
+ /**
185
+ * Element to render before the item text.
186
+ * Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
187
+ */
188
+ elemBefore?: React.ReactNode;
189
+ /**
190
+ * Element to render after the item text.
191
+ * Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
192
+ */
193
+ elemAfter?: React.ReactNode;
194
+ /**
195
+ * The relationship of the linked URL as space-separated link types.
196
+ * Generally you'll want to set this to "noopener noreferrer" when `target` is "_blank".
197
+ */
198
+ rel?: string;
199
+ /**
200
+ * A `testId` prop is provided for specified elements,
201
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
202
+ * serving as a hook for automated tests.
203
+ */
204
+ testId?: string;
205
+ }
206
+ export interface DropdownItemCheckboxProps {
207
+ /**
208
+ * Primary content for the item.
209
+ */
210
+ children: React.ReactNode;
211
+ /**
212
+ * Description of the item.
213
+ * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
214
+ */
215
+ description?: string | JSX.Element;
216
+ /**
217
+ * Makes the checkbox appear disabled as well as removing interactivity.
218
+ */
219
+ isDisabled?: boolean;
220
+ /**
221
+ * When `true` the title of the item will wrap multiple lines if it's long enough.
222
+ */
223
+ shouldTitleWrap?: boolean;
224
+ /**
225
+ * When `true` the description of the item will wrap multiple lines if it's long enough.
226
+ */
227
+ shouldDescriptionWrap?: boolean;
228
+ /**
229
+ * Event that is triggered when the checkbox is clicked.
230
+ */
231
+ onClick?: (e: MouseEvent | KeyboardEvent) => void;
232
+ /**
233
+ * Sets whether the checkbox is checked or unchecked.
234
+ */
235
+ isSelected?: boolean;
236
+ /**
237
+ * Sets whether the checkbox begins selected.
238
+ */
239
+ defaultSelected?: boolean;
240
+ /**
241
+ * Unique id of a checkbox
242
+ */
243
+ id: string;
244
+ /**
245
+ * Adds a title attribute to the root item element.
246
+ */
247
+ title?: string;
248
+ /**
249
+ * A `testId` prop is provided for specified elements,
250
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
251
+ * serving as a hook for automated tests.
252
+ */
253
+ testId?: string;
254
+ }
255
+ export interface DropdownItemRadioProps {
256
+ /**
257
+ * Primary content for the item.
258
+ */
259
+ children: React.ReactNode;
260
+ /**
261
+ * Description of the item.
262
+ * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
263
+ */
264
+ description?: string | JSX.Element;
265
+ /**
266
+ * Makes the checkbox appear disabled as well as removing interactivity.
267
+ */
268
+ isDisabled?: boolean;
269
+ /**
270
+ * When `true` the title of the item will wrap multiple lines if it's long enough.
271
+ */
272
+ shouldTitleWrap?: boolean;
273
+ /**
274
+ * When `true` the description of the item will wrap multiple lines if it's long enough.
275
+ */
276
+ shouldDescriptionWrap?: boolean;
277
+ /**
278
+ * Event that is triggered when the checkbox is clicked.
279
+ */
280
+ onClick?: (e: MouseEvent | KeyboardEvent) => void;
281
+ /**
282
+ * Sets whether the checkbox is checked or unchecked.
283
+ */
284
+ isSelected?: boolean;
285
+ /**
286
+ * Sets whether the checkbox begins selected.
287
+ */
288
+ defaultSelected?: boolean;
289
+ /**
290
+ * Unique id of a checkbox
291
+ */
292
+ id: string;
293
+ /**
294
+ * Adds a title attribute to the root item element.
295
+ */
296
+ title?: string;
297
+ /**
298
+ * A `testId` prop is provided for specified elements,
299
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
300
+ * serving as a hook for automated tests.
301
+ */
302
+ testId?: string;
303
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "12.0.0",
3
+ "version": "12.1.0",
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/"
@@ -30,11 +30,11 @@
30
30
  "@atlaskit/layering": "^0.2.0",
31
31
  "@atlaskit/menu": "^2.0.0",
32
32
  "@atlaskit/platform-feature-flags": "^0.2.2",
33
- "@atlaskit/popup": "^1.10.0",
33
+ "@atlaskit/popup": "^1.11.0",
34
34
  "@atlaskit/primitives": "^1.6.0",
35
35
  "@atlaskit/spinner": "^15.6.0",
36
36
  "@atlaskit/theme": "^12.6.0",
37
- "@atlaskit/tokens": "^1.25.0",
37
+ "@atlaskit/tokens": "^1.26.0",
38
38
  "@babel/runtime": "^7.0.0",
39
39
  "@emotion/react": "^11.7.1",
40
40
  "bind-event-listener": "^2.1.1"
@@ -105,9 +105,6 @@
105
105
  "platform.design-system-team.border-checkbox_nyoiu": {
106
106
  "type": "boolean"
107
107
  },
108
- "platform.design-system-team.new-button-adoption-in-dropdown_p8sn4": {
109
- "type": "boolean"
110
- },
111
108
  "platform.design-system-team.icon-button-spacing-fix_o1zc5": {
112
109
  "type": "boolean",
113
110
  "referenceOnly": "true"
@@ -0,0 +1,147 @@
1
+ ## API Report File for "@atlaskit/dropdown-menu"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ /// <reference types="react" />
8
+
9
+ import type { CustomItemProps } from '@atlaskit/menu/types';
10
+ import { default as DropdownItemGroup } from '@atlaskit/menu/section';
11
+ import { KeyboardEvent as KeyboardEvent_2 } from 'react';
12
+ import type { MenuGroupProps } from '@atlaskit/menu/types';
13
+ import { MouseEvent as MouseEvent_2 } from 'react';
14
+ import { default as React_2 } from 'react';
15
+ import { ReactElement } from 'react';
16
+ import { ReactNode } from 'react';
17
+ import { Ref } from 'react';
18
+ import type { SectionProps } from '@atlaskit/menu';
19
+ import type { SectionProps as SectionProps_2 } from '@atlaskit/menu/types';
20
+ import type { TriggerProps } from '@atlaskit/popup/types';
21
+
22
+ // @public (undocumented)
23
+ export interface CustomTriggerProps<TriggerElement extends HTMLElement = HTMLElement> extends Omit<TriggerProps, 'ref'> {
24
+ isSelected?: boolean;
25
+ onClick?: (e: KeyboardEvent_2 | MouseEvent_2) => void;
26
+ testId?: string;
27
+ triggerRef: Ref<TriggerElement>;
28
+ }
29
+
30
+ // @public
31
+ export const DropdownItem: React_2.ForwardRefExoticComponent<DropdownItemProps & React_2.RefAttributes<HTMLElement>>;
32
+
33
+ // @public
34
+ export const DropdownItemCheckbox: ({ children, defaultSelected, description, id, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, testId, }: DropdownItemCheckboxProps) => JSX.Element;
35
+
36
+ // @public
37
+ export const DropdownItemCheckboxGroup: ({ children, hasSeparator, id, isList, isScrollable, overrides, testId, title, }: DropdownItemCheckboxGroupProps) => JSX.Element;
38
+
39
+ // @public (undocumented)
40
+ interface DropdownItemCheckboxGroupProps extends SectionProps {
41
+ id: string;
42
+ }
43
+
44
+ // @public (undocumented)
45
+ interface DropdownItemCheckboxProps {
46
+ children: React.ReactNode;
47
+ defaultSelected?: boolean;
48
+ description?: JSX.Element | string;
49
+ id: string;
50
+ isDisabled?: boolean;
51
+ isSelected?: boolean;
52
+ onClick?: (e: KeyboardEvent_2 | MouseEvent_2) => void;
53
+ shouldDescriptionWrap?: boolean;
54
+ shouldTitleWrap?: boolean;
55
+ testId?: string;
56
+ title?: string;
57
+ }
58
+
59
+ export { DropdownItemGroup }
60
+
61
+ // @public (undocumented)
62
+ export interface DropdownItemProps {
63
+ children: React.ReactNode;
64
+ component?: CustomItemProps['component'];
65
+ description?: JSX.Element | string;
66
+ elemAfter?: React.ReactNode;
67
+ elemBefore?: React.ReactNode;
68
+ href?: string;
69
+ isDisabled?: boolean;
70
+ isSelected?: boolean;
71
+ onClick?: (e: KeyboardEvent_2 | MouseEvent_2) => void;
72
+ rel?: string;
73
+ shouldDescriptionWrap?: boolean;
74
+ shouldTitleWrap?: boolean;
75
+ target?: string;
76
+ testId?: string;
77
+ title?: string;
78
+ }
79
+
80
+ // @public
81
+ export const DropdownItemRadio: ({ children, defaultSelected, testId, id, title, description, isDisabled, isSelected, onClick: providedOnClick, shouldDescriptionWrap, shouldTitleWrap, }: DropdownItemRadioProps) => JSX.Element;
82
+
83
+ // @public
84
+ export const DropdownItemRadioGroup: ({ children, hasSeparator, id, isList, isScrollable, overrides, testId, title, }: DropdownItemRadioGroupProps) => JSX.Element;
85
+
86
+ // @public (undocumented)
87
+ interface DropdownItemRadioGroupProps extends SectionProps {
88
+ // (undocumented)
89
+ id: string;
90
+ }
91
+
92
+ // @public (undocumented)
93
+ interface DropdownItemRadioProps {
94
+ children: React.ReactNode;
95
+ defaultSelected?: boolean;
96
+ description?: JSX.Element | string;
97
+ id: string;
98
+ isDisabled?: boolean;
99
+ isSelected?: boolean;
100
+ onClick?: (e: KeyboardEvent_2 | MouseEvent_2) => void;
101
+ shouldDescriptionWrap?: boolean;
102
+ shouldTitleWrap?: boolean;
103
+ testId?: string;
104
+ title?: string;
105
+ }
106
+
107
+ // @public
108
+ const DropdownMenu: <T extends HTMLElement = HTMLElement>({ autoFocus, children, defaultOpen, isLoading, isOpen, onOpenChange, placement, shouldFlip, shouldRenderToParent, spacing, statusLabel, testId, trigger, zIndex, }: DropdownMenuProps<T>) => JSX.Element;
109
+ export default DropdownMenu;
110
+
111
+ // @public (undocumented)
112
+ export interface DropdownMenuGroupProps extends SectionProps_2 {
113
+ }
114
+
115
+ // @public (undocumented)
116
+ export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> {
117
+ appearance?: 'default' | 'tall';
118
+ autoFocus?: boolean;
119
+ children?: ReactNode;
120
+ defaultOpen?: boolean;
121
+ isLoading?: boolean;
122
+ isOpen?: boolean;
123
+ onOpenChange?: (args: OnOpenChangeArgs) => void;
124
+ placement?: Placement;
125
+ shouldFlip?: boolean;
126
+ shouldRenderToParent?: boolean;
127
+ spacing?: Extract<MenuGroupProps['spacing'], 'compact' | 'cozy'>;
128
+ statusLabel?: string;
129
+ testId?: string;
130
+ trigger?: ((triggerButtonProps: CustomTriggerProps<TriggerElement>) => ReactElement) | string;
131
+ zIndex?: number;
132
+ }
133
+
134
+ // @public (undocumented)
135
+ export interface OnOpenChangeArgs {
136
+ // (undocumented)
137
+ event: KeyboardEvent_2 | MouseEvent_2;
138
+ // (undocumented)
139
+ isOpen: boolean;
140
+ }
141
+
142
+ // @public (undocumented)
143
+ type Placement = 'auto' | 'auto-end' | 'auto-start' | 'bottom' | 'bottom-end' | 'bottom-start' | 'left' | 'left-end' | 'left-start' | 'right' | 'right-end' | 'right-start' | 'top' | 'top-end' | 'top-start';
144
+
145
+ // (No @packageDocumentation comment for this package)
146
+
147
+ ```