@deque/cauldron-react 7.1.0-canary.3dc1ee55 → 7.1.0-canary.4271d962

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.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { type ActionListSelectionType, type onActionCallbackFunction } from './ActionListContext';
3
- interface ActionListProps extends React.HTMLAttributes<HTMLUListElement> {
3
+ interface ActionListProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'defaultValue' | 'onSelect'> {
4
4
  children: React.ReactNode;
5
5
  /** Limits the amount of selections that can be made within an action list */
6
6
  selectionType?: ActionListSelectionType | null;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { ListboxOption } from './ListboxContext';
3
3
  import type { ListboxValue } from './ListboxOption';
4
- import type { PolymorphicProps, PolymorphicComponent } from '../../utils/polymorphicComponent';
4
+ import type { PolymorphicProps, PolymorphicComponentProps } from '../../utils/polymorphicComponent';
5
5
  interface BaseListboxProps extends PolymorphicProps<Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'defaultValue'>> {
6
6
  navigation?: 'cycle' | 'bound';
7
7
  focusStrategy?: 'lastSelected' | 'first' | 'last';
@@ -30,5 +30,10 @@ interface MultiSelectListboxProps extends BaseListboxProps {
30
30
  value: ListboxValue[];
31
31
  }) => void;
32
32
  }
33
- declare const Listbox: PolymorphicComponent<SingleSelectListboxProps | MultiSelectListboxProps>;
33
+ type ListboxComponent = Omit<React.ForwardRefExoticComponent<SingleSelectListboxProps | MultiSelectListboxProps>, keyof CallableFunction> & {
34
+ <T extends React.ElementType = React.ElementType>(props: PolymorphicComponentProps<MultiSelectListboxProps, T>): React.ReactElement | null;
35
+ <T extends React.ElementType = React.ElementType>(props: PolymorphicComponentProps<SingleSelectListboxProps, T>): React.ReactElement | null;
36
+ <T extends React.ElementType = React.ElementType>(props: PolymorphicComponentProps<SingleSelectListboxProps | MultiSelectListboxProps, T>): React.ReactElement | null;
37
+ };
38
+ declare const Listbox: ListboxComponent;
34
39
  export default Listbox;
@@ -12,6 +12,7 @@ export default class TopBar extends React.Component<MenuBarProps, MenuBarState>
12
12
  thin: boolean;
13
13
  hasTrigger: boolean;
14
14
  };
15
+ private menuBarRef;
15
16
  constructor(props: MenuBarProps);
16
17
  componentDidMount(): void;
17
18
  componentWillUnmount(): void;
@@ -3,6 +3,9 @@ export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  type: 'confirmation' | 'caution' | 'error' | 'action-needed' | 'info';
4
4
  onDismiss?: () => void;
5
5
  dismissText?: string;
6
+ /**
7
+ * @deprecated Use the forwarded `ref` instead. Will be removed in the next major version.
8
+ */
6
9
  toastRef?: React.Ref<HTMLDivElement>;
7
10
  focus?: boolean;
8
11
  show?: boolean;
@@ -12,8 +15,5 @@ export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
12
15
  /**
13
16
  * The cauldron toast notification component
14
17
  */
15
- declare const Toast: {
16
- ({ type, children, onDismiss, dismissText, toastRef, focus, show, dismissible, className, ...otherProps }: ToastProps): React.JSX.Element;
17
- displayName: string;
18
- };
18
+ declare const Toast: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<HTMLDivElement>>;
19
19
  export default Toast;
package/lib/index.js CHANGED
@@ -672,6 +672,7 @@ var TopBar$1 = /** @class */ (function (_super) {
672
672
  tslib.__extends(TopBar, _super);
673
673
  function TopBar(props) {
674
674
  var _this = _super.call(this, props) || this;
675
+ _this.menuBarRef = React__default["default"].createRef();
675
676
  _this.onResize = function () {
676
677
  var wide = isWide();
677
678
  if (wide === _this.state.wide) {
@@ -720,10 +721,10 @@ var TopBar$1 = /** @class */ (function (_super) {
720
721
  };
721
722
  TopBar.prototype.onKeyDown = function (e) {
722
723
  var key = keyname__default["default"](e.which);
723
- // This is a temporary workaround until have an opportunity to refactor or replace menubar
724
- // see: https://github.com/dequelabs/cauldron/issues/1934
725
- // eslint-disable-next-line react/no-find-dom-node
726
- var menuBarElement = reactDom.findDOMNode(this);
724
+ var menuBarElement = this.menuBarRef.current;
725
+ if (!menuBarElement) {
726
+ return;
727
+ }
727
728
  var menuItems = Array.from(menuBarElement.children);
728
729
  // account for hidden side bar trigger (hamburger)
729
730
  if (this.state.wide && this.props.hasTrigger) {
@@ -750,7 +751,7 @@ var TopBar$1 = /** @class */ (function (_super) {
750
751
  // disabling no-unused-vars to prevent thin/hasTrigger from being passed through to div
751
752
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
752
753
  var _a = this.props, children = _a.children, className = _a.className; _a.thin; _a.hasTrigger; tslib.__rest(_a, ["children", "className", "thin", "hasTrigger"]);
753
- return (React__default["default"].createElement("ul", { role: "menubar", onKeyDown: this.onKeyDown, className: className }, React.Children.map(children, this.renderChild)));
754
+ return (React__default["default"].createElement("ul", { role: "menubar", onKeyDown: this.onKeyDown, className: className, ref: this.menuBarRef }, React.Children.map(children, this.renderChild)));
754
755
  };
755
756
  TopBar.defaultProps = {
756
757
  thin: false,
@@ -806,9 +807,16 @@ function resolveElement(elementOrRef) {
806
807
  return null;
807
808
  }
808
809
 
810
+ function getChildRef(child, version) {
811
+ if (version === void 0) { version = React__default["default"].version; }
812
+ return parseInt(version, 10) >= 19
813
+ ? child.props.ref
814
+ : child.ref;
815
+ }
816
+
809
817
  function ClickOutsideListener(_a, ref) {
810
818
  var children = _a.children, _b = _a.mouseEvent, mouseEvent = _b === void 0 ? 'click' : _b, _c = _a.touchEvent, touchEvent = _c === void 0 ? 'touchend' : _c, target = _a.target, _d = _a.onClickOutside, onClickOutside = _d === void 0 ? function () { return null; } : _d;
811
- var childElementRef = React.useRef();
819
+ var childElementRef = React.useRef(null);
812
820
  var handleEvent = function (event) {
813
821
  if (event.defaultPrevented) {
814
822
  return;
@@ -831,9 +839,8 @@ function ClickOutsideListener(_a, ref) {
831
839
  childElementRef.current = node;
832
840
  // Ref for this component should pass-through to the child node
833
841
  setRef(ref, node);
834
- // If child has its own ref, we want to update
835
- // its ref with the newly cloned node
836
- var childRef = children.ref;
842
+ // Forward the child's own ref. In React 19 ref lives in props; in 16–18 it's element.ref.
843
+ var childRef = getChildRef(children);
837
844
  setRef(childRef, node);
838
845
  };
839
846
  React.useEffect(function () {
@@ -1342,7 +1349,7 @@ var AriaIsolate = /** @class */ (function () {
1342
1349
 
1343
1350
  /**
1344
1351
  * When a component needs to track an internal ref on a component that has a
1345
- * forwarded ref, useSharedRef will return a MutableRefObject<T> that will
1352
+ * forwarded ref, useSharedRef will return a MutableRefObject<T | null> that will
1346
1353
  * correctly invoke the parent ref as well providing an internal ref.
1347
1354
  *
1348
1355
  * @example
@@ -1355,7 +1362,7 @@ var AriaIsolate = /** @class */ (function () {
1355
1362
  * })
1356
1363
  */
1357
1364
  function useSharedRef(ref) {
1358
- var internalRef = React.useRef();
1365
+ var internalRef = React.useRef(null);
1359
1366
  React.useEffect(function () {
1360
1367
  setRef(ref, internalRef.current);
1361
1368
  return function () { return setRef(ref, null); };
@@ -1488,7 +1495,7 @@ function useFocusTrap(target, options) {
1488
1495
  if (options === void 0) { options = {}; }
1489
1496
  var _a = options.disabled, disabled = _a === void 0 ? false : _a, _b = options.returnFocus, returnFocus = _b === void 0 ? true : _b, initialFocusElementOrRef = options.initialFocusElement, returnFocusElement = options.returnFocusElement;
1490
1497
  var focusTrap = React.useRef(null);
1491
- var returnFocusElementRef = React.useRef();
1498
+ var returnFocusElementRef = React.useRef(null);
1492
1499
  function restoreFocusToReturnFocusElement() {
1493
1500
  var _a;
1494
1501
  var resolvedReturnFocusElement = resolveElement(returnFocusElement);
@@ -1538,7 +1545,7 @@ var Dialog = React.forwardRef(function (_a, ref) {
1538
1545
  var dialogRef = useSharedRef(dialogRefProp || ref);
1539
1546
  var _g = tslib.__read(nextId.useId(1, 'dialog-title-'), 1), headingId = _g[0];
1540
1547
  var headingRef = React.useRef(null);
1541
- var isolatorRef = React.useRef();
1548
+ var isolatorRef = React.useRef(null);
1542
1549
  var headingLevel = typeof heading === 'object' && 'level' in heading && heading.level
1543
1550
  ? heading.level
1544
1551
  : 2;
@@ -2133,7 +2140,7 @@ var looksLikeLink = function (props) {
2133
2140
  };
2134
2141
  var IconButton = React.forwardRef(function (_a, ref) {
2135
2142
  var _b = _a.as, Component = _b === void 0 ? 'button' : _b, icon = _a.icon, label = _a.label, _c = _a.tooltipProps, tooltipPropsProp = _c === void 0 ? {} : _c, className = _a.className, _d = _a.variant, variant = _d === void 0 ? 'secondary' : _d, disabled = _a.disabled, _e = _a.tabIndex, tabIndex = _e === void 0 ? 0 : _e, large = _a.large, other = tslib.__rest(_a, ["as", "icon", "label", "tooltipProps", "className", "variant", "disabled", "tabIndex", "large"]);
2136
- var internalRef = React.useRef();
2143
+ var internalRef = React.useRef(null);
2137
2144
  React.useImperativeHandle(ref, function () { return internalRef.current; });
2138
2145
  // Configure additional properties based on the type of the Component
2139
2146
  // for accessibility
@@ -2243,14 +2250,22 @@ var useDidUpdate = function (effect, dependencies) {
2243
2250
  /**
2244
2251
  * The cauldron toast notification component
2245
2252
  */
2246
- var Toast = function (_a) {
2253
+ var Toast = React.forwardRef(function (_a, ref) {
2247
2254
  var type = _a.type, children = _a.children, _b = _a.onDismiss, onDismiss = _b === void 0 ? function () {
2248
2255
  // noop
2249
2256
  } : _b, _c = _a.dismissText, dismissText = _c === void 0 ? 'Dismiss' : _c, toastRef = _a.toastRef, _d = _a.focus, focus = _d === void 0 ? true : _d, _e = _a.show, show = _e === void 0 ? false : _e, _f = _a.dismissible, dismissible = _f === void 0 ? true : _f, className = _a.className, otherProps = tslib.__rest(_a, ["type", "children", "onDismiss", "dismissText", "toastRef", "focus", "show", "dismissible", "className"]);
2250
- var elRef = useSharedRef(toastRef !== null && toastRef !== void 0 ? toastRef : null);
2257
+ var elRef = useSharedRef(ref);
2251
2258
  var isolatorRef = React.useRef(null);
2252
2259
  var timeoutsRef = React.useRef(new Set());
2253
2260
  var _g = tslib.__read(React.useState(show ? 'FadeIn--flex' : 'is--hidden'), 2), animationClass = _g[0], setAnimationClass = _g[1];
2261
+ // Backwards-compat: propagate to the deprecated toastRef prop as well
2262
+ React.useEffect(function () {
2263
+ var _a;
2264
+ if (!toastRef)
2265
+ return;
2266
+ setRef(toastRef, (_a = elRef.current) !== null && _a !== void 0 ? _a : null);
2267
+ return function () { return setRef(toastRef, null); };
2268
+ }, [toastRef]);
2254
2269
  // Timeout because CSS display: none/block and opacity:
2255
2270
  // 0/1 properties cannot be toggled in the same tick
2256
2271
  // see: https://codepen.io/isnerms/pen/eyQaLP
@@ -2324,7 +2339,7 @@ var Toast = function (_a) {
2324
2339
  type !== 'action-needed' && dismissible && (React__default["default"].createElement("button", { type: "button", className: "Toast__dismiss", "aria-label": dismissText, onClick: dismissToast },
2325
2340
  React__default["default"].createElement(Icon, { type: "close" })))),
2326
2341
  scrim));
2327
- };
2342
+ });
2328
2343
  Toast.displayName = 'Toast';
2329
2344
 
2330
2345
  var Link = React.forwardRef(function (_a, ref) {
@@ -2687,7 +2702,7 @@ Checkbox.displayName = 'Checkbox';
2687
2702
  */
2688
2703
  function TooltipTabstop(_a) {
2689
2704
  var children = _a.children, className = _a.className, tooltip = _a.tooltip, variant = _a.variant, association = _a.association, show = _a.show, placement = _a.placement, portal = _a.portal, hideElementOnHidden = _a.hideElementOnHidden, buttonProps = tslib.__rest(_a, ["children", "className", "tooltip", "variant", "association", "show", "placement", "portal", "hideElementOnHidden"]);
2690
- var buttonRef = React.useRef();
2705
+ var buttonRef = React.useRef(null);
2691
2706
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2692
2707
  React__default["default"].createElement("button", tslib.__assign({ type: "button", ref: buttonRef, "aria-disabled": "true", className: classNames__default["default"]('TooltipTabstop', className) }, buttonProps), children),
2693
2708
  React__default["default"].createElement(Tooltip, { target: buttonRef, variant: variant, association: association, show: show, placement: placement, portal: portal, hideElementOnHidden: hideElementOnHidden }, tooltip)));
@@ -3941,10 +3956,10 @@ var ListboxOption = React.forwardRef(function (_a, ref) {
3941
3956
  var element = listboxOptionRef.current;
3942
3957
  setOptions(function (options) {
3943
3958
  var e_1, _a;
3944
- var option = { element: element, value: optionValue };
3945
3959
  // istanbul ignore next
3946
3960
  if (!element)
3947
3961
  return options;
3962
+ var option = { element: element, value: optionValue };
3948
3963
  // Elements are frequently appended, so check to see if the newly rendered
3949
3964
  // element follows the last element first before any other checks
3950
3965
  if (!options.length ||
@@ -3981,7 +3996,7 @@ var ListboxOption = React.forwardRef(function (_a, ref) {
3981
3996
  if (disabled) {
3982
3997
  return;
3983
3998
  }
3984
- onSelect({ element: listboxOptionRef.current, value: optionValue });
3999
+ onSelect({ element: event.target, value: optionValue });
3985
4000
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
3986
4001
  }, [optionValue, onSelect, onClick, disabled]);
3987
4002
  return (React__default["default"].createElement(Component, tslib.__assign({ id: id, className: classNames__default["default"](className, (_b = {},
@@ -4131,7 +4146,7 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
4131
4146
  // istanbul ignore next
4132
4147
  React.useLayoutEffect(function () {
4133
4148
  var intersectionEntry = intersectionRef.current;
4134
- if (!intersectionEntry || !isActive) {
4149
+ if (!intersectionEntry || !isActive || !comboboxOptionRef.current) {
4135
4150
  return;
4136
4151
  }
4137
4152
  var rect = comboboxOptionRef.current.getBoundingClientRect();
@@ -4175,6 +4190,8 @@ var ComboboxOption = React.forwardRef(function (_a, ref) {
4175
4190
  ? propValue
4176
4191
  : (_a = comboboxOptionRef.current) === null || _a === void 0 ? void 0 : _a.innerText;
4177
4192
  setMatchingOptions(function (options) {
4193
+ if (!comboboxOptionRef.current)
4194
+ return options;
4178
4195
  return new Map(options.set(comboboxOptionRef.current, {
4179
4196
  value: comboboxValue_1,
4180
4197
  displayValue: children,
@@ -4314,6 +4331,17 @@ var Combobox = React.forwardRef(function (_a, ref) {
4314
4331
  return value === lastSelectedValue;
4315
4332
  }) || [], 2), element = _a[0], option = _a[1];
4316
4333
  if (autocomplete === 'manual') {
4334
+ // In multiselect, the listbox manages its own active option via
4335
+ // keyboard navigation. When the last-selected value no longer
4336
+ // matches any option (e.g. after deselecting the only selected
4337
+ // option), preserve the existing active descendant so the next
4338
+ // Enter keypress can re-toggle the highlighted option.
4339
+ if (multiselect &&
4340
+ !element &&
4341
+ activeDescendant &&
4342
+ matchingOptions.has(activeDescendant.element)) {
4343
+ return;
4344
+ }
4317
4345
  setActiveDescendant(!element ? null : tslib.__assign({ element: element }, option));
4318
4346
  }
4319
4347
  else if (autocomplete === 'automatic' &&
@@ -4493,6 +4521,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4493
4521
  });
4494
4522
  }, [disabled, selectedValues, onSelectionChange]);
4495
4523
  var handlePillKeyDown = React.useCallback(function (event) {
4524
+ var _a, _b;
4496
4525
  if (!PillKeys.includes(event.key)) {
4497
4526
  return;
4498
4527
  }
@@ -4510,7 +4539,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4510
4539
  handleRemovePill(pillsRef.current[focusedIndex], selectedValues[focusedIndex]);
4511
4540
  var nextIndex = focusedIndex + 1;
4512
4541
  if (nextIndex == pillsLength) {
4513
- inputRef.current.focus();
4542
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
4514
4543
  }
4515
4544
  else {
4516
4545
  pillsRef.current[nextIndex].focus();
@@ -4519,7 +4548,7 @@ var Combobox = React.forwardRef(function (_a, ref) {
4519
4548
  else if (isArrowLeft || isArrowRight) {
4520
4549
  var nextIndex = Math.max(focusedIndex + (isArrowLeft ? -1 : 1), 0);
4521
4550
  if (isArrowRight && nextIndex === pillsLength) {
4522
- inputRef.current.focus();
4551
+ (_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
4523
4552
  }
4524
4553
  else {
4525
4554
  pillsRef.current[nextIndex].focus();
@@ -4807,10 +4836,12 @@ var TextEllipsis = React__default["default"].forwardRef(function (_a, ref) {
4807
4836
  : overflowElement.clientWidth < overflowElement.scrollWidth);
4808
4837
  });
4809
4838
  };
4839
+ if (!sharedRef.current)
4840
+ return;
4810
4841
  var observer = new ResizeObserver(listener);
4811
4842
  observer.observe(sharedRef.current);
4812
4843
  return function () {
4813
- observer === null || observer === void 0 ? void 0 : observer.disconnect();
4844
+ observer.disconnect();
4814
4845
  };
4815
4846
  }, []);
4816
4847
  React.useEffect(function () {
@@ -4855,7 +4886,7 @@ var Drawer = React.forwardRef(function (_a, ref) {
4855
4886
  openRef.current = open;
4856
4887
  }, [open, setIsTransitioning]);
4857
4888
  React.useEffect(function () {
4858
- if (!isModal) {
4889
+ if (!isModal || !drawerRef.current) {
4859
4890
  return;
4860
4891
  }
4861
4892
  var isolator = new AriaIsolate(drawerRef.current);
@@ -5036,7 +5067,7 @@ function getActiveElement(root) {
5036
5067
  */
5037
5068
  function useMnemonics(_a) {
5038
5069
  var elementOrRef = _a.elementOrRef, matchingElementsSelector = _a.matchingElementsSelector, onMatch = _a.onMatch, _b = _a.enabled, enabled = _b === void 0 ? true : _b;
5039
- var containerRef = React.useRef();
5070
+ var containerRef = React.useRef(null);
5040
5071
  React.useEffect(function () {
5041
5072
  if (elementOrRef instanceof HTMLElement) {
5042
5073
  containerRef.current = elementOrRef;
@@ -5046,7 +5077,8 @@ function useMnemonics(_a) {
5046
5077
  }
5047
5078
  }, [elementOrRef]);
5048
5079
  React.useEffect(function () {
5049
- if (!enabled || !containerRef.current) {
5080
+ var listenerTarget = containerRef.current;
5081
+ if (!enabled || !listenerTarget) {
5050
5082
  return;
5051
5083
  }
5052
5084
  var keyboardHandler = function (event) {
@@ -5059,14 +5091,14 @@ function useMnemonics(_a) {
5059
5091
  if (event.key.length !== 1 || !/[a-z\d]/i.test(event.key)) {
5060
5092
  return;
5061
5093
  }
5062
- var container = containerRef.current;
5063
- if (!container) {
5094
+ var currentContainer = containerRef.current;
5095
+ if (!currentContainer) {
5064
5096
  return;
5065
5097
  }
5066
5098
  // Prevent default behavior and stop propagation for mnemonic keys
5067
5099
  event.preventDefault();
5068
5100
  event.stopPropagation();
5069
- var elements = Array.from(container.querySelectorAll(matchingElementsSelector !== null && matchingElementsSelector !== void 0 ? matchingElementsSelector : focusable__default["default"]));
5101
+ var elements = Array.from(currentContainer.querySelectorAll(matchingElementsSelector !== null && matchingElementsSelector !== void 0 ? matchingElementsSelector : focusable__default["default"]));
5070
5102
  var matchingElements = elements.filter(function (element) {
5071
5103
  return getAccessibleLabel(element).toLowerCase()[0] ===
5072
5104
  event.key.toLowerCase();
@@ -5074,7 +5106,7 @@ function useMnemonics(_a) {
5074
5106
  if (!matchingElements.length) {
5075
5107
  return;
5076
5108
  }
5077
- var currentActiveElement = getActiveElement(containerRef.current);
5109
+ var currentActiveElement = getActiveElement(currentContainer);
5078
5110
  var nextActiveElement = null;
5079
5111
  if (currentActiveElement) {
5080
5112
  nextActiveElement = matchingElements.find(function (element) {
@@ -5088,17 +5120,15 @@ function useMnemonics(_a) {
5088
5120
  onMatch(nextActiveElement !== null && nextActiveElement !== void 0 ? nextActiveElement : matchingElements[0]);
5089
5121
  }
5090
5122
  };
5091
- var container = containerRef.current;
5092
- container.addEventListener('keydown', keyboardHandler);
5093
- return function () { return container.removeEventListener('keydown', keyboardHandler); };
5123
+ listenerTarget.addEventListener('keydown', keyboardHandler);
5124
+ return function () { return listenerTarget.removeEventListener('keydown', keyboardHandler); };
5094
5125
  }, [enabled, containerRef, matchingElementsSelector, onMatch]);
5095
5126
  return containerRef;
5096
5127
  }
5097
5128
 
5098
5129
  var ActionList = React.forwardRef(function (_a, ref) {
5099
5130
  var _b = _a.selectionType, selectionType = _b === void 0 ? null : _b, onAction = _a.onAction, className = _a.className, children = _a.children, props = tslib.__rest(_a, ["selectionType", "onAction", "className", "children"]);
5100
- var actionListContext = useActionListContext();
5101
- var activeElement = React.useRef();
5131
+ var activeElement = React.useRef(null);
5102
5132
  var _c = tslib.__read(React.useState(), 2), activeOption = _c[0], setActiveOption = _c[1];
5103
5133
  var handleActiveChange = React.useCallback(function (value) {
5104
5134
  activeElement.current = value === null || value === void 0 ? void 0 : value.element;
@@ -5119,12 +5149,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
5119
5149
  ? '[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio]'
5120
5150
  : '[role=option]'
5121
5151
  });
5122
- return (
5123
- // Note: we should be able to use listbox without passing a prop
5124
- // value for "multiselect"
5125
- // see: https://github.com/dequelabs/cauldron/issues/1890
5126
- // @ts-expect-error this should be allowed
5127
- React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
5152
+ return (React__default["default"].createElement(Listbox, tslib.__assign({ ref: function (element) {
5128
5153
  if (ref) {
5129
5154
  setRef(ref, element);
5130
5155
  }
@@ -5133,7 +5158,7 @@ var ActionList = React.forwardRef(function (_a, ref) {
5133
5158
  /* Listbox comes with an explicit role of "listbox", but we want to either
5134
5159
  * use the role from props, or default to the intrinsic role */
5135
5160
  // eslint-disable-next-line jsx-a11y/aria-role
5136
- role: undefined, "aria-multiselectable": actionListContext.role === 'listbox' ? undefined : null, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { onActiveChange: handleActiveChange, navigation: "bound" }),
5161
+ role: undefined, "aria-multiselectable": undefined, className: classNames__default["default"]('ActionList', className), activeOption: activeOption }, props, { onActiveChange: handleActiveChange, navigation: "bound" }),
5137
5162
  React__default["default"].createElement(ActionListProvider, { role: props.role || 'list', onAction: handleAction, selectionType: selectionType }, children)));
5138
5163
  });
5139
5164
  ActionList.displayName = 'ActionList';
@@ -5188,7 +5213,7 @@ var ActionListItem = React.forwardRef(function (_a, ref) {
5188
5213
  // istanbul ignore next
5189
5214
  React.useLayoutEffect(function () {
5190
5215
  var intersectionEntry = intersectionRef.current;
5191
- if (!intersectionEntry || !isActive) {
5216
+ if (!intersectionEntry || !isActive || !actionListItemRef.current) {
5192
5217
  return;
5193
5218
  }
5194
5219
  var rect = actionListItemRef.current.getBoundingClientRect();
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function getChildRef(child: React.ReactElement, version?: string): React.Ref<HTMLElement> | null | undefined;
@@ -1,4 +1,4 @@
1
- import type { RefObject } from 'react';
1
+ import type { MutableRefObject } from 'react';
2
2
  import type { ElementOrRef } from '../types';
3
3
  type useMnemonicsOptions = {
4
4
  /**
@@ -19,7 +19,7 @@ type useMnemonicsOptions = {
19
19
  */
20
20
  enabled?: boolean;
21
21
  };
22
- type useMnemonicsResults<T extends HTMLElement> = RefObject<T>;
22
+ type useMnemonicsResults<T extends HTMLElement> = MutableRefObject<T | null>;
23
23
  /**
24
24
  * A hook that provides mnemonic navigation for keyboard users.
25
25
  *
@@ -1,7 +1,7 @@
1
1
  import { MutableRefObject, Ref } from 'react';
2
2
  /**
3
3
  * When a component needs to track an internal ref on a component that has a
4
- * forwarded ref, useSharedRef will return a MutableRefObject<T> that will
4
+ * forwarded ref, useSharedRef will return a MutableRefObject<T | null> that will
5
5
  * correctly invoke the parent ref as well providing an internal ref.
6
6
  *
7
7
  * @example
@@ -13,4 +13,4 @@ import { MutableRefObject, Ref } from 'react';
13
13
  * return (<div ref={internalRef}>...</div>)
14
14
  * })
15
15
  */
16
- export default function useSharedRef<T>(ref: Ref<T>): MutableRefObject<T>;
16
+ export default function useSharedRef<T>(ref: Ref<T>): MutableRefObject<T | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "7.1.0-canary.3dc1ee55",
3
+ "version": "7.1.0-canary.4271d962",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",
@@ -41,7 +41,7 @@
41
41
  "@babel/preset-env": "^7.22.10",
42
42
  "@babel/preset-react": "^7.22.5",
43
43
  "@babel/preset-typescript": "^7.22.5",
44
- "@figma/code-connect": "^1.4.4",
44
+ "@figma/code-connect": "^1.4.5",
45
45
  "@rollup/plugin-commonjs": "^14.0.0",
46
46
  "@rollup/plugin-dynamic-import-vars": "^1.4.2",
47
47
  "@rollup/plugin-typescript": "^11.1.2",