@jobber/components 6.101.4 → 6.101.5-JOB-140604-4487daa.55

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 (177) hide show
  1. package/dist/Autocomplete/Autocomplete.types.d.ts +11 -51
  2. package/dist/Autocomplete/components/MenuList.d.ts +3 -2
  3. package/dist/Autocomplete/components/PersistentRegion.d.ts +3 -2
  4. package/dist/Autocomplete/hooks/useAutocompleteListNav.d.ts +3 -2
  5. package/dist/Autocomplete/index.cjs +95 -51
  6. package/dist/Autocomplete/index.mjs +97 -53
  7. package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +14 -1
  8. package/dist/Autocomplete/useAutocomplete.d.ts +4 -3
  9. package/dist/Autocomplete/utils/interactionUtils.d.ts +14 -0
  10. package/dist/Card-cjs.js +1 -1
  11. package/dist/Card-es.js +1 -1
  12. package/dist/Checkbox/Checkbox.rebuilt.d.ts +2 -2
  13. package/dist/Checkbox/Checkbox.types.d.ts +24 -18
  14. package/dist/Checkbox/index.cjs +9 -2
  15. package/dist/Checkbox/index.mjs +9 -2
  16. package/dist/Chip/Chip.d.ts +1 -2
  17. package/dist/Chip/hooks/useChildComponent.d.ts +4 -3
  18. package/dist/Chip/index.cjs +1 -1
  19. package/dist/Chip-cjs.js +5 -4
  20. package/dist/Chip-es.js +5 -4
  21. package/dist/ChipDismissible-cjs.js +4 -4
  22. package/dist/ChipDismissible-es.js +5 -5
  23. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
  24. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
  25. package/dist/Chips/InternalChipDismissible/hooks/useInView.d.ts +1 -1
  26. package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissibleInput.d.ts +1 -1
  27. package/dist/Chips/InternalChipDismissible/hooks/useScrollToActive.d.ts +1 -1
  28. package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
  29. package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
  30. package/dist/Chips/index.cjs +2 -2
  31. package/dist/Chips/index.mjs +2 -2
  32. package/dist/Combobox/Combobox.d.ts +2 -1
  33. package/dist/Combobox/Combobox.types.d.ts +2 -2
  34. package/dist/Combobox/ComboboxProvider.d.ts +3 -3
  35. package/dist/Combobox/components/ComboboxActivator/ComboboxActivator.d.ts +1 -1
  36. package/dist/Combobox/components/ComboboxContent/ComboboxContent.d.ts +2 -1
  37. package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/ComboboxContentHeader.d.ts +2 -1
  38. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/ComboboxContentList.d.ts +2 -1
  39. package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/ComboboxContentSearch.d.ts +2 -1
  40. package/dist/Combobox/hooks/useCombobox.d.ts +1 -1
  41. package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +2 -2
  42. package/dist/Combobox/hooks/useComboboxContent.d.ts +2 -1
  43. package/dist/Combobox/hooks/useMakeComboboxHandlers.d.ts +1 -1
  44. package/dist/ComboboxActivator-cjs.js +2 -2
  45. package/dist/ComboboxActivator-es.js +3 -3
  46. package/dist/ComboboxTrigger-cjs.js +1 -1
  47. package/dist/ComboboxTrigger-es.js +2 -2
  48. package/dist/DataList/DataList.types.d.ts +2 -2
  49. package/dist/DataList/DataList.utils.d.ts +2 -2
  50. package/dist/DataList/components/DataListHeader/index.cjs +1 -0
  51. package/dist/DataList/components/DataListHeader/index.mjs +1 -0
  52. package/dist/DataList/components/DataListHeaderTile/components/DataListSortingOptions.d.ts +2 -2
  53. package/dist/DataList/components/DataListItem/DataListItemInternal.d.ts +2 -2
  54. package/dist/DataList/components/DataListItem/index.cjs +1 -0
  55. package/dist/DataList/components/DataListItem/index.mjs +1 -0
  56. package/dist/DataList/components/DataListItems/index.cjs +1 -0
  57. package/dist/DataList/components/DataListItems/index.mjs +1 -0
  58. package/dist/DataList/components/DataListLayout/index.cjs +1 -0
  59. package/dist/DataList/components/DataListLayout/index.mjs +1 -0
  60. package/dist/DataList/components/DataListSearch/index.cjs +2 -12
  61. package/dist/DataList/components/DataListSearch/index.mjs +2 -12
  62. package/dist/DataList/hooks/useGetItemActions.d.ts +1 -1
  63. package/dist/DataList/index.cjs +1 -8
  64. package/dist/DataList/index.mjs +1 -8
  65. package/dist/DataListActions-cjs.js +4 -2
  66. package/dist/DataListActions-es.js +4 -2
  67. package/dist/DataListItem-cjs.js +8 -7
  68. package/dist/DataListItem-es.js +9 -8
  69. package/dist/DataListSort-cjs.js +1 -1
  70. package/dist/DataListSort-es.js +2 -2
  71. package/dist/DataTable/SortIcon.d.ts +2 -1
  72. package/dist/DataTable/components/DataTableSortableHeader.d.ts +1 -1
  73. package/dist/DataTable/index.cjs +3 -2
  74. package/dist/DataTable/index.mjs +3 -2
  75. package/dist/DatePicker/DatePicker.d.ts +5 -1
  76. package/dist/DatePicker/index.cjs +2 -2
  77. package/dist/DatePicker/index.mjs +2 -2
  78. package/dist/DatePicker/useFocusOnSelectedDate.d.ts +1 -2
  79. package/dist/DatePicker-cjs.js +4 -2
  80. package/dist/DatePicker-es.js +5 -3
  81. package/dist/FormField/FormFieldAffix.d.ts +2 -2
  82. package/dist/FormField/FormFieldTypes.d.ts +3 -5
  83. package/dist/FormField/FormFieldWrapper.d.ts +5 -1
  84. package/dist/FormField/hooks/useFormFieldFocus.d.ts +1 -1
  85. package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +9 -4
  86. package/dist/FormField-cjs.js +35 -31
  87. package/dist/FormField-es.js +35 -31
  88. package/dist/InputDate/InputDate.types.d.ts +12 -7
  89. package/dist/InputDate/index.cjs +35 -12
  90. package/dist/InputDate/index.mjs +35 -12
  91. package/dist/InputDate/useInputDateActivatorActions.d.ts +4 -8
  92. package/dist/InputEmail/InputEmail.types.d.ts +10 -20
  93. package/dist/InputEmail/hooks/useInputEmailActions.d.ts +10 -4
  94. package/dist/InputEmail/index.cjs +43 -60
  95. package/dist/InputEmail/index.mjs +44 -61
  96. package/dist/InputFile-cjs.js +5 -2
  97. package/dist/InputFile-es.js +5 -2
  98. package/dist/InputGroup-cjs.js +5 -2
  99. package/dist/InputGroup-es.js +5 -2
  100. package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +7 -15
  101. package/dist/InputNumber/index.cjs +7 -5
  102. package/dist/InputNumber/index.mjs +7 -5
  103. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +12 -28
  104. package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +9 -4
  105. package/dist/InputPhoneNumber/index.cjs +37 -36
  106. package/dist/InputPhoneNumber/index.mjs +38 -37
  107. package/dist/InputText/InputText.d.ts +2 -2
  108. package/dist/InputText/InputText.types.d.ts +30 -25
  109. package/dist/InputText/index.cjs +54 -62
  110. package/dist/InputText/index.mjs +55 -63
  111. package/dist/InputText/useInputTextActions.d.ts +11 -5
  112. package/dist/InputText/useTextAreaResize.d.ts +2 -2
  113. package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
  114. package/dist/InputTime/InputTime.types.d.ts +13 -4
  115. package/dist/InputTime/hooks/useInputTimeActions.d.ts +21 -0
  116. package/dist/InputTime/index.cjs +90 -30
  117. package/dist/InputTime/index.mjs +93 -33
  118. package/dist/InternalChipDismissible-cjs.js +3 -3
  119. package/dist/InternalChipDismissible-es.js +4 -4
  120. package/dist/List/index.cjs +2 -2
  121. package/dist/List/index.mjs +2 -2
  122. package/dist/Menu/Menu.d.ts +2 -4
  123. package/dist/Menu/Menu.types.d.ts +21 -5
  124. package/dist/Menu-cjs.js +9 -9
  125. package/dist/Menu-es.js +9 -9
  126. package/dist/Modal/Modal.types.d.ts +3 -3
  127. package/dist/Modal/ModalContext.rebuilt.d.ts +2 -2
  128. package/dist/MultiSelect/DropDownMenu.d.ts +1 -1
  129. package/dist/MultiSelect/index.cjs +1 -0
  130. package/dist/MultiSelect/index.mjs +1 -0
  131. package/dist/MultiSelect-cjs.js +13 -7
  132. package/dist/MultiSelect-es.js +13 -7
  133. package/dist/RadioGroup/RadioGroup.d.ts +2 -1
  134. package/dist/RadioGroup/RadioOption.d.ts +1 -1
  135. package/dist/RecurringSelect/index.cjs +3 -2
  136. package/dist/RecurringSelect/index.mjs +3 -2
  137. package/dist/Select/Select.types.d.ts +7 -3
  138. package/dist/Select/hooks/useSelectActions.d.ts +5 -5
  139. package/dist/Select/index.cjs +27 -42
  140. package/dist/Select/index.mjs +29 -44
  141. package/dist/StatusLabel/StatusLabel.d.ts +2 -1
  142. package/dist/Tabs/hooks/useTabsOverflow.d.ts +2 -2
  143. package/dist/Tabs-cjs.js +4 -2
  144. package/dist/Tabs-es.js +5 -3
  145. package/dist/Tooltip/useTooltipPositioning.d.ts +1 -1
  146. package/dist/_baseEach-cjs.js +12 -12
  147. package/dist/_baseEach-es.js +1 -1
  148. package/dist/_baseFlatten-cjs.js +2 -2
  149. package/dist/_baseFlatten-es.js +1 -1
  150. package/dist/{_baseGet-cjs.js → _getAllKeys-cjs.js} +181 -181
  151. package/dist/{_baseGet-es.js → _getAllKeys-es.js} +182 -182
  152. package/dist/debounce-es.js +1 -1
  153. package/dist/filterDataAttributes-cjs.js +26 -0
  154. package/dist/filterDataAttributes-es.js +24 -0
  155. package/dist/floating-ui.react-cjs.js +115 -0
  156. package/dist/floating-ui.react-es.js +115 -1
  157. package/dist/helpers-cjs.js +1 -1
  158. package/dist/helpers-es.js +1 -1
  159. package/dist/index.cjs +4 -3
  160. package/dist/index.mjs +3 -2
  161. package/dist/omit-cjs.js +14 -14
  162. package/dist/omit-es.js +1 -1
  163. package/dist/sharedHelpers/filterDataAttributes.d.ts +17 -0
  164. package/dist/sharedHelpers/types.d.ts +231 -0
  165. package/dist/showToast-cjs.js +2 -2
  166. package/dist/showToast-es.js +2 -2
  167. package/dist/styles.css +32 -23
  168. package/dist/useChildComponent-cjs.js +1 -1
  169. package/dist/useChildComponent-es.js +1 -1
  170. package/dist/useScrollToActive-cjs.js +3 -3
  171. package/dist/useScrollToActive-es.js +2 -2
  172. package/dist/utils/mergeRefs.d.ts +2 -2
  173. package/package.json +2 -2
  174. package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +0 -32
  175. package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +0 -71
  176. package/dist/InputText/useInputTextFormField.d.ts +0 -352
  177. package/dist/Select/hooks/useSelectFormField.d.ts +0 -34
@@ -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';
@@ -10,7 +10,8 @@ import { T as Typography } from '../Typography-es.js';
10
10
  import { I as Icon } from '../Icon-es.js';
11
11
  import { InputText } from '../InputText/index.mjs';
12
12
  import { G as Glimmer } from '../Glimmer-es.js';
13
- import { m as mergeRefs } from '../FormField-es.js';
13
+ import { n as mergeRefs } from '../FormField-es.js';
14
+ import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
14
15
  import { _ as __rest, a as __awaiter } from '../tslib.es6-es.js';
15
16
  import 'react/jsx-runtime';
16
17
  import 'react-dom';
@@ -18,18 +19,6 @@ import 'react-hook-form';
18
19
  import 'framer-motion';
19
20
  import '../Button-es.js';
20
21
  import 'react-router-dom';
21
- import '../omit-es.js';
22
- import '../_commonjsHelpers-es.js';
23
- import '../_baseGet-es.js';
24
- import '../isTypedArray-es.js';
25
- import '../isObjectLike-es.js';
26
- import '../identity-es.js';
27
- import '../_getTag-es.js';
28
- import '../isSymbol-es.js';
29
- import '../keysIn-es.js';
30
- import '../_baseAssignValue-es.js';
31
- import '../_baseFlatten-es.js';
32
- import '../_setToString-es.js';
33
22
  import '../useFormFieldFocus-es.js';
34
23
  import '../InputValidation-es.js';
35
24
  import '../Spinner-es.js';
@@ -138,7 +127,7 @@ function invokeActiveItemOnEnter(event, activeIndex, renderable, onSelect, onAct
138
127
 
139
128
  const MENU_OFFSET = tokens["space-small"];
140
129
  const AUTOCOMPLETE_MAX_HEIGHT$1 = 300;
141
- function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, }) {
130
+ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose, onMenuClose, selectedIndex, readOnly = false, }) {
142
131
  const [open, setOpen] = useState(false);
143
132
  const [activeIndex, setActiveIndex] = useState(null);
144
133
  const listRef = useRef([]);
@@ -170,6 +159,10 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
170
159
  }),
171
160
  ],
172
161
  });
162
+ const click = useClick(context, {
163
+ enabled: !readOnly,
164
+ toggle: false, // Only open, never close on click
165
+ });
173
166
  const listNav = useListNavigation(context, {
174
167
  listRef,
175
168
  activeIndex,
@@ -191,7 +184,7 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
191
184
  escapeKey: true,
192
185
  outsidePressEvent: "click",
193
186
  });
194
- const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([listNav, dismiss]);
187
+ const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([click, listNav, dismiss]);
195
188
  useEffect(() => {
196
189
  listRef.current.length = navigableCount;
197
190
  setActiveIndex(prev => {
@@ -218,11 +211,34 @@ function useAutocompleteListNav({ navigableCount, shouldResetActiveIndexOnClose,
218
211
  };
219
212
  }
220
213
 
214
+ /**
215
+ * Handler that prevents default pointer behavior.
216
+ * Used to prevent blur/focus issues when clicking on non-interactive menu elements.
217
+ */
218
+ function preventDefaultPointerDown(e) {
219
+ e.preventDefault();
220
+ }
221
+ /**
222
+ * Creates a handler for pointer down events on interactive menu items (options/actions).
223
+ * Prevents default to avoid blur and sets flag for focus management.
224
+ *
225
+ * @param isHandlingMenuInteractionRef - Ref to track if a menu interaction is in progress
226
+ * @returns A pointer down event handler
227
+ */
228
+ function createInteractionPointerDownHandler(isHandlingMenuInteractionRef) {
229
+ return (e) => {
230
+ e.preventDefault();
231
+ // Set flag to prevent blur/focus handlers from interfering
232
+ isHandlingMenuInteractionRef.current = true;
233
+ };
234
+ }
235
+
221
236
  // Keeping this hook cohesive improves readability by centralizing related
222
237
  // interactions and state transitions.
223
238
  // eslint-disable-next-line max-statements
224
239
  function useAutocomplete(props) {
225
240
  const { menu, emptyActions, getOptionLabel: getOptionLabelProp, isOptionEqualToValue, inputValue, onInputChange, value, onChange, multiple, openOnFocus = true, readOnly = false, debounce: debounceMs = 300, } = props;
241
+ const isHandlingMenuInteractionRef = useRef(false);
226
242
  // TODO: Clean up the types in these refs by enhancing the type system in useCallbackRef
227
243
  const getOptionLabelPropRef = useCallbackRef((opt) => getOptionLabelProp === null || getOptionLabelProp === void 0 ? void 0 : getOptionLabelProp(opt));
228
244
  const getOptionLabel = useCallback((opt) => {
@@ -265,7 +281,8 @@ function useAutocomplete(props) {
265
281
  const [debouncedInputValue, setDebouncedInputValue] = useState(inputValue);
266
282
  const debouncedSetter = useDebounce(setDebouncedInputValue, debounceMs);
267
283
  useEffect(() => {
268
- if (debounceMs === 0) {
284
+ // Skip debounce when clearing input for immediate feedback, preventing flickering of last selected item
285
+ if (debounceMs === 0 || inputValue === "") {
269
286
  setDebouncedInputValue(inputValue);
270
287
  return;
271
288
  }
@@ -355,6 +372,7 @@ function useAutocomplete(props) {
355
372
  navigableCount: totalNavigableCount,
356
373
  shouldResetActiveIndexOnClose: () => !hasSelection,
357
374
  selectedIndex,
375
+ readOnly,
358
376
  onMenuClose: () => {
359
377
  if (props.allowFreeForm !== true) {
360
378
  const hasText = inputValue.trim().length > 0;
@@ -366,7 +384,6 @@ function useAutocomplete(props) {
366
384
  }
367
385
  },
368
386
  });
369
- const [inputFocused, setInputFocused] = useState(false);
370
387
  // Handles activeIndex reset and, in single-select mode only, clearing selection when input is empty
371
388
  useEffect(() => {
372
389
  const hasText = inputValue.trim().length > 0;
@@ -462,13 +479,24 @@ function useAutocomplete(props) {
462
479
  selectOption(option);
463
480
  // Might not always want to close on selection. Multi for example.
464
481
  setOpen(false);
482
+ if (refs.domReference.current instanceof HTMLElement) {
483
+ refs.domReference.current.focus();
484
+ }
465
485
  }, [selectOption, setOpen]);
466
486
  const onAction = useCallback((action) => {
467
487
  action.run();
468
488
  setActiveIndex(null);
469
489
  if (action.closeOnRun !== false)
470
490
  setOpen(false);
491
+ if (refs.domReference.current instanceof HTMLElement) {
492
+ refs.domReference.current.focus();
493
+ }
471
494
  }, [setOpen, setActiveIndex]);
495
+ /**
496
+ * Handler for mousedown on interactive menu items (options/actions)
497
+ * Prevents default to avoid blur and sets flag for focus management
498
+ */
499
+ const onInteractionPointerDown = useMemo(() => createInteractionPointerDownHandler(isHandlingMenuInteractionRef), []);
472
500
  function commitFromInputText(inputText) {
473
501
  var _a;
474
502
  if (inputText.length === 0)
@@ -508,18 +536,24 @@ function useAutocomplete(props) {
508
536
  multiple,
509
537
  value,
510
538
  ]);
511
- const onInputFocus = useCallback(() => {
539
+ const onInputFocus = useCallback((event) => {
512
540
  var _a;
513
- setInputFocused(true);
514
- if (!readOnly && openOnFocus)
541
+ if (!readOnly && openOnFocus && !isHandlingMenuInteractionRef.current) {
515
542
  setOpen(true);
516
- (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props);
543
+ }
544
+ // Only call user's onFocus for genuine focus events, not programmatic restorations
545
+ if (!isHandlingMenuInteractionRef.current) {
546
+ (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
547
+ }
548
+ isHandlingMenuInteractionRef.current = false;
517
549
  }, [props.onFocus, readOnly, openOnFocus, setOpen]);
518
- const onInputBlur = useCallback(() => {
550
+ const onInputBlur = useCallback((event) => {
519
551
  var _a, _b;
520
- setInputFocused(false);
552
+ if (isHandlingMenuInteractionRef.current) {
553
+ return;
554
+ }
521
555
  if (readOnly) {
522
- (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
556
+ (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
523
557
  return;
524
558
  }
525
559
  if (props.allowFreeForm === true) {
@@ -531,7 +565,7 @@ function useAutocomplete(props) {
531
565
  tryRestoreInputToSelectedLabel();
532
566
  }
533
567
  lastInputWasUser.current = false;
534
- (_b = props.onBlur) === null || _b === void 0 ? void 0 : _b.call(props);
568
+ (_b = props.onBlur) === null || _b === void 0 ? void 0 : _b.call(props, event);
535
569
  }, [
536
570
  readOnly,
537
571
  props.allowFreeForm,
@@ -623,11 +657,11 @@ function useAutocomplete(props) {
623
657
  setActiveIndex(null);
624
658
  }
625
659
  // Important: update open state before propagating the change so that downstream effects
626
- // dont see an intermediate state where inputValue changed but open was stale
660
+ // don't see an intermediate state where inputValue changed but open was stale
627
661
  if (!readOnly) {
628
662
  const hasText = val.trim().length > 0;
629
663
  const mustSelectFromOptions = hasText && !props.allowFreeForm;
630
- const keepOpenOnEmpty = openOnFocus && inputFocused;
664
+ const keepOpenOnEmpty = openOnFocus;
631
665
  setOpen(mustSelectFromOptions || keepOpenOnEmpty);
632
666
  }
633
667
  onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(val);
@@ -638,7 +672,6 @@ function useAutocomplete(props) {
638
672
  readOnly,
639
673
  props.allowFreeForm,
640
674
  openOnFocus,
641
- inputFocused,
642
675
  setOpen,
643
676
  ]);
644
677
  return {
@@ -667,6 +700,7 @@ function useAutocomplete(props) {
667
700
  // actions
668
701
  onSelection,
669
702
  onAction,
703
+ onInteractionPointerDown,
670
704
  // input handlers
671
705
  onInputChangeFromUser,
672
706
  onInputBlur,
@@ -677,7 +711,7 @@ function useAutocomplete(props) {
677
711
  };
678
712
  }
679
713
 
680
- function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, isOptionSelected, slotOverrides, }) {
714
+ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef, listboxId, customRenderOption, customRenderSection, customRenderAction, getOptionLabel, onSelect, onAction, onInteractionPointerDown, isOptionSelected, slotOverrides, }) {
681
715
  let navigableIndex = -1;
682
716
  function renderItemNode(item) {
683
717
  var _a, _b, _c, _d, _e, _f;
@@ -701,6 +735,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
701
735
  customRenderOption,
702
736
  getOptionLabel,
703
737
  onSelect,
738
+ onInteractionPointerDown,
704
739
  indexOffset,
705
740
  optionClassName: (_c = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _c === void 0 ? void 0 : _c.className,
706
741
  optionStyle: (_d = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.option) === null || _d === void 0 ? void 0 : _d.style,
@@ -717,6 +752,7 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
717
752
  listboxId,
718
753
  customRenderAction,
719
754
  onAction,
755
+ onInteractionPointerDown,
720
756
  indexOffset,
721
757
  actionClassName: (_e = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _e === void 0 ? void 0 : _e.className,
722
758
  actionStyle: (_f = slotOverrides === null || slotOverrides === void 0 ? void 0 : slotOverrides.action) === null || _f === void 0 ? void 0 : _f.style,
@@ -730,12 +766,12 @@ function MenuList({ items, activeIndex, indexOffset = 0, getItemProps, listRef,
730
766
  function handleSectionRendering({ customRenderSection, section, sectionClassName, sectionStyle, }) {
731
767
  var _a;
732
768
  const headerContent = customRenderSection ? (customRenderSection(section)) : (React__default.createElement(DefaultSectionContent, { section: section }));
733
- 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));
769
+ 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, onPointerDown: preventDefaultPointerDown }, headerContent));
734
770
  }
735
771
  function DefaultSectionContent({ section, }) {
736
772
  return React__default.createElement(Heading, { level: 5 }, section.label);
737
773
  }
738
- function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, indexOffset = 0, optionClassName, optionStyle, }) {
774
+ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemProps, listRef, listboxId, isOptionSelected, customRenderOption, getOptionLabel, onSelect, onInteractionPointerDown, indexOffset = 0, optionClassName, optionStyle, }) {
739
775
  var _a;
740
776
  const nextNavigableIndex = navigableIndex + 1;
741
777
  const isActive = activeIndex === nextNavigableIndex;
@@ -749,6 +785,7 @@ function handleOptionRendering({ option, activeIndex, navigableIndex, getItemPro
749
785
  listRef.current[idx] = node;
750
786
  },
751
787
  onClick: () => onSelect(option),
788
+ onPointerDown: onInteractionPointerDown,
752
789
  className: classnames(styles$1.option, isActive && styles$1.optionActive, optionClassName),
753
790
  style: optionStyle,
754
791
  }), { role: "option", tabIndex: -1, "aria-selected": isSelected ? true : false, id: `${listboxId}-item-${nextNavigableIndex + indexOffset}`, "data-index": nextNavigableIndex + indexOffset, "data-active": isActive ? true : undefined }), optionContent)),
@@ -760,7 +797,7 @@ function DefaultOptionContent({ isSelected, text, }) {
760
797
  React__default.createElement("div", { className: styles$1.icon }, isSelected && React__default.createElement(Icon, { name: "checkmark", size: "small" })),
761
798
  React__default.createElement(Text, null, text)));
762
799
  }
763
- function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, indexOffset = 0, actionClassName, actionStyle, origin, }) {
800
+ function handleActionRendering({ action, activeIndex, navigableIndex, getItemProps, listRef, listboxId, customRenderAction, onAction, onInteractionPointerDown, indexOffset = 0, actionClassName, actionStyle, origin, }) {
764
801
  var _a;
765
802
  const nextNavigableIndex = navigableIndex + 1;
766
803
  const isActive = activeIndex === nextNavigableIndex;
@@ -778,6 +815,7 @@ function handleActionRendering({ action, activeIndex, navigableIndex, getItemPro
778
815
  closeOnRun: action.shouldClose,
779
816
  });
780
817
  },
818
+ onPointerDown: onInteractionPointerDown,
781
819
  className: classnames(styles$1.action, isActive && styles$1.actionActive, actionClassName),
782
820
  style: actionStyle,
783
821
  });
@@ -795,7 +833,7 @@ function DefaultActionContent({ textContent, }) {
795
833
  } }, textContent));
796
834
  }
797
835
 
798
- function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, }) {
836
+ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemProps, listRef, customRenderHeader, customRenderFooter, className, style, onAction, onInteractionPointerDown, }) {
799
837
  if (!items || items.length === 0)
800
838
  return null;
801
839
  let navigableIndex = -1;
@@ -810,13 +848,14 @@ function PersistentRegion({ items, position, activeIndex, indexOffset, getItemPr
810
848
  customRenderFooter,
811
849
  listRef,
812
850
  onAction,
851
+ onInteractionPointerDown,
813
852
  navigableIndex,
814
853
  });
815
854
  navigableIndex = result.nextNavigableIndex;
816
855
  return result.node;
817
856
  })));
818
857
  }
819
- function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
858
+ function handlePersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionPointerDown, navigableIndex, }) {
820
859
  const interactive = Boolean(persistent.onClick);
821
860
  if (!interactive) {
822
861
  const node = handleTextPersistentRendering({
@@ -837,6 +876,7 @@ function handlePersistentRendering({ persistent, position, activeIndex, indexOff
837
876
  customRenderFooter,
838
877
  listRef,
839
878
  onAction,
879
+ onInteractionPointerDown,
840
880
  navigableIndex,
841
881
  });
842
882
  }
@@ -852,9 +892,9 @@ function handleTextPersistentRendering({ persistent, position, customRenderHeade
852
892
  else {
853
893
  content = React__default.createElement(DefaultTextPersistentContent, { persistent: persistent });
854
894
  }
855
- 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));
895
+ 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, onPointerDown: preventDefaultPointerDown }, content));
856
896
  }
857
- function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, navigableIndex, }) {
897
+ function handleActionPersistentRendering({ persistent, position, activeIndex, indexOffset, getItemProps, customRenderHeader, customRenderFooter, listRef, onAction, onInteractionPointerDown, navigableIndex, }) {
858
898
  var _a;
859
899
  const nextNavigableIndex = navigableIndex + 1;
860
900
  const isActive = activeIndex === indexOffset + nextNavigableIndex;
@@ -881,13 +921,16 @@ function handleActionPersistentRendering({ persistent, position, activeIndex, in
881
921
  if (persistNode)
882
922
  listRef.current[idx] = persistNode;
883
923
  },
884
- onClick: () => onAction({
885
- run: () => {
886
- var _a;
887
- (_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
888
- },
889
- closeOnRun: persistent.shouldClose,
890
- }),
924
+ onClick: () => {
925
+ onAction({
926
+ run: () => {
927
+ var _a;
928
+ (_a = persistent.onClick) === null || _a === void 0 ? void 0 : _a.call(persistent);
929
+ },
930
+ closeOnRun: persistent.shouldClose,
931
+ });
932
+ },
933
+ onPointerDown: onInteractionPointerDown,
891
934
  className: classnames(styles$1.action, isActive && styles$1.actionActive),
892
935
  }), { role: "button", tabIndex: -1 }), content)),
893
936
  nextNavigableIndex,
@@ -902,7 +945,7 @@ const AutocompleteRebuilt = forwardRef(AutocompleteRebuiltInternal);
902
945
  function AutocompleteRebuiltInternal(props, forwardedRef) {
903
946
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
904
947
  const { inputValue, placeholder, disabled, error, invalid, description, size: sizeProp, loading = false, } = props;
905
- 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);
948
+ 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);
906
949
  const listboxId = React__default.useId();
907
950
  // Provides mount/unmount-aware transition styles for the floating element
908
951
  const { isMounted, styles: transitionStyles } = useTransitionStyles(context, {
@@ -918,10 +961,11 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
918
961
  onFocus: onInputFocus,
919
962
  onBlur: onInputBlur,
920
963
  });
921
- const inputProps = Object.assign(Object.assign(Object.assign(Object.assign({ version: 2, value: inputValue, onChange: props.readOnly ? undefined : onInputChangeFromUser }, (props.readOnly ? { onFocus: onInputFocus, onBlur: onInputBlur } : {})), { placeholder,
922
- disabled, readOnly: props.readOnly, error: error !== null && error !== void 0 ? error : undefined, name: props.name, invalid, autoComplete: "off", description, size: sizeProp ? sizeProp : undefined, prefix: props.prefix, suffix: props.suffix }), (props.readOnly ? {} : composedReferenceProps)), { role: "combobox", "aria-autocomplete": "list", "aria-expanded": open ? true : false, "aria-controls": listboxId, "aria-activedescendant": open && activeIndex != null
964
+ const dataAttrs = filterDataAttributes(props);
965
+ const inputProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ version: 2, value: inputValue, onChange: props.readOnly ? undefined : onInputChangeFromUser }, (props.readOnly ? { onFocus: onInputFocus, onBlur: onInputBlur } : {})), { placeholder,
966
+ disabled, readOnly: props.readOnly, error: error !== null && error !== void 0 ? error : undefined, name: props.name, invalid, autoComplete: "off", autoFocus: props.autoFocus, description, size: sizeProp ? sizeProp : undefined, prefix: props.prefix, suffix: props.suffix }), (props.readOnly ? {} : composedReferenceProps)), { role: "combobox", "aria-autocomplete": "list", "aria-expanded": open ? true : false, "aria-controls": listboxId, "aria-activedescendant": open && activeIndex != null
923
967
  ? `${listboxId}-item-${activeIndex}`
924
- : undefined });
968
+ : undefined }), dataAttrs);
925
969
  const referenceInputRef = (node) => {
926
970
  setReferenceElement(node);
927
971
  // Workaround to get the width of the visual InputText element, which is not the same as
@@ -961,10 +1005,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
961
1005
  ? { width: menuWidth, maxWidth: menuWidth }
962
1006
  : {})),
963
1007
  })),
964
- 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 }),
1008
+ 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, 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 }),
965
1009
  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,
966
1010
  showEmptyStateMessage && (React__default.createElement(EmptyStateMessage, { emptyState: props.emptyStateMessage })),
967
- 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: {
1011
+ 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, onInteractionPointerDown: onInteractionPointerDown, isOptionSelected: isOptionSelected, slotOverrides: {
968
1012
  option: {
969
1013
  className: (_f = props.UNSAFE_className) === null || _f === void 0 ? void 0 : _f.option,
970
1014
  style: (_g = props.UNSAFE_styles) === null || _g === void 0 ? void 0 : _g.option,
@@ -978,10 +1022,10 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
978
1022
  style: (_l = props.UNSAFE_styles) === null || _l === void 0 ? void 0 : _l.section,
979
1023
  },
980
1024
  } }))))),
981
- 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 })))))));
1025
+ 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, 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 })))))));
982
1026
  }
983
1027
  function LoadingContent() {
984
- return (React__default.createElement("div", { className: styles$1.loadingList },
1028
+ return (React__default.createElement("div", { className: styles$1.loadingList, onPointerDown: preventDefaultPointerDown },
985
1029
  React__default.createElement(Glimmer, { shape: "rectangle", size: "base" }),
986
1030
  React__default.createElement(Glimmer, { shape: "rectangle", size: "base" }),
987
1031
  React__default.createElement(Glimmer, { shape: "rectangle", size: "base" })));
@@ -989,7 +1033,7 @@ function LoadingContent() {
989
1033
  function EmptyStateMessage({ emptyState, }) {
990
1034
  const emptyStateDefault = "No options";
991
1035
  const emptyStateContent = emptyState !== null && emptyState !== void 0 ? emptyState : emptyStateDefault;
992
- return React__default.createElement("div", { className: styles$1.emptyStateMessage }, emptyStateContent);
1036
+ return (React__default.createElement("div", { className: styles$1.emptyStateMessage, onPointerDown: preventDefaultPointerDown }, emptyStateContent));
993
1037
  }
994
1038
 
995
1039
  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,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { type AutocompleteRebuiltProps, type MenuItem, type OptionLike } from "../Autocomplete.types";
3
- export declare function Wrapper<T extends OptionLike>({ initialValue, initialInputValue, onChange, onInputChange, onBlur, onFocus, menu, openOnFocus, filterOptions, emptyActions, customRenderOption, customRenderAction, customRenderSection, customRenderInput, customRenderHeader, customRenderFooter, loading, customRenderLoading, emptyStateMessage, ref, readOnly, UNSAFE_className, UNSAFE_styles, debounce, }: {
3
+ export declare function Wrapper<T extends OptionLike>({ initialValue, initialInputValue, onChange, onInputChange, onBlur, onFocus, menu, openOnFocus, filterOptions, emptyActions, customRenderOption, customRenderAction, customRenderSection, customRenderInput, customRenderHeader, customRenderFooter, loading, customRenderLoading, emptyStateMessage, ref, readOnly, UNSAFE_className, UNSAFE_styles, debounce, ...props }: {
4
4
  readonly initialValue?: T;
5
5
  readonly initialInputValue?: string;
6
6
  readonly onChange?: (v: T | undefined) => void;
@@ -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;
@@ -55,12 +55,13 @@ export declare function useAutocomplete<Value extends OptionLike, Multiple exten
55
55
  setOpen: (open: boolean) => void;
56
56
  activeIndex: number | null;
57
57
  setActiveIndex: (index: number | null) => void;
58
- listRef: React.MutableRefObject<(HTMLElement | null)[]>;
58
+ listRef: React.RefObject<(HTMLElement | null)[]>;
59
59
  onSelection: (option: Value) => void;
60
60
  onAction: (action: ActionConfig) => void;
61
+ onInteractionPointerDown: (e: React.PointerEvent) => void;
61
62
  onInputChangeFromUser: (val: string) => void;
62
- onInputBlur: () => void;
63
- onInputFocus: () => void;
63
+ onInputBlur: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
64
+ onInputFocus: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
64
65
  onInputKeyDown: (event: React.KeyboardEvent) => void;
65
66
  setReferenceElement: (el: HTMLElement | null) => void;
66
67
  };
@@ -0,0 +1,14 @@
1
+ import type React from "react";
2
+ /**
3
+ * Handler that prevents default pointer behavior.
4
+ * Used to prevent blur/focus issues when clicking on non-interactive menu elements.
5
+ */
6
+ export declare function preventDefaultPointerDown(e: React.PointerEvent): void;
7
+ /**
8
+ * Creates a handler for pointer down events on interactive menu items (options/actions).
9
+ * Prevents default to avoid blur and sets flag for focus management.
10
+ *
11
+ * @param isHandlingMenuInteractionRef - Ref to track if a menu interaction is in progress
12
+ * @returns A pointer down event handler
13
+ */
14
+ export declare function createInteractionPointerDownHandler(isHandlingMenuInteractionRef: React.RefObject<boolean>): (e: React.PointerEvent) => void;
package/dist/Card-cjs.js CHANGED
@@ -19,7 +19,7 @@ const SPACEBAR_KEY = " ";
19
19
  * Please use `<Card onClick={onClick} />` component instead.
20
20
  */
21
21
  function CardClickable({ className, onClick, children, UNSAFE_style = {}, }) {
22
- const cardRef = React.useRef();
22
+ const cardRef = React.useRef(null);
23
23
  return (React.createElement("div", { ref: cardRef, "data-testid": "clickable-card", className: className, style: UNSAFE_style, onClick: onClick, onKeyUp: handleKeyup, onKeyDown: handleKeyDown, role: "button", tabIndex: 0 }, children));
24
24
  function isCardFocused() {
25
25
  return document.activeElement === cardRef.current;
package/dist/Card-es.js CHANGED
@@ -17,7 +17,7 @@ const SPACEBAR_KEY = " ";
17
17
  * Please use `<Card onClick={onClick} />` component instead.
18
18
  */
19
19
  function CardClickable({ className, onClick, children, UNSAFE_style = {}, }) {
20
- const cardRef = useRef();
20
+ const cardRef = useRef(null);
21
21
  return (React__default.createElement("div", { ref: cardRef, "data-testid": "clickable-card", className: className, style: UNSAFE_style, onClick: onClick, onKeyUp: handleKeyup, onKeyDown: handleKeyDown, role: "button", tabIndex: 0 }, children));
22
22
  function isCardFocused() {
23
23
  return document.activeElement === cardRef.current;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
- export declare const CheckboxRebuilt: React.ForwardRefExoticComponent<Omit<import("./Checkbox.types").BaseCheckboxProps, "children" | "onChange" | "label" | "description"> & {
2
+ export declare const CheckboxRebuilt: React.ForwardRefExoticComponent<import("./Checkbox.types").CheckboxCoreProps & import("../sharedHelpers/types").AriaInputProps & import("../sharedHelpers/types").FocusEvents<HTMLInputElement> & import("../sharedHelpers/types").MouseEvents<HTMLInputElement> & Pick<import("../sharedHelpers/types").HTMLInputBaseProps, "id" | "name" | "disabled"> & Pick<import("../sharedHelpers/types").RebuiltInputCommonProps, "version"> & {
3
3
  label?: string | React.ReactElement;
4
4
  description?: React.ReactNode;
5
+ invalid?: boolean;
5
6
  onChange?(newValue: boolean, event: React.ChangeEvent<HTMLInputElement>): void;
6
- version: 2;
7
7
  } & React.RefAttributes<HTMLInputElement>>;
@@ -1,6 +1,10 @@
1
1
  import type { ReactElement, ReactNode } from "react";
2
2
  import type { XOR } from "ts-xor";
3
- export interface BaseCheckboxProps {
3
+ import type { AriaInputProps, FocusEvents, HTMLInputBaseProps, MouseEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
4
+ /**
5
+ * Shared checkbox-specific props used by both legacy and rebuilt versions
6
+ */
7
+ export interface CheckboxCoreProps {
4
8
  /**
5
9
  * Determines if the checkbox is checked or not.
6
10
  */
@@ -11,24 +15,29 @@ export interface BaseCheckboxProps {
11
15
  * state. If a state is controlling it, use the `checked` prop instead.
12
16
  */
13
17
  readonly defaultChecked?: boolean;
14
- /**
15
- * Disables the checkbox.
16
- */
17
- readonly disabled?: boolean;
18
18
  /**
19
19
  * When `true` the checkbox to appears in indeterminate.
20
20
  *
21
21
  * @default false
22
22
  */
23
23
  readonly indeterminate?: boolean;
24
- /**
25
- * Checkbox input name
26
- */
27
- readonly name?: string;
28
24
  /**
29
25
  * Value of the checkbox.
30
26
  */
31
27
  readonly value?: string;
28
+ }
29
+ /**
30
+ * Base props for legacy checkbox
31
+ */
32
+ export interface BaseCheckboxProps extends CheckboxCoreProps {
33
+ /**
34
+ * Disables the checkbox.
35
+ */
36
+ readonly disabled?: boolean;
37
+ /**
38
+ * Checkbox input name
39
+ */
40
+ readonly name?: string;
32
41
  /**
33
42
  * Further description of the label
34
43
  */
@@ -49,10 +58,6 @@ export interface BaseCheckboxProps {
49
58
  * Called when the checkbox loses focus
50
59
  */
51
60
  onBlur?(event: React.FocusEvent<HTMLInputElement>): void;
52
- /**
53
- * Whether the checkbox is invalid
54
- */
55
- invalid?: boolean;
56
61
  }
57
62
  interface CheckboxLabelProps extends BaseCheckboxProps {
58
63
  /**
@@ -66,7 +71,7 @@ interface CheckboxChildrenProps extends BaseCheckboxProps {
66
71
  */
67
72
  readonly children?: ReactElement;
68
73
  }
69
- export type CheckboxRebuiltProps = Omit<BaseCheckboxProps, "label" | "description" | "children" | "onChange"> & {
74
+ export type CheckboxRebuiltProps = CheckboxCoreProps & AriaInputProps & FocusEvents<HTMLInputElement> & MouseEvents<HTMLInputElement> & Pick<HTMLInputBaseProps, "id" | "name" | "disabled"> & Pick<RebuiltInputCommonProps, "version"> & {
70
75
  /**
71
76
  * Label that shows up beside the checkbox.
72
77
  * String will be rendered with the default markup.
@@ -79,15 +84,16 @@ export type CheckboxRebuiltProps = Omit<BaseCheckboxProps, "label" | "descriptio
79
84
  * ReactElement will be rendered with provided positioning.
80
85
  */
81
86
  description?: ReactNode;
87
+ /**
88
+ * Whether the checkbox is invalid
89
+ */
90
+ invalid?: boolean;
82
91
  /**
83
92
  * Called when the checkbox value changes.
84
93
  * Includes the change event as a second argument.
94
+ * This is the recommended event handler to access the new value.
85
95
  */
86
96
  onChange?(newValue: boolean, event: React.ChangeEvent<HTMLInputElement>): void;
87
- /**
88
- * Version 2 is highly experimental, avoid using it unless you have talked with Atlantis first.
89
- */
90
- version: 2;
91
97
  };
92
98
  export type CheckboxLegacyProps = XOR<CheckboxLabelProps, CheckboxChildrenProps> & {
93
99
  version?: 1;
@@ -6,6 +6,7 @@ var classnames = require('classnames');
6
6
  var reactHookForm = require('react-hook-form');
7
7
  var Icon = require('../Icon-cjs.js');
8
8
  var Text = require('../Text-cjs.js');
9
+ var filterDataAttributes = require('../filterDataAttributes-cjs.js');
9
10
  require('@jobber/design');
10
11
  require('../Typography-cjs.js');
11
12
 
@@ -54,12 +55,16 @@ function CheckboxLegacy({ checked, defaultChecked, disabled, label, name, value,
54
55
  } }));
55
56
  }
56
57
 
57
- const CheckboxRebuilt = React.forwardRef(function CheckboxRebuiltInternal({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, invalid, }, ref) {
58
+ const CheckboxRebuilt = React.forwardRef(function CheckboxRebuiltInternal(props, ref) {
59
+ const { checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, id, onBlur, onChange, onFocus, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, invalid, } = props;
58
60
  const descriptionIdentifier = React.useId();
61
+ const descriptionVisible = Boolean(description);
59
62
  const wrapperClassName = classnames(styles.wrapper, disabled && styles.disabled, invalid && styles.invalid);
63
+ const isInvalid = Boolean(invalid);
60
64
  const inputClassName = classnames(styles.input, {
61
65
  [styles.indeterminate]: indeterminate,
62
66
  });
67
+ const dataAttrs = filterDataAttributes.filterDataAttributes(props);
63
68
  const iconName = indeterminate ? "minus2" : "checkmark";
64
69
  const labelContent = typeof label === "string" ? React.createElement(Text.Text, null, label) : label;
65
70
  const descriptionContent = typeof description === "string" ? (React.createElement(Text.Text, { size: "small", variation: "subdued" }, description)) : (description);
@@ -70,7 +75,9 @@ const CheckboxRebuilt = React.forwardRef(function CheckboxRebuiltInternal({ chec
70
75
  return (React.createElement("div", { className: styles.checkBoxParent },
71
76
  React.createElement("label", { className: wrapperClassName },
72
77
  React.createElement("span", { className: styles.checkHolder },
73
- React.createElement("input", { ref: ref, type: "checkbox", id: id, className: inputClassName, name: name, "aria-describedby": description ? descriptionIdentifier : undefined, checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur }),
78
+ React.createElement("input", Object.assign({ ref: ref, type: "checkbox", id: id, className: inputClassName, name: name, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
79
+ ? descriptionIdentifier
80
+ : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], checked: checked, value: value, defaultChecked: defaultChecked, disabled: disabled, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, onClick: onClick, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onPointerDown: onPointerDown, onPointerUp: onPointerUp }, dataAttrs)),
74
81
  React.createElement("span", { className: styles.checkBox },
75
82
  React.createElement(Icon.Icon, { name: iconName, color: "surface" }))),
76
83
  labelContent && React.createElement("span", { className: styles.label }, labelContent)),