@atlaskit/dropdown-menu 10.1.8 → 11.0.2

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 (211) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/__perf__/default.tsx +1 -1
  3. package/__perf__/dropdown-menu.tsx +216 -0
  4. package/codemods/11.0.0-lite-mode.tsx +39 -0
  5. package/codemods/__tests__/11.0.0-lite-mode.test.tsx +48 -0
  6. package/codemods/__tests__/convert-position.test.tsx +88 -0
  7. package/codemods/__tests__/convert-triggerType.test.tsx +100 -0
  8. package/codemods/__tests__/deprecate-items.test.tsx +108 -0
  9. package/codemods/__tests__/deprecate-onItemActivated.test.tsx +108 -0
  10. package/codemods/__tests__/deprecate-onPositioned.test.tsx +108 -0
  11. package/codemods/__tests__/deprecate-shouldFitContainer.tsx +108 -0
  12. package/codemods/__tests__/rename-imports.tsx +136 -0
  13. package/codemods/__tests__/replace-position-to-placement.test.tsx +84 -0
  14. package/codemods/__tests__/replace-shouldAllowMultipleLine.test.tsx +122 -0
  15. package/codemods/__tests__/update-component-callsites.tsx +66 -0
  16. package/codemods/migrates/convert-trigger-type.tsx +57 -0
  17. package/codemods/migrates/deprecate-items.tsx +9 -0
  18. package/codemods/migrates/deprecate-onItemActivated.tsx +9 -0
  19. package/codemods/migrates/deprecate-onPositioned.tsx +9 -0
  20. package/codemods/migrates/deprecate-shouldFitContainer.tsx +9 -0
  21. package/codemods/migrates/rename-imports.tsx +22 -0
  22. package/codemods/migrates/replace-position-to-placement.tsx +38 -0
  23. package/codemods/migrates/replace-shouldAllowMultiline.tsx +47 -0
  24. package/codemods/migrates/update-component-callsites.tsx +13 -0
  25. package/codemods/utils/convert-position.tsx +24 -0
  26. package/codemods/utils/create-rename-import.tsx +41 -0
  27. package/codemods/utils/create-update-callsite.tsx +32 -0
  28. package/dist/cjs/checkbox/dropdown-item-checkbox-group.js +31 -0
  29. package/dist/cjs/checkbox/dropdown-item-checkbox.js +108 -0
  30. package/dist/cjs/dropdown-menu-item-group.js +22 -0
  31. package/dist/cjs/dropdown-menu-item.js +67 -0
  32. package/dist/cjs/dropdown-menu.js +194 -0
  33. package/dist/cjs/index.js +21 -29
  34. package/dist/cjs/{components/item/DropdownItemRadio.js → internal/components/focus-manager.js} +40 -9
  35. package/dist/cjs/internal/components/menu-wrapper.js +68 -0
  36. package/dist/cjs/internal/context/checkbox-group-context.js +14 -0
  37. package/dist/cjs/internal/context/selection-store.js +76 -0
  38. package/dist/cjs/internal/hooks/use-checkbox-state.js +68 -0
  39. package/dist/cjs/internal/hooks/use-radio-state.js +84 -0
  40. package/dist/cjs/internal/hooks/use-register-item-with-focus-manager.js +29 -0
  41. package/dist/cjs/internal/utils/get-icon-colors.js +25 -0
  42. package/dist/cjs/internal/utils/handle-focus.js +58 -0
  43. package/dist/cjs/internal/utils/is-checkbox-item.js +11 -0
  44. package/dist/cjs/internal/utils/is-radio-item.js +11 -0
  45. package/dist/cjs/internal/utils/is-voice-over-supported.js +23 -0
  46. package/dist/cjs/internal/utils/reset-options-in-group.js +23 -0
  47. package/dist/cjs/radio/dropdown-item-radio-group.js +89 -0
  48. package/dist/cjs/radio/dropdown-item-radio.js +108 -0
  49. package/dist/cjs/version.json +1 -1
  50. package/dist/es2019/checkbox/dropdown-item-checkbox-group.js +21 -0
  51. package/dist/es2019/checkbox/dropdown-item-checkbox.js +67 -0
  52. package/dist/es2019/dropdown-menu-item-group.js +11 -0
  53. package/dist/es2019/dropdown-menu-item.js +49 -0
  54. package/dist/es2019/dropdown-menu.js +151 -0
  55. package/dist/es2019/index.js +7 -11
  56. package/dist/es2019/internal/components/focus-manager.js +40 -0
  57. package/dist/es2019/internal/components/menu-wrapper.js +44 -0
  58. package/dist/es2019/internal/context/checkbox-group-context.js +6 -0
  59. package/dist/es2019/internal/context/selection-store.js +54 -0
  60. package/dist/es2019/internal/hooks/use-checkbox-state.js +45 -0
  61. package/dist/es2019/internal/hooks/use-radio-state.js +56 -0
  62. package/dist/es2019/internal/hooks/use-register-item-with-focus-manager.js +19 -0
  63. package/dist/es2019/internal/utils/get-icon-colors.js +17 -0
  64. package/dist/es2019/internal/utils/handle-focus.js +48 -0
  65. package/dist/es2019/internal/utils/is-checkbox-item.js +4 -0
  66. package/dist/es2019/internal/utils/is-radio-item.js +4 -0
  67. package/dist/es2019/internal/utils/is-voice-over-supported.js +11 -0
  68. package/dist/es2019/internal/utils/reset-options-in-group.js +7 -0
  69. package/dist/es2019/radio/dropdown-item-radio-group.js +56 -0
  70. package/dist/es2019/radio/dropdown-item-radio.js +67 -0
  71. package/dist/es2019/version.json +1 -1
  72. package/dist/esm/checkbox/dropdown-item-checkbox-group.js +19 -0
  73. package/dist/esm/checkbox/dropdown-item-checkbox.js +81 -0
  74. package/dist/esm/dropdown-menu-item-group.js +11 -0
  75. package/dist/esm/dropdown-menu-item.js +52 -0
  76. package/dist/esm/dropdown-menu.js +168 -0
  77. package/dist/esm/index.js +7 -11
  78. package/dist/esm/internal/components/focus-manager.js +39 -0
  79. package/dist/esm/internal/components/menu-wrapper.js +45 -0
  80. package/dist/esm/internal/context/checkbox-group-context.js +6 -0
  81. package/dist/esm/internal/context/selection-store.js +58 -0
  82. package/dist/esm/internal/hooks/use-checkbox-state.js +55 -0
  83. package/dist/esm/internal/hooks/use-radio-state.js +70 -0
  84. package/dist/esm/internal/hooks/use-register-item-with-focus-manager.js +19 -0
  85. package/dist/esm/internal/utils/get-icon-colors.js +17 -0
  86. package/dist/esm/internal/utils/handle-focus.js +47 -0
  87. package/dist/esm/internal/utils/is-checkbox-item.js +4 -0
  88. package/dist/esm/internal/utils/is-radio-item.js +4 -0
  89. package/dist/esm/internal/utils/is-voice-over-supported.js +15 -0
  90. package/dist/esm/internal/utils/reset-options-in-group.js +13 -0
  91. package/dist/esm/radio/dropdown-item-radio-group.js +66 -0
  92. package/dist/esm/radio/dropdown-item-radio.js +81 -0
  93. package/dist/esm/version.json +1 -1
  94. package/dist/types/checkbox/dropdown-item-checkbox-group.d.ts +16 -0
  95. package/dist/types/checkbox/dropdown-item-checkbox.d.ts +13 -0
  96. package/dist/types/dropdown-menu-item-group.d.ts +11 -0
  97. package/dist/types/dropdown-menu-item.d.ts +13 -0
  98. package/dist/types/dropdown-menu.d.ts +13 -0
  99. package/dist/types/index.d.ts +8 -10
  100. package/dist/types/internal/components/focus-manager.d.ts +19 -0
  101. package/dist/types/internal/components/menu-wrapper.d.ts +11 -0
  102. package/dist/types/internal/context/checkbox-group-context.d.ts +5 -0
  103. package/dist/types/internal/context/selection-store.d.ts +27 -0
  104. package/dist/types/internal/hooks/use-checkbox-state.d.ts +14 -0
  105. package/dist/types/internal/hooks/use-radio-state.d.ts +9 -0
  106. package/dist/types/internal/hooks/use-register-item-with-focus-manager.d.ts +4 -0
  107. package/dist/types/internal/utils/get-icon-colors.d.ts +8 -0
  108. package/dist/types/internal/utils/handle-focus.d.ts +2 -0
  109. package/dist/types/internal/utils/is-checkbox-item.d.ts +1 -0
  110. package/dist/types/internal/utils/is-radio-item.d.ts +1 -0
  111. package/dist/types/internal/utils/is-voice-over-supported.d.ts +2 -0
  112. package/dist/types/internal/utils/reset-options-in-group.d.ts +4 -0
  113. package/dist/types/radio/dropdown-item-radio-group.d.ts +25 -0
  114. package/dist/types/radio/dropdown-item-radio.d.ts +13 -0
  115. package/dist/types/types.d.ts +254 -79
  116. package/package.json +39 -23
  117. package/dist/cjs/components/DropdownMenu.js +0 -230
  118. package/dist/cjs/components/DropdownMenuStateless.js +0 -523
  119. package/dist/cjs/components/context/DropdownItemClickManager.js +0 -72
  120. package/dist/cjs/components/context/DropdownItemFocusManager.js +0 -178
  121. package/dist/cjs/components/context/DropdownItemSelectionCache.js +0 -131
  122. package/dist/cjs/components/context/DropdownItemSelectionManager.js +0 -185
  123. package/dist/cjs/components/group/DropdownItemGroup.js +0 -61
  124. package/dist/cjs/components/group/DropdownItemGroupCheckbox.js +0 -16
  125. package/dist/cjs/components/group/DropdownItemGroupRadio.js +0 -16
  126. package/dist/cjs/components/group/ert-group-selection.js +0 -8
  127. package/dist/cjs/components/hoc/withItemSelectionManager.js +0 -66
  128. package/dist/cjs/components/hoc/withToggleInteraction.js +0 -175
  129. package/dist/cjs/components/item/DropdownItem.js +0 -19
  130. package/dist/cjs/components/item/DropdownItemCheckbox.js +0 -28
  131. package/dist/cjs/components/item/ert-item-checkbox.js +0 -8
  132. package/dist/cjs/components/item/ert-item-radio.js +0 -8
  133. package/dist/cjs/components/item/ert-item.js +0 -8
  134. package/dist/cjs/styled/WidthConstrainer.js +0 -21
  135. package/dist/cjs/util/contextNamespace.js +0 -19
  136. package/dist/cjs/util/getDisplayName.js +0 -14
  137. package/dist/cjs/util/keys.js +0 -18
  138. package/dist/cjs/util/safeContextCall.js +0 -27
  139. package/dist/cjs/util/supportsVoiceover.js +0 -17
  140. package/dist/es2019/components/DropdownMenu.js +0 -156
  141. package/dist/es2019/components/DropdownMenuStateless.js +0 -459
  142. package/dist/es2019/components/context/DropdownItemClickManager.js +0 -31
  143. package/dist/es2019/components/context/DropdownItemFocusManager.js +0 -134
  144. package/dist/es2019/components/context/DropdownItemSelectionCache.js +0 -68
  145. package/dist/es2019/components/context/DropdownItemSelectionManager.js +0 -140
  146. package/dist/es2019/components/group/DropdownItemGroup.js +0 -17
  147. package/dist/es2019/components/group/DropdownItemGroupCheckbox.js +0 -3
  148. package/dist/es2019/components/group/DropdownItemGroupRadio.js +0 -3
  149. package/dist/es2019/components/group/ert-group-selection.js +0 -1
  150. package/dist/es2019/components/hoc/withItemSelectionManager.js +0 -20
  151. package/dist/es2019/components/hoc/withToggleInteraction.js +0 -119
  152. package/dist/es2019/components/item/DropdownItem.js +0 -3
  153. package/dist/es2019/components/item/DropdownItemCheckbox.js +0 -5
  154. package/dist/es2019/components/item/DropdownItemRadio.js +0 -5
  155. package/dist/es2019/components/item/ert-item-checkbox.js +0 -1
  156. package/dist/es2019/components/item/ert-item-radio.js +0 -1
  157. package/dist/es2019/components/item/ert-item.js +0 -1
  158. package/dist/es2019/styled/WidthConstrainer.js +0 -6
  159. package/dist/es2019/util/contextNamespace.js +0 -6
  160. package/dist/es2019/util/getDisplayName.js +0 -4
  161. package/dist/es2019/util/keys.js +0 -6
  162. package/dist/es2019/util/safeContextCall.js +0 -10
  163. package/dist/es2019/util/supportsVoiceover.js +0 -5
  164. package/dist/esm/components/DropdownMenu.js +0 -215
  165. package/dist/esm/components/DropdownMenuStateless.js +0 -516
  166. package/dist/esm/components/context/DropdownItemClickManager.js +0 -59
  167. package/dist/esm/components/context/DropdownItemFocusManager.js +0 -164
  168. package/dist/esm/components/context/DropdownItemSelectionCache.js +0 -113
  169. package/dist/esm/components/context/DropdownItemSelectionManager.js +0 -174
  170. package/dist/esm/components/group/DropdownItemGroup.js +0 -43
  171. package/dist/esm/components/group/DropdownItemGroupCheckbox.js +0 -3
  172. package/dist/esm/components/group/DropdownItemGroupRadio.js +0 -3
  173. package/dist/esm/components/group/ert-group-selection.js +0 -1
  174. package/dist/esm/components/hoc/withItemSelectionManager.js +0 -47
  175. package/dist/esm/components/hoc/withToggleInteraction.js +0 -155
  176. package/dist/esm/components/item/DropdownItem.js +0 -3
  177. package/dist/esm/components/item/DropdownItemCheckbox.js +0 -7
  178. package/dist/esm/components/item/DropdownItemRadio.js +0 -7
  179. package/dist/esm/components/item/ert-item-checkbox.js +0 -1
  180. package/dist/esm/components/item/ert-item-radio.js +0 -1
  181. package/dist/esm/components/item/ert-item.js +0 -1
  182. package/dist/esm/styled/WidthConstrainer.js +0 -9
  183. package/dist/esm/util/contextNamespace.js +0 -8
  184. package/dist/esm/util/getDisplayName.js +0 -6
  185. package/dist/esm/util/keys.js +0 -6
  186. package/dist/esm/util/safeContextCall.js +0 -18
  187. package/dist/esm/util/supportsVoiceover.js +0 -9
  188. package/dist/types/components/DropdownMenu.d.ts +0 -36
  189. package/dist/types/components/DropdownMenuStateless.d.ts +0 -82
  190. package/dist/types/components/context/DropdownItemClickManager.d.ts +0 -19
  191. package/dist/types/components/context/DropdownItemFocusManager.d.ts +0 -35
  192. package/dist/types/components/context/DropdownItemSelectionCache.d.ts +0 -31
  193. package/dist/types/components/context/DropdownItemSelectionManager.d.ts +0 -34
  194. package/dist/types/components/group/DropdownItemGroup.d.ts +0 -12
  195. package/dist/types/components/group/DropdownItemGroupCheckbox.d.ts +0 -55
  196. package/dist/types/components/group/DropdownItemGroupRadio.d.ts +0 -55
  197. package/dist/types/components/group/ert-group-selection.d.ts +0 -6
  198. package/dist/types/components/hoc/withItemSelectionManager.d.ts +0 -63
  199. package/dist/types/components/hoc/withToggleInteraction.d.ts +0 -98
  200. package/dist/types/components/item/DropdownItem.d.ts +0 -65
  201. package/dist/types/components/item/DropdownItemCheckbox.d.ts +0 -80
  202. package/dist/types/components/item/DropdownItemRadio.d.ts +0 -80
  203. package/dist/types/components/item/ert-item-checkbox.d.ts +0 -2
  204. package/dist/types/components/item/ert-item-radio.d.ts +0 -2
  205. package/dist/types/components/item/ert-item.d.ts +0 -2
  206. package/dist/types/styled/WidthConstrainer.d.ts +0 -7
  207. package/dist/types/util/contextNamespace.d.ts +0 -4
  208. package/dist/types/util/getDisplayName.d.ts +0 -3
  209. package/dist/types/util/keys.d.ts +0 -6
  210. package/dist/types/util/safeContextCall.d.ts +0 -6
  211. package/dist/types/util/supportsVoiceover.d.ts +0 -2
@@ -1,6 +1,9 @@
1
- import { KeyboardEvent, MouseEvent, ReactNode } from 'react';
2
- import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
3
- import { CustomThemeButtonProps } from '@atlaskit/button/types';
1
+ import { KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from 'react';
2
+ import type { MenuGroupProps, SectionProps } from '@atlaskit/menu/types';
3
+ import type { ContentProps, TriggerProps } from '@atlaskit/popup/types';
4
+ export declare type FocusableElement = HTMLAnchorElement | HTMLButtonElement;
5
+ export declare type Action = 'next' | 'prev' | 'first' | 'last';
6
+ export declare 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';
4
7
  export declare type ItemId = string;
5
8
  export declare type GroupId = string;
6
9
  export declare type CachedItem = {
@@ -12,93 +15,265 @@ export declare type FocusItem = {
12
15
  itemNode: HTMLElement;
13
16
  };
14
17
  export declare type Behaviors = 'checkbox' | 'radio' | 'menuitemcheckbox' | 'menuitemradio';
15
- export interface DeprecatedItem {
16
- content?: string;
17
- elemBefore?: ReactNode;
18
- href?: string;
19
- isChecked?: boolean;
20
- isDisabled?: boolean;
21
- target?: '_blank' | '_self';
22
- type?: string;
18
+ export interface CustomTriggerProps 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<HTMLElement>;
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;
23
45
  }
24
- export interface DeprecatedItemGroup {
25
- elemAfter?: ReactNode;
26
- heading?: string;
27
- items: Array<DeprecatedItem>;
46
+ export interface MenuWrapperProps extends MenuGroupProps {
47
+ setInitialFocusRef?: ContentProps['setInitialFocusRef'];
48
+ onClose?: ContentProps['onClose'];
28
49
  }
29
- export interface OnItemActivatedArgs {
30
- event?: Event;
31
- item: DeprecatedItem;
50
+ export interface DropdownMenuGroupProps extends SectionProps {
32
51
  }
33
- interface DropdownMenuBaseProps {
52
+ export interface DropdownMenuProps {
34
53
  /**
35
54
  * Controls the appearance of the menu.
36
55
  * Default menu has scroll after its height exceeds the pre-defined amount.
37
56
  * Tall menu has no scroll until the height exceeds the height of the viewport.
38
57
  */
39
- appearance: 'default' | 'tall';
40
- /** Value passed to the Layer component to determine when to reposition the droplist */
41
- boundariesElement: 'viewport' | 'window' | 'scrollParent';
42
- /** Content that will be rendered inside the layer element. Should typically be
43
- * `DropdownItemGroup` or `DropdownItem`, or checkbox / radio variants of those. */
58
+ appearance?: 'default' | 'tall';
59
+ /**
60
+ * Controls if the first menu item receives focus when menu is opened. Note that the menu has a focus lock
61
+ * which traps the focus within the menu. Also, the first item gets fouced automatically
62
+ * if the menu is triggered using the keyboard.
63
+ *
64
+ */
65
+ autoFocus?: boolean;
66
+ /**
67
+ * Content that will be rendered inside the layer element. Should typically be
68
+ * `DropdownItemGroup` or `DropdownItem`, or checkbox / radio variants of those.
69
+ */
44
70
  children?: ReactNode;
45
- /** If true, a Spinner is rendered instead of the items */
46
- isLoading: boolean;
47
- /** Controls the open state of the dropdown. */
48
- isOpen: boolean;
49
- /** Deprecated. An array of groups. Every group must contain an array of items */
50
- items: Array<DeprecatedItemGroup>;
51
- /** Deprecated. Called when an item is activated. Receives an object with the activated item. */
52
- onItemActivated: (args: OnItemActivatedArgs) => void;
53
- /** Position of the menu. See the documentation of @atlaskit/layer for more details. */
54
- position: string;
55
- /** Determines if the dropdown menu should be positioned fixed. Useful for breaking out of overflow scroll/hidden containers, however, extra layout
56
- management will be required to control scroll behaviour when this property is enabled as the menu will not update position with the target on scroll. */
57
- isMenuFixed: boolean;
58
- /** Deprecated. Option to display multiline items when content is too long.
59
- * Instead of ellipsing the overflown text it causes item to flow over multiple lines.
60
- */
61
- shouldAllowMultilineItems: boolean;
62
- /** Option to fit dropdown menu width to its parent width */
63
- shouldFitContainer: boolean;
64
- /** Allows the dropdown menu to be placed on the opposite side of its trigger if it does not
65
- * fit in the viewport. */
66
- shouldFlip: boolean;
67
- /** Content which will trigger the dropdown menu to open and close. Use with `triggerType`
68
- * to easily get a button trigger. */
69
- trigger?: ReactNode;
70
- /** Props to pass through to the trigger button. See @atlaskit/button for allowed props. */
71
- triggerButtonProps?: CustomThemeButtonProps;
72
- /** Controls the interface of trigger to be used for the dropdown menu. The default trigger allows
73
- * you to supply your own trigger component. Setting this prop to `button` will render a
74
- * Button component with an 'expand' icon, and the `trigger` prop contents inside the
75
- * button. */
76
- triggerType: 'default' | 'button';
77
- /** Callback to know when the menu is correctly positioned after it is opened */
78
- onPositioned?: Function;
79
- /**
80
- A `testId` prop is provided for specified elements, which is a unique
81
- string that appears as a data attribute `data-testid` in the rendered code,
82
- serving as a hook for automated tests.
83
-
84
- As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
85
- - `testId--trigger` to get the menu trigger.
86
- - `testId--content` to get the dropdown content trigger.
87
- */
71
+ /**
72
+ * If true, a Spinner is rendered instead of the items
73
+ */
74
+ isLoading?: boolean;
75
+ /**
76
+ * Text to be used as status for assistive technologies. Defaults to "Loading".
77
+ */
78
+ statusLabel?: string;
79
+ /**
80
+ * Controls the open state of the dropdown.
81
+ */
82
+ isOpen?: boolean;
83
+ /**
84
+ * Position of the menu.
85
+ */
86
+ placement?: Placement;
87
+ /**
88
+ * Allows the dropdown menu to be placed on the opposite side of its trigger if it does not
89
+ * fit in the viewport.
90
+ */
91
+ shouldFlip?: boolean;
92
+ /**
93
+ * Content which will trigger the dropdown menu to open and close. Use with `triggerType`
94
+ * to easily get a button trigger.
95
+ */
96
+ trigger?: string | ((triggerButtonProps: CustomTriggerProps) => ReactElement);
97
+ /**
98
+ * A `testId` prop is provided for specified elements, which is a unique
99
+ * string that appears as a data attribute `data-testid` in the rendered code,
100
+ * serving as a hook for automated tests.
101
+ *
102
+ * As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
103
+ * - `testId--trigger` to get the menu trigger.
104
+ * - `testId--content` to get the dropdown content trigger.
105
+ */
88
106
  testId?: string;
107
+ /**
108
+ * Controls the initial open state of the dropdown. If provided, the component is considered to be controlled
109
+ * which means that the user is responsible for managing the open and close state of the menu.
110
+ */
111
+ defaultOpen?: boolean;
112
+ /**
113
+ * Called when the menu should be open/closed. Receives an object with `isOpen` state.
114
+ */
115
+ onOpenChange?: (args: OnOpenChangeArgs) => void;
89
116
  }
90
- export interface OnOpenChangeArgs {
91
- isOpen: boolean;
92
- event?: MouseEvent | KeyboardEvent;
117
+ export interface DropdownItemProps {
118
+ /**
119
+ * Primary content for the item.
120
+ */
121
+ children: React.ReactNode;
122
+ /**
123
+ * Description of the item.
124
+ * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
125
+ */
126
+ description?: string | JSX.Element;
127
+ /**
128
+ * Makes the element appear disabled as well as removing interactivity.
129
+ */
130
+ isDisabled?: boolean;
131
+ /**
132
+ * When `true` the title of the item will wrap multiple lines if it's long enough.
133
+ */
134
+ shouldTitleWrap?: boolean;
135
+ /**
136
+ * When `true` the description of the item will wrap multiple lines if it's long enough.
137
+ */
138
+ shouldDescriptionWrap?: boolean;
139
+ /**
140
+ * Event that is triggered when the element is clicked.
141
+ */
142
+ onClick?: (e: MouseEvent | KeyboardEvent) => void;
143
+ /**
144
+ * Makes the element appear selected.
145
+ */
146
+ isSelected?: boolean;
147
+ /**
148
+ * Link to another page.
149
+ */
150
+ href?: string;
151
+ /**
152
+ * Where to display the linked URL,
153
+ * see [anchor information](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) on mdn for more information.
154
+ */
155
+ target?: string;
156
+ /**
157
+ * Adds a title attribute to the root item element.
158
+ */
159
+ title?: string;
160
+ /**
161
+ * Element to render before the item text.
162
+ * Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
163
+ */
164
+ elemBefore?: React.ReactNode;
165
+ /**
166
+ * Element to render after the item text.
167
+ * Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
168
+ */
169
+ elemAfter?: React.ReactNode;
170
+ /**
171
+ * The relationship of the linked URL as space-separated link types.
172
+ * Generally you'll want to set this to "noopener noreferrer" when `target` is "_blank".
173
+ */
174
+ rel?: string;
175
+ /**
176
+ * A `testId` prop is provided for specified elements,
177
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
178
+ * serving as a hook for automated tests.
179
+ */
180
+ testId?: string;
93
181
  }
94
- export interface DropdownMenuStatelessProps extends DropdownMenuBaseProps, WithAnalyticsEventsProps {
95
- /** Called when the menu should be open/closed. Received an object with `isOpen` state. */
96
- onOpenChange: (args: OnOpenChangeArgs) => void;
182
+ export interface DropdownItemCheckboxProps {
183
+ /**
184
+ * Primary content for the item.
185
+ */
186
+ children: React.ReactNode;
187
+ /**
188
+ * Description of the item.
189
+ * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
190
+ */
191
+ description?: string | JSX.Element;
192
+ /**
193
+ * Makes the checkbox appear disabled as well as removing interactivity.
194
+ */
195
+ isDisabled?: boolean;
196
+ /**
197
+ * When `true` the title of the item will wrap multiple lines if it's long enough.
198
+ */
199
+ shouldTitleWrap?: boolean;
200
+ /**
201
+ * When `true` the description of the item will wrap multiple lines if it's long enough.
202
+ */
203
+ shouldDescriptionWrap?: boolean;
204
+ /**
205
+ * Event that is triggered when the checkbox is clicked.
206
+ */
207
+ onClick?: (e: MouseEvent | KeyboardEvent) => void;
208
+ /**
209
+ * Sets whether the checkbox is checked or unchecked.
210
+ */
211
+ isSelected?: boolean;
212
+ /**
213
+ * Sets whether the checkbox begins selected.
214
+ */
215
+ defaultSelected?: boolean;
216
+ /**
217
+ * Unique id of a checkbox
218
+ */
219
+ id: string;
220
+ /**
221
+ * Adds a title attribute to the root item element.
222
+ */
223
+ title?: string;
224
+ /**
225
+ * A `testId` prop is provided for specified elements,
226
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
227
+ * serving as a hook for automated tests.
228
+ */
229
+ testId?: string;
97
230
  }
98
- export interface DropdownMenuStatefulProps extends DropdownMenuBaseProps {
99
- /** Controls the initial open state of the dropdown. */
100
- defaultOpen: boolean;
101
- /** Called when the menu is open or closed. Received an object with `isOpen` state. */
102
- onOpenChange: (args: OnOpenChangeArgs, ...restArgs: any) => void;
231
+ export interface DropdownItemRadioProps {
232
+ /**
233
+ * Primary content for the item.
234
+ */
235
+ children: React.ReactNode;
236
+ /**
237
+ * Description of the item.
238
+ * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
239
+ */
240
+ description?: string | JSX.Element;
241
+ /**
242
+ * Makes the checkbox appear disabled as well as removing interactivity.
243
+ */
244
+ isDisabled?: boolean;
245
+ /**
246
+ * When `true` the title of the item will wrap multiple lines if it's long enough.
247
+ */
248
+ shouldTitleWrap?: boolean;
249
+ /**
250
+ * When `true` the description of the item will wrap multiple lines if it's long enough.
251
+ */
252
+ shouldDescriptionWrap?: boolean;
253
+ /**
254
+ * Event that is triggered when the checkbox is clicked.
255
+ */
256
+ onClick?: (e: MouseEvent | KeyboardEvent) => void;
257
+ /**
258
+ * Sets whether the checkbox is checked or unchecked.
259
+ */
260
+ isSelected?: boolean;
261
+ /**
262
+ * Sets whether the checkbox begins selected.
263
+ */
264
+ defaultSelected?: boolean;
265
+ /**
266
+ * Unique id of a checkbox
267
+ */
268
+ id: string;
269
+ /**
270
+ * Adds a title attribute to the root item element.
271
+ */
272
+ title?: string;
273
+ /**
274
+ * A `testId` prop is provided for specified elements,
275
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
276
+ * serving as a hook for automated tests.
277
+ */
278
+ testId?: string;
103
279
  }
104
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "10.1.8",
3
+ "version": "11.0.2",
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/"
@@ -13,49 +13,50 @@
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
15
  "sideEffects": false,
16
- "atlaskit:src": "src/index.ts",
16
+ "atlaskit:src": "src/index.tsx",
17
17
  "atlassian": {
18
18
  "team": "Design System Team",
19
- "inPublicMirror": true,
20
19
  "releaseModel": "scheduled",
21
20
  "website": {
22
21
  "name": "Dropdown menu"
23
22
  }
24
23
  },
25
- "af:exports": {
26
- ".": "./src/index.ts",
27
- "./types": "./src/types.tsx"
28
- },
29
24
  "dependencies": {
30
- "@atlaskit/analytics-next": "^8.2.0",
31
- "@atlaskit/button": "^16.0.0",
32
- "@atlaskit/droplist": "^11.0.0",
33
- "@atlaskit/icon": "^21.7.0",
34
- "@atlaskit/item": "^12.0.0",
35
- "@atlaskit/theme": "^11.4.0",
25
+ "@atlaskit/button": "^16.1.0",
26
+ "@atlaskit/codemod-utils": "^3.2.0",
27
+ "@atlaskit/ds-lib": "^1.1.0",
28
+ "@atlaskit/icon": "^21.10.0",
29
+ "@atlaskit/menu": "^1.0.0",
30
+ "@atlaskit/popup": "^1.3.0",
31
+ "@atlaskit/spinner": "^15.0.0",
32
+ "@atlaskit/theme": "^12.1.0",
33
+ "@atlaskit/tokens": "^0.5.0",
34
+ "@atlaskit/visually-hidden": "^0.1.1",
36
35
  "@babel/runtime": "^7.0.0",
37
- "array-find": "^1.0.0",
38
- "prop-types": "^15.5.10"
36
+ "@emotion/core": "^10.0.9"
39
37
  },
40
38
  "peerDependencies": {
41
39
  "react": "^16.8.0",
42
- "react-dom": "^16.8.0",
43
- "styled-components": "^3.2.6"
40
+ "react-dom": "^16.8.0"
44
41
  },
45
42
  "devDependencies": {
46
- "@atlaskit/avatar": "^20.1.0",
47
- "@atlaskit/build-utils": "*",
43
+ "@atlaskit/avatar": "^20.5.0",
48
44
  "@atlaskit/docs": "*",
49
- "@atlaskit/lozenge": "11.0.0",
50
- "@atlaskit/modal-dialog": "^11.5.0",
45
+ "@atlaskit/lozenge": "11.1.5",
46
+ "@atlaskit/modal-dialog": "^12.2.0",
47
+ "@atlaskit/section-message": "^6.1.0",
51
48
  "@atlaskit/ssr": "*",
52
- "@atlaskit/tooltip": "^17.3.0",
49
+ "@atlaskit/tooltip": "^17.5.0",
53
50
  "@atlaskit/visual-regression": "*",
54
51
  "@atlaskit/webdriver-runner": "*",
55
52
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
53
+ "@testing-library/dom": "^7.7.3",
56
54
  "@testing-library/react": "^8.0.1",
57
- "enzyme": "^3.10.0",
55
+ "@testing-library/react-hooks": "^1.0.4",
56
+ "jscodeshift": "^0.13.0",
58
57
  "react-dom": "^16.8.0",
58
+ "storybook-addon-performance": "^0.16.0",
59
+ "tiny-invariant": "^0.0.3",
59
60
  "typescript": "3.9.6"
60
61
  },
61
62
  "keywords": [
@@ -66,8 +67,23 @@
66
67
  "techstack": {
67
68
  "@atlassian/frontend": {
68
69
  "import-structure": "atlassian-conventions"
70
+ },
71
+ "@repo/internal": {
72
+ "ui-components": "lite-mode",
73
+ "design-system": "v1",
74
+ "styling": [
75
+ "static",
76
+ "emotion"
77
+ ],
78
+ "analytics": "analytics-next",
79
+ "deprecation": "no-deprecated-imports",
80
+ "theming": "tokens"
69
81
  }
70
82
  },
83
+ "af:exports": {
84
+ ".": "./src/index.tsx",
85
+ "./types": "./src/types.tsx"
86
+ },
71
87
  "homepage": "https://atlassian.design/components/dropdown-menu/",
72
88
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
73
89
  }