@primer/components 30.3.0-rc.2010c7d4 → 31.0.0-rc.15aa0a10

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 (180) hide show
  1. package/.eslintrc.json +2 -1
  2. package/.storybook/preview.js +4 -4
  3. package/CHANGELOG.md +12 -2
  4. package/codemods/deprecateUtilityComponents.js +1 -1
  5. package/contributor-docs/adrs/adr-003-prop-norms.md +72 -0
  6. package/dist/browser.esm.js +798 -794
  7. package/dist/browser.esm.js.map +1 -1
  8. package/dist/browser.umd.js +801 -797
  9. package/dist/browser.umd.js.map +1 -1
  10. package/docs/content/Autocomplete.mdx +627 -0
  11. package/docs/content/TextInputTokens.mdx +89 -0
  12. package/docs/content/getting-started.md +1 -1
  13. package/docs/content/overriding-styles.mdx +7 -6
  14. package/docs/content/theming.md +5 -5
  15. package/docs/package-lock.json +288 -511
  16. package/docs/package.json +1 -1
  17. package/docs/src/@primer/gatsby-theme-doctocat/components/hero.js +14 -12
  18. package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +2 -0
  19. package/docs/src/@primer/gatsby-theme-doctocat/primer-components-hero.svg +7 -7
  20. package/lib/ActionList/Item.js +1 -1
  21. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
  22. package/lib/AnchoredOverlay/AnchoredOverlay.js +11 -3
  23. package/lib/Autocomplete/Autocomplete.d.ts +304 -0
  24. package/lib/Autocomplete/Autocomplete.js +145 -0
  25. package/lib/Autocomplete/AutocompleteContext.d.ts +17 -0
  26. package/lib/Autocomplete/AutocompleteContext.js +11 -0
  27. package/lib/Autocomplete/AutocompleteInput.d.ts +292 -0
  28. package/lib/Autocomplete/AutocompleteInput.js +157 -0
  29. package/lib/Autocomplete/AutocompleteMenu.d.ts +72 -0
  30. package/lib/Autocomplete/AutocompleteMenu.js +224 -0
  31. package/lib/Autocomplete/AutocompleteOverlay.d.ts +20 -0
  32. package/lib/Autocomplete/AutocompleteOverlay.js +80 -0
  33. package/lib/Autocomplete/index.d.ts +2 -0
  34. package/lib/Autocomplete/index.js +15 -0
  35. package/lib/BaseStyles.js +1 -1
  36. package/lib/BorderBox.js +1 -1
  37. package/lib/Button/ButtonInvisible.js +1 -1
  38. package/lib/Caret.js +2 -2
  39. package/lib/Dialog.js +1 -1
  40. package/lib/FilteredActionList/FilteredActionList.js +5 -31
  41. package/lib/Flash.js +16 -16
  42. package/lib/Label.js +1 -1
  43. package/lib/Overlay.d.ts +1 -0
  44. package/lib/Overlay.js +3 -1
  45. package/lib/ProgressBar.js +1 -1
  46. package/lib/StateLabel.js +13 -19
  47. package/lib/Token/_RemoveTokenButton.js +1 -1
  48. package/lib/__tests__/Autocomplete.test.d.ts +1 -0
  49. package/lib/__tests__/Autocomplete.test.js +528 -0
  50. package/lib/__tests__/BorderBox.test.js +1 -1
  51. package/lib/__tests__/CircleOcticon.test.js +1 -1
  52. package/lib/__tests__/CounterLabel.test.js +4 -4
  53. package/lib/__tests__/Flash.test.js +4 -4
  54. package/lib/__tests__/Link.test.js +1 -1
  55. package/lib/__tests__/behaviors/scrollIntoViewingArea.test.d.ts +1 -0
  56. package/lib/__tests__/behaviors/scrollIntoViewingArea.test.js +226 -0
  57. package/lib/behaviors/scrollIntoViewingArea.d.ts +1 -0
  58. package/lib/behaviors/scrollIntoViewingArea.js +39 -0
  59. package/lib/hooks/useOpenAndCloseFocus.d.ts +2 -1
  60. package/lib/hooks/useOpenAndCloseFocus.js +7 -2
  61. package/lib/hooks/useOverlay.d.ts +2 -1
  62. package/lib/hooks/useOverlay.js +4 -2
  63. package/lib/index.d.ts +2 -0
  64. package/lib/index.js +8 -0
  65. package/lib/stories/Autocomplete.stories.js +608 -0
  66. package/lib/stories/Dialog.stories.js +3 -3
  67. package/lib/stories/IssueLabelToken.stories.js +1 -1
  68. package/lib/stories/ProfileToken.stories.js +1 -1
  69. package/lib/theme-preval.js +370 -3100
  70. package/lib/utils/testing.d.ts +50 -493
  71. package/lib/utils/types/MandateProps.d.ts +3 -0
  72. package/lib/utils/types/MandateProps.js +1 -0
  73. package/lib/utils/types/index.d.ts +1 -0
  74. package/lib/utils/types/index.js +13 -0
  75. package/lib-esm/ActionList/Item.js +1 -1
  76. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
  77. package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +11 -3
  78. package/lib-esm/Autocomplete/Autocomplete.d.ts +304 -0
  79. package/lib-esm/Autocomplete/Autocomplete.js +123 -0
  80. package/lib-esm/Autocomplete/AutocompleteContext.d.ts +17 -0
  81. package/lib-esm/Autocomplete/AutocompleteContext.js +2 -0
  82. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +292 -0
  83. package/lib-esm/Autocomplete/AutocompleteInput.js +138 -0
  84. package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +72 -0
  85. package/lib-esm/Autocomplete/AutocompleteMenu.js +205 -0
  86. package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +20 -0
  87. package/lib-esm/Autocomplete/AutocompleteOverlay.js +62 -0
  88. package/lib-esm/Autocomplete/index.d.ts +2 -0
  89. package/lib-esm/Autocomplete/index.js +1 -0
  90. package/lib-esm/BaseStyles.js +1 -1
  91. package/lib-esm/BorderBox.js +1 -1
  92. package/lib-esm/Button/ButtonInvisible.js +1 -1
  93. package/lib-esm/Caret.js +2 -2
  94. package/lib-esm/Dialog.js +1 -1
  95. package/lib-esm/FilteredActionList/FilteredActionList.js +3 -31
  96. package/lib-esm/Flash.js +16 -16
  97. package/lib-esm/Label.js +1 -1
  98. package/lib-esm/Overlay.d.ts +1 -0
  99. package/lib-esm/Overlay.js +3 -1
  100. package/lib-esm/ProgressBar.js +1 -1
  101. package/lib-esm/StateLabel.js +13 -19
  102. package/lib-esm/Token/_RemoveTokenButton.js +1 -1
  103. package/lib-esm/__tests__/Autocomplete.test.d.ts +1 -0
  104. package/lib-esm/__tests__/Autocomplete.test.js +494 -0
  105. package/lib-esm/__tests__/BorderBox.test.js +1 -1
  106. package/lib-esm/__tests__/CircleOcticon.test.js +1 -1
  107. package/lib-esm/__tests__/CounterLabel.test.js +4 -4
  108. package/lib-esm/__tests__/Flash.test.js +4 -4
  109. package/lib-esm/__tests__/Link.test.js +1 -1
  110. package/lib-esm/__tests__/behaviors/scrollIntoViewingArea.test.d.ts +1 -0
  111. package/lib-esm/__tests__/behaviors/scrollIntoViewingArea.test.js +224 -0
  112. package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +1 -0
  113. package/lib-esm/behaviors/scrollIntoViewingArea.js +30 -0
  114. package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +2 -1
  115. package/lib-esm/hooks/useOpenAndCloseFocus.js +7 -2
  116. package/lib-esm/hooks/useOverlay.d.ts +2 -1
  117. package/lib-esm/hooks/useOverlay.js +4 -2
  118. package/lib-esm/index.d.ts +2 -0
  119. package/lib-esm/index.js +1 -0
  120. package/lib-esm/stories/Autocomplete.stories.js +549 -0
  121. package/lib-esm/stories/Dialog.stories.js +3 -3
  122. package/lib-esm/stories/IssueLabelToken.stories.js +1 -1
  123. package/lib-esm/stories/ProfileToken.stories.js +1 -1
  124. package/lib-esm/theme-preval.js +370 -3100
  125. package/lib-esm/utils/testing.d.ts +50 -493
  126. package/lib-esm/utils/types/MandateProps.d.ts +3 -0
  127. package/lib-esm/utils/types/MandateProps.js +1 -0
  128. package/lib-esm/utils/types/index.d.ts +1 -0
  129. package/lib-esm/utils/types/index.js +2 -1
  130. package/package-lock.json +11 -8
  131. package/package.json +3 -3
  132. package/src/ActionList/Item.tsx +1 -1
  133. package/src/AnchoredOverlay/AnchoredOverlay.tsx +14 -3
  134. package/src/Autocomplete/Autocomplete.tsx +103 -0
  135. package/src/Autocomplete/AutocompleteContext.tsx +19 -0
  136. package/src/Autocomplete/AutocompleteInput.tsx +179 -0
  137. package/src/Autocomplete/AutocompleteMenu.tsx +341 -0
  138. package/src/Autocomplete/AutocompleteOverlay.tsx +68 -0
  139. package/src/Autocomplete/index.ts +2 -0
  140. package/src/BaseStyles.tsx +1 -1
  141. package/src/BorderBox.tsx +1 -1
  142. package/src/Button/ButtonInvisible.tsx +7 -2
  143. package/src/Caret.tsx +2 -2
  144. package/src/Dialog.tsx +1 -1
  145. package/src/FilteredActionList/FilteredActionList.tsx +10 -25
  146. package/src/Flash.tsx +16 -16
  147. package/src/Label.tsx +1 -1
  148. package/src/Overlay.tsx +4 -1
  149. package/src/ProgressBar.tsx +1 -1
  150. package/src/StateLabel.tsx +12 -20
  151. package/src/Token/_RemoveTokenButton.tsx +4 -2
  152. package/src/__tests__/Autocomplete.test.tsx +444 -0
  153. package/src/__tests__/BorderBox.test.tsx +1 -1
  154. package/src/__tests__/CircleOcticon.test.tsx +1 -1
  155. package/src/__tests__/CounterLabel.test.tsx +4 -4
  156. package/src/__tests__/Flash.test.tsx +4 -4
  157. package/src/__tests__/Link.test.tsx +1 -1
  158. package/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap +3 -3
  159. package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +3414 -0
  160. package/src/__tests__/__snapshots__/Button.test.tsx.snap +9 -1
  161. package/src/__tests__/__snapshots__/ConfirmationDialog.test.tsx.snap +1 -1
  162. package/src/__tests__/__snapshots__/SelectPanel.test.tsx.snap +1 -1
  163. package/src/__tests__/__snapshots__/StateLabel.test.tsx.snap +0 -21
  164. package/src/__tests__/__snapshots__/TextInputWithTokens.test.tsx.snap +16 -16
  165. package/src/__tests__/__snapshots__/Token.test.tsx.snap +34 -34
  166. package/src/__tests__/behaviors/scrollIntoViewingArea.test.ts +195 -0
  167. package/src/behaviors/scrollIntoViewingArea.ts +27 -0
  168. package/src/hooks/useOpenAndCloseFocus.ts +7 -2
  169. package/src/hooks/useOverlay.tsx +4 -2
  170. package/src/index.ts +2 -0
  171. package/src/stories/Autocomplete.stories.tsx +572 -0
  172. package/src/stories/Dialog.stories.tsx +3 -3
  173. package/src/stories/IssueLabelToken.stories.tsx +1 -1
  174. package/src/stories/ProfileToken.stories.tsx +1 -1
  175. package/src/utils/types/MandateProps.ts +19 -0
  176. package/src/utils/types/index.ts +1 -0
  177. package/stats.html +1 -1
  178. package/docs/src/@primer/gatsby-theme-doctocat/components/live-code.js +0 -84
  179. package/docs/src/@primer/gatsby-theme-doctocat/components/nav-dropdown.js +0 -48
  180. package/docs/src/@primer/gatsby-theme-doctocat/components/wrap-page-element.js +0 -25
@@ -0,0 +1,224 @@
1
+ import { scrollIntoViewingArea } from '../../behaviors/scrollIntoViewingArea';
2
+
3
+ function scrollPositionFormula(positionData, isChildAboveViewingArea) {
4
+ const {
5
+ viewingAreaEdgePosition,
6
+ childEdgePosition,
7
+ margin
8
+ } = positionData;
9
+ const marginOffset = margin * (isChildAboveViewingArea ? -1 : 1);
10
+ return childEdgePosition - viewingAreaEdgePosition + marginOffset;
11
+ } // The DOMRect constructor isn't available in JSDOM, so we improvise here.
12
+
13
+
14
+ function makeDOMRect(x, y, width, height) {
15
+ return {
16
+ x,
17
+ y,
18
+ width,
19
+ height,
20
+ top: y,
21
+ left: x,
22
+ right: x + width,
23
+ bottom: y + height,
24
+
25
+ toJSON() {
26
+ return this;
27
+ }
28
+
29
+ };
30
+ } // Since Jest/JSDOM doesn't support layout, we can stub out getBoundingClientRect if we know the
31
+ // correct dimensions. JSDOM will handle the rest of the DOM API used by getAnchoredPosition.
32
+
33
+
34
+ function createVirtualDOM(viewingAreaRect, childRect) {
35
+ const viewingArea = document.createElement('div');
36
+ viewingArea.style.overflow = 'auto';
37
+ viewingArea.id = 'viewingArea'; // eslint-disable-next-line github/unescaped-html-literal
38
+
39
+ viewingArea.innerHTML = '<div id="child"></div>';
40
+ const child = viewingArea.querySelector('#child');
41
+
42
+ child.getBoundingClientRect = () => childRect;
43
+
44
+ viewingArea.getBoundingClientRect = () => viewingAreaRect;
45
+
46
+ return {
47
+ viewingArea,
48
+ child
49
+ };
50
+ }
51
+
52
+ describe('scrollIntoViewingArea', () => {
53
+ it('scrolls the expected amount when only the viewingArea element and child element are passed to the function', () => {
54
+ const scrollToMock = jest.fn();
55
+ Object.defineProperty(window.Element.prototype, 'scrollTo', {
56
+ writable: true,
57
+ value: scrollToMock
58
+ });
59
+ const childHeight = 50;
60
+ const viewAreaHeight = 100;
61
+ const childStart = viewAreaHeight + 10;
62
+ const expectedScrollPosition = scrollPositionFormula({
63
+ viewingAreaEdgePosition: viewAreaHeight,
64
+ childEdgePosition: childStart + childHeight,
65
+ margin: 8
66
+ }, false);
67
+ const viewingAreaRect = makeDOMRect(0, 0, 100, viewAreaHeight);
68
+ const childRect = makeDOMRect(0, childStart, 100, childHeight);
69
+ const {
70
+ viewingArea,
71
+ child
72
+ } = createVirtualDOM(viewingAreaRect, childRect);
73
+
74
+ viewingArea.getBoundingClientRect = () => viewingAreaRect;
75
+
76
+ viewingArea.scrollTop = 0;
77
+
78
+ child.getBoundingClientRect = () => childRect;
79
+
80
+ scrollIntoViewingArea(child, viewingArea);
81
+ expect(scrollToMock).toHaveBeenCalledWith({
82
+ behavior: 'smooth',
83
+ top: expectedScrollPosition
84
+ });
85
+ });
86
+ describe('y-axis', () => {
87
+ it('scrolls the child into the viewing area when it is AFTER the overflow cutoff point', () => {
88
+ const scrollToMock = jest.fn();
89
+ Object.defineProperty(window.Element.prototype, 'scrollTo', {
90
+ writable: true,
91
+ value: scrollToMock
92
+ });
93
+ const childHeight = 50;
94
+ const viewAreaHeight = 100;
95
+ const childStart = viewAreaHeight + 10;
96
+ const scrollMargin = 10;
97
+ const expectedScrollPosition = scrollPositionFormula({
98
+ viewingAreaEdgePosition: viewAreaHeight,
99
+ childEdgePosition: childStart + childHeight,
100
+ margin: scrollMargin
101
+ }, false);
102
+ const viewingAreaRect = makeDOMRect(0, 0, 100, viewAreaHeight);
103
+ const childRect = makeDOMRect(0, childStart, 100, childHeight);
104
+ const {
105
+ viewingArea,
106
+ child
107
+ } = createVirtualDOM(viewingAreaRect, childRect);
108
+
109
+ viewingArea.getBoundingClientRect = () => viewingAreaRect;
110
+
111
+ viewingArea.scrollTop = 0;
112
+
113
+ child.getBoundingClientRect = () => childRect;
114
+
115
+ scrollIntoViewingArea(child, viewingArea, 'vertical', scrollMargin, scrollMargin, 'auto');
116
+ expect(scrollToMock).toHaveBeenCalledWith({
117
+ behavior: 'auto',
118
+ top: expectedScrollPosition
119
+ });
120
+ });
121
+ it('scrolls the child into the viewing area when it is BEFORE the overflow cutoff point', () => {
122
+ const scrollToMock = jest.fn();
123
+ Object.defineProperty(window.Element.prototype, 'scrollTo', {
124
+ writable: true,
125
+ value: scrollToMock
126
+ });
127
+ const childHeight = 50;
128
+ const childStart = childHeight * -1 - 10;
129
+ const scrollMargin = 10;
130
+ const expectedScrollPosition = scrollPositionFormula({
131
+ viewingAreaEdgePosition: 0,
132
+ childEdgePosition: childStart,
133
+ margin: scrollMargin
134
+ }, true);
135
+ const viewingAreaRect = makeDOMRect(0, 0, 100, 100);
136
+ const childRect = makeDOMRect(0, childStart, 100, childHeight);
137
+ const {
138
+ viewingArea,
139
+ child
140
+ } = createVirtualDOM(viewingAreaRect, childRect);
141
+
142
+ viewingArea.getBoundingClientRect = () => viewingAreaRect;
143
+
144
+ viewingArea.scrollTop = 0;
145
+
146
+ child.getBoundingClientRect = () => childRect;
147
+
148
+ scrollIntoViewingArea(child, viewingArea, 'vertical', scrollMargin, scrollMargin, 'auto');
149
+ expect(scrollToMock).toHaveBeenCalledWith({
150
+ behavior: 'auto',
151
+ top: expectedScrollPosition
152
+ });
153
+ });
154
+ });
155
+ describe('x-axis', () => {
156
+ it('scrolls the child into the viewing area when it is AFTER the overflow cutoff point', () => {
157
+ const scrollToMock = jest.fn();
158
+ Object.defineProperty(window.Element.prototype, 'scrollTo', {
159
+ writable: true,
160
+ value: scrollToMock
161
+ });
162
+ const childWidth = 50;
163
+ const viewAreaWidth = 100;
164
+ const childStart = viewAreaWidth + 10;
165
+ const scrollMargin = 10;
166
+ const expectedScrollPosition = scrollPositionFormula({
167
+ viewingAreaEdgePosition: viewAreaWidth,
168
+ childEdgePosition: childStart + childWidth,
169
+ margin: scrollMargin
170
+ }, false);
171
+ const viewingAreaRect = makeDOMRect(0, 0, 100, viewAreaWidth);
172
+ const childRect = makeDOMRect(childStart, 0, childWidth, 100);
173
+ const {
174
+ viewingArea,
175
+ child
176
+ } = createVirtualDOM(viewingAreaRect, childRect);
177
+
178
+ viewingArea.getBoundingClientRect = () => viewingAreaRect;
179
+
180
+ viewingArea.scrollLeft = 0;
181
+
182
+ child.getBoundingClientRect = () => childRect;
183
+
184
+ scrollIntoViewingArea(child, viewingArea, 'horizontal', scrollMargin, scrollMargin, 'auto');
185
+ expect(scrollToMock).toHaveBeenCalledWith({
186
+ behavior: 'auto',
187
+ left: expectedScrollPosition
188
+ });
189
+ });
190
+ it('scrolls the child into the viewing area when it is BEFORE the overflow cutoff point', () => {
191
+ const scrollToMock = jest.fn();
192
+ Object.defineProperty(window.Element.prototype, 'scrollTo', {
193
+ writable: true,
194
+ value: scrollToMock
195
+ });
196
+ const childWidth = 50;
197
+ const childStart = childWidth * -1 - 10;
198
+ const scrollMargin = 10;
199
+ const expectedScrollPosition = scrollPositionFormula({
200
+ viewingAreaEdgePosition: 0,
201
+ childEdgePosition: childStart,
202
+ margin: scrollMargin
203
+ }, true);
204
+ const viewingAreaRect = makeDOMRect(0, 0, 100, 100);
205
+ const childRect = makeDOMRect(childStart, 0, childWidth, 100);
206
+ const {
207
+ viewingArea,
208
+ child
209
+ } = createVirtualDOM(viewingAreaRect, childRect);
210
+
211
+ viewingArea.getBoundingClientRect = () => viewingAreaRect;
212
+
213
+ viewingArea.scrollTop = 0;
214
+
215
+ child.getBoundingClientRect = () => childRect;
216
+
217
+ scrollIntoViewingArea(child, viewingArea, 'horizontal', scrollMargin, scrollMargin, 'auto');
218
+ expect(scrollToMock).toHaveBeenCalledWith({
219
+ behavior: 'auto',
220
+ left: expectedScrollPosition
221
+ });
222
+ });
223
+ });
224
+ });
@@ -0,0 +1 @@
1
+ export declare const scrollIntoViewingArea: (child: HTMLElement, viewingArea: HTMLElement, direction?: 'horizontal' | 'vertical', startMargin?: number, endMargin?: number, behavior?: ScrollBehavior) => void;
@@ -0,0 +1,30 @@
1
+ export const scrollIntoViewingArea = (child, viewingArea, direction = 'vertical', startMargin = 8, endMargin = 0, behavior = 'smooth') => {
2
+ const startSide = direction === 'vertical' ? 'top' : 'left';
3
+ const endSide = direction === 'vertical' ? 'bottom' : 'right';
4
+ const scrollSide = direction === 'vertical' ? 'scrollTop' : 'scrollLeft';
5
+ const {
6
+ [startSide]: childStart,
7
+ [endSide]: childEnd
8
+ } = child.getBoundingClientRect();
9
+ const {
10
+ [startSide]: viewingAreaStart,
11
+ [endSide]: viewingAreaEnd
12
+ } = viewingArea.getBoundingClientRect();
13
+ const isChildStartAboveViewingArea = childStart < viewingAreaStart + endMargin;
14
+ const isChildBottomBelowViewingArea = childEnd > viewingAreaEnd - startMargin;
15
+
16
+ if (isChildStartAboveViewingArea) {
17
+ const scrollHeightToChildStart = childStart - viewingAreaStart + viewingArea[scrollSide];
18
+ viewingArea.scrollTo({
19
+ behavior,
20
+ [startSide]: scrollHeightToChildStart - endMargin
21
+ });
22
+ } else if (isChildBottomBelowViewingArea) {
23
+ const scrollHeightToChildBottom = childEnd - viewingAreaEnd + viewingArea[scrollSide];
24
+ viewingArea.scrollTo({
25
+ behavior,
26
+ [startSide]: scrollHeightToChildBottom + startMargin
27
+ });
28
+ } // either completely in view or outside viewing area on both ends, don't scroll
29
+
30
+ };
@@ -3,5 +3,6 @@ export declare type UseOpenAndCloseFocusSettings = {
3
3
  initialFocusRef?: React.RefObject<HTMLElement>;
4
4
  containerRef: React.RefObject<HTMLElement>;
5
5
  returnFocusRef: React.RefObject<HTMLElement>;
6
+ preventFocusOnOpen?: boolean;
6
7
  };
7
- export declare function useOpenAndCloseFocus({ initialFocusRef, returnFocusRef, containerRef }: UseOpenAndCloseFocusSettings): void;
8
+ export declare function useOpenAndCloseFocus({ initialFocusRef, returnFocusRef, containerRef, preventFocusOnOpen }: UseOpenAndCloseFocusSettings): void;
@@ -3,9 +3,14 @@ import { iterateFocusableElements } from '../utils/iterateFocusableElements';
3
3
  export function useOpenAndCloseFocus({
4
4
  initialFocusRef,
5
5
  returnFocusRef,
6
- containerRef
6
+ containerRef,
7
+ preventFocusOnOpen
7
8
  }) {
8
9
  useEffect(() => {
10
+ if (preventFocusOnOpen) {
11
+ return;
12
+ }
13
+
9
14
  const returnRef = returnFocusRef.current;
10
15
 
11
16
  if (initialFocusRef && initialFocusRef.current) {
@@ -18,5 +23,5 @@ export function useOpenAndCloseFocus({
18
23
  return function () {
19
24
  returnRef === null || returnRef === void 0 ? void 0 : returnRef.focus();
20
25
  };
21
- }, [initialFocusRef, returnFocusRef, containerRef]);
26
+ }, [initialFocusRef, returnFocusRef, containerRef, preventFocusOnOpen]);
22
27
  }
@@ -7,8 +7,9 @@ export declare type UseOverlaySettings = {
7
7
  onEscape: (e: KeyboardEvent) => void;
8
8
  onClickOutside: (e: TouchOrMouseEvent) => void;
9
9
  overlayRef?: React.RefObject<HTMLDivElement>;
10
+ preventFocusOnOpen?: boolean;
10
11
  };
11
12
  export declare type OverlayReturnProps = {
12
13
  ref: React.RefObject<HTMLDivElement>;
13
14
  };
14
- export declare const useOverlay: ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside }: UseOverlaySettings) => OverlayReturnProps;
15
+ export declare const useOverlay: ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside, preventFocusOnOpen }: UseOverlaySettings) => OverlayReturnProps;
@@ -8,13 +8,15 @@ export const useOverlay = ({
8
8
  initialFocusRef,
9
9
  onEscape,
10
10
  ignoreClickRefs,
11
- onClickOutside
11
+ onClickOutside,
12
+ preventFocusOnOpen
12
13
  }) => {
13
14
  const overlayRef = useProvidedRefOrCreate(_overlayRef);
14
15
  useOpenAndCloseFocus({
15
16
  containerRef: overlayRef,
16
17
  returnFocusRef,
17
- initialFocusRef
18
+ initialFocusRef,
19
+ preventFocusOnOpen
18
20
  });
19
21
  useOnOutsideClick({
20
22
  containerRef: overlayRef,
@@ -24,6 +24,8 @@ export { useConfirm } from './Dialog/ConfirmationDialog';
24
24
  export { ActionList } from './ActionList';
25
25
  export { ActionMenu } from './ActionMenu';
26
26
  export type { ActionMenuProps } from './ActionMenu';
27
+ export { default as Autocomplete } from './Autocomplete';
28
+ export type { AutocompleteMenuProps, AutocompleteInputProps, AutocompleteOverlayProps } from './Autocomplete';
27
29
  export { default as Avatar } from './Avatar';
28
30
  export type { AvatarProps } from './Avatar';
29
31
  export { default as AvatarPair } from './AvatarPair';
package/lib-esm/index.js CHANGED
@@ -19,6 +19,7 @@ export { useConfirm } from './Dialog/ConfirmationDialog'; // Components
19
19
 
20
20
  export { ActionList } from './ActionList';
21
21
  export { ActionMenu } from './ActionMenu';
22
+ export { default as Autocomplete } from './Autocomplete';
22
23
  export { default as Avatar } from './Avatar';
23
24
  export { default as AvatarPair } from './AvatarPair';
24
25
  export { default as AvatarStack } from './AvatarStack';