@lumx/react 4.3.2-alpha.21 → 4.3.2-alpha.23

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.
package/package.json CHANGED
@@ -6,8 +6,8 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@lumx/core": "^4.3.2-alpha.21",
10
- "@lumx/icons": "^4.3.2-alpha.21",
9
+ "@lumx/core": "^4.3.2-alpha.23",
10
+ "@lumx/icons": "^4.3.2-alpha.23",
11
11
  "@popperjs/core": "^2.5.4",
12
12
  "body-scroll-lock": "^3.1.5",
13
13
  "react-popper": "^2.2.4"
@@ -102,6 +102,6 @@
102
102
  "build:storybook": "storybook build"
103
103
  },
104
104
  "sideEffects": false,
105
- "version": "4.3.2-alpha.21",
105
+ "version": "4.3.2-alpha.23",
106
106
  "stableVersion": "4.3.1"
107
107
  }
package/utils/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
+ import * as React$1 from 'react';
1
2
  import React__default, { RefObject, ReactNode, AriaAttributes } from 'react';
2
3
  import { Falsy, ObjectValues } from '@lumx/core/js/types';
4
+ import { q as ComboboxAction, X as ComboboxState, y as OnComboboxSelect, T as TextFieldProps, r as ComboboxProps, Y as ComboboxSelectionType, Z as ComboboxTranslations, _ as BaseLoadingStatus, $ as RegisteredComboboxOption, a0 as ComboboxOptionSelectEventSource } from '../Tooltip-D7GkxJsY.js';
3
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
6
  import { DisabledStateContextValue } from '@lumx/core/js/utils/disabledState';
7
+ import '@lumx/core/js/constants';
5
8
 
6
9
  interface ClickAwayParameters {
7
10
  /**
@@ -395,5 +398,186 @@ type Output = [
395
398
  */
396
399
  declare const useRovingTabIndex: (...args: BaseHookOptions) => Output;
397
400
 
398
- export { A11YLiveMessage, ClickAwayProvider, DisabledStateProvider, InfiniteScroll, MovingFocusContext, MovingFocusProvider, Portal, PortalProvider, useDisabledStateContext, useRovingTabIndex, useVirtualFocus, useVirtualFocusParent };
399
- export type { A11YLiveMessageProps, InfiniteScrollProps, PortalInit, PortalProps, PortalProviderProps };
401
+ /** Dispatch for the combobox component */
402
+ type ComboboxDispatch = React.Dispatch<ComboboxAction>;
403
+
404
+ interface ComboboxContextActions {
405
+ onSelect?: OnComboboxSelect;
406
+ onInputChange?: TextFieldProps['onChange'];
407
+ onOpen?: (params: {
408
+ manual: boolean;
409
+ currentValue: string;
410
+ }) => void;
411
+ }
412
+ interface ComboboxContextProps extends ComboboxState, ComboboxContextActions {
413
+ openOnFocus?: ComboboxProps['openOnFocus'];
414
+ openOnClick?: ComboboxProps['openOnClick'];
415
+ optionsLength: number;
416
+ /** The dispatch function to manage the inner state */
417
+ dispatch: ComboboxDispatch;
418
+ /** The ids of the currently selected options */
419
+ selectedIds?: Array<string>;
420
+ /** the type of selection currently configured for the combobox */
421
+ selectionType?: ComboboxSelectionType;
422
+ /**
423
+ * Whether the error state should be displayed when the status is in error.
424
+ */
425
+ showErrorState?: boolean;
426
+ /**
427
+ * Whether the empty state should be displayed when there is no results.
428
+ */
429
+ showEmptyState?: boolean;
430
+ /** translations to be used across the combobox */
431
+ translations: ComboboxTranslations;
432
+ }
433
+ /** Context for the Combobox component */
434
+ declare const ComboboxContext: React__default.Context<ComboboxContextProps>;
435
+ /** Context for a combobox section to store its unique id */
436
+ declare const SectionContext: React__default.Context<{
437
+ sectionId: string;
438
+ isLoading?: boolean;
439
+ }>;
440
+
441
+ interface ComboboxOptionContextValue {
442
+ optionId?: string;
443
+ isKeyboardHighlighted?: boolean;
444
+ }
445
+ declare const ComboboxOptionContext: React__default.Context<ComboboxOptionContextValue>;
446
+ interface ComboboxOptionIdProviderProps extends Required<ComboboxOptionContextValue> {
447
+ /** Option to display */
448
+ children: ReactNode;
449
+ }
450
+ /** Context Provider to store the current combobox option id. */
451
+ declare const ComboboxOptionContextProvider: ({ optionId, isKeyboardHighlighted, children, }: ComboboxOptionIdProviderProps) => react_jsx_runtime.JSX.Element;
452
+ /**
453
+ * Retrieve the current combobox option id.
454
+ * Must be used within a ComboboxOptionIdProvider
455
+ */
456
+ declare const useComboboxOptionContext: () => Required<ComboboxOptionContextValue>;
457
+
458
+ interface ComboboxProviderProps {
459
+ children: ReactNode;
460
+ /** The data to pass the provider. Can be generated by the useCombobox hook */
461
+ value: ComboboxContextProps;
462
+ }
463
+ /** Context provider for the combobox. */
464
+ declare const ComboboxProvider: ({ children, value }: ComboboxProviderProps) => react_jsx_runtime.JSX.Element;
465
+
466
+ interface ComboboxRefsContext {
467
+ triggerRef: RefObject<HTMLElement>;
468
+ anchorRef: RefObject<HTMLElement>;
469
+ }
470
+ /** Context to store the refs of the combobox elements */
471
+ declare const ComboboxRefsContext: React$1.Context<ComboboxRefsContext>;
472
+ interface ComboboxRefsProviderProps extends ComboboxRefsContext {
473
+ children: ReactNode;
474
+ }
475
+ /** Provider to store the required refs for the Combobox */
476
+ declare const ComboboxRefsProvider: ({ triggerRef, anchorRef, children }: ComboboxRefsProviderProps) => react_jsx_runtime.JSX.Element;
477
+ /** Retrieves the combobox elements references from context */
478
+ declare const useComboboxRefs: () => ComboboxRefsContext;
479
+
480
+ /** Retrieve the current combobox state and actions */
481
+ declare const useCombobox: () => {
482
+ openOnFocus?: ComboboxProps["openOnFocus"];
483
+ openOnClick?: ComboboxProps["openOnClick"];
484
+ optionsLength: number;
485
+ selectedIds?: Array<string>;
486
+ selectionType?: ComboboxSelectionType;
487
+ showErrorState?: boolean;
488
+ showEmptyState?: boolean;
489
+ translations: ComboboxTranslations;
490
+ comboboxId: string;
491
+ listboxId: string;
492
+ status: BaseLoadingStatus;
493
+ options: Record<string, RegisteredComboboxOption>;
494
+ isOpen: boolean;
495
+ showAll: boolean;
496
+ type: "listbox" | "grid";
497
+ defaultInputValue?: string;
498
+ handleClose: () => void;
499
+ handleOpen: (params?: {
500
+ manual?: boolean;
501
+ }) => Promise<RegisteredComboboxOption[] | undefined>;
502
+ handleInputChange: (value: string, name?: string, event?: React__default.SyntheticEvent) => void;
503
+ handleSelected: (option: RegisteredComboboxOption, source?: ComboboxOptionSelectEventSource) => void;
504
+ dispatch: ComboboxDispatch;
505
+ inputValue: string;
506
+ };
507
+
508
+ interface UseComboboxTriggerArgs {
509
+ context: ReturnType<typeof useCombobox>;
510
+ refs: ReturnType<typeof useComboboxRefs>;
511
+ onKeyDown?: React__default.KeyboardEventHandler;
512
+ onFocus?: React__default.FocusEventHandler;
513
+ onBlur?: React__default.FocusEventHandler;
514
+ }
515
+ /**
516
+ * Provide props for the semantic and behaviors the combobox trigger.
517
+ *
518
+ *
519
+ */
520
+ declare function useComboboxTrigger({ context, refs, onBlur, onFocus, onKeyDown }: UseComboboxTriggerArgs): {
521
+ id: string;
522
+ role: string;
523
+ 'aria-activedescendant': string;
524
+ 'aria-controls': string;
525
+ 'aria-owns': string;
526
+ 'aria-expanded': boolean;
527
+ onFocus: (event: React__default.FocusEvent) => void;
528
+ onBlur: (event: React__default.FocusEvent<Element>) => void;
529
+ onClick: () => void;
530
+ onKeyDown: React__default.KeyboardEventHandler<Element>;
531
+ };
532
+
533
+ /**
534
+ * Provide props for the semantic and behaviors the combobox button trigger
535
+ *
536
+ * Overrides the useComboboxTrigger() props & behavior to add a jump to option
537
+ * on printable character key down.
538
+ */
539
+ declare function useComboboxButton(args: UseComboboxTriggerArgs): {
540
+ id: string;
541
+ role: string;
542
+ 'aria-activedescendant': string;
543
+ 'aria-controls': string;
544
+ 'aria-owns': string;
545
+ 'aria-expanded': boolean;
546
+ onFocus: (event: React__default.FocusEvent) => void;
547
+ onBlur: (event: React__default.FocusEvent<Element>) => void;
548
+ onClick: () => void;
549
+ onKeyDown: React__default.KeyboardEventHandler<Element>;
550
+ };
551
+
552
+ /**
553
+ * Provide props for the semantic and behaviors the combobox input trigger
554
+ *
555
+ * Overrides the useComboboxTrigger() props & behavior to prevent open on click
556
+ * if `openOnFocus` is not enabled.
557
+ */
558
+ declare function useComboboxInput({ onKeyDown: propsOnKeyDown, ...args }: UseComboboxTriggerArgs): {
559
+ onClick: () => void;
560
+ onKeyDown: React__default.KeyboardEventHandler<Element>;
561
+ id: string;
562
+ role: string;
563
+ 'aria-activedescendant': string;
564
+ 'aria-controls': string;
565
+ 'aria-owns': string;
566
+ 'aria-expanded': boolean;
567
+ onFocus: (event: React__default.FocusEvent) => void;
568
+ onBlur: (event: React__default.FocusEvent<Element>) => void;
569
+ };
570
+
571
+ /** Retrieve the current combobox section id */
572
+ declare const useComboboxSectionId: () => {
573
+ sectionId: string;
574
+ isLoading?: boolean;
575
+ };
576
+
577
+ /**
578
+ * Register the given option to the context
579
+ */
580
+ declare const useRegisterOption: (registerId: string, option: RegisteredComboboxOption, shouldRegister?: boolean) => void;
581
+
582
+ export { A11YLiveMessage, ClickAwayProvider, ComboboxContext, ComboboxOptionContext, ComboboxOptionContextProvider, ComboboxProvider, ComboboxRefsProvider, DisabledStateProvider, InfiniteScroll, MovingFocusContext, MovingFocusProvider, Portal, PortalProvider, SectionContext, useCombobox, useComboboxButton, useComboboxInput, useComboboxOptionContext, useComboboxRefs, useComboboxSectionId, useComboboxTrigger, useDisabledStateContext, useRegisterOption, useRovingTabIndex, useVirtualFocus, useVirtualFocusParent };
583
+ export type { A11YLiveMessageProps, ComboboxContextActions, ComboboxContextProps, ComboboxOptionContextValue, ComboboxProviderProps, InfiniteScrollProps, PortalInit, PortalProps, PortalProviderProps, UseComboboxTriggerArgs };
package/utils/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { r as reducer, I as INITIAL_STATE, b as buildLoopAroundObject, M as MovingFocusContext, N as NAV_KEYS, g as getPointerTypeFromEvent } from '../_internal/CzTdCnO5.js';
2
- export { A as A11YLiveMessage, C as ClickAwayProvider, D as DisabledStateProvider, P as Portal, c as PortalProvider, u as useDisabledStateContext, a as useVirtualFocus } from '../_internal/CzTdCnO5.js';
3
- import React__default, { useEffect } from 'react';
1
+ import { r as reducer, I as INITIAL_STATE, i as buildLoopAroundObject, M as MovingFocusContext, N as NAV_KEYS, j as getPointerTypeFromEvent, k as ComboboxContext, l as isComboboxValue } from '../_internal/BSETDrpT.js';
2
+ export { A as A11YLiveMessage, h as ClickAwayProvider, m as ComboboxOptionContext, C as ComboboxOptionContextProvider, n as ComboboxRefsProvider, D as DisabledStateProvider, P as Portal, o as PortalProvider, S as SectionContext, b as useCombobox, e as useComboboxOptionContext, f as useComboboxRefs, a as useComboboxSectionId, u as useDisabledStateContext, c as useRegisterOption, d as useVirtualFocus } from '../_internal/BSETDrpT.js';
4
3
  import { jsx } from 'react/jsx-runtime';
4
+ import React__default, { useEffect } from 'react';
5
+ import debounce from 'lodash/debounce.js';
5
6
  import isNil from 'lodash/isNil.js';
6
7
  import uniqueId from 'lodash/uniqueId.js';
7
8
 
@@ -275,5 +276,364 @@ const useRovingTabIndex = (ref, disabled = false, rowKey = null, autofocus = fal
275
276
  return [tabIndex, focused, handleKeyDown, handleClick];
276
277
  };
277
278
 
278
- export { InfiniteScroll, MovingFocusContext, MovingFocusProvider, useRovingTabIndex, useVirtualFocusParent };
279
+ /** Context provider for the combobox. */
280
+ const ComboboxProvider = ({
281
+ children,
282
+ value
283
+ }) => {
284
+ return /*#__PURE__*/jsx(ComboboxContext.Provider, {
285
+ value: value,
286
+ children: /*#__PURE__*/jsx(MovingFocusProvider, {
287
+ options: {
288
+ direction: value.type === 'grid' ? 'both' : 'vertical',
289
+ firstFocusDirection: value.type === 'grid' ? 'vertical' : undefined,
290
+ loopAround: {
291
+ row: 'next-loop',
292
+ col: 'inside'
293
+ },
294
+ gridJumpToShortcutDirection: 'vertical',
295
+ defaultSelectedId: value.selectedIds?.[0],
296
+ listKey: value.inputValue
297
+ },
298
+ children: children
299
+ })
300
+ });
301
+ };
302
+
303
+ /**
304
+ * Provide props for the semantic and behaviors the combobox trigger.
305
+ *
306
+ *
307
+ */
308
+ function useComboboxTrigger({
309
+ context,
310
+ refs,
311
+ onBlur,
312
+ onFocus,
313
+ onKeyDown
314
+ }) {
315
+ const {
316
+ comboboxId,
317
+ listboxId,
318
+ isOpen,
319
+ options,
320
+ optionsLength,
321
+ selectedIds,
322
+ openOnFocus,
323
+ handleClose,
324
+ handleOpen,
325
+ handleSelected,
326
+ showEmptyState = false,
327
+ showErrorState = false,
328
+ status
329
+ } = context;
330
+ const highlightedId = useVirtualFocusParent(refs.triggerRef);
331
+ const {
332
+ dispatch: movingFocusDispatch
333
+ } = React__default.useContext(MovingFocusContext);
334
+ const isErrorStateDisplayed = showErrorState && isOpen && status === 'error';
335
+ const isEmptyStateDisplayed = showEmptyState && isOpen && status === 'idle' && optionsLength === 0;
336
+ const showPopover = isOpen && optionsLength > 0 || isEmptyStateDisplayed || isErrorStateDisplayed;
337
+
338
+ /**
339
+ * A debounce close to use to leave time for the
340
+ * listbox to process things before closing.
341
+ * This can be useful when clicking an option to leave time for the
342
+ * event to be processed before closing the popover.
343
+ */
344
+ // eslint-disable-next-line react-hooks/exhaustive-deps
345
+ const debouncedClose = React__default.useCallback(debounce(handleClose, 200), []);
346
+
347
+ /** Cleanup any ongoing cleanup */
348
+ React__default.useEffect(() => {
349
+ return () => {
350
+ if (debouncedClose?.cancel) {
351
+ debouncedClose.cancel();
352
+ }
353
+ };
354
+ }, [debouncedClose]);
355
+ const handleBlur = React__default.useCallback(event => {
356
+ debouncedClose();
357
+ if (onBlur) {
358
+ onBlur(event);
359
+ }
360
+ }, [debouncedClose, onBlur]);
361
+
362
+ /** Actions triggered when the input field is focused */
363
+ const handleFocus = event => {
364
+ // If the field is refocused in the process of closing, cancel close
365
+ if (debouncedClose?.cancel) {
366
+ debouncedClose.cancel();
367
+ }
368
+ if (onFocus) {
369
+ onFocus(event);
370
+ }
371
+ /**
372
+ * Only set the open on focus if the combobox isn't already opened.
373
+ * This avoids the popover re-opening when an option is selected and the
374
+ * field is refocused
375
+ */
376
+ if (openOnFocus && !showPopover) {
377
+ handleOpen({
378
+ manual: true
379
+ });
380
+ }
381
+ };
382
+ const handleClick = () => {
383
+ handleOpen({
384
+ manual: true
385
+ });
386
+ };
387
+
388
+ /**
389
+ * Keyboard shortcut management following the WAI APG pattern
390
+ * https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-list/#kbd_label
391
+ */
392
+ const handleKeyDown = React__default.useCallback(async event => {
393
+ const {
394
+ key,
395
+ altKey
396
+ } = event;
397
+
398
+ /**
399
+ * On Enter key
400
+ * * Select option that is currently highlighted, if any
401
+ * * Close suggestions, event if none is highlighted
402
+ */
403
+ if (event.key === 'Enter') {
404
+ if (!showPopover) {
405
+ return;
406
+ }
407
+ if (highlightedId) {
408
+ // prevent any potential form submission
409
+ event.preventDefault();
410
+ const option = options[highlightedId];
411
+ handleSelected(option, 'keyboard');
412
+ } else {
413
+ handleClose();
414
+ }
415
+ return;
416
+ }
417
+
418
+ /**
419
+ * On arrow up/down
420
+ * * If popover is already opened, do nothing
421
+ * * If alt key pressed, show the listbox without focusing an option
422
+ * * If arrow Up is pressed, select last option
423
+ * * If arrow Down is pressed, select first option
424
+ * */
425
+ if (key === 'ArrowDown' || key === 'ArrowUp') {
426
+ if (showPopover) {
427
+ return;
428
+ }
429
+
430
+ /** Open the listbox */
431
+ const listBoxOptions = await handleOpen({
432
+ manual: true
433
+ });
434
+ if (!listBoxOptions) {
435
+ return;
436
+ }
437
+
438
+ /**
439
+ * If alt key is pressed, only open without changing visual focus
440
+ * as per WAI Guidelines
441
+ */
442
+ if (!altKey) {
443
+ /** If a selected id is set, set it as current tabstop */
444
+ if (selectedIds?.length) {
445
+ movingFocusDispatch({
446
+ type: 'SELECT_TAB_STOP',
447
+ payload: {
448
+ id: selectedIds?.[0],
449
+ type: 'keyboard'
450
+ }
451
+ });
452
+ } else {
453
+ /** Focus either the first or last item depending on the keyboard arrow pressed */
454
+ movingFocusDispatch({
455
+ type: 'KEY_NAV',
456
+ payload: {
457
+ ctrlKey: false,
458
+ key: key === 'ArrowUp' ? 'End' : 'Home'
459
+ }
460
+ });
461
+ }
462
+ }
463
+ return;
464
+ }
465
+
466
+ // Forward event
467
+ onKeyDown?.(event);
468
+ }, [onKeyDown, showPopover, highlightedId, options, handleSelected, handleClose, handleOpen, selectedIds, movingFocusDispatch]);
469
+ return {
470
+ id: comboboxId,
471
+ role: 'combobox',
472
+ 'aria-activedescendant': showPopover && highlightedId ? highlightedId : '',
473
+ 'aria-controls': listboxId,
474
+ 'aria-owns': listboxId,
475
+ 'aria-expanded': showPopover,
476
+ onFocus: handleFocus,
477
+ onBlur: handleBlur,
478
+ onClick: handleClick,
479
+ onKeyDown: handleKeyDown
480
+ };
481
+ }
482
+
483
+ /** Is printable character key press */
484
+ const isTypeEvent = ({
485
+ key,
486
+ altKey,
487
+ ctrlKey,
488
+ metaKey
489
+ }) => key.length === 1 && key !== ' ' && !altKey && !ctrlKey && !metaKey;
490
+
491
+ /**
492
+ * Provide props for the semantic and behaviors the combobox button trigger
493
+ *
494
+ * Overrides the useComboboxTrigger() props & behavior to add a jump to option
495
+ * on printable character key down.
496
+ */
497
+ function useComboboxButton(args) {
498
+ const {
499
+ context: {
500
+ handleOpen
501
+ },
502
+ onKeyDown: parentOnKeyDown
503
+ } = args;
504
+ const {
505
+ dispatch: movingFocusDispatch,
506
+ state: {
507
+ selectedId: highlightedId
508
+ }
509
+ } = React__default.useContext(MovingFocusContext);
510
+ const searchValueRef = React__default.useRef('');
511
+ const searchTimeoutRef = React__default.useRef();
512
+ const onKeyDown = React__default.useMemo(() => {
513
+ function clearSearchTimeout() {
514
+ const searchTimeout = searchTimeoutRef.current;
515
+ if (!searchTimeout) {
516
+ return;
517
+ }
518
+ clearTimeout(searchTimeout);
519
+ searchTimeoutRef.current = undefined;
520
+ }
521
+ function clearSearch() {
522
+ searchValueRef.current = '';
523
+ clearSearchTimeout();
524
+ }
525
+ return async event => {
526
+ if (!isTypeEvent(event)) {
527
+ // Forward key down event
528
+ parentOnKeyDown?.(event);
529
+ return undefined;
530
+ }
531
+ event.stopPropagation();
532
+
533
+ // Clear current search timeout
534
+ clearSearchTimeout();
535
+
536
+ // Open combobox and wait for options to mount
537
+ const options = await handleOpen({
538
+ manual: false
539
+ });
540
+ const optionArray = options && Object.values(options);
541
+ if (!optionArray?.length) {
542
+ return undefined;
543
+ }
544
+
545
+ // Append key to current search
546
+ searchValueRef.current += event.key.toLowerCase();
547
+ const searchValue = searchValueRef.current;
548
+
549
+ // Clear search after 500ms
550
+ searchTimeoutRef.current = setTimeout(clearSearch, 500);
551
+
552
+ // Search is containing all the same letters (ex: aaaa)
553
+ const allTheSameLetters = searchValue.split('').every(letter => letter === searchValue[0]);
554
+
555
+ // start from currently selected option
556
+ let startIndex = optionArray.findIndex(option => option.generatedId === highlightedId);
557
+ if (startIndex === -1) {
558
+ startIndex = 0;
559
+ }
560
+ let index = startIndex;
561
+ do {
562
+ // Increment index and loop around to 0 if we get over the array length
563
+ index = (index + 1) % optionArray.length;
564
+ const option = optionArray[index];
565
+ // Search by text value or fallback on id.
566
+ const optionText = isComboboxValue(option) ? option?.textValue || option?.id : null;
567
+ if (isComboboxValue(option) && optionText) {
568
+ const optionTextValue = optionText.toLowerCase();
569
+
570
+ // Search on first letter if search is all the same letters
571
+ const searchText = allTheSameLetters ? searchValue[0] : searchValue;
572
+
573
+ // Option text value starts with searched text
574
+ if (optionTextValue.startsWith(searchText)) {
575
+ movingFocusDispatch({
576
+ type: 'SELECT_TAB_STOP',
577
+ payload: {
578
+ id: option.generatedId,
579
+ type: 'keyboard'
580
+ }
581
+ });
582
+ break;
583
+ }
584
+ }
585
+ } while (index !== startIndex);
586
+ return clearSearchTimeout;
587
+ };
588
+ }, [handleOpen, parentOnKeyDown, highlightedId, movingFocusDispatch]);
589
+ return useComboboxTrigger({
590
+ ...args,
591
+ onKeyDown
592
+ });
593
+ }
594
+
595
+ /**
596
+ * Provide props for the semantic and behaviors the combobox input trigger
597
+ *
598
+ * Overrides the useComboboxTrigger() props & behavior to prevent open on click
599
+ * if `openOnFocus` is not enabled.
600
+ */
601
+ function useComboboxInput({
602
+ onKeyDown: propsOnKeyDown,
603
+ ...args
604
+ }) {
605
+ const triggerProps = useComboboxTrigger(args);
606
+ const {
607
+ onClick,
608
+ onKeyDown,
609
+ 'aria-expanded': showPopover
610
+ } = triggerProps;
611
+ const handleClick = () => {
612
+ if (!args.context.openOnFocus && !args.context.openOnClick) {
613
+ // Skip if input should not opening on focus nor click
614
+ return;
615
+ }
616
+ onClick();
617
+ };
618
+ const handleKeyDown = evt => {
619
+ if (evt.key === 'Escape') {
620
+ // Reset field if closed
621
+ if (!showPopover) {
622
+ args.context.handleInputChange('');
623
+ }
624
+ return;
625
+ }
626
+ onKeyDown(evt);
627
+ if (propsOnKeyDown) {
628
+ propsOnKeyDown(evt);
629
+ }
630
+ };
631
+ return {
632
+ ...triggerProps,
633
+ onClick: handleClick,
634
+ onKeyDown: handleKeyDown
635
+ };
636
+ }
637
+
638
+ export { ComboboxContext, ComboboxProvider, InfiniteScroll, MovingFocusContext, MovingFocusProvider, useComboboxButton, useComboboxInput, useComboboxTrigger, useRovingTabIndex, useVirtualFocusParent };
279
639
  //# sourceMappingURL=index.js.map