@jobber/components 6.104.1 → 6.105.1

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 (38) hide show
  1. package/dist/Autocomplete/Autocomplete.types.d.ts +2 -0
  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 +86 -32
  6. package/dist/Autocomplete/index.mjs +87 -33
  7. package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +13 -0
  8. package/dist/Autocomplete/useAutocomplete.d.ts +1 -0
  9. package/dist/Autocomplete/utils/interactionUtils.d.ts +14 -0
  10. package/dist/Checkbox/Checkbox.rebuilt.d.ts +2 -1
  11. package/dist/Checkbox/Checkbox.types.d.ts +40 -3
  12. package/dist/Checkbox/index.cjs +2 -2
  13. package/dist/Checkbox/index.mjs +2 -2
  14. package/dist/DatePicker-es.js +1 -1
  15. package/dist/InputEmail/InputEmail.types.d.ts +2 -2
  16. package/dist/InputEmail/hooks/useInputEmailActions.d.ts +8 -3
  17. package/dist/InputEmail/index.cjs +28 -3
  18. package/dist/InputEmail/index.mjs +28 -3
  19. package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +2 -2
  20. package/dist/InputNumber/index.cjs +1 -1
  21. package/dist/InputNumber/index.mjs +1 -1
  22. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +2 -2
  23. package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +8 -3
  24. package/dist/InputPhoneNumber/index.cjs +29 -3
  25. package/dist/InputPhoneNumber/index.mjs +29 -3
  26. package/dist/InputText/InputText.types.d.ts +2 -2
  27. package/dist/InputText/index.cjs +28 -3
  28. package/dist/InputText/index.mjs +28 -3
  29. package/dist/InputText/useInputTextActions.d.ts +8 -3
  30. package/dist/InputTime/InputTime.types.d.ts +2 -2
  31. package/dist/InputTime/hooks/useInputTimeActions.d.ts +8 -3
  32. package/dist/InputTime/index.cjs +28 -3
  33. package/dist/InputTime/index.mjs +28 -3
  34. package/dist/floating-ui.react-cjs.js +115 -0
  35. package/dist/floating-ui.react-es.js +115 -1
  36. package/dist/sharedHelpers/types.d.ts +26 -0
  37. package/dist/styles.css +3 -0
  38. package/package.json +2 -2
@@ -379,6 +379,8 @@ interface AutocompleteRebuiltBaseProps<Value extends OptionLike, Multiple extend
379
379
  }) => MenuAction<ActionExtra>[]);
380
380
  /**
381
381
  * Whether the menu should open when the input gains focus.
382
+ * Note: Clicking on the input will always open the menu.
383
+ * openOnFocus only determines the behavior of focus events such as tabs or programmatic focus.
382
384
  *
383
385
  * @default true
384
386
  */
@@ -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 onInteractionPointerDown: (e: React.PointerEvent) => 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, onInteractionPointerDown, 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 onInteractionPointerDown: (e: React.PointerEvent) => 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, onInteractionPointerDown, }: 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;
@@ -129,7 +129,7 @@ function invokeActiveItemOnEnter(event, activeIndex, renderable, onSelect, onAct
129
129
 
130
130
  const MENU_OFFSET = design.tokens["space-small"];
131
131
  const AUTOCOMPLETE_MAX_HEIGHT$1 = 300;
132
- function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, }) {
132
+ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, readOnly = false, }) {
133
133
  const [open, setOpen] = React.useState(false);
134
134
  const [activeIndex, setActiveIndex] = React.useState(null);
135
135
  const listRef = React.useRef([]);
@@ -161,6 +161,10 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
161
161
  }),
162
162
  ],
163
163
  });
164
+ const click = floatingUi_react.useClick(context, {
165
+ enabled: !readOnly,
166
+ toggle: false, // Only open, never close on click
167
+ });
164
168
  const listNav = floatingUi_react.useListNavigation(context, {
165
169
  listRef,
166
170
  activeIndex,
@@ -182,7 +186,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
182
186
  escapeKey: true,
183
187
  outsidePressEvent: "click",
184
188
  });
185
- const { getReferenceProps, getFloatingProps, getItemProps } = floatingUi_react.useInteractions([listNav, dismiss]);
189
+ const { getReferenceProps, getFloatingProps, getItemProps } = floatingUi_react.useInteractions([click, listNav, dismiss]);
186
190
  React.useEffect(() => {
187
191
  listRef.current.length = navigableCount;
188
192
  setActiveIndex(prev => {
@@ -209,11 +213,34 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
209
213
  };
210
214
  }
211
215
 
216
+ /**
217
+ * Handler that prevents default pointer behavior.
218
+ * Used to prevent blur/focus issues when clicking on non-interactive menu elements.
219
+ */
220
+ function preventDefaultPointerDown(e) {
221
+ e.preventDefault();
222
+ }
223
+ /**
224
+ * Creates a handler for pointer down events on interactive menu items (options/actions).
225
+ * Prevents default to avoid blur and sets flag for focus management.
226
+ *
227
+ * @param isHandlingMenuInteractionRef - Ref to track if a menu interaction is in progress
228
+ * @returns A pointer down event handler
229
+ */
230
+ function createInteractionPointerDownHandler(isHandlingMenuInteractionRef) {
231
+ return (e) => {
232
+ e.preventDefault();
233
+ // Set flag to prevent blur/focus handlers from interfering
234
+ isHandlingMenuInteractionRef.current = true;
235
+ };
236
+ }
237
+
212
238
  // Keeping this hook cohesive improves readability by centralizing related
213
239
  // interactions and state transitions.
214
240
  // eslint-disable-next-line max-statements
215
241
  function useAutocomplete(props) {
216
242
  const { menu, emptyActions, getOptionLabel: getOptionLabelProp, isOptionEqualToValue, inputValue, onInputChange, value, onChange, multiple, openOnFocus = true, readOnly = false, debounce: debounceMs = 300, } = props;
243
+ const isHandlingMenuInteractionRef = React.useRef(false);
217
244
  // TODO: Clean up the types in these refs by enhancing the type system in useCallbackRef
218
245
  const getOptionLabelPropRef = jobberHooks.useCallbackRef((opt) => getOptionLabelProp === null || getOptionLabelProp === void 0 ? void 0 : getOptionLabelProp(opt));
219
246
  const getOptionLabel = React.useCallback((opt) => {
@@ -256,7 +283,8 @@ function useAutocomplete(props) {
256
283
  const [debouncedInputValue, setDebouncedInputValue] = React.useState(inputValue);
257
284
  const debouncedSetter = jobberHooks.useDebounce(setDebouncedInputValue, debounceMs);
258
285
  React.useEffect(() => {
259
- if (debounceMs === 0) {
286
+ // Skip debounce when clearing input for immediate feedback, preventing flickering of last selected item
287
+ if (debounceMs === 0 || inputValue === "") {
260
288
  setDebouncedInputValue(inputValue);
261
289
  return;
262
290
  }
@@ -346,6 +374,7 @@ function useAutocomplete(props) {
346
374
  navigableCount: totalNavigableCount,
347
375
  shouldResetActiveIndexOnClose: () => !hasSelection,
348
376
  selectedIndex,
377
+ readOnly,
349
378
  onMenuClose: () => {
350
379
  if (props.allowFreeForm !== true) {
351
380
  const hasText = inputValue.trim().length > 0;
@@ -357,7 +386,6 @@ function useAutocomplete(props) {
357
386
  }
358
387
  },
359
388
  });
360
- const [inputFocused, setInputFocused] = React.useState(false);
361
389
  // Handles activeIndex reset and, in single-select mode only, clearing selection when input is empty
362
390
  React.useEffect(() => {
363
391
  const hasText = inputValue.trim().length > 0;
@@ -453,13 +481,24 @@ function useAutocomplete(props) {
453
481
  selectOption(option);
454
482
  // Might not always want to close on selection. Multi for example.
455
483
  setOpen(false);
484
+ if (refs.domReference.current instanceof HTMLElement) {
485
+ refs.domReference.current.focus();
486
+ }
456
487
  }, [selectOption, setOpen]);
457
488
  const onAction = React.useCallback((action) => {
458
489
  action.run();
459
490
  setActiveIndex(null);
460
491
  if (action.closeOnRun !== false)
461
492
  setOpen(false);
493
+ if (refs.domReference.current instanceof HTMLElement) {
494
+ refs.domReference.current.focus();
495
+ }
462
496
  }, [setOpen, setActiveIndex]);
497
+ /**
498
+ * Handler for mousedown on interactive menu items (options/actions)
499
+ * Prevents default to avoid blur and sets flag for focus management
500
+ */
501
+ const onInteractionPointerDown = React.useMemo(() => createInteractionPointerDownHandler(isHandlingMenuInteractionRef), []);
463
502
  function commitFromInputText(inputText) {
464
503
  var _a;
465
504
  if (inputText.length === 0)
@@ -501,14 +540,20 @@ function useAutocomplete(props) {
501
540
  ]);
502
541
  const onInputFocus = React.useCallback((event) => {
503
542
  var _a;
504
- setInputFocused(true);
505
- if (!readOnly && openOnFocus)
543
+ if (!readOnly && openOnFocus && !isHandlingMenuInteractionRef.current) {
506
544
  setOpen(true);
507
- (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
545
+ }
546
+ // Only call user's onFocus for genuine focus events, not programmatic restorations
547
+ if (!isHandlingMenuInteractionRef.current) {
548
+ (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
549
+ }
550
+ isHandlingMenuInteractionRef.current = false;
508
551
  }, [props.onFocus, readOnly, openOnFocus, setOpen]);
509
552
  const onInputBlur = React.useCallback((event) => {
510
553
  var _a, _b;
511
- setInputFocused(false);
554
+ if (isHandlingMenuInteractionRef.current) {
555
+ return;
556
+ }
512
557
  if (readOnly) {
513
558
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
514
559
  return;
@@ -614,11 +659,11 @@ function useAutocomplete(props) {
614
659
  setActiveIndex(null);
615
660
  }
616
661
  // Important: update open state before propagating the change so that downstream effects
617
- // dont see an intermediate state where inputValue changed but open was stale
662
+ // don't see an intermediate state where inputValue changed but open was stale
618
663
  if (!readOnly) {
619
664
  const hasText = val.trim().length > 0;
620
665
  const mustSelectFromOptions = hasText && !props.allowFreeForm;
621
- const keepOpenOnEmpty = openOnFocus && inputFocused;
666
+ const keepOpenOnEmpty = openOnFocus;
622
667
  setOpen(mustSelectFromOptions || keepOpenOnEmpty);
623
668
  }
624
669
  onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(val);
@@ -629,7 +674,6 @@ function useAutocomplete(props) {
629
674
  readOnly,
630
675
  props.allowFreeForm,
631
676
  openOnFocus,
632
- inputFocused,
633
677
  setOpen,
634
678
  ]);
635
679
  return {
@@ -658,6 +702,7 @@ function useAutocomplete(props) {
658
702
  // actions
659
703
  onSelection,
660
704
  onAction,
705
+ onInteractionPointerDown,
661
706
  // input handlers
662
707
  onInputChangeFromUser,
663
708
  onInputBlur,
@@ -668,7 +713,7 @@ function useAutocomplete(props) {
668
713
  };
669
714
  }
670
715
 
671
- function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, isOptionSelected, slotOverrides, }) {
716
+ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, onInteractionPointerDown, isOptionSelected, slotOverrides, }) {
672
717
  let navigableIndex = -1;
673
718
  function renderItemNode(item) {
674
719
  var _a, _b, _c, _d, _e, _f;
@@ -692,6 +737,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
692
737
  customRenderOption,
693
738
  getOptionLabel,
694
739
  onSelect,
740
+ onInteractionPointerDown,
695
741
  indexOffset,
696
742
  optionClassName: (_c = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _c === void 0 ? void 0 : _c.className,
697
743
  optionStyle: (_d = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _d === void 0 ? void 0 : _d.style,
@@ -708,6 +754,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
708
754
  listboxId,
709
755
  customRenderAction,
710
756
  onAction,
757
+ onInteractionPointerDown,
711
758
  indexOffset,
712
759
  actionClassName: (_e = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _e === void 0 ? void 0 : _e.className,
713
760
  actionStyle: (_f = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _f === void 0 ? void 0 : _f.style,
@@ -721,12 +768,12 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
721
768
  function handleSectionRendering({ customRenderSection, section, sectionClassName, sectionStyle, }) {
722
769
  var _a;
723
770
  const headerContent = customRenderSection ? (customRenderSection(section)) : (React.createElement(DefaultSectionContent, { section: section }));
724
- 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));
771
+ 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, onPointerDown: preventDefaultPointerDown }, headerContent));
725
772
  }
726
773
  function DefaultSectionContent({ section, }) {
727
774
  return React.createElement(Heading.Heading, { level: 5 }, section.label);
728
775
  }
729
- function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, indexOffset = 0, optionClassName, optionStyle, }) {
776
+ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, onInteractionPointerDown, indexOffset = 0, optionClassName, optionStyle, }) {
730
777
  var _a;
731
778
  const nextNavigableIndex = navigableIndex + 1;
732
779
  const isActive = activeIndex === nextNavigableIndex;
@@ -740,6 +787,7 @@ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemPro
740
787
  listRef.current[idx] = node;
741
788
  },
742
789
  onClick: () => onSelect(option),
790
+ onPointerDown: onInteractionPointerDown,
743
791
  className: classnames(styles$1.option, isActive && styles$1.optionActive, optionClassName),
744
792
  style: optionStyle,
745
793
  }), { role: "option", tabIndex: -1, "aria-selected": isSelected ? true : false, id: `${listboxId}-item-${nextNavigableIndex + indexOffset}`, "data-index": nextNavigableIndex + indexOffset, "data-active": isActive ? true : undefined }), optionContent)),
@@ -751,7 +799,7 @@ function DefaultOptionContent({ isSelected, text, }) {
751
799
  React.createElement("div", { className: styles$1.icon }, isSelected && React.createElement(Icon.Icon, { name: "checkmark", size: "small" })),
752
800
  React.createElement(Text.Text, null, text)));
753
801
  }
754
- function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, indexOffset = 0, actionClassName, actionStyle, origin, }) {
802
+ function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, onInteractionPointerDown, indexOffset = 0, actionClassName, actionStyle, origin, }) {
755
803
  var _a;
756
804
  const nextNavigableIndex = navigableIndex + 1;
757
805
  const isActive = activeIndex === nextNavigableIndex;
@@ -769,6 +817,7 @@ function handleActionRendering({ action, activeIndex, navigableIndex, getItemPro
769
817
  closeOnRun: action.shouldClose,
770
818
  });
771
819
  },
820
+ onPointerDown: onInteractionPointerDown,
772
821
  className: classnames(styles$1.action, isActive && styles$1.actionActive, actionClassName),
773
822
  style: actionStyle,
774
823
  });
@@ -786,7 +835,7 @@ function DefaultActionContent({ textContent, }) {
786
835
  } }, textContent));
787
836
  }
788
837
 
789
- function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, }) {
838
+ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, onInteractionPointerDown, }) {
790
839
  if (!items || items.length === 0)
791
840
  return null;
792
841
  let navigableIndex = -1;
@@ -801,13 +850,14 @@ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemPr
801
850
  customRenderFooter,
802
851
  listRef,
803
852
  onAction,
853
+ onInteractionPointerDown,
804
854
  navigableIndex,
805
855
  });
806
856
  navigableIndex = result.nextNavigableIndex;
807
857
  return result.node;
808
858
  })));
809
859
  }
810
- function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
860
+ function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionPointerDown, navigableIndex, }) {
811
861
  const interactive = Boolean(persistent.onClick);
812
862
  if (!interactive) {
813
863
  const node = handleTextPersistentRendering({
@@ -828,6 +878,7 @@ function handlePersistentRendering({ persistent, position, activeIndex, indexOff
828
878
  customRenderFooter,
829
879
  listRef,
830
880
  onAction,
881
+ onInteractionPointerDown,
831
882
  navigableIndex,
832
883
  });
833
884
  }
@@ -843,9 +894,9 @@ function handleTextPersistentRendering({ persistent, position, customRenderHeade
843
894
  else {
844
895
  content = React.createElement(DefaultTextPersistentContent, { persistent: persistent });
845
896
  }
846
- 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));
897
+ 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, onPointerDown: preventDefaultPointerDown }, content));
847
898
  }
848
- function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
899
+ function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionPointerDown, navigableIndex, }) {
849
900
  var _a;
850
901
  const nextNavigableIndex = navigableIndex + 1;
851
902
  const isActive = activeIndex === indexOffset + nextNavigableIndex;
@@ -872,13 +923,16 @@ function handleActionPersistentRendering({ persistent, position, activeIndex, in
872
923
  if (persistNode)
873
924
  listRef.current[idx] = persistNode;
874
925
  },
875
- onClick: () => onAction({
876
- run: () => {
877
- var _a;
878
- (_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
879
- },
880
- closeOnRun: persistent.shouldClose,
881
- }),
926
+ onClick: () => {
927
+ onAction({
928
+ run: () => {
929
+ var _a;
930
+ (_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
931
+ },
932
+ closeOnRun: persistent.shouldClose,
933
+ });
934
+ },
935
+ onPointerDown: onInteractionPointerDown,
882
936
  className: classnames(styles$1.action, isActive && styles$1.actionActive),
883
937
  }), { role: "button", tabIndex: -1 }), content)),
884
938
  nextNavigableIndex,
@@ -893,7 +947,7 @@ const AutocompleteRebuilt = React.forwardRef(AutocompleteRebuiltInternal);
893
947
  function AutocompleteRebuiltInternal(props, forwardedRef) {
894
948
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
895
949
  const { inputValue, placeholder, disabled, error, invalid, description, size: sizeProp, loading = false, } = props;
896
- 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);
950
+ const { renderable, optionCount, persistentsHeaders, persistentsFooters, headerInteractiveCount, middleNavigableCount, getOptionLabel, isOptionSelected, refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps, activeIndex, open, listRef, onSelection, onAction, onInteractionPointerDown, onInputChangeFromUser, onInputBlur, onInputFocus, onInputKeyDown, setReferenceElement, } = useAutocomplete(props);
897
951
  const listboxId = React.useId();
898
952
  // Provides mount/unmount-aware transition styles for the floating element
899
953
  const { isMounted, styles: transitionStyles } = floatingUi_react.useTransitionStyles(context, {
@@ -953,10 +1007,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
953
1007
  ? { width: menuWidth, maxWidth: menuWidth }
954
1008
  : {})),
955
1009
  })),
956
- 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 }),
1010
+ 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, onInteractionPointerDown: onInteractionPointerDown, 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 }),
957
1011
  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,
958
1012
  showEmptyStateMessage && (React.createElement(EmptyStateMessage, { emptyState: props.emptyStateMessage })),
959
- 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: {
1013
+ 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, onInteractionPointerDown: onInteractionPointerDown, isOptionSelected: isOptionSelected, slotOverrides: {
960
1014
  option: {
961
1015
  className: (_f = props.UNSAFE_className) === null || _f === void 0 ? void 0 : _f.option,
962
1016
  style: (_g = props.UNSAFE_styles) === null || _g === void 0 ? void 0 : _g.option,
@@ -970,10 +1024,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
970
1024
  style: (_l = props.UNSAFE_styles) === null || _l === void 0 ? void 0 : _l.section,
971
1025
  },
972
1026
  } }))))),
973
- 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 })))))));
1027
+ 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, onInteractionPointerDown: onInteractionPointerDown, 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 })))))));
974
1028
  }
975
1029
  function LoadingContent() {
976
- return (React.createElement("div", { className: styles$1.loadingList },
1030
+ return (React.createElement("div", { className: styles$1.loadingList, onPointerDown: preventDefaultPointerDown },
977
1031
  React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" }),
978
1032
  React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" }),
979
1033
  React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" })));
@@ -981,7 +1035,7 @@ function LoadingContent() {
981
1035
  function EmptyStateMessage({ emptyState, }) {
982
1036
  const emptyStateDefault = "No options";
983
1037
  const emptyStateContent = emptyState !== null && emptyState !== void 0 ? emptyState : emptyStateDefault;
984
- return React.createElement("div", { className: styles$1.emptyStateMessage }, emptyStateContent);
1038
+ return (React.createElement("div", { className: styles$1.emptyStateMessage, onPointerDown: preventDefaultPointerDown }, emptyStateContent));
985
1039
  }
986
1040
 
987
1041
  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-"};