@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
@@ -17,7 +17,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
  const StyledDivider = _styledComponents.default.div.withConfig({
18
18
  displayName: "Divider__StyledDivider",
19
19
  componentId: "sc-42656i-0"
20
- })(["height:1px;background:", ";margin-top:calc(", " - 1px);margin-bottom:", ";"], (0, _constants.get)('colors.border.muted'), (0, _constants.get)('space.2'), (0, _constants.get)('space.2'));
20
+ })(["height:1px;background:", ";margin-top:calc(", " - 1px);margin-bottom:", ";"], (0, _constants.get)('colors.selectMenu.borderSecondary'), (0, _constants.get)('space.2'), (0, _constants.get)('space.2'));
21
21
  /**
22
22
  * Visually separates `Item`s or `Group`s in an `ActionList`.
23
23
  */
@@ -25,9 +25,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
25
25
  const StyledHeader = _styledComponents.default.div.withConfig({
26
26
  displayName: "Header__StyledHeader",
27
27
  componentId: "qmofje-0"
28
- })(["{}padding:6px ", ";font-size:", ";font-weight:", ";color:", ";", " ", ""], (0, _constants.get)('space.3'), (0, _constants.get)('fontSizes.0'), (0, _constants.get)('fontWeights.bold'), (0, _constants.get)('colors.fg.muted'), ({
28
+ })(["{}padding:6px ", ";font-size:", ";font-weight:", ";color:", ";", " ", ""], (0, _constants.get)('space.3'), (0, _constants.get)('fontSizes.0'), (0, _constants.get)('fontWeights.bold'), (0, _constants.get)('colors.text.secondary'), ({
29
29
  variant
30
- }) => variant === 'filled' && (0, _styledComponents.css)(["background:", ";margin:", " 0;border-top:1px solid ", ";border-bottom:1px solid ", ";&:first-child{margin-top:0;}"], (0, _constants.get)('colors.canvas.subtle'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.neutral.muted'), (0, _constants.get)('colors.neutral.muted')), _sx.default);
30
+ }) => variant === 'filled' && (0, _styledComponents.css)(["background:", ";margin:", " 0;border-top:1px solid ", ";border-bottom:1px solid ", ";&:first-child{margin-top:0;}"], (0, _constants.get)('colors.bg.tertiary'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.border.tertiary'), (0, _constants.get)('colors.border.tertiary')), _sx.default);
31
31
  /**
32
32
  * Displays the name and description of a `Group`.
33
33
  */
@@ -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;
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Item = exports.TextContainer = void 0;
6
+ exports.Item = Item;
7
+ exports.TextContainer = void 0;
7
8
 
8
9
  var _octiconsReact = require("@primer/octicons-react");
9
10
 
@@ -25,7 +26,7 @@ var _ThemeProvider = require("../ThemeProvider");
25
26
 
26
27
  var _focusZone = require("../behaviors/focusZone");
27
28
 
28
- var _ssr = require("@react-aria/ssr");
29
+ var _uniqueId = require("../utils/uniqueId");
29
30
 
30
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
32
 
@@ -71,9 +72,9 @@ const customItemThemes = {
71
72
  const getItemVariant = (variant = 'default', disabled) => {
72
73
  if (disabled) {
73
74
  return {
74
- color: (0, _constants.get)('colors.fg.muted'),
75
- iconColor: (0, _constants.get)('colors.fg.muted'),
76
- annotationColor: (0, _constants.get)('colors.fg.muted'),
75
+ color: (0, _constants.get)('colors.text.disabled'),
76
+ iconColor: (0, _constants.get)('colors.text.disabled'),
77
+ annotationColor: (0, _constants.get)('colors.text.disabled'),
77
78
  hoverCursor: 'default'
78
79
  };
79
80
  }
@@ -81,17 +82,17 @@ const getItemVariant = (variant = 'default', disabled) => {
81
82
  switch (variant) {
82
83
  case 'danger':
83
84
  return {
84
- color: (0, _constants.get)('colors.danger.fg'),
85
- iconColor: (0, _constants.get)('colors.danger.fg'),
86
- annotationColor: (0, _constants.get)('colors.fg.muted'),
85
+ color: (0, _constants.get)('colors.text.danger'),
86
+ iconColor: (0, _constants.get)('colors.icon.danger'),
87
+ annotationColor: (0, _constants.get)('colors.text.disabled'),
87
88
  hoverCursor: 'pointer'
88
89
  };
89
90
 
90
91
  default:
91
92
  return {
92
93
  color: 'inherit',
93
- iconColor: (0, _constants.get)('colors.fg.muted'),
94
- annotationColor: (0, _constants.get)('colors.fg.muted'),
94
+ iconColor: (0, _constants.get)('colors.text.secondary'),
95
+ annotationColor: (0, _constants.get)('colors.text.secondary'),
95
96
  hoverCursor: 'pointer'
96
97
  };
97
98
  }
@@ -110,7 +111,7 @@ const MainContent = _styledComponents.default.div.withConfig({
110
111
  const StyledItem = _styledComponents.default.div.withConfig({
111
112
  displayName: "Item__StyledItem",
112
113
  componentId: "jqpvy8-2"
113
- })(["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:", ";}", ""], (0, _constants.get)('space.2'), (0, _constants.get)('radii.2'), ({
114
+ })(["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:", ";}", ""], (0, _constants.get)('space.2'), (0, _constants.get)('radii.2'), ({
114
115
  variant,
115
116
  item
116
117
  }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).color, ({
@@ -120,7 +121,7 @@ const StyledItem = _styledComponents.default.div.withConfig({
120
121
  item
121
122
  }) => getItemVariant(variant, item === null || item === void 0 ? void 0 : item.disabled).hoverCursor, _Divider.StyledDivider, _Header.StyledHeader, ({
122
123
  showDivider
123
- }) => showDivider ? `1px` : '0', DividedContent, (0, _constants.get)('colors.border.muted'), ({
124
+ }) => showDivider ? `1px` : '0', DividedContent, (0, _constants.get)('colors.selectMenu.borderSecondary'), ({
124
125
  showDivider
125
126
  }) => showDivider ? `1px` : '0', DividedContent, DividedContent, DividedContent, DividedContent, _focusZone.isActiveDescendantAttribute, DividedContent, _focusZone.isActiveDescendantAttribute, DividedContent, _focusZone.isActiveDescendantAttribute, _focusZone.activeDescendantActivatedDirectly, ({
126
127
  focusBackground
@@ -166,7 +167,7 @@ const TrailingContent = (0, _styledComponents.default)(ColoredVisualContainer).w
166
167
  const DescriptionContainer = _styledComponents.default.span.withConfig({
167
168
  displayName: "Item__DescriptionContainer",
168
169
  componentId: "jqpvy8-8"
169
- })(["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);"], (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('fontSizes.0'));
170
+ })(["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);"], (0, _constants.get)('colors.text.secondary'), (0, _constants.get)('fontSizes.0'));
170
171
 
171
172
  const MultiSelectInput = _styledComponents.default.input.withConfig({
172
173
  displayName: "Item__MultiSelectInput",
@@ -177,9 +178,8 @@ const MultiSelectInput = _styledComponents.default.input.withConfig({
177
178
  */
178
179
 
179
180
 
180
- const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
181
+ function Item(itemProps) {
181
182
  const {
182
- as: Component,
183
183
  text,
184
184
  description,
185
185
  descriptionVariant = 'inline',
@@ -198,8 +198,8 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
198
198
  id,
199
199
  ...props
200
200
  } = itemProps;
201
- const labelId = (0, _ssr.useSSRSafeId)();
202
- const descriptionId = (0, _ssr.useSSRSafeId)();
201
+ const labelId = (0, _react.useMemo)(() => (0, _uniqueId.uniqueId)(), []);
202
+ const descriptionId = (0, _react.useMemo)(() => (0, _uniqueId.uniqueId)(), []);
203
203
  const keyPressHandler = (0, _react.useCallback)(event => {
204
204
  if (disabled) {
205
205
  return;
@@ -235,8 +235,6 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
235
235
  theme
236
236
  } = (0, _ThemeProvider.useTheme)();
237
237
  return /*#__PURE__*/_react.default.createElement(StyledItem, _extends({
238
- ref: ref,
239
- as: Component,
240
238
  tabIndex: disabled ? undefined : -1,
241
239
  variant: variant,
242
240
  showDivider: showDivider,
@@ -282,6 +280,6 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
282
280
  variant: variant,
283
281
  disabled: disabled
284
282
  }, trailingText, TrailingIcon && /*#__PURE__*/_react.default.createElement(TrailingIcon, null)) : null));
285
- });
283
+ }
286
284
 
287
- exports.Item = Item;
285
+ 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 {};
@@ -38,7 +38,7 @@ function isGroupedListProps(props) {
38
38
  const StyledList = _styledComponents.default.div.withConfig({
39
39
  displayName: "List__StyledList",
40
40
  componentId: "yr2k7d-0"
41
- })(["font-size:", ";line-height:20px;&[", "],&:focus-within{--item-hover-bg-override:none;--item-hover-divider-border-color-override:", ";}"], (0, _constants.get)('fontSizes.1'), _focusZone.hasActiveDescendantAttribute, (0, _constants.get)('colors.border.muted'));
41
+ })(["font-size:", ";line-height:20px;&[", "],&:focus-within{--item-hover-bg-override:none;--item-hover-divider-border-color-override:", ";}"], (0, _constants.get)('fontSizes.1'), _focusZone.hasActiveDescendantAttribute, (0, _constants.get)('colors.selectMenu.borderSecondary'));
42
42
  /**
43
43
  * Returns `sx` prop values for `List` children matching the given `List` style variation.
44
44
  * @param variant `List` style variation.
@@ -106,11 +106,11 @@ const List = /*#__PURE__*/_react.default.forwardRef((props, forwardedRef) => {
106
106
 
107
107
 
108
108
  const renderItem = (itemProps, item, itemIndex) => {
109
- var _ref2, _ref3, _itemProps$id;
109
+ var _ref2, _itemProps$key, _itemProps$id;
110
110
 
111
111
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
112
112
  const ItemComponent = 'renderItem' in itemProps && itemProps.renderItem || props.renderItem || _Item.Item;
113
- 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();
113
+ 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();
114
114
  return /*#__PURE__*/_react.default.createElement(ItemComponent, _extends({
115
115
  showDivider: props.showItemDividers,
116
116
  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
  };
@@ -15,7 +15,7 @@ var _useFocusZone = require("../hooks/useFocusZone");
15
15
 
16
16
  var _hooks = require("../hooks");
17
17
 
18
- var _ssr = require("@react-aria/ssr");
18
+ var _uniqueId = require("../utils/uniqueId");
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
@@ -44,7 +44,7 @@ const AnchoredOverlay = ({
44
44
  }) => {
45
45
  const anchorRef = (0, _hooks.useProvidedRefOrCreate)(externalAnchorRef);
46
46
  const [overlayRef, updateOverlayRef] = (0, _hooks.useRenderForcingRef)();
47
- const anchorId = (0, _ssr.useSSRSafeId)();
47
+ const anchorId = (0, _react.useMemo)(_uniqueId.uniqueId, []);
48
48
  const onClickOutside = (0, _react.useCallback)(() => onClose === null || onClose === void 0 ? void 0 : onClose('click-outside'), [onClose]);
49
49
  const onEscape = (0, _react.useCallback)(() => onClose === null || onClose === void 0 ? void 0 : onClose('escape'), [onClose]);
50
50
  const onAnchorKeyDown = (0, _react.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,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _AutocompleteContext = require("./AutocompleteContext");
11
+
12
+ var _AutocompleteInput = _interopRequireDefault(require("./AutocompleteInput"));
13
+
14
+ var _AutocompleteMenu = _interopRequireDefault(require("./AutocompleteMenu"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ const Autocomplete = ({
23
+ children
24
+ }) => {
25
+ const activeDescendantRef = (0, _react.useRef)(null);
26
+ const inputRef = (0, _react.useRef)(null);
27
+ const [inputValue, setInputValue] = (0, _react.useState)('');
28
+ const [showMenu, setShowMenu] = (0, _react.useState)(false);
29
+ const [autocompleteSuggestion, setAutocompleteSuggestion] = (0, _react.useState)('');
30
+ const [isMenuDirectlyActivated, setIsMenuDirectlyActivated] = (0, _react.useState)(false);
31
+ return /*#__PURE__*/_react.default.createElement(_AutocompleteContext.AutocompleteContext.Provider, {
32
+ value: {
33
+ activeDescendantRef,
34
+ autocompleteSuggestion,
35
+ inputRef,
36
+ inputValue,
37
+ isMenuDirectlyActivated,
38
+ setAutocompleteSuggestion,
39
+ setInputValue,
40
+ setIsMenuDirectlyActivated,
41
+ setShowMenu,
42
+ showMenu
43
+ }
44
+ }, children);
45
+ };
46
+
47
+ Autocomplete.displayName = "Autocomplete";
48
+
49
+ var _default = Object.assign(Autocomplete, {
50
+ AutocompleteContext: _AutocompleteContext.AutocompleteContext,
51
+ Input: _AutocompleteInput.default,
52
+ Menu: _AutocompleteMenu.default
53
+ });
54
+
55
+ exports.default = _default;
@@ -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,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AutocompleteContext = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ // TODO:
11
+ // - figure out how we can make all of these properties required without having to define them when calling `createContext`
12
+ // - figure out how we can reduce the number of properties that need to be passed
13
+ // COLEHELP
14
+ const AutocompleteContext = /*#__PURE__*/(0, _react.createContext)({});
15
+ exports.AutocompleteContext = AutocompleteContext;
@@ -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,139 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _AutocompleteContext = require("./AutocompleteContext");
11
+
12
+ var _TextInput = _interopRequireDefault(require("../TextInput"));
13
+
14
+ var _useCombinedRefs = require("../hooks/useCombinedRefs");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ 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); }
23
+
24
+ const AutocompleteInput = /*#__PURE__*/_react.default.forwardRef(({
25
+ as: Component = _TextInput.default,
26
+ onFocus,
27
+ onBlur,
28
+ onChange,
29
+ onKeyDown,
30
+ onKeyPress,
31
+ value,
32
+ ...props
33
+ }, forwardedRef) => {
34
+ const {
35
+ activeDescendantRef,
36
+ autocompleteSuggestion = '',
37
+ inputRef,
38
+ inputValue = '',
39
+ isMenuDirectlyActivated,
40
+ setInputValue,
41
+ setShowMenu,
42
+ showMenu
43
+ } = (0, _react.useContext)(_AutocompleteContext.AutocompleteContext);
44
+ const combinedInputRef = (0, _useCombinedRefs.useCombinedRefs)(inputRef, forwardedRef);
45
+ const [highlightRemainingText, setHighlightRemainingText] = (0, _react.useState)(true);
46
+
47
+ const handleInputFocus = e => {
48
+ onFocus && onFocus(e);
49
+ setShowMenu && setShowMenu(true);
50
+ };
51
+
52
+ const handleInputBlur = e => {
53
+ onBlur && onBlur(e); // HACK: wait a tick and check the focused element before hiding the autocomplete menu
54
+ // this prevents the menu from hiding when the user is clicking an option in the Autoselect.Menu,
55
+ // but still hides the menu when the user blurs the input by tabbing out or clicking somewhere else on the page
56
+ // COLEHELP
57
+
58
+ setTimeout(() => {
59
+ if (setShowMenu && document.activeElement !== combinedInputRef.current) {
60
+ setShowMenu(false);
61
+ }
62
+ }, 0);
63
+ };
64
+
65
+ const handleInputChange = e => {
66
+ if (onChange) {
67
+ onChange(e);
68
+ }
69
+
70
+ if (setInputValue) {
71
+ setInputValue(e.currentTarget.value);
72
+ }
73
+
74
+ if (setShowMenu && !showMenu) {
75
+ setShowMenu(true);
76
+ }
77
+ };
78
+
79
+ const handleInputKeyDown = e => {
80
+ if (e.key === 'Backspace') {
81
+ setHighlightRemainingText(false);
82
+ }
83
+ };
84
+
85
+ const handleInputKeyUp = e => {
86
+ if (e.key === 'Backspace') {
87
+ setHighlightRemainingText(true);
88
+ }
89
+ };
90
+
91
+ const onInputKeyPress = (0, _react.useCallback)(event => {
92
+ if (activeDescendantRef && event.key === 'Enter' && activeDescendantRef.current) {
93
+ event.preventDefault();
94
+ event.nativeEvent.stopImmediatePropagation(); // Forward Enter key press to active descendant so that item gets activated
95
+
96
+ const activeDescendantEvent = new KeyboardEvent(event.type, event.nativeEvent);
97
+ activeDescendantRef.current.dispatchEvent(activeDescendantEvent);
98
+ }
99
+ }, [activeDescendantRef]);
100
+ (0, _react.useEffect)(() => {
101
+ if (!(inputRef !== null && inputRef !== void 0 && inputRef.current)) {
102
+ return;
103
+ } // resets input value to being empty after a selection has been made
104
+
105
+
106
+ if (!autocompleteSuggestion) {
107
+ inputRef.current.value = inputValue;
108
+ } // TODO: fix bug where this function prevents `onChange` from being triggered if the highlighted item text
109
+ // is the same as what I'm typing
110
+ // e.g.: typing 'tw' highights 'two', but when I 'two', the text input change does not get triggered
111
+ // COLEHELP
112
+
113
+
114
+ if (highlightRemainingText && autocompleteSuggestion && (inputValue || isMenuDirectlyActivated)) {
115
+ inputRef.current.value = autocompleteSuggestion;
116
+
117
+ if (autocompleteSuggestion.toLowerCase().indexOf(inputValue.toLowerCase()) === 0) {
118
+ inputRef.current.setSelectionRange(inputValue.length, autocompleteSuggestion.length);
119
+ }
120
+ }
121
+ }, [autocompleteSuggestion, inputValue]);
122
+ (0, _react.useEffect)(() => {
123
+ if (value && setInputValue) {
124
+ setInputValue(value.toString());
125
+ }
126
+ }, [value]);
127
+ return /*#__PURE__*/_react.default.createElement(Component, _extends({
128
+ onFocus: handleInputFocus,
129
+ onBlur: handleInputBlur,
130
+ onChange: handleInputChange,
131
+ onKeyDown: handleInputKeyDown,
132
+ onKeyPress: onInputKeyPress,
133
+ onKeyUp: handleInputKeyUp,
134
+ ref: combinedInputRef
135
+ }, props));
136
+ });
137
+
138
+ var _default = AutocompleteInput;
139
+ exports.default = _default;
@@ -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;