@primer/components 0.0.0-2021827171555 → 0.0.0-202182722258

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 (250) hide show
  1. package/CHANGELOG.md +2 -44
  2. package/dist/browser.esm.js +626 -671
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +388 -433
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Divider.js +1 -1
  7. package/lib/ActionList/Header.js +2 -2
  8. package/lib/ActionList/Item.d.ts +4 -17
  9. package/lib/ActionList/Item.js +19 -21
  10. package/lib/ActionList/List.d.ts +7 -11
  11. package/lib/ActionList/List.js +3 -3
  12. package/lib/ActionList/index.d.ts +2 -1
  13. package/lib/AnchoredOverlay/AnchoredOverlay.js +2 -2
  14. package/lib/Autocomplete/Autocomplete.d.ts +26 -0
  15. package/lib/Autocomplete/Autocomplete.js +55 -0
  16. package/lib/Autocomplete/AutocompleteContext.d.ts +13 -0
  17. package/lib/Autocomplete/AutocompleteContext.js +15 -0
  18. package/lib/Autocomplete/AutocompleteInput.d.ts +9 -0
  19. package/lib/Autocomplete/AutocompleteInput.js +139 -0
  20. package/lib/Autocomplete/AutocompleteMenu.d.ts +67 -0
  21. package/lib/Autocomplete/AutocompleteMenu.js +284 -0
  22. package/lib/Autocomplete/index.d.ts +2 -0
  23. package/lib/Autocomplete/index.js +15 -0
  24. package/lib/Avatar.d.ts +0 -4
  25. package/lib/AvatarPair.js +1 -1
  26. package/lib/AvatarStack.js +1 -1
  27. package/lib/Badge/Badge.d.ts +8 -0
  28. package/lib/Badge/Badge.js +59 -0
  29. package/lib/Badge/BadgeState.d.ts +13 -0
  30. package/lib/Badge/BadgeState.js +51 -0
  31. package/lib/Badge/_badgeStyleUtils.d.ts +3 -0
  32. package/lib/Badge/_badgeStyleUtils.js +39 -0
  33. package/lib/BranchName.js +1 -1
  34. package/lib/Breadcrumb.d.ts +23 -0
  35. package/lib/{Breadcrumbs.js → Breadcrumb.js} +23 -33
  36. package/lib/Button/Button.d.ts +1 -0
  37. package/lib/Button/Button.js +1 -1
  38. package/lib/Button/ButtonClose.d.ts +2 -1
  39. package/lib/Button/ButtonClose.js +1 -1
  40. package/lib/Button/ButtonDanger.d.ts +1 -0
  41. package/lib/Button/ButtonInvisible.d.ts +1 -0
  42. package/lib/Button/ButtonInvisible.js +1 -1
  43. package/lib/Button/ButtonOutline.d.ts +1 -0
  44. package/lib/Button/ButtonPrimary.d.ts +1 -0
  45. package/lib/Button/ButtonTableList.js +1 -1
  46. package/lib/CircleBadge.js +1 -1
  47. package/lib/CircleOcticon.d.ts +1 -0
  48. package/lib/CircleOcticon.js +1 -1
  49. package/lib/CounterLabel.js +2 -2
  50. package/lib/Dialog/ConfirmationDialog.js +1 -1
  51. package/lib/Dialog/Dialog.js +9 -9
  52. package/lib/Dialog.d.ts +3 -2
  53. package/lib/Dialog.js +4 -4
  54. package/lib/Dropdown.d.ts +4 -0
  55. package/lib/Dropdown.js +2 -2
  56. package/lib/DropdownMenu/DropdownButton.d.ts +2 -1
  57. package/lib/DropdownStyles.js +6 -6
  58. package/lib/FilterList.d.ts +1 -0
  59. package/lib/FilterList.js +1 -1
  60. package/lib/FilteredActionList/FilteredActionList.js +8 -34
  61. package/lib/Flash.js +1 -1
  62. package/lib/Label.js +2 -2
  63. package/lib/Link.js +1 -1
  64. package/lib/Overlay.d.ts +2 -1
  65. package/lib/Overlay.js +11 -6
  66. package/lib/Pagehead.js +1 -1
  67. package/lib/Pagination/Pagination.js +1 -1
  68. package/lib/Popover.js +1 -1
  69. package/lib/Position.d.ts +4 -4
  70. package/lib/ProgressBar.js +1 -1
  71. package/lib/SelectMenu/SelectMenu.d.ts +344 -15
  72. package/lib/SelectMenu/SelectMenuDivider.js +1 -1
  73. package/lib/SelectMenu/SelectMenuFilter.d.ts +1 -1
  74. package/lib/SelectMenu/SelectMenuFilter.js +1 -1
  75. package/lib/SelectMenu/SelectMenuFooter.js +1 -1
  76. package/lib/SelectMenu/SelectMenuHeader.js +2 -2
  77. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  78. package/lib/SelectMenu/SelectMenuItem.js +1 -1
  79. package/lib/SelectMenu/SelectMenuList.js +1 -1
  80. package/lib/SelectMenu/SelectMenuLoadingAnimation.js +1 -1
  81. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  82. package/lib/SelectMenu/SelectMenuModal.js +2 -2
  83. package/lib/SelectMenu/SelectMenuTab.js +1 -1
  84. package/lib/SelectMenu/SelectMenuTabPanel.js +1 -1
  85. package/lib/SelectPanel/SelectPanel.js +2 -3
  86. package/lib/SideNav.js +5 -5
  87. package/lib/StateLabel.js +1 -1
  88. package/lib/SubNav.js +1 -1
  89. package/lib/TabNav.js +2 -2
  90. package/lib/TextInput.d.ts +10 -7
  91. package/lib/TextInput.js +24 -29
  92. package/lib/TextInputTokens.d.ts +43 -0
  93. package/lib/TextInputTokens.js +227 -0
  94. package/lib/TextInputWithTokens.d.ts +41 -0
  95. package/lib/TextInputWithTokens.js +396 -0
  96. package/lib/Timeline.d.ts +1 -0
  97. package/lib/Timeline.js +19 -16
  98. package/lib/Token/Token.d.ts +7 -0
  99. package/lib/Token/Token.js +63 -0
  100. package/lib/Token/TokenBase.d.ts +16 -0
  101. package/lib/Token/TokenBase.js +76 -0
  102. package/lib/Token/TokenLabel.d.ts +10 -0
  103. package/lib/Token/TokenLabel.js +115 -0
  104. package/lib/Token/TokenProfile.d.ts +7 -0
  105. package/lib/Token/TokenProfile.js +45 -0
  106. package/lib/Token/_RemoveTokenButton.d.ts +3 -0
  107. package/lib/Token/_RemoveTokenButton.js +43 -0
  108. package/lib/Token/_tokenButtonUtils.d.ts +9 -0
  109. package/lib/Token/_tokenButtonUtils.js +42 -0
  110. package/lib/Tooltip.js +1 -1
  111. package/lib/UnderlineNav.js +2 -2
  112. package/lib/_UnstyledTextInput.d.ts +2 -0
  113. package/lib/_UnstyledTextInput.js +20 -0
  114. package/lib/hooks/useOverlay.d.ts +2 -1
  115. package/lib/hooks/useOverlay.js +11 -6
  116. package/lib/index.d.ts +2 -3
  117. package/lib/index.js +2 -22
  118. package/lib/theme-preval.d.ts +6 -12
  119. package/lib/theme-preval.js +0 -940
  120. package/lib/utils/scrollIntoViewingArea.d.ts +1 -0
  121. package/lib/utils/scrollIntoViewingArea.js +39 -0
  122. package/lib/utils/testing.d.ts +0 -1854
  123. package/lib/utils/types.d.ts +3 -0
  124. package/lib/utils/uniqueId.js +0 -1
  125. package/lib-esm/ActionList/Divider.js +1 -1
  126. package/lib-esm/ActionList/Header.js +2 -2
  127. package/lib-esm/ActionList/Item.d.ts +4 -17
  128. package/lib-esm/ActionList/Item.js +19 -22
  129. package/lib-esm/ActionList/List.d.ts +7 -11
  130. package/lib-esm/ActionList/List.js +3 -3
  131. package/lib-esm/ActionList/index.d.ts +2 -1
  132. package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +3 -3
  133. package/lib-esm/Autocomplete/Autocomplete.d.ts +26 -0
  134. package/lib-esm/Autocomplete/Autocomplete.js +36 -0
  135. package/lib-esm/Autocomplete/AutocompleteContext.d.ts +13 -0
  136. package/lib-esm/Autocomplete/AutocompleteContext.js +6 -0
  137. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +9 -0
  138. package/lib-esm/Autocomplete/AutocompleteInput.js +120 -0
  139. package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +67 -0
  140. package/lib-esm/Autocomplete/AutocompleteMenu.js +258 -0
  141. package/lib-esm/Autocomplete/index.d.ts +2 -0
  142. package/lib-esm/Autocomplete/index.js +1 -0
  143. package/lib-esm/Avatar.d.ts +0 -4
  144. package/lib-esm/AvatarPair.js +1 -1
  145. package/lib-esm/AvatarStack.js +1 -1
  146. package/lib-esm/Badge/Badge.d.ts +8 -0
  147. package/lib-esm/Badge/Badge.js +44 -0
  148. package/lib-esm/Badge/BadgeState.d.ts +13 -0
  149. package/lib-esm/Badge/BadgeState.js +40 -0
  150. package/lib-esm/Badge/_badgeStyleUtils.d.ts +3 -0
  151. package/lib-esm/Badge/_badgeStyleUtils.js +29 -0
  152. package/lib-esm/BranchName.js +1 -1
  153. package/lib-esm/Breadcrumb.d.ts +23 -0
  154. package/lib-esm/{Breadcrumbs.js → Breadcrumb.js} +21 -30
  155. package/lib-esm/Button/Button.d.ts +1 -0
  156. package/lib-esm/Button/Button.js +1 -1
  157. package/lib-esm/Button/ButtonClose.d.ts +2 -1
  158. package/lib-esm/Button/ButtonClose.js +1 -1
  159. package/lib-esm/Button/ButtonDanger.d.ts +1 -0
  160. package/lib-esm/Button/ButtonInvisible.d.ts +1 -0
  161. package/lib-esm/Button/ButtonInvisible.js +1 -1
  162. package/lib-esm/Button/ButtonOutline.d.ts +1 -0
  163. package/lib-esm/Button/ButtonPrimary.d.ts +1 -0
  164. package/lib-esm/Button/ButtonTableList.js +1 -1
  165. package/lib-esm/CircleBadge.js +1 -1
  166. package/lib-esm/CircleOcticon.d.ts +1 -0
  167. package/lib-esm/CircleOcticon.js +1 -1
  168. package/lib-esm/CounterLabel.js +2 -2
  169. package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
  170. package/lib-esm/Dialog/Dialog.js +8 -8
  171. package/lib-esm/Dialog.d.ts +3 -2
  172. package/lib-esm/Dialog.js +4 -4
  173. package/lib-esm/Dropdown.d.ts +4 -0
  174. package/lib-esm/Dropdown.js +2 -2
  175. package/lib-esm/DropdownMenu/DropdownButton.d.ts +2 -1
  176. package/lib-esm/DropdownStyles.js +6 -6
  177. package/lib-esm/FilterList.d.ts +1 -0
  178. package/lib-esm/FilterList.js +1 -1
  179. package/lib-esm/FilteredActionList/FilteredActionList.js +6 -34
  180. package/lib-esm/Flash.js +1 -1
  181. package/lib-esm/Label.js +2 -2
  182. package/lib-esm/Link.js +1 -1
  183. package/lib-esm/Overlay.d.ts +2 -1
  184. package/lib-esm/Overlay.js +9 -6
  185. package/lib-esm/Pagehead.js +1 -1
  186. package/lib-esm/Pagination/Pagination.js +1 -1
  187. package/lib-esm/Popover.js +1 -1
  188. package/lib-esm/Position.d.ts +4 -4
  189. package/lib-esm/ProgressBar.js +1 -1
  190. package/lib-esm/SelectMenu/SelectMenu.d.ts +344 -15
  191. package/lib-esm/SelectMenu/SelectMenuDivider.js +1 -1
  192. package/lib-esm/SelectMenu/SelectMenuFilter.d.ts +1 -1
  193. package/lib-esm/SelectMenu/SelectMenuFilter.js +1 -1
  194. package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
  195. package/lib-esm/SelectMenu/SelectMenuHeader.js +2 -2
  196. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  197. package/lib-esm/SelectMenu/SelectMenuItem.js +1 -1
  198. package/lib-esm/SelectMenu/SelectMenuList.js +1 -1
  199. package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.js +1 -1
  200. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  201. package/lib-esm/SelectMenu/SelectMenuModal.js +2 -2
  202. package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
  203. package/lib-esm/SelectMenu/SelectMenuTabPanel.js +1 -1
  204. package/lib-esm/SelectPanel/SelectPanel.js +2 -3
  205. package/lib-esm/SideNav.js +5 -5
  206. package/lib-esm/StateLabel.js +1 -1
  207. package/lib-esm/SubNav.js +1 -1
  208. package/lib-esm/TabNav.js +2 -2
  209. package/lib-esm/TextInput.d.ts +10 -7
  210. package/lib-esm/TextInput.js +23 -29
  211. package/lib-esm/TextInputTokens.d.ts +43 -0
  212. package/lib-esm/TextInputTokens.js +200 -0
  213. package/lib-esm/TextInputWithTokens.d.ts +41 -0
  214. package/lib-esm/TextInputWithTokens.js +361 -0
  215. package/lib-esm/Timeline.d.ts +1 -0
  216. package/lib-esm/Timeline.js +17 -12
  217. package/lib-esm/Token/Token.d.ts +7 -0
  218. package/lib-esm/Token/Token.js +44 -0
  219. package/lib-esm/Token/TokenBase.d.ts +16 -0
  220. package/lib-esm/Token/TokenBase.js +56 -0
  221. package/lib-esm/Token/TokenLabel.d.ts +10 -0
  222. package/lib-esm/Token/TokenLabel.js +99 -0
  223. package/lib-esm/Token/TokenProfile.d.ts +7 -0
  224. package/lib-esm/Token/TokenProfile.js +28 -0
  225. package/lib-esm/Token/_RemoveTokenButton.d.ts +3 -0
  226. package/lib-esm/Token/_RemoveTokenButton.js +28 -0
  227. package/lib-esm/Token/_tokenButtonUtils.d.ts +9 -0
  228. package/lib-esm/Token/_tokenButtonUtils.js +26 -0
  229. package/lib-esm/Tooltip.js +1 -1
  230. package/lib-esm/UnderlineNav.js +2 -2
  231. package/lib-esm/_UnstyledTextInput.d.ts +2 -0
  232. package/lib-esm/_UnstyledTextInput.js +7 -0
  233. package/lib-esm/hooks/useOverlay.d.ts +2 -1
  234. package/lib-esm/hooks/useOverlay.js +11 -6
  235. package/lib-esm/index.d.ts +2 -3
  236. package/lib-esm/index.js +2 -3
  237. package/lib-esm/theme-preval.d.ts +6 -12
  238. package/lib-esm/theme-preval.js +0 -940
  239. package/lib-esm/utils/scrollIntoViewingArea.d.ts +1 -0
  240. package/lib-esm/utils/scrollIntoViewingArea.js +30 -0
  241. package/lib-esm/utils/testing.d.ts +0 -1854
  242. package/lib-esm/utils/types.d.ts +3 -0
  243. package/lib-esm/utils/uniqueId.js +0 -1
  244. package/package.json +13 -14
  245. package/lib/Breadcrumbs.d.ts +0 -40
  246. package/lib/utils/ssr.d.ts +0 -1
  247. package/lib/utils/ssr.js +0 -19
  248. package/lib-esm/Breadcrumbs.d.ts +0 -40
  249. package/lib-esm/utils/ssr.d.ts +0 -1
  250. package/lib-esm/utils/ssr.js +0 -1
@@ -12,3 +12,6 @@ export declare type ComponentProps<T> = T extends React.ComponentType<infer Prop
12
12
  */
13
13
  export declare type Flatten<T extends unknown> = T extends (infer U)[] ? U : never;
14
14
  export declare type AriaRole = 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'button' | 'cell' | 'checkbox' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'dialog' | 'directory' | 'document' | 'feed' | 'figure' | 'form' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox ' | 'menuitemradio' | 'navigation' | 'none' | 'note' | 'option' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'term' | 'textbox' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem';
15
+ export declare type MandateProps<T extends {}, K extends keyof T> = Omit<T, K> & {
16
+ [MK in K]-?: NonNullable<T[MK]>;
17
+ };
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.uniqueId = uniqueId;
7
- // Note: uniqueId may be unsafe in SSR contexts if it is used create DOM IDs or otherwise cause a hydration warning. Use useSSRSafeId instead.
8
7
  let idSeed = 10000;
9
8
 
10
9
  function uniqueId() {
@@ -4,7 +4,7 @@ import { get } from '../constants';
4
4
  export const StyledDivider = styled.div.withConfig({
5
5
  displayName: "Divider__StyledDivider",
6
6
  componentId: "sc-42656i-0"
7
- })(["height:1px;background:", ";margin-top:calc(", " - 1px);margin-bottom:", ";"], get('colors.border.muted'), get('space.2'), get('space.2'));
7
+ })(["height:1px;background:", ";margin-top:calc(", " - 1px);margin-bottom:", ";"], get('colors.selectMenu.borderSecondary'), get('space.2'), get('space.2'));
8
8
  /**
9
9
  * Visually separates `Item`s or `Group`s in an `ActionList`.
10
10
  */
@@ -11,9 +11,9 @@ import sx from '../sx';
11
11
  export const StyledHeader = styled.div.withConfig({
12
12
  displayName: "Header__StyledHeader",
13
13
  componentId: "qmofje-0"
14
- })(["{}padding:6px ", ";font-size:", ";font-weight:", ";color:", ";", " ", ""], get('space.3'), get('fontSizes.0'), get('fontWeights.bold'), get('colors.fg.muted'), ({
14
+ })(["{}padding:6px ", ";font-size:", ";font-weight:", ";color:", ";", " ", ""], get('space.3'), get('fontSizes.0'), get('fontWeights.bold'), get('colors.text.secondary'), ({
15
15
  variant
16
- }) => variant === 'filled' && css(["background:", ";margin:", " 0;border-top:1px solid ", ";border-bottom:1px solid ", ";&:first-child{margin-top:0;}"], get('colors.canvas.subtle'), get('space.2'), get('colors.neutral.muted'), get('colors.neutral.muted')), sx);
16
+ }) => variant === 'filled' && css(["background:", ";margin:", " 0;border-top:1px solid ", ";border-bottom:1px solid ", ";&:first-child{margin-top:0;}"], get('colors.bg.tertiary'), get('space.2'), get('colors.border.tertiary'), get('colors.border.tertiary')), sx);
17
17
  /**
18
18
  * Displays the name and description of a `Group`.
19
19
  */
@@ -2,12 +2,10 @@ import { IconProps } from '@primer/octicons-react';
2
2
  import React from 'react';
3
3
  import { SxProp } from '../sx';
4
4
  import { ItemInput } from './List';
5
- import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
6
- import { AriaRole } from '../utils/types';
7
5
  /**
8
6
  * Contract for props passed to the `Item` component.
9
7
  */
10
- export interface ItemProps extends SxProp {
8
+ export interface ItemProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'id'>, SxProp {
11
9
  /**
12
10
  * Primary text which names an `Item`.
13
11
  */
@@ -70,18 +68,6 @@ export interface ItemProps extends SxProp {
70
68
  * An id associated with this item. Should be unique between items
71
69
  */
72
70
  id?: number | string;
73
- /**
74
- * Node to be included inside the item before the text.
75
- */
76
- children?: React.ReactNode;
77
- /**
78
- * The ARIA role describing the function of `List` component. `option` is a common value.
79
- */
80
- role?: AriaRole;
81
- /**
82
- * An item to pass back in the `onAction` callback, meant as
83
- */
84
- item?: ItemInput;
85
71
  }
86
72
  export declare const TextContainer: import("styled-components").StyledComponent<"span", any, {
87
73
  dangerouslySetInnerHtml?: React.DOMAttributes<HTMLDivElement>['dangerouslySetInnerHTML'];
@@ -89,5 +75,6 @@ export declare const TextContainer: import("styled-components").StyledComponent<
89
75
  /**
90
76
  * An actionable or selectable `Item` with an optional icon and description.
91
77
  */
92
- declare const Item: PolymorphicForwardRefComponent<"div", ItemProps>;
93
- export { Item };
78
+ export declare function Item(itemProps: Partial<ItemProps> & {
79
+ item?: ItemInput;
80
+ }): JSX.Element;
@@ -1,7 +1,7 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import { CheckIcon } from '@primer/octicons-react';
4
- import React, { useCallback } from 'react';
4
+ import React, { useCallback, useMemo } from 'react';
5
5
  import { get } from '../constants';
6
6
  import sx from '../sx';
7
7
  import Truncate from '../Truncate';
@@ -10,11 +10,11 @@ import { StyledHeader } from './Header';
10
10
  import { StyledDivider } from './Divider';
11
11
  import { useColorSchemeVar, useTheme } from '../ThemeProvider';
12
12
  import { activeDescendantActivatedDirectly, activeDescendantActivatedIndirectly, isActiveDescendantAttribute } from '../behaviors/focusZone';
13
- import { useSSRSafeId } from '@react-aria/ssr';
14
-
13
+ import { uniqueId } from '../utils/uniqueId';
15
14
  /**
16
15
  * These colors are not yet in our default theme. Need to remove this once they are added.
17
16
  */
17
+
18
18
  const customItemThemes = {
19
19
  default: {
20
20
  hover: {
@@ -48,9 +48,9 @@ const customItemThemes = {
48
48
  const getItemVariant = (variant = 'default', disabled) => {
49
49
  if (disabled) {
50
50
  return {
51
- color: get('colors.fg.muted'),
52
- iconColor: get('colors.fg.muted'),
53
- annotationColor: get('colors.fg.muted'),
51
+ color: get('colors.text.disabled'),
52
+ iconColor: get('colors.text.disabled'),
53
+ annotationColor: get('colors.text.disabled'),
54
54
  hoverCursor: 'default'
55
55
  };
56
56
  }
@@ -58,17 +58,17 @@ const getItemVariant = (variant = 'default', disabled) => {
58
58
  switch (variant) {
59
59
  case 'danger':
60
60
  return {
61
- color: get('colors.danger.fg'),
62
- iconColor: get('colors.danger.fg'),
63
- annotationColor: get('colors.fg.muted'),
61
+ color: get('colors.text.danger'),
62
+ iconColor: get('colors.icon.danger'),
63
+ annotationColor: get('colors.text.disabled'),
64
64
  hoverCursor: 'pointer'
65
65
  };
66
66
 
67
67
  default:
68
68
  return {
69
69
  color: 'inherit',
70
- iconColor: get('colors.fg.muted'),
71
- annotationColor: get('colors.fg.muted'),
70
+ iconColor: get('colors.text.secondary'),
71
+ annotationColor: get('colors.text.secondary'),
72
72
  hoverCursor: 'pointer'
73
73
  };
74
74
  }
@@ -85,7 +85,7 @@ const MainContent = styled.div.withConfig({
85
85
  const StyledItem = styled.div.withConfig({
86
86
  displayName: "Item__StyledItem",
87
87
  componentId: "jqpvy8-2"
88
- })(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;text-decoration:none;@media (hover:hover) and (pointer:fine){:hover{background:var(--item-hover-bg-override,", ");cursor:", ";}}:not(:first-of-type):not(", " + &):not(", " + &){margin-top:", ";", "::before{content:' ';display:block;position:absolute;width:100%;top:-7px;border:0 solid ", ";border-top-width:", ";}}&:hover ", "::before,:hover + * ", "::before{border-color:var(--item-hover-divider-border-color-override,transparent) !important;}&:focus ", "::before,:focus + * ", "::before,&[", "] ", "::before,[", "] + & ", "::before{border-color:transparent !important;}&[", "='", "']{background:", ";}&[", "='", "']{background:", ";}&:focus{background:", ";outline:none;}&:active{background:", ";}", ""], get('space.2'), get('radii.2'), ({
88
+ })(["padding:6px ", ";display:flex;border-radius:", ";color:", ";transition:background 33.333ms linear;@media (hover:hover) and (pointer:fine){:hover{background:var(--item-hover-bg-override,", ");cursor:", ";}}:not(:first-of-type):not(", " + &):not(", " + &){margin-top:", ";", "::before{content:' ';display:block;position:absolute;width:100%;top:-7px;border:0 solid ", ";border-top-width:", ";}}&:hover ", "::before,:hover + * ", "::before{border-color:var(--item-hover-divider-border-color-override,transparent) !important;}&:focus ", "::before,:focus + * ", "::before,&[", "] ", "::before,[", "] + & ", "::before{border-color:transparent !important;}&[", "='", "']{background:", ";}&[", "='", "']{background:", ";}&:focus{background:", ";outline:none;}&:active{background:", ";}", ""], get('space.2'), get('radii.2'), ({
89
89
  variant,
90
90
  item
91
91
  }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).color, ({
@@ -95,7 +95,7 @@ const StyledItem = styled.div.withConfig({
95
95
  item
96
96
  }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).hoverCursor, StyledDivider, StyledHeader, ({
97
97
  showDivider
98
- }) => showDivider ? `1px` : '0', DividedContent, get('colors.border.muted'), ({
98
+ }) => showDivider ? `1px` : '0', DividedContent, get('colors.selectMenu.borderSecondary'), ({
99
99
  showDivider
100
100
  }) => showDivider ? `1px` : '0', DividedContent, DividedContent, DividedContent, DividedContent, isActiveDescendantAttribute, DividedContent, isActiveDescendantAttribute, DividedContent, isActiveDescendantAttribute, activeDescendantActivatedDirectly, ({
101
101
  focusBackground
@@ -135,7 +135,7 @@ const TrailingContent = styled(ColoredVisualContainer).withConfig({
135
135
  const DescriptionContainer = styled.span.withConfig({
136
136
  displayName: "Item__DescriptionContainer",
137
137
  componentId: "jqpvy8-8"
138
- })(["color:", ";font-size:", ";line-height:16px;margin-left:var(--description-container-margin-left);min-width:0;flex-grow:1;flex-basis:var(--description-container-flex-basis);"], get('colors.fg.muted'), get('fontSizes.0'));
138
+ })(["color:", ";font-size:", ";line-height:16px;margin-left:var(--description-container-margin-left);min-width:0;flex-grow:1;flex-basis:var(--description-container-flex-basis);"], get('colors.text.secondary'), get('fontSizes.0'));
139
139
  const MultiSelectInput = styled.input.withConfig({
140
140
  displayName: "Item__MultiSelectInput",
141
141
  componentId: "jqpvy8-9"
@@ -144,9 +144,8 @@ const MultiSelectInput = styled.input.withConfig({
144
144
  * An actionable or selectable `Item` with an optional icon and description.
145
145
  */
146
146
 
147
- const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
147
+ export function Item(itemProps) {
148
148
  const {
149
- as: Component,
150
149
  text,
151
150
  description,
152
151
  descriptionVariant = 'inline',
@@ -165,8 +164,8 @@ const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
165
164
  id,
166
165
  ...props
167
166
  } = itemProps;
168
- const labelId = useSSRSafeId();
169
- const descriptionId = useSSRSafeId();
167
+ const labelId = useMemo(() => uniqueId(), []);
168
+ const descriptionId = useMemo(() => uniqueId(), []);
170
169
  const keyPressHandler = useCallback(event => {
171
170
  if (disabled) {
172
171
  return;
@@ -202,8 +201,6 @@ const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
202
201
  theme
203
202
  } = useTheme();
204
203
  return /*#__PURE__*/React.createElement(StyledItem, _extends({
205
- ref: ref,
206
- as: Component,
207
204
  tabIndex: disabled ? undefined : -1,
208
205
  variant: variant,
209
206
  showDivider: showDivider,
@@ -249,5 +246,5 @@ const Item = /*#__PURE__*/React.forwardRef((itemProps, ref) => {
249
246
  variant: variant,
250
247
  disabled: disabled
251
248
  }, trailingText, TrailingIcon && /*#__PURE__*/React.createElement(TrailingIcon, null)) : null));
252
- });
253
- export { Item };
249
+ }
250
+ Item.displayName = "Item";
@@ -1,12 +1,9 @@
1
- import React, { Key } from 'react';
1
+ import React from 'react';
2
2
  import type { AriaRole } from '../utils/types';
3
3
  import { Group, GroupProps } from './Group';
4
- import { ItemProps } from './Item';
5
- declare type RenderItemFn = (props: ItemProps) => React.ReactElement;
6
- export declare type ItemInput = ItemProps | ((Partial<ItemProps> & {
7
- renderItem: RenderItemFn;
8
- }) & {
9
- key?: Key;
4
+ import { Item, ItemProps } from './Item';
5
+ export declare type ItemInput = ItemProps | (Partial<ItemProps> & {
6
+ renderItem: typeof Item;
10
7
  });
11
8
  /**
12
9
  * Contract for props passed to the `List` component.
@@ -29,7 +26,7 @@ export interface ListPropsBase {
29
26
  * without a `Group`-level or `Item`-level custom `Item` renderer will be
30
27
  * rendered using this function component.
31
28
  */
32
- renderItem?: RenderItemFn;
29
+ renderItem?: typeof Item;
33
30
  /**
34
31
  * A `List`-level custom `Group` renderer. Every `Group` within this `List`
35
32
  * without a `Group`-level custom `Item` renderer will be rendered using
@@ -61,7 +58,7 @@ export interface GroupedListProps extends ListPropsBase {
61
58
  * and `Group`-level custom `Item` or `Group` renderers.
62
59
  */
63
60
  groupMetadata: ((Omit<GroupProps, 'items'> | Omit<Partial<GroupProps> & {
64
- renderItem?: RenderItemFn;
61
+ renderItem?: typeof Item;
65
62
  renderGroup?: typeof Group;
66
63
  }, 'items'>) & {
67
64
  groupId: string;
@@ -71,7 +68,7 @@ export interface GroupedListProps extends ListPropsBase {
71
68
  * and `Item`-level custom `Item` renderers.
72
69
  */
73
70
  items: ((ItemProps | (Partial<ItemProps> & {
74
- renderItem: RenderItemFn;
71
+ renderItem: typeof Item;
75
72
  })) & {
76
73
  groupId: string;
77
74
  })[];
@@ -84,4 +81,3 @@ export declare type ListProps = ListPropsBase | GroupedListProps;
84
81
  * Lists `Item`s, either grouped or ungrouped, with a `Divider` between each `Group`.
85
82
  */
86
83
  export declare const List: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<HTMLDivElement>>;
87
- export {};
@@ -23,7 +23,7 @@ function isGroupedListProps(props) {
23
23
  const StyledList = styled.div.withConfig({
24
24
  displayName: "List__StyledList",
25
25
  componentId: "yr2k7d-0"
26
- })(["font-size:", ";line-height:20px;&[", "],&:focus-within{--item-hover-bg-override:none;--item-hover-divider-border-color-override:", ";}"], get('fontSizes.1'), hasActiveDescendantAttribute, get('colors.border.muted'));
26
+ })(["font-size:", ";line-height:20px;&[", "],&:focus-within{--item-hover-bg-override:none;--item-hover-divider-border-color-override:", ";}"], get('fontSizes.1'), hasActiveDescendantAttribute, get('colors.selectMenu.borderSecondary'));
27
27
  /**
28
28
  * Returns `sx` prop values for `List` children matching the given `List` style variation.
29
29
  * @param variant `List` style variation.
@@ -90,11 +90,11 @@ export const List = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
90
90
 
91
91
 
92
92
  const renderItem = (itemProps, item, itemIndex) => {
93
- var _ref2, _ref3, _itemProps$id;
93
+ var _ref2, _itemProps$key, _itemProps$id;
94
94
 
95
95
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
96
96
  const ItemComponent = 'renderItem' in itemProps && itemProps.renderItem || props.renderItem || Item;
97
- const key = (_ref2 = (_ref3 = 'key' in itemProps ? itemProps.key : undefined) !== null && _ref3 !== void 0 ? _ref3 : (_itemProps$id = itemProps.id) === null || _itemProps$id === void 0 ? void 0 : _itemProps$id.toString()) !== null && _ref2 !== void 0 ? _ref2 : itemIndex.toString();
97
+ const key = (_ref2 = (_itemProps$key = itemProps.key) !== null && _itemProps$key !== void 0 ? _itemProps$key : (_itemProps$id = itemProps.id) === null || _itemProps$id === void 0 ? void 0 : _itemProps$id.toString()) !== null && _ref2 !== void 0 ? _ref2 : itemIndex.toString();
98
98
  return /*#__PURE__*/React.createElement(ItemComponent, _extends({
99
99
  showDivider: props.showItemDividers,
100
100
  selectionVariant: props.selectionVariant
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { Group } from './Group';
3
+ import { Item } from './Item';
3
4
  import { Divider } from './Divider';
4
5
  export type { ListProps as ActionListProps } from './List';
5
6
  export type { GroupProps } from './Group';
@@ -11,7 +12,7 @@ export declare const ActionList: import("react").ForwardRefExoticComponent<impor
11
12
  /** Collects related `Items` in an `ActionList`. */
12
13
  Group: typeof Group;
13
14
  /** An actionable or selectable `Item` with an optional icon and description. */
14
- Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"div", import("./Item").ItemProps>;
15
+ Item: typeof Item;
15
16
  /** Visually separates `Item`s or `Group`s in an `ActionList`. */
16
17
  Divider: typeof Divider;
17
18
  };
@@ -1,11 +1,11 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React, { useCallback, useEffect } from 'react';
3
+ import React, { useCallback, useEffect, useMemo } from 'react';
4
4
  import Overlay from '../Overlay';
5
5
  import { useFocusTrap } from '../hooks/useFocusTrap';
6
6
  import { useFocusZone } from '../hooks/useFocusZone';
7
7
  import { useAnchoredPosition, useProvidedRefOrCreate, useRenderForcingRef } from '../hooks';
8
- import { useSSRSafeId } from '@react-aria/ssr';
8
+ import { uniqueId } from '../utils/uniqueId';
9
9
 
10
10
  /**
11
11
  * An `AnchoredOverlay` provides an anchor that will open a floating overlay positioned relative to the anchor.
@@ -26,7 +26,7 @@ export const AnchoredOverlay = ({
26
26
  }) => {
27
27
  const anchorRef = useProvidedRefOrCreate(externalAnchorRef);
28
28
  const [overlayRef, updateOverlayRef] = useRenderForcingRef();
29
- const anchorId = useSSRSafeId();
29
+ const anchorId = useMemo(uniqueId, []);
30
30
  const onClickOutside = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose('click-outside'), [onClose]);
31
31
  const onEscape = useCallback(() => onClose === null || onClose === void 0 ? void 0 : onClose('escape'), [onClose]);
32
32
  const onAnchorKeyDown = useCallback(event => {
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { ComponentProps } from '../utils/types';
3
+ import AutocompleteMenu from './AutocompleteMenu';
4
+ declare const Autocomplete: React.FC;
5
+ export declare type AutocompleteProps = ComponentProps<typeof Autocomplete>;
6
+ export type { AutocompleteInputProps } from './AutocompleteInput';
7
+ export type { AutocompleteMenuProps } from './AutocompleteMenu';
8
+ declare const _default: React.FC<{}> & {
9
+ AutocompleteContext: React.Context<{
10
+ activeDescendantRef?: React.MutableRefObject<HTMLElement | null> | undefined;
11
+ autocompleteSuggestion?: string | undefined;
12
+ inputRef?: React.MutableRefObject<HTMLInputElement | null> | undefined;
13
+ inputValue?: string | undefined;
14
+ showMenu?: boolean | undefined;
15
+ setAutocompleteSuggestion?: React.Dispatch<React.SetStateAction<string>> | undefined;
16
+ setShowMenu?: React.Dispatch<React.SetStateAction<boolean>> | undefined;
17
+ setInputValue?: React.Dispatch<React.SetStateAction<string>> | undefined;
18
+ isMenuDirectlyActivated?: boolean | undefined;
19
+ setIsMenuDirectlyActivated?: React.Dispatch<React.SetStateAction<boolean>> | undefined;
20
+ }>;
21
+ Input: import("@radix-ui/react-polymorphic").ForwardRefComponent<"input", {
22
+ as?: React.ComponentType<any> | undefined;
23
+ }>;
24
+ Menu: typeof AutocompleteMenu;
25
+ };
26
+ export default _default;
@@ -0,0 +1,36 @@
1
+ import React, { useRef, useState } from 'react';
2
+ import { AutocompleteContext } from './AutocompleteContext';
3
+ import AutocompleteInput from './AutocompleteInput';
4
+ import AutocompleteMenu from './AutocompleteMenu';
5
+
6
+ const Autocomplete = ({
7
+ children
8
+ }) => {
9
+ const activeDescendantRef = useRef(null);
10
+ const inputRef = useRef(null);
11
+ const [inputValue, setInputValue] = useState('');
12
+ const [showMenu, setShowMenu] = useState(false);
13
+ const [autocompleteSuggestion, setAutocompleteSuggestion] = useState('');
14
+ const [isMenuDirectlyActivated, setIsMenuDirectlyActivated] = useState(false);
15
+ return /*#__PURE__*/React.createElement(AutocompleteContext.Provider, {
16
+ value: {
17
+ activeDescendantRef,
18
+ autocompleteSuggestion,
19
+ inputRef,
20
+ inputValue,
21
+ isMenuDirectlyActivated,
22
+ setAutocompleteSuggestion,
23
+ setInputValue,
24
+ setIsMenuDirectlyActivated,
25
+ setShowMenu,
26
+ showMenu
27
+ }
28
+ }, children);
29
+ };
30
+
31
+ Autocomplete.displayName = "Autocomplete";
32
+ export default Object.assign(Autocomplete, {
33
+ AutocompleteContext,
34
+ Input: AutocompleteInput,
35
+ Menu: AutocompleteMenu
36
+ });
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export declare const AutocompleteContext: import("react").Context<{
3
+ activeDescendantRef?: import("react").MutableRefObject<HTMLElement | null> | undefined;
4
+ autocompleteSuggestion?: string | undefined;
5
+ inputRef?: import("react").MutableRefObject<HTMLInputElement | null> | undefined;
6
+ inputValue?: string | undefined;
7
+ showMenu?: boolean | undefined;
8
+ setAutocompleteSuggestion?: import("react").Dispatch<import("react").SetStateAction<string>> | undefined;
9
+ setShowMenu?: import("react").Dispatch<import("react").SetStateAction<boolean>> | undefined;
10
+ setInputValue?: import("react").Dispatch<import("react").SetStateAction<string>> | undefined;
11
+ isMenuDirectlyActivated?: boolean | undefined;
12
+ setIsMenuDirectlyActivated?: import("react").Dispatch<import("react").SetStateAction<boolean>> | undefined;
13
+ }>;
@@ -0,0 +1,6 @@
1
+ import { createContext } from 'react'; // TODO:
2
+ // - figure out how we can make all of these properties required without having to define them when calling `createContext`
3
+ // - figure out how we can reduce the number of properties that need to be passed
4
+ // COLEHELP
5
+
6
+ export const AutocompleteContext = /*#__PURE__*/createContext({});
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type * as Polymorphic from "@radix-ui/react-polymorphic";
3
+ import { ComponentProps } from '../utils/types';
4
+ declare type InternalAutocompleteInputProps = {
5
+ as?: React.ComponentType<any>;
6
+ };
7
+ declare const AutocompleteInput: Polymorphic.ForwardRefComponent<"input", InternalAutocompleteInputProps>;
8
+ export declare type AutocompleteInputProps = ComponentProps<typeof AutocompleteInput>;
9
+ export default AutocompleteInput;
@@ -0,0 +1,120 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React, { useCallback, useContext, useEffect, useState } from 'react';
4
+ import { AutocompleteContext } from './AutocompleteContext';
5
+ import TextInput from '../TextInput';
6
+ import { useCombinedRefs } from '../hooks/useCombinedRefs';
7
+ const AutocompleteInput = /*#__PURE__*/React.forwardRef(({
8
+ as: Component = TextInput,
9
+ onFocus,
10
+ onBlur,
11
+ onChange,
12
+ onKeyDown,
13
+ onKeyPress,
14
+ value,
15
+ ...props
16
+ }, forwardedRef) => {
17
+ const {
18
+ activeDescendantRef,
19
+ autocompleteSuggestion = '',
20
+ inputRef,
21
+ inputValue = '',
22
+ isMenuDirectlyActivated,
23
+ setInputValue,
24
+ setShowMenu,
25
+ showMenu
26
+ } = useContext(AutocompleteContext);
27
+ const combinedInputRef = useCombinedRefs(inputRef, forwardedRef);
28
+ const [highlightRemainingText, setHighlightRemainingText] = useState(true);
29
+
30
+ const handleInputFocus = e => {
31
+ onFocus && onFocus(e);
32
+ setShowMenu && setShowMenu(true);
33
+ };
34
+
35
+ const handleInputBlur = e => {
36
+ onBlur && onBlur(e); // HACK: wait a tick and check the focused element before hiding the autocomplete menu
37
+ // this prevents the menu from hiding when the user is clicking an option in the Autoselect.Menu,
38
+ // but still hides the menu when the user blurs the input by tabbing out or clicking somewhere else on the page
39
+ // COLEHELP
40
+
41
+ setTimeout(() => {
42
+ if (setShowMenu && document.activeElement !== combinedInputRef.current) {
43
+ setShowMenu(false);
44
+ }
45
+ }, 0);
46
+ };
47
+
48
+ const handleInputChange = e => {
49
+ if (onChange) {
50
+ onChange(e);
51
+ }
52
+
53
+ if (setInputValue) {
54
+ setInputValue(e.currentTarget.value);
55
+ }
56
+
57
+ if (setShowMenu && !showMenu) {
58
+ setShowMenu(true);
59
+ }
60
+ };
61
+
62
+ const handleInputKeyDown = e => {
63
+ if (e.key === 'Backspace') {
64
+ setHighlightRemainingText(false);
65
+ }
66
+ };
67
+
68
+ const handleInputKeyUp = e => {
69
+ if (e.key === 'Backspace') {
70
+ setHighlightRemainingText(true);
71
+ }
72
+ };
73
+
74
+ const onInputKeyPress = useCallback(event => {
75
+ if (activeDescendantRef && event.key === 'Enter' && activeDescendantRef.current) {
76
+ event.preventDefault();
77
+ event.nativeEvent.stopImmediatePropagation(); // Forward Enter key press to active descendant so that item gets activated
78
+
79
+ const activeDescendantEvent = new KeyboardEvent(event.type, event.nativeEvent);
80
+ activeDescendantRef.current.dispatchEvent(activeDescendantEvent);
81
+ }
82
+ }, [activeDescendantRef]);
83
+ useEffect(() => {
84
+ if (!(inputRef !== null && inputRef !== void 0 && inputRef.current)) {
85
+ return;
86
+ } // resets input value to being empty after a selection has been made
87
+
88
+
89
+ if (!autocompleteSuggestion) {
90
+ inputRef.current.value = inputValue;
91
+ } // TODO: fix bug where this function prevents `onChange` from being triggered if the highlighted item text
92
+ // is the same as what I'm typing
93
+ // e.g.: typing 'tw' highights 'two', but when I 'two', the text input change does not get triggered
94
+ // COLEHELP
95
+
96
+
97
+ if (highlightRemainingText && autocompleteSuggestion && (inputValue || isMenuDirectlyActivated)) {
98
+ inputRef.current.value = autocompleteSuggestion;
99
+
100
+ if (autocompleteSuggestion.toLowerCase().indexOf(inputValue.toLowerCase()) === 0) {
101
+ inputRef.current.setSelectionRange(inputValue.length, autocompleteSuggestion.length);
102
+ }
103
+ }
104
+ }, [autocompleteSuggestion, inputValue]);
105
+ useEffect(() => {
106
+ if (value && setInputValue) {
107
+ setInputValue(value.toString());
108
+ }
109
+ }, [value]);
110
+ return /*#__PURE__*/React.createElement(Component, _extends({
111
+ onFocus: handleInputFocus,
112
+ onBlur: handleInputBlur,
113
+ onChange: handleInputChange,
114
+ onKeyDown: handleInputKeyDown,
115
+ onKeyPress: onInputKeyPress,
116
+ onKeyUp: handleInputKeyUp,
117
+ ref: combinedInputRef
118
+ }, props));
119
+ });
120
+ export default AutocompleteInput;
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import { ItemProps } from '../ActionList';
3
+ import { OverlayProps } from '../Overlay';
4
+ import { ComponentProps, MandateProps } from '../utils/types';
5
+ declare type OnAction<T> = (item: T, event: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
6
+ declare type AutocompleteMenuInternalProps<T extends MandateProps<ItemProps, 'id'>> = {
7
+ /**
8
+ * A menu item that is used to allow users make a selection that is not available in the array passed to the `items` prop.
9
+ * This menu item gets appended to the end of the list of options.
10
+ */
11
+ addNewItem?: Omit<T, 'onAction' | 'leadingVisual' | 'id'> & {
12
+ handleAddItem: (item: Omit<T, 'onAction' | 'leadingVisual'>) => void;
13
+ };
14
+ /**
15
+ * The text that appears in the menu when there are no options in the array passed to the `items` prop.
16
+ */
17
+ emptyStateText?: React.ReactNode | false;
18
+ /**
19
+ * A custom function used to filter the options in the array passed to the `items` prop.
20
+ * By default, we filter out items that don't match the value of the autocomplete text input. The default filter is not case-sensitive.
21
+ */
22
+ filterFn?: (item: T, i: number) => boolean;
23
+ /**
24
+ * The options for field values that are displayed in the dropdown menu.
25
+ * One or more may be selected depending on the value of the `selectionVariant` prop.
26
+ */
27
+ items: T[];
28
+ /**
29
+ * The function that is called when an item in the list is de-selected
30
+ */
31
+ onItemDeselect?: OnAction<T>;
32
+ /**
33
+ * The function that is called when an item in the list is selected
34
+ */
35
+ onItemSelect?: OnAction<T>;
36
+ /**
37
+ * Whether the data is loaded for the menu items
38
+ */
39
+ loading?: boolean;
40
+ /**
41
+ * The IDs of the selected items
42
+ */
43
+ selectedItemIds: Array<string | number>;
44
+ /**
45
+ * The sort function that is applied to the options in the array passed to the `items` prop after the user closes the menu.
46
+ * By default, selected items are sorted to the top after the user closes the menu.
47
+ */
48
+ selectedSortFn?: (itemIdA: string | number, itemIdB: string | number) => number;
49
+ /**
50
+ * Whether there can be one item selected from the menu or multiple items selected from the menu
51
+ */
52
+ selectionVariant?: 'single' | 'multiple';
53
+ /**
54
+ * The ref of the element that the position of the menu is based on. By default, the menu is positioned based on the text input
55
+ */
56
+ menuAnchorRef?: React.RefObject<Element>;
57
+ };
58
+ declare function AutocompleteMenu<T extends MandateProps<ItemProps, 'id'>>(props: AutocompleteMenuInternalProps<T> & Pick<OverlayProps, 'width' | 'height' | 'maxHeight'>): JSX.Element;
59
+ declare namespace AutocompleteMenu {
60
+ var defaultProps: {
61
+ emptyStateText: string;
62
+ selectionVariant: string;
63
+ };
64
+ var displayName: string;
65
+ }
66
+ export declare type AutocompleteMenuProps = ComponentProps<typeof AutocompleteMenu>;
67
+ export default AutocompleteMenu;