@jobber/components 6.103.2-JOB-141426-1b49367.0 → 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.
@@ -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;
@@ -140,7 +140,7 @@ function invokeActiveItemOnEnter(event, activeIndex, renderable, onSelect, onAct
140
140
 
141
141
  const MENU_OFFSET = design.tokens["space-small"];
142
142
  const AUTOCOMPLETE_MAX_HEIGHT$1 = 300;
143
- function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, }) {
143
+ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, readOnly = false, }) {
144
144
  const [open, setOpen] = React.useState(false);
145
145
  const [activeIndex, setActiveIndex] = React.useState(null);
146
146
  const listRef = React.useRef([]);
@@ -172,6 +172,10 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
172
172
  }),
173
173
  ],
174
174
  });
175
+ const click = floatingUi_react.useClick(context, {
176
+ enabled: !readOnly,
177
+ toggle: false, // Only open, never close on click
178
+ });
175
179
  const listNav = floatingUi_react.useListNavigation(context, {
176
180
  listRef,
177
181
  activeIndex,
@@ -193,7 +197,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
193
197
  escapeKey: true,
194
198
  outsidePressEvent: "click",
195
199
  });
196
- const { getReferenceProps, getFloatingProps, getItemProps } = floatingUi_react.useInteractions([listNav, dismiss]);
200
+ const { getReferenceProps, getFloatingProps, getItemProps } = floatingUi_react.useInteractions([click, listNav, dismiss]);
197
201
  React.useEffect(() => {
198
202
  listRef.current.length = navigableCount;
199
203
  setActiveIndex(prev => {
@@ -225,7 +229,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
225
229
  // eslint-disable-next-line max-statements
226
230
  function useAutocomplete(props) {
227
231
  const { menu, emptyActions, getOptionLabel: getOptionLabelProp, isOptionEqualToValue, inputValue, onInputChange, value, onChange, multiple, openOnFocus = true, readOnly = false, debounce: debounceMs = 300, } = props;
228
- const isClickingWithinRef = React.useRef(false);
232
+ const isHandlingMenuInteractionRef = React.useRef(false);
229
233
  // TODO: Clean up the types in these refs by enhancing the type system in useCallbackRef
230
234
  const getOptionLabelPropRef = jobberHooks.useCallbackRef((opt) => getOptionLabelProp === null || getOptionLabelProp === void 0 ? void 0 : getOptionLabelProp(opt));
231
235
  const getOptionLabel = React.useCallback((opt) => {
@@ -268,7 +272,8 @@ function useAutocomplete(props) {
268
272
  const [debouncedInputValue, setDebouncedInputValue] = React.useState(inputValue);
269
273
  const debouncedSetter = jobberHooks.useDebounce(setDebouncedInputValue, debounceMs);
270
274
  React.useEffect(() => {
271
- if (debounceMs === 0) {
275
+ // Skip debounce when clearing input for immediate feedback, preventing flickering of last selected item
276
+ if (debounceMs === 0 || inputValue === "") {
272
277
  setDebouncedInputValue(inputValue);
273
278
  return;
274
279
  }
@@ -358,6 +363,7 @@ function useAutocomplete(props) {
358
363
  navigableCount: totalNavigableCount,
359
364
  shouldResetActiveIndexOnClose: () => !hasSelection,
360
365
  selectedIndex,
366
+ readOnly,
361
367
  onMenuClose: () => {
362
368
  if (props.allowFreeForm !== true) {
363
369
  const hasText = inputValue.trim().length > 0;
@@ -369,7 +375,6 @@ function useAutocomplete(props) {
369
375
  }
370
376
  },
371
377
  });
372
- const [inputFocused, setInputFocused] = React.useState(false);
373
378
  // Handles activeIndex reset and, in single-select mode only, clearing selection when input is empty
374
379
  React.useEffect(() => {
375
380
  const hasText = inputValue.trim().length > 0;
@@ -462,16 +467,29 @@ function useAutocomplete(props) {
462
467
  setActiveIndex(null);
463
468
  }, [open, multiple, value, renderable, equals, setActiveIndex]);
464
469
  const onSelection = React.useCallback((option) => {
470
+ var _a;
465
471
  selectOption(option);
466
472
  // Might not always want to close on selection. Multi for example.
467
473
  setOpen(false);
468
- }, [selectOption, setOpen]);
474
+ (_a = refs.domReference.current) === null || _a === void 0 ? void 0 : _a.focus();
475
+ }, [selectOption, setOpen, refs.domReference]);
469
476
  const onAction = React.useCallback((action) => {
477
+ var _a;
470
478
  action.run();
471
479
  setActiveIndex(null);
472
480
  if (action.closeOnRun !== false)
473
481
  setOpen(false);
474
- }, [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
+ }, []);
475
493
  function commitFromInputText(inputText) {
476
494
  var _a;
477
495
  if (inputText.length === 0)
@@ -513,15 +531,18 @@ function useAutocomplete(props) {
513
531
  ]);
514
532
  const onInputFocus = React.useCallback(() => {
515
533
  var _a;
516
- setInputFocused(true);
517
- if (!readOnly && openOnFocus)
534
+ if (!readOnly && openOnFocus && !isHandlingMenuInteractionRef.current) {
518
535
  setOpen(true);
519
- (_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;
520
542
  }, [props.onFocus, readOnly, openOnFocus, setOpen]);
521
543
  const onInputBlur = React.useCallback(() => {
522
544
  var _a, _b;
523
- setInputFocused(false);
524
- if (isClickingWithinRef.current) {
545
+ if (isHandlingMenuInteractionRef.current) {
525
546
  return;
526
547
  }
527
548
  if (readOnly) {
@@ -629,11 +650,11 @@ function useAutocomplete(props) {
629
650
  setActiveIndex(null);
630
651
  }
631
652
  // Important: update open state before propagating the change so that downstream effects
632
- // 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
633
654
  if (!readOnly) {
634
655
  const hasText = val.trim().length > 0;
635
656
  const mustSelectFromOptions = hasText && !props.allowFreeForm;
636
- const keepOpenOnEmpty = openOnFocus && inputFocused;
657
+ const keepOpenOnEmpty = openOnFocus;
637
658
  setOpen(mustSelectFromOptions || keepOpenOnEmpty);
638
659
  }
639
660
  onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(val);
@@ -644,7 +665,6 @@ function useAutocomplete(props) {
644
665
  readOnly,
645
666
  props.allowFreeForm,
646
667
  openOnFocus,
647
- inputFocused,
648
668
  setOpen,
649
669
  ]);
650
670
  return {
@@ -670,10 +690,10 @@ function useAutocomplete(props) {
670
690
  activeIndex,
671
691
  setActiveIndex,
672
692
  listRef,
673
- isClickingWithinRef,
674
693
  // actions
675
694
  onSelection,
676
695
  onAction,
696
+ onInteractionMouseDown,
677
697
  // input handlers
678
698
  onInputChangeFromUser,
679
699
  onInputBlur,
@@ -684,7 +704,7 @@ function useAutocomplete(props) {
684
704
  };
685
705
  }
686
706
 
687
- 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, }) {
688
708
  let navigableIndex = -1;
689
709
  function renderItemNode(item) {
690
710
  var _a, _b, _c, _d, _e, _f;
@@ -708,6 +728,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
708
728
  customRenderOption,
709
729
  getOptionLabel,
710
730
  onSelect,
731
+ onInteractionMouseDown,
711
732
  indexOffset,
712
733
  optionClassName: (_c = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _c === void 0 ? void 0 : _c.className,
713
734
  optionStyle: (_d = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _d === void 0 ? void 0 : _d.style,
@@ -724,6 +745,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
724
745
  listboxId,
725
746
  customRenderAction,
726
747
  onAction,
748
+ onInteractionMouseDown,
727
749
  indexOffset,
728
750
  actionClassName: (_e = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _e === void 0 ? void 0 : _e.className,
729
751
  actionStyle: (_f = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _f === void 0 ? void 0 : _f.style,
@@ -737,12 +759,14 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
737
759
  function handleSectionRendering({ customRenderSection, section, sectionClassName, sectionStyle, }) {
738
760
  var _a;
739
761
  const headerContent = customRenderSection ? (customRenderSection(section)) : (React.createElement(DefaultSectionContent, { section: section }));
740
- 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));
741
765
  }
742
766
  function DefaultSectionContent({ section, }) {
743
767
  return React.createElement(Heading.Heading, { level: 5 }, section.label);
744
768
  }
745
- 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, }) {
746
770
  var _a;
747
771
  const nextNavigableIndex = navigableIndex + 1;
748
772
  const isActive = activeIndex === nextNavigableIndex;
@@ -756,6 +780,7 @@ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemPro
756
780
  listRef.current[idx] = node;
757
781
  },
758
782
  onClick: () => onSelect(option),
783
+ onMouseDown: onInteractionMouseDown,
759
784
  className: classnames(styles$1.option, isActive && styles$1.optionActive, optionClassName),
760
785
  style: optionStyle,
761
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)),
@@ -767,7 +792,7 @@ function DefaultOptionContent({ isSelected, text, }) {
767
792
  React.createElement("div", { className: styles$1.icon }, isSelected && React.createElement(Icon.Icon, { name: "checkmark", size: "small" })),
768
793
  React.createElement(Text.Text, null, text)));
769
794
  }
770
- 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, }) {
771
796
  var _a;
772
797
  const nextNavigableIndex = navigableIndex + 1;
773
798
  const isActive = activeIndex === nextNavigableIndex;
@@ -785,6 +810,7 @@ function handleActionRendering({ action, activeIndex, navigableIndex, getItemPro
785
810
  closeOnRun: action.shouldClose,
786
811
  });
787
812
  },
813
+ onMouseDown: onInteractionMouseDown,
788
814
  className: classnames(styles$1.action, isActive && styles$1.actionActive, actionClassName),
789
815
  style: actionStyle,
790
816
  });
@@ -802,7 +828,7 @@ function DefaultActionContent({ textContent, }) {
802
828
  } }, textContent));
803
829
  }
804
830
 
805
- 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, }) {
806
832
  if (!items || items.length === 0)
807
833
  return null;
808
834
  let navigableIndex = -1;
@@ -817,13 +843,14 @@ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemPr
817
843
  customRenderFooter,
818
844
  listRef,
819
845
  onAction,
846
+ onInteractionMouseDown,
820
847
  navigableIndex,
821
848
  });
822
849
  navigableIndex = result.nextNavigableIndex;
823
850
  return result.node;
824
851
  })));
825
852
  }
826
- 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, }) {
827
854
  const interactive = Boolean(persistent.onClick);
828
855
  if (!interactive) {
829
856
  const node = handleTextPersistentRendering({
@@ -844,6 +871,7 @@ function handlePersistentRendering({ persistent, position, activeIndex, indexOff
844
871
  customRenderFooter,
845
872
  listRef,
846
873
  onAction,
874
+ onInteractionMouseDown,
847
875
  navigableIndex,
848
876
  });
849
877
  }
@@ -859,9 +887,11 @@ function handleTextPersistentRendering({ persistent, position, customRenderHeade
859
887
  else {
860
888
  content = React.createElement(DefaultTextPersistentContent, { persistent: persistent });
861
889
  }
862
- 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));
863
893
  }
864
- 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, }) {
865
895
  var _a;
866
896
  const nextNavigableIndex = navigableIndex + 1;
867
897
  const isActive = activeIndex === indexOffset + nextNavigableIndex;
@@ -888,13 +918,16 @@ function handleActionPersistentRendering({ persistent, position, activeIndex, in
888
918
  if (persistNode)
889
919
  listRef.current[idx] = persistNode;
890
920
  },
891
- onClick: () => onAction({
892
- run: () => {
893
- var _a;
894
- (_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
895
- },
896
- closeOnRun: persistent.shouldClose,
897
- }),
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,
898
931
  className: classnames(styles$1.action, isActive && styles$1.actionActive),
899
932
  }), { role: "button", tabIndex: -1 }), content)),
900
933
  nextNavigableIndex,
@@ -909,7 +942,7 @@ const AutocompleteRebuilt = React.forwardRef(AutocompleteRebuiltInternal);
909
942
  function AutocompleteRebuiltInternal(props, forwardedRef) {
910
943
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
911
944
  const { inputValue, placeholder, disabled, error, invalid, description, size: sizeProp, loading = false, } = props;
912
- const { renderable, optionCount, persistentsHeaders, persistentsFooters, headerInteractiveCount, middleNavigableCount, getOptionLabel, isOptionSelected, refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps, activeIndex, open, listRef, isClickingWithinRef, 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);
913
946
  const listboxId = React.useId();
914
947
  // Provides mount/unmount-aware transition styles for the floating element
915
948
  const { isMounted, styles: transitionStyles } = floatingUi_react.useTransitionStyles(context, {
@@ -967,15 +1000,11 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
967
1000
  style: Object.assign(Object.assign(Object.assign(Object.assign({}, floatingStyles), transitionStyles), (_b = props.UNSAFE_styles) === null || _b === void 0 ? void 0 : _b.menu), (menuWidth
968
1001
  ? { width: menuWidth, maxWidth: menuWidth }
969
1002
  : {})),
970
- }), { onPointerDown: () => {
971
- isClickingWithinRef.current = true;
972
- }, onPointerUp: () => {
973
- isClickingWithinRef.current = false;
974
- } }),
975
- 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 }),
1003
+ })),
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 }),
976
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,
977
1006
  showEmptyStateMessage && (React.createElement(EmptyStateMessage, { emptyState: props.emptyStateMessage })),
978
- 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: {
979
1008
  option: {
980
1009
  className: (_f = props.UNSAFE_className) === null || _f === void 0 ? void 0 : _f.option,
981
1010
  style: (_g = props.UNSAFE_styles) === null || _g === void 0 ? void 0 : _g.option,
@@ -989,10 +1018,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
989
1018
  style: (_l = props.UNSAFE_styles) === null || _l === void 0 ? void 0 : _l.section,
990
1019
  },
991
1020
  } }))))),
992
- 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 })))))));
993
1022
  }
994
1023
  function LoadingContent() {
995
- return (React.createElement("div", { className: styles$1.loadingList },
1024
+ return (React.createElement("div", { className: styles$1.loadingList, onMouseDown: e => e.preventDefault() },
996
1025
  React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" }),
997
1026
  React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" }),
998
1027
  React.createElement(Glimmer.Glimmer, { shape: "rectangle", size: "base" })));
@@ -1000,7 +1029,7 @@ function LoadingContent() {
1000
1029
  function EmptyStateMessage({ emptyState, }) {
1001
1030
  const emptyStateDefault = "No options";
1002
1031
  const emptyStateContent = emptyState !== null && emptyState !== void 0 ? emptyState : emptyStateDefault;
1003
- return React.createElement("div", { className: styles$1.emptyStateMessage }, emptyStateContent);
1032
+ return (React.createElement("div", { className: styles$1.emptyStateMessage, onMouseDown: e => e.preventDefault() }, emptyStateContent));
1004
1033
  }
1005
1034
 
1006
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-"};
@@ -1,5 +1,5 @@
1
1
  import React__default, { useState, useRef, useEffect, useCallback, useMemo, forwardRef } from 'react';
2
- import { u as useFloating, b as autoUpdate, o as offset, f as flip, c as size, e as useListNavigation, d as useDismiss, g as useInteractions, r as useTransitionStyles, F as FloatingPortal, p as FloatingFocusManager } from '../floating-ui.react-es.js';
2
+ import { u as useFloating, b as autoUpdate, o as offset, f as flip, c as size, r as useClick, e as useListNavigation, d as useDismiss, g as useInteractions, t as useTransitionStyles, F as FloatingPortal, p as FloatingFocusManager } from '../floating-ui.react-es.js';
3
3
  import classnames from 'classnames';
4
4
  import { tokens } from '@jobber/design';
5
5
  import { useCallbackRef, useDebounce, useSafeLayoutEffect, useIsMounted, useOnKeyDown } from '@jobber/hooks';
@@ -138,7 +138,7 @@ function invokeActiveItemOnEnter(event, activeIndex, renderable, onSelect, onAct
138
138
 
139
139
  const MENU_OFFSET = tokens["space-small"];
140
140
  const AUTOCOMPLETE_MAX_HEIGHT$1 = 300;
141
- function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, }) {
141
+ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, readOnly = false, }) {
142
142
  const [open, setOpen] = useState(false);
143
143
  const [activeIndex, setActiveIndex] = useState(null);
144
144
  const listRef = useRef([]);
@@ -170,6 +170,10 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
170
170
  }),
171
171
  ],
172
172
  });
173
+ const click = useClick(context, {
174
+ enabled: !readOnly,
175
+ toggle: false, // Only open, never close on click
176
+ });
173
177
  const listNav = useListNavigation(context, {
174
178
  listRef,
175
179
  activeIndex,
@@ -191,7 +195,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
191
195
  escapeKey: true,
192
196
  outsidePressEvent: "click",
193
197
  });
194
- const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([listNav, dismiss]);
198
+ const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([click, listNav, dismiss]);
195
199
  useEffect(() => {
196
200
  listRef.current.length = navigableCount;
197
201
  setActiveIndex(prev => {
@@ -223,7 +227,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
223
227
  // eslint-disable-next-line max-statements
224
228
  function useAutocomplete(props) {
225
229
  const { menu, emptyActions, getOptionLabel: getOptionLabelProp, isOptionEqualToValue, inputValue, onInputChange, value, onChange, multiple, openOnFocus = true, readOnly = false, debounce: debounceMs = 300, } = props;
226
- const isClickingWithinRef = useRef(false);
230
+ const isHandlingMenuInteractionRef = useRef(false);
227
231
  // TODO: Clean up the types in these refs by enhancing the type system in useCallbackRef
228
232
  const getOptionLabelPropRef = useCallbackRef((opt) => getOptionLabelProp === null || getOptionLabelProp === void 0 ? void 0 : getOptionLabelProp(opt));
229
233
  const getOptionLabel = useCallback((opt) => {
@@ -266,7 +270,8 @@ function useAutocomplete(props) {
266
270
  const [debouncedInputValue, setDebouncedInputValue] = useState(inputValue);
267
271
  const debouncedSetter = useDebounce(setDebouncedInputValue, debounceMs);
268
272
  useEffect(() => {
269
- if (debounceMs === 0) {
273
+ // Skip debounce when clearing input for immediate feedback, preventing flickering of last selected item
274
+ if (debounceMs === 0 || inputValue === "") {
270
275
  setDebouncedInputValue(inputValue);
271
276
  return;
272
277
  }
@@ -356,6 +361,7 @@ function useAutocomplete(props) {
356
361
  navigableCount: totalNavigableCount,
357
362
  shouldResetActiveIndexOnClose: () => !hasSelection,
358
363
  selectedIndex,
364
+ readOnly,
359
365
  onMenuClose: () => {
360
366
  if (props.allowFreeForm !== true) {
361
367
  const hasText = inputValue.trim().length > 0;
@@ -367,7 +373,6 @@ function useAutocomplete(props) {
367
373
  }
368
374
  },
369
375
  });
370
- const [inputFocused, setInputFocused] = useState(false);
371
376
  // Handles activeIndex reset and, in single-select mode only, clearing selection when input is empty
372
377
  useEffect(() => {
373
378
  const hasText = inputValue.trim().length > 0;
@@ -460,16 +465,29 @@ function useAutocomplete(props) {
460
465
  setActiveIndex(null);
461
466
  }, [open, multiple, value, renderable, equals, setActiveIndex]);
462
467
  const onSelection = useCallback((option) => {
468
+ var _a;
463
469
  selectOption(option);
464
470
  // Might not always want to close on selection. Multi for example.
465
471
  setOpen(false);
466
- }, [selectOption, setOpen]);
472
+ (_a = refs.domReference.current) === null || _a === void 0 ? void 0 : _a.focus();
473
+ }, [selectOption, setOpen, refs.domReference]);
467
474
  const onAction = useCallback((action) => {
475
+ var _a;
468
476
  action.run();
469
477
  setActiveIndex(null);
470
478
  if (action.closeOnRun !== false)
471
479
  setOpen(false);
472
- }, [setOpen, setActiveIndex]);
480
+ (_a = refs.domReference.current) === null || _a === void 0 ? void 0 : _a.focus();
481
+ }, [setOpen, setActiveIndex, refs.domReference]);
482
+ /**
483
+ * Handler for mousedown on interactive menu items (options/actions)
484
+ * Prevents default to avoid blur and sets flag for focus management
485
+ */
486
+ const onInteractionMouseDown = useCallback((e) => {
487
+ e.preventDefault();
488
+ // Set flag to prevent blur/focus handlers from interfering
489
+ isHandlingMenuInteractionRef.current = true;
490
+ }, []);
473
491
  function commitFromInputText(inputText) {
474
492
  var _a;
475
493
  if (inputText.length === 0)
@@ -511,15 +529,18 @@ function useAutocomplete(props) {
511
529
  ]);
512
530
  const onInputFocus = useCallback(() => {
513
531
  var _a;
514
- setInputFocused(true);
515
- if (!readOnly && openOnFocus)
532
+ if (!readOnly && openOnFocus && !isHandlingMenuInteractionRef.current) {
516
533
  setOpen(true);
517
- (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
534
+ }
535
+ // Only call user's onFocus for genuine focus events, not programmatic restorations
536
+ if (!isHandlingMenuInteractionRef.current) {
537
+ (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
538
+ }
539
+ isHandlingMenuInteractionRef.current = false;
518
540
  }, [props.onFocus, readOnly, openOnFocus, setOpen]);
519
541
  const onInputBlur = useCallback(() => {
520
542
  var _a, _b;
521
- setInputFocused(false);
522
- if (isClickingWithinRef.current) {
543
+ if (isHandlingMenuInteractionRef.current) {
523
544
  return;
524
545
  }
525
546
  if (readOnly) {
@@ -627,11 +648,11 @@ function useAutocomplete(props) {
627
648
  setActiveIndex(null);
628
649
  }
629
650
  // Important: update open state before propagating the change so that downstream effects
630
- // dont see an intermediate state where inputValue changed but open was stale
651
+ // don't see an intermediate state where inputValue changed but open was stale
631
652
  if (!readOnly) {
632
653
  const hasText = val.trim().length > 0;
633
654
  const mustSelectFromOptions = hasText && !props.allowFreeForm;
634
- const keepOpenOnEmpty = openOnFocus && inputFocused;
655
+ const keepOpenOnEmpty = openOnFocus;
635
656
  setOpen(mustSelectFromOptions || keepOpenOnEmpty);
636
657
  }
637
658
  onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(val);
@@ -642,7 +663,6 @@ function useAutocomplete(props) {
642
663
  readOnly,
643
664
  props.allowFreeForm,
644
665
  openOnFocus,
645
- inputFocused,
646
666
  setOpen,
647
667
  ]);
648
668
  return {
@@ -668,10 +688,10 @@ function useAutocomplete(props) {
668
688
  activeIndex,
669
689
  setActiveIndex,
670
690
  listRef,
671
- isClickingWithinRef,
672
691
  // actions
673
692
  onSelection,
674
693
  onAction,
694
+ onInteractionMouseDown,
675
695
  // input handlers
676
696
  onInputChangeFromUser,
677
697
  onInputBlur,
@@ -682,7 +702,7 @@ function useAutocomplete(props) {
682
702
  };
683
703
  }
684
704
 
685
- function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, isOptionSelected, slotOverrides, }) {
705
+ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, onInteractionMouseDown, isOptionSelected, slotOverrides, }) {
686
706
  let navigableIndex = -1;
687
707
  function renderItemNode(item) {
688
708
  var _a, _b, _c, _d, _e, _f;
@@ -706,6 +726,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
706
726
  customRenderOption,
707
727
  getOptionLabel,
708
728
  onSelect,
729
+ onInteractionMouseDown,
709
730
  indexOffset,
710
731
  optionClassName: (_c = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _c === void 0 ? void 0 : _c.className,
711
732
  optionStyle: (_d = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _d === void 0 ? void 0 : _d.style,
@@ -722,6 +743,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
722
743
  listboxId,
723
744
  customRenderAction,
724
745
  onAction,
746
+ onInteractionMouseDown,
725
747
  indexOffset,
726
748
  actionClassName: (_e = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _e === void 0 ? void 0 : _e.className,
727
749
  actionStyle: (_f = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _f === void 0 ? void 0 : _f.style,
@@ -735,12 +757,14 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
735
757
  function handleSectionRendering({ customRenderSection, section, sectionClassName, sectionStyle, }) {
736
758
  var _a;
737
759
  const headerContent = customRenderSection ? (customRenderSection(section)) : (React__default.createElement(DefaultSectionContent, { section: section }));
738
- return (React__default.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));
760
+ return (React__default.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 => {
761
+ e.preventDefault();
762
+ } }, headerContent));
739
763
  }
740
764
  function DefaultSectionContent({ section, }) {
741
765
  return React__default.createElement(Heading, { level: 5 }, section.label);
742
766
  }
743
- function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, indexOffset = 0, optionClassName, optionStyle, }) {
767
+ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, onInteractionMouseDown, indexOffset = 0, optionClassName, optionStyle, }) {
744
768
  var _a;
745
769
  const nextNavigableIndex = navigableIndex + 1;
746
770
  const isActive = activeIndex === nextNavigableIndex;
@@ -754,6 +778,7 @@ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemPro
754
778
  listRef.current[idx] = node;
755
779
  },
756
780
  onClick: () => onSelect(option),
781
+ onMouseDown: onInteractionMouseDown,
757
782
  className: classnames(styles$1.option, isActive && styles$1.optionActive, optionClassName),
758
783
  style: optionStyle,
759
784
  }), { role: "option", tabIndex: -1, "aria-selected": isSelected ? true : false, id: `${listboxId}-item-${nextNavigableIndex + indexOffset}`, "data-index": nextNavigableIndex + indexOffset, "data-active": isActive ? true : undefined }), optionContent)),
@@ -765,7 +790,7 @@ function DefaultOptionContent({ isSelected, text, }) {
765
790
  React__default.createElement("div", { className: styles$1.icon }, isSelected && React__default.createElement(Icon, { name: "checkmark", size: "small" })),
766
791
  React__default.createElement(Text, null, text)));
767
792
  }
768
- function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, indexOffset = 0, actionClassName, actionStyle, origin, }) {
793
+ function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, onInteractionMouseDown, indexOffset = 0, actionClassName, actionStyle, origin, }) {
769
794
  var _a;
770
795
  const nextNavigableIndex = navigableIndex + 1;
771
796
  const isActive = activeIndex === nextNavigableIndex;
@@ -783,6 +808,7 @@ function handleActionRendering({ action, activeIndex, navigableIndex, getItemPro
783
808
  closeOnRun: action.shouldClose,
784
809
  });
785
810
  },
811
+ onMouseDown: onInteractionMouseDown,
786
812
  className: classnames(styles$1.action, isActive && styles$1.actionActive, actionClassName),
787
813
  style: actionStyle,
788
814
  });
@@ -800,7 +826,7 @@ function DefaultActionContent({ textContent, }) {
800
826
  } }, textContent));
801
827
  }
802
828
 
803
- function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, }) {
829
+ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, onInteractionMouseDown, }) {
804
830
  if (!items || items.length === 0)
805
831
  return null;
806
832
  let navigableIndex = -1;
@@ -815,13 +841,14 @@ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemPr
815
841
  customRenderFooter,
816
842
  listRef,
817
843
  onAction,
844
+ onInteractionMouseDown,
818
845
  navigableIndex,
819
846
  });
820
847
  navigableIndex = result.nextNavigableIndex;
821
848
  return result.node;
822
849
  })));
823
850
  }
824
- function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
851
+ function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionMouseDown, navigableIndex, }) {
825
852
  const interactive = Boolean(persistent.onClick);
826
853
  if (!interactive) {
827
854
  const node = handleTextPersistentRendering({
@@ -842,6 +869,7 @@ function handlePersistentRendering({ persistent, position, activeIndex, indexOff
842
869
  customRenderFooter,
843
870
  listRef,
844
871
  onAction,
872
+ onInteractionMouseDown,
845
873
  navigableIndex,
846
874
  });
847
875
  }
@@ -857,9 +885,11 @@ function handleTextPersistentRendering({ persistent, position, customRenderHeade
857
885
  else {
858
886
  content = React__default.createElement(DefaultTextPersistentContent, { persistent: persistent });
859
887
  }
860
- return (React__default.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));
888
+ return (React__default.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 => {
889
+ e.preventDefault();
890
+ } }, content));
861
891
  }
862
- function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
892
+ function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionMouseDown, navigableIndex, }) {
863
893
  var _a;
864
894
  const nextNavigableIndex = navigableIndex + 1;
865
895
  const isActive = activeIndex === indexOffset + nextNavigableIndex;
@@ -886,13 +916,16 @@ function handleActionPersistentRendering({ persistent, position, activeIndex, in
886
916
  if (persistNode)
887
917
  listRef.current[idx] = persistNode;
888
918
  },
889
- onClick: () => onAction({
890
- run: () => {
891
- var _a;
892
- (_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
893
- },
894
- closeOnRun: persistent.shouldClose,
895
- }),
919
+ onClick: () => {
920
+ onAction({
921
+ run: () => {
922
+ var _a;
923
+ (_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
924
+ },
925
+ closeOnRun: persistent.shouldClose,
926
+ });
927
+ },
928
+ onMouseDown: onInteractionMouseDown,
896
929
  className: classnames(styles$1.action, isActive && styles$1.actionActive),
897
930
  }), { role: "button", tabIndex: -1 }), content)),
898
931
  nextNavigableIndex,
@@ -907,7 +940,7 @@ const AutocompleteRebuilt = forwardRef(AutocompleteRebuiltInternal);
907
940
  function AutocompleteRebuiltInternal(props, forwardedRef) {
908
941
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
909
942
  const { inputValue, placeholder, disabled, error, invalid, description, size: sizeProp, loading = false, } = props;
910
- const { renderable, optionCount, persistentsHeaders, persistentsFooters, headerInteractiveCount, middleNavigableCount, getOptionLabel, isOptionSelected, refs, floatingStyles, context, getReferenceProps, getFloatingProps, getItemProps, activeIndex, open, listRef, isClickingWithinRef, onSelection, onAction, onInputChangeFromUser, onInputBlur, onInputFocus, onInputKeyDown, setReferenceElement, } = useAutocomplete(props);
943
+ 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);
911
944
  const listboxId = React__default.useId();
912
945
  // Provides mount/unmount-aware transition styles for the floating element
913
946
  const { isMounted, styles: transitionStyles } = useTransitionStyles(context, {
@@ -965,15 +998,11 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
965
998
  style: Object.assign(Object.assign(Object.assign(Object.assign({}, floatingStyles), transitionStyles), (_b = props.UNSAFE_styles) === null || _b === void 0 ? void 0 : _b.menu), (menuWidth
966
999
  ? { width: menuWidth, maxWidth: menuWidth }
967
1000
  : {})),
968
- }), { onPointerDown: () => {
969
- isClickingWithinRef.current = true;
970
- }, onPointerUp: () => {
971
- isClickingWithinRef.current = false;
972
- } }),
973
- React__default.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 }),
1001
+ })),
1002
+ React__default.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 }),
974
1003
  React__default.createElement("div", { className: styles$1.scrollRegion }, loading ? ((_e = props.customRenderLoading) !== null && _e !== void 0 ? _e : React__default.createElement(LoadingContent, null)) : (React__default.createElement(React__default.Fragment, null,
975
1004
  showEmptyStateMessage && (React__default.createElement(EmptyStateMessage, { emptyState: props.emptyStateMessage })),
976
- renderable.length > 0 && (React__default.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: {
1005
+ renderable.length > 0 && (React__default.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: {
977
1006
  option: {
978
1007
  className: (_f = props.UNSAFE_className) === null || _f === void 0 ? void 0 : _f.option,
979
1008
  style: (_g = props.UNSAFE_styles) === null || _g === void 0 ? void 0 : _g.option,
@@ -987,10 +1016,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
987
1016
  style: (_l = props.UNSAFE_styles) === null || _l === void 0 ? void 0 : _l.section,
988
1017
  },
989
1018
  } }))))),
990
- React__default.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 })))))));
1019
+ React__default.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 })))))));
991
1020
  }
992
1021
  function LoadingContent() {
993
- return (React__default.createElement("div", { className: styles$1.loadingList },
1022
+ return (React__default.createElement("div", { className: styles$1.loadingList, onMouseDown: e => e.preventDefault() },
994
1023
  React__default.createElement(Glimmer, { shape: "rectangle", size: "base" }),
995
1024
  React__default.createElement(Glimmer, { shape: "rectangle", size: "base" }),
996
1025
  React__default.createElement(Glimmer, { shape: "rectangle", size: "base" })));
@@ -998,7 +1027,7 @@ function LoadingContent() {
998
1027
  function EmptyStateMessage({ emptyState, }) {
999
1028
  const emptyStateDefault = "No options";
1000
1029
  const emptyStateContent = emptyState !== null && emptyState !== void 0 ? emptyState : emptyStateDefault;
1001
- return React__default.createElement("div", { className: styles$1.emptyStateMessage }, emptyStateContent);
1030
+ return (React__default.createElement("div", { className: styles$1.emptyStateMessage, onMouseDown: e => e.preventDefault() }, emptyStateContent));
1002
1031
  }
1003
1032
 
1004
1033
  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-"};
@@ -36,3 +36,16 @@ export declare function FreeFormWrapper({ initialValue, initialInputValue, onCha
36
36
  readonly inputEqualsOption?: (input: string, option: OptionLike) => boolean;
37
37
  readonly debounce?: number;
38
38
  }): React.JSX.Element;
39
+ /**
40
+ * Wrapper for testing focus and blur behavior with tabbable siblings
41
+ * Includes tabbable elements before and after the autocomplete
42
+ * so tests can use tab navigation to focus without clicking
43
+ */
44
+ export declare function FocusableSiblingsWrapper<T extends OptionLike>({ onFocus, onChange, onInputChange, menu, readOnly, openOnFocus, }: {
45
+ readonly onChange?: (v: T | undefined) => void;
46
+ readonly onInputChange?: (v: string) => void;
47
+ readonly menu?: MenuItem<T>[];
48
+ readonly readOnly?: boolean;
49
+ readonly onFocus?: () => void;
50
+ readonly openOnFocus?: boolean;
51
+ }): React.JSX.Element;
@@ -56,9 +56,9 @@ export declare function useAutocomplete<Value extends OptionLike, Multiple exten
56
56
  activeIndex: number | null;
57
57
  setActiveIndex: (index: number | null) => void;
58
58
  listRef: React.MutableRefObject<(HTMLElement | null)[]>;
59
- isClickingWithinRef: React.MutableRefObject<boolean>;
60
59
  onSelection: (option: Value) => void;
61
60
  onAction: (action: ActionConfig) => void;
61
+ onInteractionMouseDown: (e: React.MouseEvent) => void;
62
62
  onInputChangeFromUser: (val: string) => void;
63
63
  onInputBlur: () => void;
64
64
  onInputFocus: () => void;
@@ -1,7 +1,7 @@
1
1
  import React__default, { cloneElement, Component, createRef, useRef, useCallback, useEffect, createElement, forwardRef, isValidElement, useState } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { c as clsx } from './clsx-es.js';
4
- import { u as useFloating, b as autoUpdate, f as flip, o as offset, a as arrow, t as FloatingArrow } from './floating-ui.react-es.js';
4
+ import { u as useFloating, b as autoUpdate, f as flip, o as offset, a as arrow, v as FloatingArrow } from './floating-ui.react-es.js';
5
5
  import ReactDOM__default from 'react-dom';
6
6
  import { useRefocusOnActivator } from '@jobber/hooks';
7
7
  import { T as Typography } from './Typography-es.js';
@@ -383,6 +383,7 @@ function FormField(props) {
383
383
  return React.createElement(FormFieldInternal, Object.assign({}, props, { id: id }));
384
384
  }
385
385
  function FormFieldInternal(props) {
386
+ var _a;
386
387
  const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, id, inputRef, inline, keyboard, max, maxLength, min, name: nameProp, pattern, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, onKeyUp, clearable = "never", autofocus, } = props;
387
388
  const { name } = useAtlantisFormFieldName({ id, nameProp });
388
389
  const { errorMessage, inputRefs, useControllerField, setValue, onControllerBlur, onControllerChange, } = useAtlantisReactHookForm({
@@ -429,7 +430,10 @@ function FormFieldInternal(props) {
429
430
  handleValidation,
430
431
  handleKeyDown,
431
432
  });
432
- return (React.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear }), renderField()));
433
+ // Ensure focus tracking works by providing a wrapperRef when none is passed
434
+ const internalWrapperRef = React.useRef(null);
435
+ const wrapperRef = (_a = props.wrapperRef) !== null && _a !== void 0 ? _a : internalWrapperRef;
436
+ return (React.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
433
437
  function renderField() {
434
438
  switch (type) {
435
439
  case "select":
@@ -381,6 +381,7 @@ function FormField(props) {
381
381
  return React__default.createElement(FormFieldInternal, Object.assign({}, props, { id: id }));
382
382
  }
383
383
  function FormFieldInternal(props) {
384
+ var _a;
384
385
  const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, id, inputRef, inline, keyboard, max, maxLength, min, name: nameProp, pattern, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, onKeyUp, clearable = "never", autofocus, } = props;
385
386
  const { name } = useAtlantisFormFieldName({ id, nameProp });
386
387
  const { errorMessage, inputRefs, useControllerField, setValue, onControllerBlur, onControllerChange, } = useAtlantisReactHookForm({
@@ -427,7 +428,10 @@ function FormFieldInternal(props) {
427
428
  handleValidation,
428
429
  handleKeyDown,
429
430
  });
430
- return (React__default.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear }), renderField()));
431
+ // Ensure focus tracking works by providing a wrapperRef when none is passed
432
+ const internalWrapperRef = useRef(null);
433
+ const wrapperRef = (_a = props.wrapperRef) !== null && _a !== void 0 ? _a : internalWrapperRef;
434
+ return (React__default.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
431
435
  function renderField() {
432
436
  switch (type) {
433
437
  case "select":
@@ -2773,7 +2773,7 @@ function InputNumberInternal(props, ref) {
2773
2773
  }
2774
2774
  },
2775
2775
  }));
2776
- return (React.createElement(FormField.FormField, Object.assign({}, props, { type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
2776
+ return (React.createElement(FormField.FormField, Object.assign({}, props, { clearable: "never", type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
2777
2777
  function customValidators(validators) {
2778
2778
  if (validators == null) {
2779
2779
  return getOverLimitMessage;
@@ -2771,7 +2771,7 @@ function InputNumberInternal(props, ref) {
2771
2771
  }
2772
2772
  },
2773
2773
  }));
2774
- return (React__default.createElement(FormField, Object.assign({}, props, { type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
2774
+ return (React__default.createElement(FormField, Object.assign({}, props, { clearable: "never", type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
2775
2775
  function customValidators(validators) {
2776
2776
  if (validators == null) {
2777
2777
  return getOverLimitMessage;
@@ -1065,6 +1065,12 @@ function isVirtualPointerEvent(event) {
1065
1065
  // iOS VoiceOver returns 0.333• for width/height.
1066
1066
  event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'touch';
1067
1067
  }
1068
+ function isMouseLikePointerType(pointerType, strict) {
1069
+ // On some Linux machines with Chromium, mouse inputs return a `pointerType`
1070
+ // of "pen": https://github.com/floating-ui/floating-ui/issues/2015
1071
+ const values = ['mouse', 'pen'];
1072
+ return values.includes(pointerType);
1073
+ }
1068
1074
 
1069
1075
  var isClient$1 = typeof document !== 'undefined';
1070
1076
 
@@ -4562,6 +4568,114 @@ const FloatingOverlay = /*#__PURE__*/React__namespace.forwardRef(function Floati
4562
4568
  });
4563
4569
  });
4564
4570
 
4571
+ function isButtonTarget(event) {
4572
+ return isHTMLElement(event.target) && event.target.tagName === 'BUTTON';
4573
+ }
4574
+ function isAnchorTarget(event) {
4575
+ return isHTMLElement(event.target) && event.target.tagName === 'A';
4576
+ }
4577
+ function isSpaceIgnored(element) {
4578
+ return isTypeableElement(element);
4579
+ }
4580
+ /**
4581
+ * Opens or closes the floating element when clicking the reference element.
4582
+ * @see https://floating-ui.com/docs/useClick
4583
+ */
4584
+ function useClick(context, props) {
4585
+ if (props === void 0) {
4586
+ props = {};
4587
+ }
4588
+ const {
4589
+ open,
4590
+ onOpenChange,
4591
+ dataRef,
4592
+ elements: {
4593
+ domReference
4594
+ }
4595
+ } = context;
4596
+ const {
4597
+ enabled = true,
4598
+ event: eventOption = 'click',
4599
+ toggle = true,
4600
+ ignoreMouse = false,
4601
+ keyboardHandlers = true,
4602
+ stickIfOpen = true
4603
+ } = props;
4604
+ const pointerTypeRef = React__namespace.useRef();
4605
+ const didKeyDownRef = React__namespace.useRef(false);
4606
+ const reference = React__namespace.useMemo(() => ({
4607
+ onPointerDown(event) {
4608
+ pointerTypeRef.current = event.pointerType;
4609
+ },
4610
+ onMouseDown(event) {
4611
+ const pointerType = pointerTypeRef.current;
4612
+
4613
+ // Ignore all buttons except for the "main" button.
4614
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
4615
+ if (event.button !== 0) return;
4616
+ if (eventOption === 'click') return;
4617
+ if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
4618
+ if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'mousedown' : true)) {
4619
+ onOpenChange(false, event.nativeEvent, 'click');
4620
+ } else {
4621
+ // Prevent stealing focus from the floating element
4622
+ event.preventDefault();
4623
+ onOpenChange(true, event.nativeEvent, 'click');
4624
+ }
4625
+ },
4626
+ onClick(event) {
4627
+ const pointerType = pointerTypeRef.current;
4628
+ if (eventOption === 'mousedown' && pointerTypeRef.current) {
4629
+ pointerTypeRef.current = undefined;
4630
+ return;
4631
+ }
4632
+ if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
4633
+ if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'click' : true)) {
4634
+ onOpenChange(false, event.nativeEvent, 'click');
4635
+ } else {
4636
+ onOpenChange(true, event.nativeEvent, 'click');
4637
+ }
4638
+ },
4639
+ onKeyDown(event) {
4640
+ pointerTypeRef.current = undefined;
4641
+ if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
4642
+ return;
4643
+ }
4644
+ if (event.key === ' ' && !isSpaceIgnored(domReference)) {
4645
+ // Prevent scrolling
4646
+ event.preventDefault();
4647
+ didKeyDownRef.current = true;
4648
+ }
4649
+ if (isAnchorTarget(event)) {
4650
+ return;
4651
+ }
4652
+ if (event.key === 'Enter') {
4653
+ if (open && toggle) {
4654
+ onOpenChange(false, event.nativeEvent, 'click');
4655
+ } else {
4656
+ onOpenChange(true, event.nativeEvent, 'click');
4657
+ }
4658
+ }
4659
+ },
4660
+ onKeyUp(event) {
4661
+ if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
4662
+ return;
4663
+ }
4664
+ if (event.key === ' ' && didKeyDownRef.current) {
4665
+ didKeyDownRef.current = false;
4666
+ if (open && toggle) {
4667
+ onOpenChange(false, event.nativeEvent, 'click');
4668
+ } else {
4669
+ onOpenChange(true, event.nativeEvent, 'click');
4670
+ }
4671
+ }
4672
+ }
4673
+ }), [dataRef, domReference, eventOption, ignoreMouse, keyboardHandlers, onOpenChange, open, stickIfOpen, toggle]);
4674
+ return React__namespace.useMemo(() => enabled ? {
4675
+ reference
4676
+ } : {}, [enabled, reference]);
4677
+ }
4678
+
4565
4679
  const bubbleHandlerKeys = {
4566
4680
  pointerdown: 'onPointerDown',
4567
4681
  mousedown: 'onMouseDown',
@@ -5943,6 +6057,7 @@ exports.limitShift = limitShift;
5943
6057
  exports.offset = offset;
5944
6058
  exports.shift = shift;
5945
6059
  exports.size = size;
6060
+ exports.useClick = useClick;
5946
6061
  exports.useDismiss = useDismiss;
5947
6062
  exports.useFloating = useFloating;
5948
6063
  exports.useFloatingNodeId = useFloatingNodeId;
@@ -1044,6 +1044,12 @@ function isVirtualPointerEvent(event) {
1044
1044
  // iOS VoiceOver returns 0.333• for width/height.
1045
1045
  event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'touch';
1046
1046
  }
1047
+ function isMouseLikePointerType(pointerType, strict) {
1048
+ // On some Linux machines with Chromium, mouse inputs return a `pointerType`
1049
+ // of "pen": https://github.com/floating-ui/floating-ui/issues/2015
1050
+ const values = ['mouse', 'pen'];
1051
+ return values.includes(pointerType);
1052
+ }
1047
1053
 
1048
1054
  var isClient$1 = typeof document !== 'undefined';
1049
1055
 
@@ -4541,6 +4547,114 @@ const FloatingOverlay = /*#__PURE__*/React.forwardRef(function FloatingOverlay(p
4541
4547
  });
4542
4548
  });
4543
4549
 
4550
+ function isButtonTarget(event) {
4551
+ return isHTMLElement(event.target) && event.target.tagName === 'BUTTON';
4552
+ }
4553
+ function isAnchorTarget(event) {
4554
+ return isHTMLElement(event.target) && event.target.tagName === 'A';
4555
+ }
4556
+ function isSpaceIgnored(element) {
4557
+ return isTypeableElement(element);
4558
+ }
4559
+ /**
4560
+ * Opens or closes the floating element when clicking the reference element.
4561
+ * @see https://floating-ui.com/docs/useClick
4562
+ */
4563
+ function useClick(context, props) {
4564
+ if (props === void 0) {
4565
+ props = {};
4566
+ }
4567
+ const {
4568
+ open,
4569
+ onOpenChange,
4570
+ dataRef,
4571
+ elements: {
4572
+ domReference
4573
+ }
4574
+ } = context;
4575
+ const {
4576
+ enabled = true,
4577
+ event: eventOption = 'click',
4578
+ toggle = true,
4579
+ ignoreMouse = false,
4580
+ keyboardHandlers = true,
4581
+ stickIfOpen = true
4582
+ } = props;
4583
+ const pointerTypeRef = React.useRef();
4584
+ const didKeyDownRef = React.useRef(false);
4585
+ const reference = React.useMemo(() => ({
4586
+ onPointerDown(event) {
4587
+ pointerTypeRef.current = event.pointerType;
4588
+ },
4589
+ onMouseDown(event) {
4590
+ const pointerType = pointerTypeRef.current;
4591
+
4592
+ // Ignore all buttons except for the "main" button.
4593
+ // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
4594
+ if (event.button !== 0) return;
4595
+ if (eventOption === 'click') return;
4596
+ if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
4597
+ if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'mousedown' : true)) {
4598
+ onOpenChange(false, event.nativeEvent, 'click');
4599
+ } else {
4600
+ // Prevent stealing focus from the floating element
4601
+ event.preventDefault();
4602
+ onOpenChange(true, event.nativeEvent, 'click');
4603
+ }
4604
+ },
4605
+ onClick(event) {
4606
+ const pointerType = pointerTypeRef.current;
4607
+ if (eventOption === 'mousedown' && pointerTypeRef.current) {
4608
+ pointerTypeRef.current = undefined;
4609
+ return;
4610
+ }
4611
+ if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
4612
+ if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === 'click' : true)) {
4613
+ onOpenChange(false, event.nativeEvent, 'click');
4614
+ } else {
4615
+ onOpenChange(true, event.nativeEvent, 'click');
4616
+ }
4617
+ },
4618
+ onKeyDown(event) {
4619
+ pointerTypeRef.current = undefined;
4620
+ if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
4621
+ return;
4622
+ }
4623
+ if (event.key === ' ' && !isSpaceIgnored(domReference)) {
4624
+ // Prevent scrolling
4625
+ event.preventDefault();
4626
+ didKeyDownRef.current = true;
4627
+ }
4628
+ if (isAnchorTarget(event)) {
4629
+ return;
4630
+ }
4631
+ if (event.key === 'Enter') {
4632
+ if (open && toggle) {
4633
+ onOpenChange(false, event.nativeEvent, 'click');
4634
+ } else {
4635
+ onOpenChange(true, event.nativeEvent, 'click');
4636
+ }
4637
+ }
4638
+ },
4639
+ onKeyUp(event) {
4640
+ if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
4641
+ return;
4642
+ }
4643
+ if (event.key === ' ' && didKeyDownRef.current) {
4644
+ didKeyDownRef.current = false;
4645
+ if (open && toggle) {
4646
+ onOpenChange(false, event.nativeEvent, 'click');
4647
+ } else {
4648
+ onOpenChange(true, event.nativeEvent, 'click');
4649
+ }
4650
+ }
4651
+ }
4652
+ }), [dataRef, domReference, eventOption, ignoreMouse, keyboardHandlers, onOpenChange, open, stickIfOpen, toggle]);
4653
+ return React.useMemo(() => enabled ? {
4654
+ reference
4655
+ } : {}, [enabled, reference]);
4656
+ }
4657
+
4544
4658
  const bubbleHandlerKeys = {
4545
4659
  pointerdown: 'onPointerDown',
4546
4660
  mousedown: 'onMouseDown',
@@ -5908,4 +6022,4 @@ function useTransitionStyles(context, props) {
5908
6022
  };
5909
6023
  }
5910
6024
 
5911
- export { FloatingPortal as F, arrow as a, autoUpdate as b, size as c, useDismiss as d, useListNavigation as e, flip as f, useInteractions as g, useFloatingParentNodeId as h, useFloatingNodeId as i, FloatingTree as j, FloatingNode as k, limitShift as l, autoPlacement as m, useRole as n, offset as o, FloatingFocusManager as p, FloatingOverlay as q, useTransitionStyles as r, shift as s, FloatingArrow as t, useFloating as u };
6025
+ export { FloatingPortal as F, arrow as a, autoUpdate as b, size as c, useDismiss as d, useListNavigation as e, flip as f, useInteractions as g, useFloatingParentNodeId as h, useFloatingNodeId as i, FloatingTree as j, FloatingNode as k, limitShift as l, autoPlacement as m, useRole as n, offset as o, FloatingFocusManager as p, FloatingOverlay as q, useClick as r, shift as s, useTransitionStyles as t, useFloating as u, FloatingArrow as v };
package/dist/styles.css CHANGED
@@ -99,11 +99,13 @@
99
99
  padding: var(--space-small) 0 var(--space-smaller) var(--space-small);
100
100
  border-bottom: 1px solid hsl(200, 13%, 87%);
101
101
  border-bottom: var(--border-base) solid var(--color-border);
102
+ cursor: default;
102
103
  }
103
104
 
104
105
  .Twgjn26oldE- {
105
106
  padding: 8px 16px;
106
107
  padding: var(--space-small) var(--space-base);
108
+ cursor: default;
107
109
  }
108
110
 
109
111
  .mc1-CEwZtHE- {
@@ -132,6 +134,7 @@
132
134
  .vxk57ZhP8GU- {
133
135
  padding: 8px 0 4px 8px;
134
136
  padding: var(--space-small) 0 var(--space-smaller) var(--space-small);
137
+ cursor: default;
135
138
  }
136
139
 
137
140
  .j4h-0Mxa5gk- {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.103.2-JOB-141426-1b49367.0+1b4936717",
3
+ "version": "6.103.2-JOB-141426-ee803fd.19+ee803fdda",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -538,5 +538,5 @@
538
538
  "> 1%",
539
539
  "IE 10"
540
540
  ],
541
- "gitHead": "1b4936717ac7e8c7caefc4145e02c79f7dbb7f56"
541
+ "gitHead": "ee803fdda8687a785cb75ea60585b8cf506c9e3d"
542
542
  }