@jobber/components 6.103.2-JOB-140609-8386817.45 → 6.103.2-JOB-141426-ee803fd.19

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 (87) hide show
  1. package/dist/Autocomplete/Autocomplete.types.d.ts +1 -12
  2. package/dist/Autocomplete/components/MenuList.d.ts +2 -1
  3. package/dist/Autocomplete/components/PersistentRegion.d.ts +2 -1
  4. package/dist/Autocomplete/hooks/useAutocompleteListNav.d.ts +2 -1
  5. package/dist/Autocomplete/index.cjs +85 -35
  6. package/dist/Autocomplete/index.mjs +86 -36
  7. package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +13 -0
  8. package/dist/Autocomplete/useAutocomplete.d.ts +1 -0
  9. package/dist/Checkbox/Checkbox.types.d.ts +9 -2
  10. package/dist/Checkbox/index.cjs +2 -4
  11. package/dist/Checkbox/index.mjs +2 -4
  12. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
  13. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
  14. package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
  15. package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
  16. package/dist/Chips/index.cjs +2 -2
  17. package/dist/Chips/index.mjs +2 -2
  18. package/dist/DataList/components/DataListSearch/index.cjs +12 -1
  19. package/dist/DataList/components/DataListSearch/index.mjs +12 -1
  20. package/dist/DataList/index.cjs +8 -0
  21. package/dist/DataList/index.mjs +8 -0
  22. package/dist/DataTable/index.cjs +2 -2
  23. package/dist/DataTable/index.mjs +2 -2
  24. package/dist/DatePicker/index.cjs +2 -2
  25. package/dist/DatePicker/index.mjs +2 -2
  26. package/dist/DatePicker-es.js +1 -1
  27. package/dist/FormField/FormFieldTypes.d.ts +2 -0
  28. package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +2 -7
  29. package/dist/FormField-cjs.js +6 -1
  30. package/dist/FormField-es.js +6 -2
  31. package/dist/InputDate/index.cjs +9 -5
  32. package/dist/InputDate/index.mjs +9 -5
  33. package/dist/InputDate/useInputDateActivatorActions.d.ts +8 -4
  34. package/dist/InputEmail/InputEmail.types.d.ts +20 -12
  35. package/dist/InputEmail/hooks/useInputEmailActions.d.ts +1 -1
  36. package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +32 -0
  37. package/dist/InputEmail/index.cjs +44 -8
  38. package/dist/InputEmail/index.mjs +44 -8
  39. package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +3 -20
  40. package/dist/InputNumber/index.cjs +3 -3
  41. package/dist/InputNumber/index.mjs +3 -3
  42. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +27 -13
  43. package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +1 -1
  44. package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +71 -0
  45. package/dist/InputPhoneNumber/index.cjs +34 -17
  46. package/dist/InputPhoneNumber/index.mjs +34 -17
  47. package/dist/InputText/InputText.types.d.ts +24 -24
  48. package/dist/InputText/index.cjs +54 -54
  49. package/dist/InputText/index.mjs +55 -55
  50. package/dist/InputText/useInputTextActions.d.ts +1 -1
  51. package/dist/InputText/useInputTextFormField.d.ts +352 -0
  52. package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
  53. package/dist/InputTime/InputTime.types.d.ts +1 -21
  54. package/dist/InputTime/index.cjs +33 -63
  55. package/dist/InputTime/index.d.ts +1 -1
  56. package/dist/InputTime/index.mjs +36 -66
  57. package/dist/List/index.cjs +2 -2
  58. package/dist/List/index.mjs +2 -2
  59. package/dist/RecurringSelect/index.cjs +2 -2
  60. package/dist/RecurringSelect/index.mjs +2 -2
  61. package/dist/Select/Select.rebuilt.d.ts +1 -1
  62. package/dist/Select/Select.types.d.ts +1 -14
  63. package/dist/Select/hooks/useSelectActions.d.ts +5 -5
  64. package/dist/Select/hooks/useSelectFormField.d.ts +34 -0
  65. package/dist/Select/index.cjs +41 -28
  66. package/dist/Select/index.d.ts +5 -7
  67. package/dist/Select/index.mjs +43 -30
  68. package/dist/Tabs-es.js +1 -1
  69. package/dist/_baseEach-cjs.js +12 -12
  70. package/dist/_baseEach-es.js +1 -1
  71. package/dist/_baseFlatten-cjs.js +2 -2
  72. package/dist/_baseFlatten-es.js +1 -1
  73. package/dist/{_getAllKeys-cjs.js → _baseGet-cjs.js} +181 -181
  74. package/dist/{_getAllKeys-es.js → _baseGet-es.js} +182 -182
  75. package/dist/debounce-es.js +1 -1
  76. package/dist/floating-ui.react-cjs.js +115 -0
  77. package/dist/floating-ui.react-es.js +115 -1
  78. package/dist/index.cjs +2 -2
  79. package/dist/index.mjs +2 -2
  80. package/dist/omit-cjs.js +14 -14
  81. package/dist/omit-es.js +1 -1
  82. package/dist/sharedHelpers/types.d.ts +0 -235
  83. package/dist/styles.css +3 -0
  84. package/dist/useScrollToActive-cjs.js +3 -3
  85. package/dist/useScrollToActive-es.js +2 -2
  86. package/package.json +2 -2
  87. package/dist/InputTime/hooks/useInputTimeActions.d.ts +0 -16
@@ -1,17 +1,6 @@
1
1
  import type { CSSProperties, Key, Ref, RefObject } from "react";
2
- import type { AriaInputProps } from "../sharedHelpers/types";
3
2
  import type { FormFieldProps } from "../FormField";
4
3
  import type { InputTextRebuiltProps, InputTextRef } from "../InputText";
5
- /**
6
- * ARIA attributes for Autocomplete with managed/orchestrated behavior.
7
- * Certain ARIA attributes are controlled internally by Autocomplete's
8
- * state management and floating-ui integration and shouldn't be overridden.
9
- *
10
- * Omits: ariaControls, ariaExpanded, ariaActiveDescendant, ariaAutocomplete
11
- * (These are managed by the component's internal state/floating-ui)
12
- */
13
- export interface AriaInputPropsManaged extends Omit<AriaInputProps, "ariaControls" | "ariaExpanded" | "ariaActiveDescendant" | "ariaAutocomplete"> {
14
- }
15
4
  export type ExtraProps = Record<string, unknown>;
16
5
  type OptionValue = string | number;
17
6
  export interface BaseOption {
@@ -233,7 +222,7 @@ export type MenuFooter<Extra extends object = ExtraProps> = Extra & {
233
222
  };
234
223
  export type MenuItem<T extends OptionLike, SectionExtra extends object = ExtraProps, ActionExtra extends object = ExtraProps> = MenuSection<T, SectionExtra, ActionExtra> | MenuOptions<T, ActionExtra> | MenuHeader<ActionExtra> | MenuFooter<ActionExtra>;
235
224
  export type AutocompleteValue<Value extends OptionLike, Multiple extends boolean> = Multiple extends true ? Value[] : Value | undefined;
236
- interface AutocompleteRebuiltBaseProps<Value extends OptionLike, Multiple extends boolean, SectionExtra extends object, ActionExtra extends object> extends AriaInputPropsManaged {
225
+ interface AutocompleteRebuiltBaseProps<Value extends OptionLike, Multiple extends boolean, SectionExtra extends object, ActionExtra extends object> {
237
226
  version: 2;
238
227
  /**
239
228
  * Whether the autocomplete allows multiple selections.
@@ -14,6 +14,7 @@ interface MenuListProps<T extends OptionLike> {
14
14
  readonly getOptionLabel: (option: T) => string;
15
15
  readonly onSelect: (option: T) => void;
16
16
  readonly onAction: (action: ActionConfig) => void;
17
+ readonly onInteractionMouseDown: (e: React.MouseEvent) => void;
17
18
  readonly isOptionSelected: (option: T) => boolean;
18
19
  readonly slotOverrides?: {
19
20
  option?: {
@@ -30,7 +31,7 @@ interface MenuListProps<T extends OptionLike> {
30
31
  };
31
32
  };
32
33
  }
33
- export declare function MenuList<T extends OptionLike>({ items, activeIndex, indexOffset, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, isOptionSelected, slotOverrides, }: MenuListProps<T>): React.JSX.Element;
34
+ export declare function MenuList<T extends OptionLike>({ items, activeIndex, indexOffset, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, onInteractionMouseDown, isOptionSelected, slotOverrides, }: MenuListProps<T>): React.JSX.Element;
34
35
  export declare function DefaultActionContent({ textContent, }: {
35
36
  readonly textContent: string;
36
37
  }): React.JSX.Element;
@@ -13,6 +13,7 @@ interface PersistentRegionProps<T extends OptionLike> {
13
13
  readonly className?: string;
14
14
  readonly style?: React.CSSProperties;
15
15
  readonly onAction: (action: ActionConfig) => void;
16
+ readonly onInteractionMouseDown: (e: React.MouseEvent) => void;
16
17
  }
17
- export declare function PersistentRegion<T extends OptionLike>({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, }: PersistentRegionProps<T>): React.JSX.Element | null;
18
+ export declare function PersistentRegion<T extends OptionLike>({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, onInteractionMouseDown, }: PersistentRegionProps<T>): React.JSX.Element | null;
18
19
  export {};
@@ -18,5 +18,6 @@ export interface UseAutocompleteListNavProps {
18
18
  shouldResetActiveIndexOnClose?: () => boolean;
19
19
  onMenuClose?: (reason?: string) => void;
20
20
  selectedIndex?: number | null;
21
+ readOnly?: boolean;
21
22
  }
22
- export declare function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, }: UseAutocompleteListNavProps): UseAutocompleteListNavReturn;
23
+ export declare function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, readOnly, }: UseAutocompleteListNavProps): UseAutocompleteListNavReturn;
@@ -20,6 +20,18 @@ require('react-hook-form');
20
20
  require('framer-motion');
21
21
  require('../Button-cjs.js');
22
22
  require('react-router-dom');
23
+ require('../omit-cjs.js');
24
+ require('../_commonjsHelpers-cjs.js');
25
+ require('../_baseGet-cjs.js');
26
+ require('../isTypedArray-cjs.js');
27
+ require('../isObjectLike-cjs.js');
28
+ require('../identity-cjs.js');
29
+ require('../_getTag-cjs.js');
30
+ require('../isSymbol-cjs.js');
31
+ require('../keysIn-cjs.js');
32
+ require('../_baseAssignValue-cjs.js');
33
+ require('../_baseFlatten-cjs.js');
34
+ require('../_setToString-cjs.js');
23
35
  require('../useFormFieldFocus-cjs.js');
24
36
  require('../InputValidation-cjs.js');
25
37
  require('../Spinner-cjs.js');
@@ -128,7 +140,7 @@ function invokeActiveItemOnEnter(event, activeIndex, renderable, onSelect, onAct
128
140
 
129
141
  const MENU_OFFSET = design.tokens["space-small"];
130
142
  const AUTOCOMPLETE_MAX_HEIGHT$1 = 300;
131
- function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, }) {
143
+ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, readOnly = false, }) {
132
144
  const [open, setOpen] = React.useState(false);
133
145
  const [activeIndex, setActiveIndex] = React.useState(null);
134
146
  const listRef = React.useRef([]);
@@ -160,6 +172,10 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
160
172
  }),
161
173
  ],
162
174
  });
175
+ const click = floatingUi_react.useClick(context, {
176
+ enabled: !readOnly,
177
+ toggle: false, // Only open, never close on click
178
+ });
163
179
  const listNav = floatingUi_react.useListNavigation(context, {
164
180
  listRef,
165
181
  activeIndex,
@@ -181,7 +197,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
181
197
  escapeKey: true,
182
198
  outsidePressEvent: "click",
183
199
  });
184
- const { getReferenceProps, getFloatingProps, getItemProps } = floatingUi_react.useInteractions([listNav, dismiss]);
200
+ const { getReferenceProps, getFloatingProps, getItemProps } = floatingUi_react.useInteractions([click, listNav, dismiss]);
185
201
  React.useEffect(() => {
186
202
  listRef.current.length = navigableCount;
187
203
  setActiveIndex(prev => {
@@ -213,6 +229,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
213
229
  // eslint-disable-next-line max-statements
214
230
  function useAutocomplete(props) {
215
231
  const { menu, emptyActions, getOptionLabel: getOptionLabelProp, isOptionEqualToValue, inputValue, onInputChange, value, onChange, multiple, openOnFocus = true, readOnly = false, debounce: debounceMs = 300, } = props;
232
+ const isHandlingMenuInteractionRef = React.useRef(false);
216
233
  // TODO: Clean up the types in these refs by enhancing the type system in useCallbackRef
217
234
  const getOptionLabelPropRef = jobberHooks.useCallbackRef((opt) => getOptionLabelProp === null || getOptionLabelProp === void 0 ? void 0 : getOptionLabelProp(opt));
218
235
  const getOptionLabel = React.useCallback((opt) => {
@@ -255,7 +272,8 @@ function useAutocomplete(props) {
255
272
  const [debouncedInputValue, setDebouncedInputValue] = React.useState(inputValue);
256
273
  const debouncedSetter = jobberHooks.useDebounce(setDebouncedInputValue, debounceMs);
257
274
  React.useEffect(() => {
258
- if (debounceMs === 0) {
275
+ // Skip debounce when clearing input for immediate feedback, preventing flickering of last selected item
276
+ if (debounceMs === 0 || inputValue === "") {
259
277
  setDebouncedInputValue(inputValue);
260
278
  return;
261
279
  }
@@ -345,6 +363,7 @@ function useAutocomplete(props) {
345
363
  navigableCount: totalNavigableCount,
346
364
  shouldResetActiveIndexOnClose: () => !hasSelection,
347
365
  selectedIndex,
366
+ readOnly,
348
367
  onMenuClose: () => {
349
368
  if (props.allowFreeForm !== true) {
350
369
  const hasText = inputValue.trim().length > 0;
@@ -356,7 +375,6 @@ function useAutocomplete(props) {
356
375
  }
357
376
  },
358
377
  });
359
- const [inputFocused, setInputFocused] = React.useState(false);
360
378
  // Handles activeIndex reset and, in single-select mode only, clearing selection when input is empty
361
379
  React.useEffect(() => {
362
380
  const hasText = inputValue.trim().length > 0;
@@ -449,16 +467,29 @@ function useAutocomplete(props) {
449
467
  setActiveIndex(null);
450
468
  }, [open, multiple, value, renderable, equals, setActiveIndex]);
451
469
  const onSelection = React.useCallback((option) => {
470
+ var _a;
452
471
  selectOption(option);
453
472
  // Might not always want to close on selection. Multi for example.
454
473
  setOpen(false);
455
- }, [selectOption, setOpen]);
474
+ (_a = refs.domReference.current) === null || _a === void 0 ? void 0 : _a.focus();
475
+ }, [selectOption, setOpen, refs.domReference]);
456
476
  const onAction = React.useCallback((action) => {
477
+ var _a;
457
478
  action.run();
458
479
  setActiveIndex(null);
459
480
  if (action.closeOnRun !== false)
460
481
  setOpen(false);
461
- }, [setOpen, setActiveIndex]);
482
+ (_a = refs.domReference.current) === null || _a === void 0 ? void 0 : _a.focus();
483
+ }, [setOpen, setActiveIndex, refs.domReference]);
484
+ /**
485
+ * Handler for mousedown on interactive menu items (options/actions)
486
+ * Prevents default to avoid blur and sets flag for focus management
487
+ */
488
+ const onInteractionMouseDown = React.useCallback((e) => {
489
+ e.preventDefault();
490
+ // Set flag to prevent blur/focus handlers from interfering
491
+ isHandlingMenuInteractionRef.current = true;
492
+ }, []);
462
493
  function commitFromInputText(inputText) {
463
494
  var _a;
464
495
  if (inputText.length === 0)
@@ -500,14 +531,20 @@ function useAutocomplete(props) {
500
531
  ]);
501
532
  const onInputFocus = React.useCallback(() => {
502
533
  var _a;
503
- setInputFocused(true);
504
- if (!readOnly && openOnFocus)
534
+ if (!readOnly && openOnFocus && !isHandlingMenuInteractionRef.current) {
505
535
  setOpen(true);
506
- (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
536
+ }
537
+ // Only call user's onFocus for genuine focus events, not programmatic restorations
538
+ if (!isHandlingMenuInteractionRef.current) {
539
+ (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
540
+ }
541
+ isHandlingMenuInteractionRef.current = false;
507
542
  }, [props.onFocus, readOnly, openOnFocus, setOpen]);
508
543
  const onInputBlur = React.useCallback(() => {
509
544
  var _a, _b;
510
- setInputFocused(false);
545
+ if (isHandlingMenuInteractionRef.current) {
546
+ return;
547
+ }
511
548
  if (readOnly) {
512
549
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
513
550
  return;
@@ -613,11 +650,11 @@ function useAutocomplete(props) {
613
650
  setActiveIndex(null);
614
651
  }
615
652
  // Important: update open state before propagating the change so that downstream effects
616
- // dont see an intermediate state where inputValue changed but open was stale
653
+ // don't see an intermediate state where inputValue changed but open was stale
617
654
  if (!readOnly) {
618
655
  const hasText = val.trim().length > 0;
619
656
  const mustSelectFromOptions = hasText && !props.allowFreeForm;
620
- const keepOpenOnEmpty = openOnFocus && inputFocused;
657
+ const keepOpenOnEmpty = openOnFocus;
621
658
  setOpen(mustSelectFromOptions || keepOpenOnEmpty);
622
659
  }
623
660
  onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(val);
@@ -628,7 +665,6 @@ function useAutocomplete(props) {
628
665
  readOnly,
629
666
  props.allowFreeForm,
630
667
  openOnFocus,
631
- inputFocused,
632
668
  setOpen,
633
669
  ]);
634
670
  return {
@@ -657,6 +693,7 @@ function useAutocomplete(props) {
657
693
  // actions
658
694
  onSelection,
659
695
  onAction,
696
+ onInteractionMouseDown,
660
697
  // input handlers
661
698
  onInputChangeFromUser,
662
699
  onInputBlur,
@@ -667,7 +704,7 @@ function useAutocomplete(props) {
667
704
  };
668
705
  }
669
706
 
670
- function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, isOptionSelected, slotOverrides, }) {
707
+ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, onInteractionMouseDown, isOptionSelected, slotOverrides, }) {
671
708
  let navigableIndex = -1;
672
709
  function renderItemNode(item) {
673
710
  var _a, _b, _c, _d, _e, _f;
@@ -691,6 +728,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
691
728
  customRenderOption,
692
729
  getOptionLabel,
693
730
  onSelect,
731
+ onInteractionMouseDown,
694
732
  indexOffset,
695
733
  optionClassName: (_c = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _c === void 0 ? void 0 : _c.className,
696
734
  optionStyle: (_d = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _d === void 0 ? void 0 : _d.style,
@@ -707,6 +745,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
707
745
  listboxId,
708
746
  customRenderAction,
709
747
  onAction,
748
+ onInteractionMouseDown,
710
749
  indexOffset,
711
750
  actionClassName: (_e = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _e === void 0 ? void 0 : _e.className,
712
751
  actionStyle: (_f = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _f === void 0 ? void 0 : _f.style,
@@ -720,12 +759,14 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
720
759
  function handleSectionRendering({ customRenderSection, section, sectionClassName, sectionStyle, }) {
721
760
  var _a;
722
761
  const headerContent = customRenderSection ? (customRenderSection(section)) : (React.createElement(DefaultSectionContent, { section: section }));
723
- return (React.createElement("div", { key: `section-${String((_a = section.key) !== null && _a !== void 0 ? _a : section.label)}`, role: "presentation", tabIndex: -1, "data-testid": "ATL-AutocompleteRebuilt-Section", className: classnames(styles$1.section, styles$1.stickyTop, sectionClassName), style: sectionStyle }, headerContent));
762
+ return (React.createElement("div", { key: `section-${String((_a = section.key) !== null && _a !== void 0 ? _a : section.label)}`, role: "presentation", tabIndex: -1, "data-testid": "ATL-AutocompleteRebuilt-Section", className: classnames(styles$1.section, styles$1.stickyTop, sectionClassName), style: sectionStyle, onMouseDown: e => {
763
+ e.preventDefault();
764
+ } }, headerContent));
724
765
  }
725
766
  function DefaultSectionContent({ section, }) {
726
767
  return React.createElement(Heading.Heading, { level: 5 }, section.label);
727
768
  }
728
- function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, indexOffset = 0, optionClassName, optionStyle, }) {
769
+ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, onInteractionMouseDown, indexOffset = 0, optionClassName, optionStyle, }) {
729
770
  var _a;
730
771
  const nextNavigableIndex = navigableIndex + 1;
731
772
  const isActive = activeIndex === nextNavigableIndex;
@@ -739,6 +780,7 @@ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemPro
739
780
  listRef.current[idx] = node;
740
781
  },
741
782
  onClick: () => onSelect(option),
783
+ onMouseDown: onInteractionMouseDown,
742
784
  className: classnames(styles$1.option, isActive && styles$1.optionActive, optionClassName),
743
785
  style: optionStyle,
744
786
  }), { role: "option", tabIndex: -1, "aria-selected": isSelected ? true : false, id: `${listboxId}-item-${nextNavigableIndex + indexOffset}`, "data-index": nextNavigableIndex + indexOffset, "data-active": isActive ? true : undefined }), optionContent)),
@@ -750,7 +792,7 @@ function DefaultOptionContent({ isSelected, text, }) {
750
792
  React.createElement("div", { className: styles$1.icon }, isSelected && React.createElement(Icon.Icon, { name: "checkmark", size: "small" })),
751
793
  React.createElement(Text.Text, null, text)));
752
794
  }
753
- function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, indexOffset = 0, actionClassName, actionStyle, origin, }) {
795
+ function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, onInteractionMouseDown, indexOffset = 0, actionClassName, actionStyle, origin, }) {
754
796
  var _a;
755
797
  const nextNavigableIndex = navigableIndex + 1;
756
798
  const isActive = activeIndex === nextNavigableIndex;
@@ -768,6 +810,7 @@ function handleActionRendering({ action, activeIndex, navigableIndex, getItemPro
768
810
  closeOnRun: action.shouldClose,
769
811
  });
770
812
  },
813
+ onMouseDown: onInteractionMouseDown,
771
814
  className: classnames(styles$1.action, isActive && styles$1.actionActive, actionClassName),
772
815
  style: actionStyle,
773
816
  });
@@ -785,7 +828,7 @@ function DefaultActionContent({ textContent, }) {
785
828
  } }, textContent));
786
829
  }
787
830
 
788
- function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, }) {
831
+ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, onInteractionMouseDown, }) {
789
832
  if (!items || items.length === 0)
790
833
  return null;
791
834
  let navigableIndex = -1;
@@ -800,13 +843,14 @@ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemPr
800
843
  customRenderFooter,
801
844
  listRef,
802
845
  onAction,
846
+ onInteractionMouseDown,
803
847
  navigableIndex,
804
848
  });
805
849
  navigableIndex = result.nextNavigableIndex;
806
850
  return result.node;
807
851
  })));
808
852
  }
809
- function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
853
+ function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionMouseDown, navigableIndex, }) {
810
854
  const interactive = Boolean(persistent.onClick);
811
855
  if (!interactive) {
812
856
  const node = handleTextPersistentRendering({
@@ -827,6 +871,7 @@ function handlePersistentRendering({ persistent, position, activeIndex, indexOff
827
871
  customRenderFooter,
828
872
  listRef,
829
873
  onAction,
874
+ onInteractionMouseDown,
830
875
  navigableIndex,
831
876
  });
832
877
  }
@@ -842,9 +887,11 @@ function handleTextPersistentRendering({ persistent, position, customRenderHeade
842
887
  else {
843
888
  content = React.createElement(DefaultTextPersistentContent, { persistent: persistent });
844
889
  }
845
- return (React.createElement("div", { key: `persistent-${position}-${String((_a = persistent.key) !== null && _a !== void 0 ? _a : persistent.label)}`, role: "presentation", tabIndex: -1, className: styles$1.textPersistent }, content));
890
+ return (React.createElement("div", { key: `persistent-${position}-${String((_a = persistent.key) !== null && _a !== void 0 ? _a : persistent.label)}`, role: "presentation", tabIndex: -1, className: styles$1.textPersistent, onMouseDown: e => {
891
+ e.preventDefault();
892
+ } }, content));
846
893
  }
847
- function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
894
+ function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionMouseDown, navigableIndex, }) {
848
895
  var _a;
849
896
  const nextNavigableIndex = navigableIndex + 1;
850
897
  const isActive = activeIndex === indexOffset + nextNavigableIndex;
@@ -871,13 +918,16 @@ function handleActionPersistentRendering({ persistent, position, activeIndex, in
871
918
  if (persistNode)
872
919
  listRef.current[idx] = persistNode;
873
920
  },
874
- onClick: () => onAction({
875
- run: () => {
876
- var _a;
877
- (_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
878
- },
879
- closeOnRun: persistent.shouldClose,
880
- }),
921
+ onClick: () => {
922
+ onAction({
923
+ run: () => {
924
+ var _a;
925
+ (_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
926
+ },
927
+ closeOnRun: persistent.shouldClose,
928
+ });
929
+ },
930
+ onMouseDown: onInteractionMouseDown,
881
931
  className: classnames(styles$1.action, isActive && styles$1.actionActive),
882
932
  }), { role: "button", tabIndex: -1 }), content)),
883
933
  nextNavigableIndex,
@@ -892,7 +942,7 @@ const AutocompleteRebuilt = React.forwardRef(AutocompleteRebuiltInternal);
892
942
  function AutocompleteRebuiltInternal(props, forwardedRef) {
893
943
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
894
944
  const { inputValue, placeholder, disabled, error, invalid, description, size: sizeProp, loading = false, } = props;
895
- const { renderable, optionCount, persistentsHeaders, persistentsFooters, headerInteractiveCount, middleNavigableCount, getOptionLabel, isOptionSelected, refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps, activeIndex, open, listRef, onSelection, onAction, onInputChangeFromUser, onInputBlur, onInputFocus, onInputKeyDown, setReferenceElement, } = useAutocomplete(props);
945
+ const { renderable, optionCount, persistentsHeaders, persistentsFooters, headerInteractiveCount, middleNavigableCount, getOptionLabel, isOptionSelected, refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps, activeIndex, open, listRef, onSelection, onAction, onInteractionMouseDown, onInputChangeFromUser, onInputBlur, onInputFocus, onInputKeyDown, setReferenceElement, } = useAutocomplete(props);
896
946
  const listboxId = React.useId();
897
947
  // Provides mount/unmount-aware transition styles for the floating element
898
948
  const { isMounted, styles: transitionStyles } = floatingUi_react.useTransitionStyles(context, {
@@ -909,7 +959,7 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
909
959
  onBlur: onInputBlur,
910
960
  });
911
961
  const inputProps = Object.assign(Object.assign(Object.assign(Object.assign({ version: 2, value: inputValue, onChange: props.readOnly ? undefined : onInputChangeFromUser }, (props.readOnly ? { onFocus: onInputFocus, onBlur: onInputBlur } : {})), { placeholder,
912
- disabled, readOnly: props.readOnly, error: error !== null && error !== void 0 ? error : undefined, name: props.name, invalid, autoComplete: "off", description, size: sizeProp ? sizeProp : undefined, prefix: props.prefix, suffix: props.suffix }), (props.readOnly ? {} : composedReferenceProps)), { role: "combobox", ariaAutocomplete: "list", ariaExpanded: open ? true : false, ariaControls: listboxId, ariaActiveDescendant: open && activeIndex != null
962
+ disabled, readOnly: props.readOnly, error: error !== null && error !== void 0 ? error : undefined, name: props.name, invalid, autoComplete: "off", description, size: sizeProp ? sizeProp : undefined, prefix: props.prefix, suffix: props.suffix }), (props.readOnly ? {} : composedReferenceProps)), { role: "combobox", "aria-autocomplete": "list", "aria-expanded": open ? true : false, "aria-controls": listboxId, "aria-activedescendant": open && activeIndex != null
913
963
  ? `${listboxId}-item-${activeIndex}`
914
964
  : undefined });
915
965
  const referenceInputRef = (node) => {
@@ -951,10 +1001,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
951
1001
  ? { width: menuWidth, maxWidth: menuWidth }
952
1002
  : {})),
953
1003
  })),
954
- React.createElement(PersistentRegion, { items: persistentsHeaders, position: "header", activeIndex: activeIndex, indexOffset: 0, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, className: classnames(styles$1.persistentHeader, (_c = props.UNSAFE_className) === null || _c === void 0 ? void 0 : _c.header), style: (_d = props.UNSAFE_styles) === null || _d === void 0 ? void 0 : _d.header }),
1004
+ React.createElement(PersistentRegion, { items: persistentsHeaders, position: "header", activeIndex: activeIndex, indexOffset: 0, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, onInteractionMouseDown: onInteractionMouseDown, className: classnames(styles$1.persistentHeader, (_c = props.UNSAFE_className) === null || _c === void 0 ? void 0 : _c.header), style: (_d = props.UNSAFE_styles) === null || _d === void 0 ? void 0 : _d.header }),
955
1005
  React.createElement("div", { className: styles$1.scrollRegion }, loading ? ((_e = props.customRenderLoading) !== null && _e !== void 0 ? _e : React.createElement(LoadingContent, null)) : (React.createElement(React.Fragment, null,
956
1006
  showEmptyStateMessage && (React.createElement(EmptyStateMessage, { emptyState: props.emptyStateMessage })),
957
- renderable.length > 0 && (React.createElement(MenuList, { items: renderable, activeIndex: activeIndexForMiddle, indexOffset: headerInteractiveCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, getOptionLabel: getOptionLabel, onSelect: onSelection, onAction: onAction, isOptionSelected: isOptionSelected, slotOverrides: {
1007
+ renderable.length > 0 && (React.createElement(MenuList, { items: renderable, activeIndex: activeIndexForMiddle, indexOffset: headerInteractiveCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderOption: props.customRenderOption, customRenderSection: props.customRenderSection, customRenderAction: props.customRenderAction, getOptionLabel: getOptionLabel, onSelect: onSelection, onAction: onAction, onInteractionMouseDown: onInteractionMouseDown, isOptionSelected: isOptionSelected, slotOverrides: {
958
1008
  option: {
959
1009
  className: (_f = props.UNSAFE_className) === null || _f === void 0 ? void 0 : _f.option,
960
1010
  style: (_g = props.UNSAFE_styles) === null || _g === void 0 ? void 0 : _g.option,
@@ -968,10 +1018,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
968
1018
  style: (_l = props.UNSAFE_styles) === null || _l === void 0 ? void 0 : _l.section,
969
1019
  },
970
1020
  } }))))),
971
- React.createElement(PersistentRegion, { items: persistentsFooters, position: "footer", activeIndex: activeIndex, indexOffset: headerInteractiveCount + middleNavigableCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, className: classnames(styles$1.persistentFooter, (_m = props.UNSAFE_className) === null || _m === void 0 ? void 0 : _m.footer), style: (_o = props.UNSAFE_styles) === null || _o === void 0 ? void 0 : _o.footer })))))));
1021
+ React.createElement(PersistentRegion, { items: persistentsFooters, position: "footer", activeIndex: activeIndex, indexOffset: headerInteractiveCount + middleNavigableCount, listboxId: listboxId, getItemProps: getItemProps, listRef: listRef, customRenderHeader: props.customRenderHeader, customRenderFooter: props.customRenderFooter, onAction: onAction, onInteractionMouseDown: onInteractionMouseDown, className: classnames(styles$1.persistentFooter, (_m = props.UNSAFE_className) === null || _m === void 0 ? void 0 : _m.footer), style: (_o = props.UNSAFE_styles) === null || _o === void 0 ? void 0 : _o.footer })))))));
972
1022
  }
973
1023
  function LoadingContent() {
974
- return (React.createElement("div", { className: styles$1.loadingList },
1024
+ return (React.createElement("div", { className: styles$1.loadingList, onMouseDown: e => e.preventDefault() },
975
1025
  React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" }),
976
1026
  React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" }),
977
1027
  React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" })));
@@ -979,7 +1029,7 @@ function LoadingContent() {
979
1029
  function EmptyStateMessage({ emptyState, }) {
980
1030
  const emptyStateDefault = "No options";
981
1031
  const emptyStateContent = emptyState !== null && emptyState !== void 0 ? emptyState : emptyStateDefault;
982
- return React.createElement("div", { className: styles$1.emptyStateMessage }, emptyStateContent);
1032
+ return (React.createElement("div", { className: styles$1.emptyStateMessage, onMouseDown: e => e.preventDefault() }, emptyStateContent));
983
1033
  }
984
1034
 
985
1035
  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-"};