@jobber/components 6.14.1-aidenfix--e9ec00c.0 → 6.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,107 +1,23 @@
1
1
  import { _ as __rest, a as __awaiter } from './tslib.es6-es.js';
2
- import React, { useState, useEffect, useRef, useMemo, forwardRef } from 'react';
2
+ import React, { useState, useCallback, useEffect, useRef, useMemo, forwardRef } from 'react';
3
3
  import classnames from 'classnames';
4
+ import { u as useIsMounted_2 } from './useIsMounted-es.js';
4
5
  import { createPortal } from 'react-dom';
5
- import { usePopper } from 'react-popper';
6
- import { u as useOnKeyDown_2 } from './useOnKeyDown-es.js';
7
6
  import { u as useSafeLayoutEffect_1 } from './useSafeLayoutEffect-es.js';
8
- import { u as useIsMounted_2 } from './useIsMounted-es.js';
7
+ import { usePopper } from 'react-popper';
8
+ import { H as Heading } from './Heading-es.js';
9
9
  import { T as Text } from './Text-es.js';
10
10
  import { I as Icon } from './Icon-es.js';
11
- import { H as Heading } from './Heading-es.js';
11
+ import { u as useOnKeyDown_2 } from './useOnKeyDown-es.js';
12
12
  import { InputText } from './InputText/index.mjs';
13
13
  import { a as debounce } from './debounce-es.js';
14
+ import { m as mergeRefs } from './FormField-es.js';
14
15
 
15
- var styles = {"autocomplete":"_7mObJiwfPh4-","options":"dL5JShAJlKM-","visible":"_2RzcnTdaPyc-","option":"y9zhi8Wr8QA-","active":"_3Xg49dtL1Q8-","separator":"LIeh390F3W8-","heading":"PWZL-94hH7k-","icon":"K2phy6IC3TY-","text":"a6-LbUm5WnY-","label":"tQNbuxcE9nU-","details":"qacStG9-XbE-","spinning":"P9cQDL4MZ-s-"};
16
+ var styles = {"autocomplete":"_7mObJiwfPh4-","options":"dL5JShAJlKM-","heading":"PWZL-94hH7k-","visible":"_2RzcnTdaPyc-","option":"y9zhi8Wr8QA-","active":"_3Xg49dtL1Q8-","separator":"LIeh390F3W8-","icon":"K2phy6IC3TY-","text":"a6-LbUm5WnY-","label":"tQNbuxcE9nU-","details":"qacStG9-XbE-","spinning":"P9cQDL4MZ-s-"};
16
17
 
17
- var IndexChange;
18
- (function (IndexChange) {
19
- IndexChange[IndexChange["Previous"] = -1] = "Previous";
20
- IndexChange[IndexChange["Next"] = 1] = "Next";
21
- })(IndexChange || (IndexChange = {}));
22
- // Adding useIsMounted is what tipped this to 13 statements.
23
- // Any additions beyond useIsMounted should probably see this component refactored a bit
24
- // eslint-disable-next-line max-statements
25
- function Menu({ visible, options, selectedOption, onOptionSelect, attachTo, }) {
26
- const [highlightedIndex, setHighlightedIndex] = useState(0);
27
- const { menuRef, setMenuRef, styles: popperStyles, attributes, targetWidth, } = useRepositionMenu(attachTo, visible);
28
- const detectSeparatorCondition = (option) => option.description || option.details;
29
- const detectGroups = (option) => option.options;
30
- const addSeparators = options.some(detectSeparatorCondition);
31
- const initialHighlight = options.some(detectGroups) ? 1 : 0;
32
- setupKeyListeners();
33
- useEffect(() => setHighlightedIndex(initialHighlight), [options]);
34
- const mounted = useIsMounted_2();
35
- const menu = (React.createElement("div", Object.assign({ className: classnames(styles.options, { [styles.visible]: visible }), ref: setMenuRef, style: Object.assign(Object.assign({}, popperStyles.popper), { width: targetWidth }), "data-elevation": "elevated" }, attributes.popper), options.map((option, index) => {
36
- const optionClass = classnames(styles.option, {
37
- [styles.active]: index === highlightedIndex,
38
- [styles.separator]: addSeparators,
39
- });
40
- if (isGroup(option)) {
41
- return (React.createElement("div", { key: option.label, className: styles.heading },
42
- React.createElement(Heading, { level: 5 }, option.label)));
43
- }
44
- return (React.createElement("button", { className: optionClass, key: option.value, onMouseDown: onOptionSelect.bind(undefined, option) },
45
- React.createElement("div", { className: styles.icon }, isOptionSelected(selectedOption, option) && (React.createElement(Icon, { name: "checkmark", size: "small" }))),
46
- React.createElement("div", { className: styles.text },
47
- React.createElement("div", { className: styles.label },
48
- React.createElement(Text, null, option.label),
49
- option.description !== undefined && (React.createElement(Text, { variation: "subdued" }, option.description))),
50
- option.details !== undefined && (React.createElement("div", { className: styles.details },
51
- React.createElement(Text, null, option.details))))));
52
- })));
53
- return mounted.current ? createPortal(menu, document.body) : menu;
54
- function setupKeyListeners() {
55
- useEffect(() => {
56
- var _a, _b;
57
- (_b = (_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.children[highlightedIndex]) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, {
58
- behavior: "smooth",
59
- block: "nearest",
60
- inline: "start",
61
- });
62
- }, [highlightedIndex]);
63
- useOnKeyDown_2((event) => {
64
- const indexChange = arrowKeyPress(event, IndexChange.Next);
65
- if (indexChange) {
66
- setHighlightedIndex(Math.min(options.length - 1, highlightedIndex + indexChange));
67
- }
68
- }, "ArrowDown");
69
- useOnKeyDown_2((event) => {
70
- const indexChange = arrowKeyPress(event, IndexChange.Previous);
71
- if (indexChange) {
72
- setHighlightedIndex(Math.max(0, highlightedIndex + indexChange));
73
- }
74
- }, "ArrowUp");
75
- useOnKeyDown_2((event) => {
76
- if (!visible)
77
- return;
78
- if (isGroup(options[highlightedIndex]))
79
- return;
80
- event.preventDefault();
81
- onOptionSelect(options[highlightedIndex]);
82
- }, "Enter");
83
- }
84
- function arrowKeyPress(event, direction) {
85
- if (!visible)
86
- return;
87
- event.preventDefault();
88
- const requestedIndex = options[highlightedIndex + direction];
89
- return requestedIndex && isGroup(requestedIndex)
90
- ? direction + direction
91
- : direction;
92
- }
93
- }
94
- function isOptionSelected(selectedOption, option) {
95
- return selectedOption && selectedOption.value === option.value;
96
- }
97
- function isGroup(option) {
98
- if (option.options)
99
- return true;
100
- return false;
101
- }
102
18
  function useRepositionMenu(attachTo, visible = false) {
103
19
  var _a;
104
- const [menuRef, setMenuRef] = useState();
20
+ const [menuRef, setMenuRef] = useState(null);
105
21
  const popper = usePopper(attachTo.current, menuRef, {
106
22
  modifiers: [
107
23
  { name: "offset", options: { offset: [0, 8] } },
@@ -116,6 +32,207 @@ function useRepositionMenu(attachTo, visible = false) {
116
32
  return Object.assign(Object.assign({}, popper), { menuRef, setMenuRef, targetWidth });
117
33
  }
118
34
 
35
+ function BaseAutocompleteMenuWrapperInternal({ setMenuRef, popperStyles, attributes, targetWidth, visible, children, }) {
36
+ return (React.createElement("div", Object.assign({ className: classnames(styles.options, { [styles.visible]: visible }), ref: setMenuRef, style: Object.assign(Object.assign({}, popperStyles.popper), { width: targetWidth }), "data-elevation": "elevated" }, attributes.popper), children));
37
+ }
38
+ /**
39
+ * Provides a wrapper for the Autocomplete menu that handles positioning and visibility.
40
+ * @param attachTo - The element that the menu should be attached to.
41
+ */
42
+ function useAutocompleteMenu({ attachTo, }) {
43
+ const [menuRef, setMenuRef] = React.useState(null);
44
+ const AutocompleteMenuWrapper = useCallback(({ children, visible, }) => {
45
+ const menuPopperProps = useRepositionMenu(attachTo, visible);
46
+ useEffect(() => {
47
+ setMenuRef(menuPopperProps.menuRef);
48
+ }, [menuPopperProps.menuRef]);
49
+ return (React.createElement(BaseAutocompleteMenuWrapper, { attributes: menuPopperProps.attributes, popperStyles: menuPopperProps.styles, setMenuRef: menuPopperProps.setMenuRef, targetWidth: menuPopperProps.targetWidth, visible: visible }, children));
50
+ }, [attachTo]);
51
+ return { MenuWrapper: AutocompleteMenuWrapper, menuRef };
52
+ }
53
+ function BaseAutocompleteMenuWrapper(props) {
54
+ const mounted = useIsMounted_2();
55
+ const menu = React.createElement(BaseAutocompleteMenuWrapperInternal, Object.assign({}, props));
56
+ return mounted.current ? createPortal(menu, document.body) : menu;
57
+ }
58
+
59
+ function isOptionSelected(selectedOption, option) {
60
+ return Boolean(selectedOption && selectedOption.value === option.value);
61
+ }
62
+ /**
63
+ * Helper function to determine if the option is a group. This is used to
64
+ * determine if the option contains a list of options for rendering Section
65
+ * Labels in the Autocomplete component.
66
+ */
67
+ function isOptionGroup(option) {
68
+ return "options" in option;
69
+ }
70
+
71
+ /**
72
+ * The rendering of the default MenuOption
73
+ */
74
+ function MenuOption({ isHighlighted, option, onOptionSelect, isSelected, addSeparators, UNSAFE_className = {}, UNSAFE_style = {}, }) {
75
+ if (isOptionGroup(option)) {
76
+ return (React.createElement(MenuGroupOptions, { UNSAFE_className: UNSAFE_className.groupOption, option: option, UNSAFE_style: UNSAFE_style.groupOption }));
77
+ }
78
+ return (React.createElement(BaseMenuOption, { UNSAFE_className: UNSAFE_className.option, UNSAFE_style: UNSAFE_style.option, option: option, isHighlighted: isHighlighted, onOptionSelect: onOptionSelect, addSeparators: addSeparators },
79
+ React.createElement(MenuOptionContent, { option: option, isSelected: isSelected, UNSAFE_className: UNSAFE_className.content, UNSAFE_style: UNSAFE_style.content })));
80
+ }
81
+ function MenuOptionContent({ option, isSelected, UNSAFE_className = {}, UNSAFE_style = {}, }) {
82
+ const iconClassName = classnames(styles.icon, UNSAFE_className.icon);
83
+ const textClassName = classnames(styles.text, UNSAFE_className.text);
84
+ const labelClassName = classnames(styles.label, UNSAFE_className.label);
85
+ const detailsClassName = classnames(styles.details, UNSAFE_className.details);
86
+ return (React.createElement(React.Fragment, null,
87
+ React.createElement("div", { className: iconClassName, style: UNSAFE_style.icon }, isSelected && React.createElement(Icon, { name: "checkmark", size: "small" })),
88
+ React.createElement("div", { className: textClassName, style: UNSAFE_style.text },
89
+ React.createElement("div", { className: labelClassName, style: UNSAFE_style.label },
90
+ React.createElement(Text, null, option.label),
91
+ option.description !== undefined && (React.createElement(Text, { variation: "subdued" }, option.description))),
92
+ option.details !== undefined && (React.createElement("div", { className: detailsClassName, style: UNSAFE_style.details },
93
+ React.createElement(Text, null, option.details))))));
94
+ }
95
+ /**
96
+ * The rendering of the default MenuGroupOption
97
+ */
98
+ function MenuGroupOptions({ option, UNSAFE_className = {}, UNSAFE_style = {}, }) {
99
+ return (React.createElement(BaseMenuGroupOption, { UNSAFE_className: UNSAFE_className.heading, UNSAFE_style: UNSAFE_style.heading },
100
+ React.createElement(Heading, { level: 5 }, option.label)));
101
+ }
102
+ function BaseMenuGroupOption({ children, UNSAFE_className = "", UNSAFE_style = {}, }) {
103
+ const headingClassName = classnames(styles.heading, UNSAFE_className);
104
+ return (React.createElement("div", { className: headingClassName, style: UNSAFE_style }, children));
105
+ }
106
+ /**
107
+ * Renders the base option component. The component takes children and renders them inside a button.
108
+ */
109
+ function BaseMenuOption({ option, isHighlighted, onOptionSelect, addSeparators, children, UNSAFE_className = "", UNSAFE_style = {}, }) {
110
+ const optionClass = classnames(styles.option, {
111
+ [styles.active]: isHighlighted,
112
+ [styles.separator]: addSeparators,
113
+ }, UNSAFE_className);
114
+ return (React.createElement("button", { role: "option", type: "button", className: optionClass, onMouseDown: onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect.bind(undefined, option), style: UNSAFE_style }, children));
115
+ }
116
+
117
+ var KeyboardAction;
118
+ (function (KeyboardAction) {
119
+ KeyboardAction[KeyboardAction["Previous"] = -1] = "Previous";
120
+ KeyboardAction[KeyboardAction["Next"] = 1] = "Next";
121
+ KeyboardAction[KeyboardAction["Select"] = 0] = "Select";
122
+ })(KeyboardAction || (KeyboardAction = {}));
123
+ /**
124
+ * Hook to handle custom keyboard navigation for the Autocomplete component.
125
+ * Use this hook if you are using components in the menu that aren't MenuOption or BaseMenuOption.
126
+ */
127
+ function useCustomKeyboardNavigation({ onRequestHighlightChange, }) {
128
+ useOnKeyDown_2((event) => {
129
+ onRequestHighlightChange === null || onRequestHighlightChange === void 0 ? void 0 : onRequestHighlightChange(event, KeyboardAction.Next);
130
+ }, "ArrowDown");
131
+ useOnKeyDown_2((event) => {
132
+ onRequestHighlightChange === null || onRequestHighlightChange === void 0 ? void 0 : onRequestHighlightChange(event, KeyboardAction.Previous);
133
+ }, "ArrowUp");
134
+ useOnKeyDown_2((event) => {
135
+ onRequestHighlightChange === null || onRequestHighlightChange === void 0 ? void 0 : onRequestHighlightChange(event, KeyboardAction.Select);
136
+ }, "Enter");
137
+ }
138
+ /**
139
+ * Hook to handle keyboard navigation for the Menu in the Autocomplete component.
140
+ * If using components in the menu that aren't MenuOption or BaseMenuOption, you should use the `useCustomKeyboardNavigation` hook.
141
+ */
142
+ function useKeyboardNavigation({ options, onOptionSelect, menuRef, visible, }) {
143
+ const [highlightedIndex, setHighlightedIndex] = useState(0);
144
+ const initialHighlight = options.some(isOptionGroup) ? 1 : 0;
145
+ useEffect(() => setHighlightedIndex(initialHighlight), [options]);
146
+ useEffect(() => {
147
+ var _a, _b;
148
+ (_b = (_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.children[highlightedIndex]) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, {
149
+ behavior: "smooth",
150
+ block: "nearest",
151
+ inline: "start",
152
+ });
153
+ }, [highlightedIndex]);
154
+ const onRequestHighlightChange = useCallback((event, direction) => {
155
+ if (!visible)
156
+ return;
157
+ const indexChange = getRequestedIndexChange({
158
+ event,
159
+ options,
160
+ direction,
161
+ highlightedIndex,
162
+ });
163
+ switch (direction) {
164
+ case KeyboardAction.Previous:
165
+ setHighlightedIndex(prev => Math.max(0, prev + indexChange));
166
+ break;
167
+ case KeyboardAction.Next:
168
+ setHighlightedIndex(prev => Math.min(options.length - 1, prev + indexChange));
169
+ break;
170
+ case KeyboardAction.Select:
171
+ if (isOptionGroup(options[highlightedIndex]))
172
+ return;
173
+ onOptionSelect(options[highlightedIndex]);
174
+ break;
175
+ }
176
+ }, [highlightedIndex, options, onOptionSelect, visible]);
177
+ useCustomKeyboardNavigation({ onRequestHighlightChange });
178
+ return { highlightedIndex };
179
+ }
180
+ /**
181
+ * Function to get the requested index change based on the current highlighted index and the direction of the keyboard action.
182
+ * Accounts for groups in the options array.
183
+ */
184
+ function getRequestedIndexChange({ event, options, direction, highlightedIndex, }) {
185
+ event.preventDefault();
186
+ const requestedIndex = options[highlightedIndex + direction];
187
+ return requestedIndex && isOptionGroup(requestedIndex)
188
+ ? direction + direction
189
+ : direction;
190
+ }
191
+
192
+ /**
193
+ * Renders the default Menu for the Autocomplete component.
194
+ */
195
+ function DefaultMenu({ options, selectedOption, onOptionSelect, attachTo, visible, }) {
196
+ const { menuRef, setMenuRef, styles: popperStyles, attributes, targetWidth, } = useRepositionMenu(attachTo, visible);
197
+ const detectSeparatorCondition = (option) => option.description || option.details;
198
+ const addSeparators = options.some(detectSeparatorCondition);
199
+ const { highlightedIndex } = useKeyboardNavigation({
200
+ onOptionSelect,
201
+ options,
202
+ visible,
203
+ menuRef,
204
+ });
205
+ return (React.createElement(BaseAutocompleteMenuWrapper, { setMenuRef, popperStyles, attributes, targetWidth, visible }, options === null || options === void 0 ? void 0 : options.map((option, index) => {
206
+ return (React.createElement(MenuOption, { key: index, option: option, isHighlighted: index === highlightedIndex, onOptionSelect: onOptionSelect, isSelected: isOptionSelected(selectedOption, option), addSeparators: addSeparators }));
207
+ })));
208
+ }
209
+
210
+ function Menu({ options, selectedOption, onOptionSelect, inputFocused, attachTo, inputRef, customRenderMenu, }) {
211
+ if (customRenderMenu) {
212
+ return (React.createElement(CustomMenu, { attachTo: attachTo, inputFocused: inputFocused, inputRef: inputRef, customRenderMenu: customRenderMenu, options: options, onOptionSelect: onOptionSelect, selectedOption: selectedOption }));
213
+ }
214
+ if (!inputFocused || !options.length)
215
+ return null;
216
+ return (React.createElement(DefaultMenu, { attachTo: attachTo, options: options, onOptionSelect: onOptionSelect, selectedOption: selectedOption, visible: inputFocused }));
217
+ }
218
+ /**
219
+ * Renders the custom Menu for the Autocomplete component.
220
+ * Provides the menuRef and MenuWrapper to the customRenderMenu function.
221
+ */
222
+ function CustomMenu({ options, selectedOption, onOptionSelect, customRenderMenu, attachTo, inputFocused, inputRef, }) {
223
+ const { MenuWrapper, menuRef } = useAutocompleteMenu({ attachTo });
224
+ const menuContent = customRenderMenu({
225
+ options,
226
+ menuRef,
227
+ onOptionSelect,
228
+ selectedOption,
229
+ inputFocused,
230
+ MenuWrapper,
231
+ inputRef,
232
+ });
233
+ return menuContent;
234
+ }
235
+
119
236
  /**
120
237
  * A hook to easily manage debounced functions, including their cleanup.
121
238
  * @param func The function to debounce.
@@ -147,15 +264,17 @@ function useDebounce(func, wait, options) {
147
264
  }
148
265
 
149
266
  // Max statements increased to make room for the debounce functions
150
- /* eslint max-statements: ["error", 14] */
267
+ // eslint-disable-next-line max-statements
151
268
  function AutocompleteInternal(_a, ref) {
152
269
  var _b;
153
- var { initialOptions = [], value, allowFreeForm = true, size = undefined, debounce: debounceRate = 300, onChange, getOptions, placeholder, onBlur, onFocus, validations } = _a, inputProps = __rest(_a, ["initialOptions", "value", "allowFreeForm", "size", "debounce", "onChange", "getOptions", "placeholder", "onBlur", "onFocus", "validations"]);
154
- const [options, setOptions] = useState(initialOptions);
155
- const [menuVisible, setMenuVisible] = useState(false);
270
+ var { initialOptions = [], value, allowFreeForm = true, size = undefined, debounce: debounceRate = 300, onChange, getOptions, placeholder, onBlur, onFocus, validations, customRenderMenu } = _a, inputProps = __rest(_a, ["initialOptions", "value", "allowFreeForm", "size", "debounce", "onChange", "getOptions", "placeholder", "onBlur", "onFocus", "validations", "customRenderMenu"]);
271
+ const initialOptionsMemo = useMemo(() => mapToOptions(initialOptions), [initialOptions]);
272
+ const [options, setOptions] = useState(initialOptionsMemo);
273
+ const [inputFocused, setInputFocused] = useState(false);
156
274
  const [inputText, setInputText] = useState((_b = value === null || value === void 0 ? void 0 : value.label) !== null && _b !== void 0 ? _b : "");
157
275
  const autocompleteRef = useRef(null);
158
276
  const delayedSearch = useDebounce(updateSearch, debounceRate);
277
+ const inputRef = useRef(null);
159
278
  useEffect(() => {
160
279
  delayedSearch();
161
280
  }, [inputText]);
@@ -164,8 +283,8 @@ function AutocompleteInternal(_a, ref) {
164
283
  updateInput((_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : "");
165
284
  }, [value]);
166
285
  return (React.createElement("div", { className: styles.autocomplete, ref: autocompleteRef },
167
- React.createElement(InputText, Object.assign({ ref: ref, autocomplete: false, size: size, value: inputText, onChange: handleInputChange, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur, validations: validations }, inputProps)),
168
- menuVisible && (React.createElement(Menu, { attachTo: autocompleteRef, visible: menuVisible && options.length > 0, options: options, selectedOption: value, onOptionSelect: handleMenuChange }))));
286
+ React.createElement(InputText, Object.assign({ ref: mergeRefs([ref, inputRef]), autocomplete: false, size: size, value: inputText, onChange: handleInputChange, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur, validations: validations }, inputProps)),
287
+ React.createElement(Menu, { attachTo: autocompleteRef, inputRef: inputRef, inputFocused: inputFocused, options: options, customRenderMenu: customRenderMenu, selectedOption: value, onOptionSelect: handleMenuChange })));
169
288
  function updateInput(newText) {
170
289
  setInputText(newText);
171
290
  if (newText === "") {
@@ -175,14 +294,15 @@ function AutocompleteInternal(_a, ref) {
175
294
  function updateSearch() {
176
295
  return __awaiter(this, void 0, void 0, function* () {
177
296
  const updatedOptions = yield getOptions(inputText);
178
- const filteredOptions = updatedOptions.filter((option) => "options" in option && option.options ? option.options.length > 0 : true);
297
+ const filteredOptions = updatedOptions.filter(option => isOptionGroup(option) ? option.options.length > 0 : true);
179
298
  setOptions(mapToOptions(filteredOptions));
180
299
  });
181
300
  }
182
301
  function handleMenuChange(chosenOption) {
302
+ var _a;
183
303
  onChange(chosenOption);
184
- updateInput(chosenOption.label);
185
- setMenuVisible(false);
304
+ updateInput((_a = chosenOption === null || chosenOption === void 0 ? void 0 : chosenOption.label) !== null && _a !== void 0 ? _a : "");
305
+ setInputFocused(false);
186
306
  }
187
307
  function handleInputChange(newText) {
188
308
  updateInput(newText);
@@ -191,7 +311,7 @@ function AutocompleteInternal(_a, ref) {
191
311
  }
192
312
  }
193
313
  function handleInputBlur() {
194
- setMenuVisible(false);
314
+ setInputFocused(false);
195
315
  if (value == undefined || value.label !== inputText) {
196
316
  setInputText("");
197
317
  onChange(undefined);
@@ -199,21 +319,23 @@ function AutocompleteInternal(_a, ref) {
199
319
  onBlur && onBlur();
200
320
  }
201
321
  function handleInputFocus() {
202
- setMenuVisible(true);
322
+ setInputFocused(true);
203
323
  if (onFocus) {
204
324
  onFocus();
205
325
  }
206
326
  }
207
327
  }
208
328
  function mapToOptions(items) {
209
- return items.reduce(function (result, item) {
210
- result = result.concat([item]);
211
- if (item.options) {
329
+ const retVal = items.reduce((result, item) => {
330
+ result.push(item);
331
+ if (isOptionGroup(item) && item.options) {
212
332
  result = result.concat(item.options);
213
333
  }
214
334
  return result;
215
335
  }, []);
336
+ return retVal;
216
337
  }
338
+ // Casts the Generics to the forward ref so autocomplete works as expected for consumers
217
339
  const Autocomplete = forwardRef(AutocompleteInternal);
218
340
 
219
- export { Autocomplete as A };
341
+ export { Autocomplete as A, BaseMenuOption as B, KeyboardAction as K, MenuOption as M, BaseMenuGroupOption as a, useCustomKeyboardNavigation as b, useRepositionMenu as c, BaseAutocompleteMenuWrapper as d, useAutocompleteMenu as e, isOptionGroup as f, getRequestedIndexChange as g, isOptionSelected as i, useKeyboardNavigation as u };
@@ -5,7 +5,6 @@ require('react');
5
5
  require('react-popper');
6
6
  require('../useRefocusOnActivator-cjs.js');
7
7
  require('classnames');
8
- require('react-dom');
9
8
  require('../ButtonDismiss-cjs.js');
10
9
  require('../Button-cjs.js');
11
10
  require('react-router-dom');
@@ -3,7 +3,6 @@ import 'react';
3
3
  import 'react-popper';
4
4
  import '../useRefocusOnActivator-es.js';
5
5
  import 'classnames';
6
- import 'react-dom';
7
6
  import '../ButtonDismiss-es.js';
8
7
  import '../Button-es.js';
9
8
  import 'react-router-dom';
@@ -4,7 +4,6 @@ var React = require('react');
4
4
  var reactPopper = require('react-popper');
5
5
  var useRefocusOnActivator = require('./useRefocusOnActivator-cjs.js');
6
6
  var classnames = require('classnames');
7
- var ReactDOM = require('react-dom');
8
7
  var ButtonDismiss = require('./ButtonDismiss-cjs.js');
9
8
 
10
9
  var classes = {"popover":"rY8OtuArIi0-","header":"UI1AohefbSo-","dismissButton":"HyA0TM5soDM-","arrow":"uClo-5-xhAc-","spinning":"VA0ROLmpLPs-"};
@@ -21,15 +20,11 @@ function Popover({ onRequestClose, children, attachTo, open, preferredPlacement
21
20
  const popoverClassNames = classnames(classes.popover, UNSAFE_className.container);
22
21
  const dismissButtonClassNames = classnames(classes.dismissButton, UNSAFE_className.dismissButtonContainer);
23
22
  const arrowClassNames = classnames(classes.arrow, UNSAFE_className.arrow);
24
- const popoverContent = (React.createElement("div", Object.assign({ role: "dialog", "data-elevation": "elevated", ref: setPopperElement, style: Object.assign(Object.assign({}, popperStyles.popper), ((_a = UNSAFE_style.container) !== null && _a !== void 0 ? _a : {})), className: popoverClassNames }, attributes.popper, { "data-testid": "popover-container" }),
23
+ return (React.createElement(React.Fragment, null, open && (React.createElement("div", Object.assign({ role: "dialog", "data-elevation": "elevated", ref: setPopperElement, style: Object.assign(Object.assign({}, popperStyles.popper), ((_a = UNSAFE_style.container) !== null && _a !== void 0 ? _a : {})), className: popoverClassNames }, attributes.popper, { "data-testid": "popover-container" }),
25
24
  React.createElement("div", { className: dismissButtonClassNames, style: (_b = UNSAFE_style.dismissButtonContainer) !== null && _b !== void 0 ? _b : {}, "data-testid": "popover-dismiss-button-container" },
26
25
  React.createElement(ButtonDismiss.ButtonDismiss, { onClick: onRequestClose, ariaLabel: "Close dialog" })),
27
26
  children,
28
- React.createElement("div", { ref: setArrowElement, className: arrowClassNames, style: Object.assign(Object.assign({}, popperStyles.arrow), ((_c = UNSAFE_style.arrow) !== null && _c !== void 0 ? _c : {})), "data-testid": "popover-arrow" })));
29
- return React.createElement(React.Fragment, null, open && React.createElement(PopoverPortal, null, popoverContent));
30
- }
31
- function PopoverPortal({ children }) {
32
- return ReactDOM.createPortal(children, document.body);
27
+ React.createElement("div", { ref: setArrowElement, className: arrowClassNames, style: Object.assign(Object.assign({}, popperStyles.arrow), ((_c = UNSAFE_style.arrow) !== null && _c !== void 0 ? _c : {})), "data-testid": "popover-arrow" })))));
33
28
  }
34
29
  function buildModifiers(arrowElement) {
35
30
  const modifiers = [
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
2
2
  import { usePopper } from 'react-popper';
3
3
  import { u as useRefocusOnActivator_2 } from './useRefocusOnActivator-es.js';
4
4
  import classnames from 'classnames';
5
- import ReactDOM from 'react-dom';
6
5
  import { B as ButtonDismiss } from './ButtonDismiss-es.js';
7
6
 
8
7
  var classes = {"popover":"rY8OtuArIi0-","header":"UI1AohefbSo-","dismissButton":"HyA0TM5soDM-","arrow":"uClo-5-xhAc-","spinning":"VA0ROLmpLPs-"};
@@ -19,15 +18,11 @@ function Popover({ onRequestClose, children, attachTo, open, preferredPlacement
19
18
  const popoverClassNames = classnames(classes.popover, UNSAFE_className.container);
20
19
  const dismissButtonClassNames = classnames(classes.dismissButton, UNSAFE_className.dismissButtonContainer);
21
20
  const arrowClassNames = classnames(classes.arrow, UNSAFE_className.arrow);
22
- const popoverContent = (React.createElement("div", Object.assign({ role: "dialog", "data-elevation": "elevated", ref: setPopperElement, style: Object.assign(Object.assign({}, popperStyles.popper), ((_a = UNSAFE_style.container) !== null && _a !== void 0 ? _a : {})), className: popoverClassNames }, attributes.popper, { "data-testid": "popover-container" }),
21
+ return (React.createElement(React.Fragment, null, open && (React.createElement("div", Object.assign({ role: "dialog", "data-elevation": "elevated", ref: setPopperElement, style: Object.assign(Object.assign({}, popperStyles.popper), ((_a = UNSAFE_style.container) !== null && _a !== void 0 ? _a : {})), className: popoverClassNames }, attributes.popper, { "data-testid": "popover-container" }),
23
22
  React.createElement("div", { className: dismissButtonClassNames, style: (_b = UNSAFE_style.dismissButtonContainer) !== null && _b !== void 0 ? _b : {}, "data-testid": "popover-dismiss-button-container" },
24
23
  React.createElement(ButtonDismiss, { onClick: onRequestClose, ariaLabel: "Close dialog" })),
25
24
  children,
26
- React.createElement("div", { ref: setArrowElement, className: arrowClassNames, style: Object.assign(Object.assign({}, popperStyles.arrow), ((_c = UNSAFE_style.arrow) !== null && _c !== void 0 ? _c : {})), "data-testid": "popover-arrow" })));
27
- return React.createElement(React.Fragment, null, open && React.createElement(PopoverPortal, null, popoverContent));
28
- }
29
- function PopoverPortal({ children }) {
30
- return ReactDOM.createPortal(children, document.body);
25
+ React.createElement("div", { ref: setArrowElement, className: arrowClassNames, style: Object.assign(Object.assign({}, popperStyles.arrow), ((_c = UNSAFE_style.arrow) !== null && _c !== void 0 ? _c : {})), "data-testid": "popover-arrow" })))));
31
26
  }
32
27
  function buildModifiers(arrowElement) {
33
28
  const modifiers = [
package/dist/index.cjs CHANGED
@@ -5,6 +5,15 @@ var AnimatedSwitcher = require('./AnimatedSwitcher-cjs.js');
5
5
  var AtlantisContext = require('./AtlantisContext-cjs.js');
6
6
  var updateTheme = require('./updateTheme-cjs.js');
7
7
  var Autocomplete = require('./Autocomplete-cjs.js');
8
+ require('react');
9
+ require('classnames');
10
+ var Heading = require('./Heading-cjs.js');
11
+ var Text = require('./Text-cjs.js');
12
+ var Icon = require('./Icon-cjs.js');
13
+ require('./useSafeLayoutEffect-cjs.js');
14
+ require('react-popper');
15
+ require('./useIsMounted-cjs.js');
16
+ require('react-dom');
8
17
  var Avatar = require('./Avatar-cjs.js');
9
18
  var Banner = require('./Banner-cjs.js');
10
19
  var Box = require('./Box-cjs.js');
@@ -14,8 +23,6 @@ var Card = require('./Card-cjs.js');
14
23
  var Checkbox = require('./Checkbox-cjs.js');
15
24
  var Chip = require('./Chip-cjs.js');
16
25
  var ChipDismissible = require('./ChipDismissible-cjs.js');
17
- require('react');
18
- var Icon = require('./Icon-cjs.js');
19
26
  var Chips = require('./Chips-cjs.js');
20
27
  require('./useAssert-cjs.js');
21
28
  var Combobox = require('./Combobox-cjs.js');
@@ -46,7 +53,6 @@ var FormatTime = require('./FormatTime-cjs.js');
46
53
  var Gallery = require('./Gallery-cjs.js');
47
54
  var Glimmer = require('./Glimmer-cjs.js');
48
55
  var Grid = require('./Grid-cjs.js');
49
- var Heading = require('./Heading-cjs.js');
50
56
  var InlineLabel = require('./InlineLabel-cjs.js');
51
57
  var InputAvatar = require('./InputAvatar-cjs.js');
52
58
  var InputDate_index = require('./InputDate/index.cjs');
@@ -81,7 +87,6 @@ var StatusLabel = require('./StatusLabel-cjs.js');
81
87
  var Switch = require('./Switch-cjs.js');
82
88
  var Body = require('./Body-cjs.js');
83
89
  var Tabs = require('./Tabs-cjs.js');
84
- var Text = require('./Text-cjs.js');
85
90
  var showToast = require('./showToast-cjs.js');
86
91
  var Tooltip = require('./Tooltip-cjs.js');
87
92
  var Typography = require('./Typography-cjs.js');
@@ -97,12 +102,7 @@ require('./keysIn-cjs.js');
97
102
  require('./_isIterateeCall-cjs.js');
98
103
  require('./_setToString-cjs.js');
99
104
  require('./tslib.es6-cjs.js');
100
- require('classnames');
101
- require('react-dom');
102
- require('react-popper');
103
105
  require('./useOnKeyDown-cjs.js');
104
- require('./useSafeLayoutEffect-cjs.js');
105
- require('./useIsMounted-cjs.js');
106
106
  require('./debounce-cjs.js');
107
107
  require('./isSymbol-cjs.js');
108
108
  require('color');
@@ -188,6 +188,9 @@ exports.atlantisThemeContextDefaultValues = updateTheme.atlantisThemeContextDefa
188
188
  exports.updateTheme = updateTheme.updateTheme;
189
189
  exports.useAtlantisTheme = updateTheme.useAtlantisTheme;
190
190
  exports.Autocomplete = Autocomplete.Autocomplete;
191
+ exports.Heading = Heading.Heading;
192
+ exports.Text = Text.Text;
193
+ exports.Icon = Icon.Icon;
191
194
  exports.Avatar = Avatar.Avatar;
192
195
  exports.Banner = Banner.Banner;
193
196
  exports.Box = Box.Box;
@@ -198,7 +201,6 @@ exports.Checkbox = Checkbox.Checkbox;
198
201
  exports.Chip = Chip.Chip;
199
202
  exports.ChipDismissible = ChipDismissible.ChipDismissible;
200
203
  exports.ChipSelectable = ChipDismissible.ChipSelectable;
201
- exports.Icon = Icon.Icon;
202
204
  exports.Chips = Chips.Chips;
203
205
  exports.Combobox = Combobox.Combobox;
204
206
  exports.ComboboxContextProvider = ComboboxProvider.ComboboxContextProvider;
@@ -241,7 +243,6 @@ exports.GLIMMER_TEST_ID = Glimmer.GLIMMER_TEST_ID;
241
243
  exports.Glimmer = Glimmer.Glimmer;
242
244
  exports.GRID_TEST_ID = Grid.GRID_TEST_ID;
243
245
  exports.Grid = Grid.Grid;
244
- exports.Heading = Heading.Heading;
245
246
  exports.InlineLabel = InlineLabel.InlineLabel;
246
247
  exports.InputAvatar = InputAvatar.InputAvatar;
247
248
  exports.InputDate = InputDate_index.InputDate;
@@ -299,7 +300,6 @@ exports.Row = Body.Row;
299
300
  exports.Table = Body.Table;
300
301
  exports.Tab = Tabs.Tab;
301
302
  exports.Tabs = Tabs.Tabs;
302
- exports.Text = Text.Text;
303
303
  exports.Toast = showToast.Toast;
304
304
  exports.showToast = showToast.showToast;
305
305
  exports.Tooltip = Tooltip.Tooltip;
package/dist/index.mjs CHANGED
@@ -3,6 +3,15 @@ export { A as AnimatedSwitcher } from './AnimatedSwitcher-es.js';
3
3
  export { A as AtlantisContext, a as atlantisContextDefaultValues, u as useAtlantisContext } from './AtlantisContext-es.js';
4
4
  export { A as AtlantisThemeContextProvider, T as THEME_CHANGE_EVENT, a as atlantisThemeContextDefaultValues, b as updateTheme, u as useAtlantisTheme } from './updateTheme-es.js';
5
5
  export { A as Autocomplete } from './Autocomplete-es.js';
6
+ import 'react';
7
+ import 'classnames';
8
+ export { H as Heading } from './Heading-es.js';
9
+ export { T as Text } from './Text-es.js';
10
+ export { I as Icon } from './Icon-es.js';
11
+ import './useSafeLayoutEffect-es.js';
12
+ import 'react-popper';
13
+ import './useIsMounted-es.js';
14
+ import 'react-dom';
6
15
  export { A as Avatar } from './Avatar-es.js';
7
16
  export { B as Banner } from './Banner-es.js';
8
17
  export { B as Box } from './Box-es.js';
@@ -12,8 +21,6 @@ export { C as Card } from './Card-es.js';
12
21
  export { C as Checkbox } from './Checkbox-es.js';
13
22
  export { C as Chip } from './Chip-es.js';
14
23
  export { a as ChipDismissible, C as ChipSelectable } from './ChipDismissible-es.js';
15
- import 'react';
16
- export { I as Icon } from './Icon-es.js';
17
24
  export { C as Chips } from './Chips-es.js';
18
25
  import './useAssert-es.js';
19
26
  export { C as Combobox } from './Combobox-es.js';
@@ -44,7 +51,6 @@ export { F as FormatTime } from './FormatTime-es.js';
44
51
  export { G as Gallery } from './Gallery-es.js';
45
52
  export { a as GLIMMER_TEST_ID, G as Glimmer } from './Glimmer-es.js';
46
53
  export { G as GRID_TEST_ID, a as Grid } from './Grid-es.js';
47
- export { H as Heading } from './Heading-es.js';
48
54
  export { I as InlineLabel } from './InlineLabel-es.js';
49
55
  export { I as InputAvatar } from './InputAvatar-es.js';
50
56
  export { InputDate } from './InputDate/index.mjs';
@@ -79,7 +85,6 @@ export { S as StatusLabel } from './StatusLabel-es.js';
79
85
  export { S as Switch } from './Switch-es.js';
80
86
  export { B as Body, C as Cell, b as CellCurrency, a as CellNumeric, F as Footer, H as Header, R as Row, T as Table } from './Body-es.js';
81
87
  export { a as Tab, T as Tabs } from './Tabs-es.js';
82
- export { T as Text } from './Text-es.js';
83
88
  export { T as Toast, s as showToast } from './showToast-es.js';
84
89
  export { T as Tooltip } from './Tooltip-es.js';
85
90
  export { T as Typography } from './Typography-es.js';
@@ -95,12 +100,7 @@ import './keysIn-es.js';
95
100
  import './_isIterateeCall-es.js';
96
101
  import './_setToString-es.js';
97
102
  import './tslib.es6-es.js';
98
- import 'classnames';
99
- import 'react-dom';
100
- import 'react-popper';
101
103
  import './useOnKeyDown-es.js';
102
- import './useSafeLayoutEffect-es.js';
103
- import './useIsMounted-es.js';
104
104
  import './debounce-es.js';
105
105
  import './isSymbol-es.js';
106
106
  import 'color';